2
$\begingroup$

I need to compute the inner product between two generic quantum states. To this aim, one can use the swap test as explained in https://en.wikipedia.org/wiki/Swap_test .

In my case, both of the quantum states are given by two parametrized quantum circuits having the same structure but different parameters.

Since the swap test requires a relatively big register (one ancilla, a set of $n$ qubits for $\psi$ and a set of $n$ qubits for $\phi$), I am wondering if there are alternatives where I do not have to double the quantum register size for $\psi$ and $\phi$, so use $n+1$ qubits instead of $2n+1$. Or, maybe there is no way to do that.

$\endgroup$

2 Answers 2

4
$\begingroup$

Let us say that you want to evaluate $|\langle\psi|\varphi\rangle|^2$. Let us denote $U$ and $V$ the unitaires associated to your parametrized quantum circuits, producing respectively $|\psi\rangle$ and $|\varphi\rangle$. Using these notations, you actually want to evaluate $|\langle0|U^\dagger V|0\rangle|^2$. Note that this is equal to the probability of getting $|0\rangle$ when measuring the $U^\dagger V|0\rangle$ state in the computational basis.

I'm assuming here that you are able to apply $U^\dagger$, which is true if you have access to $U$'s circuit description.

Thus, what you can do is:

  1. Start from the $|0\rangle$ state.
  2. Apply $V$.
  3. Apply $U^\dagger$.
  4. Measure in the computational basis.

You're interested in the frequency at which you've measured $|0\rangle$ state, which will provide a good estimate for the quantity you're interested in. You can furthermore upper-bound the absolute error of this estimation using a simple confidence interval.

I'm not sure this is the most efficient way to do it though, but it uses the least number of qubits you could ask for.

$\endgroup$
2
  • $\begingroup$ Thanks, this is exactly what I needed. I have in fact the quantum circuit associated with $U$, but how do I build the quantum circuit associated with $U^\dagger$? $\endgroup$
    – francler
    Dec 11, 2023 at 10:51
  • 2
    $\begingroup$ @francler - you just run it backwards, taking the adjoint of each gate. If you know that $U=U_3 U_2 U_1$ then you know that $U^\dagger=U_1^\dagger U_2^\dagger U_3^\dagger$. $\endgroup$ Dec 11, 2023 at 14:43
2
$\begingroup$

The SWAP test is great when you don't have access to $U$ or $V$ and have no other way to prepare $|\psi\rangle$ or $|\phi\rangle$, and uses $2n+1$ qubits - while Tristan's test uses only $n$ qubits, in addition to any ancillary registers used for $U$ or $V$. Tristan's approach assumes we can deduce $U^\dagger$ from $U$, which, as indicated, is almost as simple as running $U$ backwards.

Alternatively and morally equivalently you could use a Hadamard test on $n+1$ qubits (+other ancillary qubits) as follows:

  1. Prepare a single-qubit control register as $|0\rangle$;
  2. Apply a Hadamard gate to $|0\rangle$;
  3. Apply $U$ to $|00\cdots 0\rangle$, controlled off of the control qubit being $|0\rangle$;
  4. Apply $V$ to the same register, controlled off of the control qubit being $|1\rangle$;
  5. Hadamard the control qubit;
  6. Measure the control qubit in the computational basis.

This test runs both $U$ and $V$ forward, but uses at least one more qubit than Tristan's ($n+1$) while also having to assume that we have a way to control $U$ and $V$.

(We almost always assume that if we know how to execute $U$ then we can execute $U^\dagger$, and/or that we can execute controlled versions of $U$ - these assumptions may be risky though, especially the second one and especially on real-world devices!)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.