The quantum SWAP test is a basic quantum subroutine used to compare two quantum states. Given two input states, it checks if they are equal, and it estimates how close they are by measuring an auxiliary control qubit after a controlled-SWAP operation.
In quantum protocols, the SWAP test can be used as a local procedure inside a node whenever the protocol needs to compare two quantum registers, estimate an inner product, test equality of quantum states, estimate purity, or evaluate state overlap. It is especially useful when the states are not known classically and full quantum state tomography would be too expensive.
For pure states $|\psi\rangle$ and $|\phi\rangle$, the SWAP test estimates the squared overlap $|\langle \psi|\phi\rangle|^2$. For mixed states $\rho$ and $\sigma$, it estimates the Hilbert-Schmidt inner product $\mathrm{Tr}(\rho\sigma)$.
The subroutine can be described abstractly as follows.
No particular assumptions on the inputs or subroutine.
The test usually requires fresh copies of the input states for repeated runs. Estimating the overlap to high precision therefore requires multiple copies of the states.
Also the SWAP test has a one-sided error, meaning that if the two states are equal it always returns equality (outcome 0), while as if they are completely orthogonal, it gives a random outcome with probability 1/2.
For pure input states $|\psi\rangle$ and $|\phi\rangle$, the initial state is
$$
|0\rangle|\psi\rangle|\phi\rangle .
$$
After applying a Hadamard gate to the auxiliary qubit, the state becomes
$$
\frac{1}{\sqrt{2}}\left(|0\rangle|\psi\rangle|\phi\rangle + |1\rangle|\psi\rangle|\phi\rangle\right).
$$
The controlled-SWAP operation gives
$$
\frac{1}{\sqrt{2}}\left(|0\rangle|\psi\rangle|\phi\rangle + |1\rangle|\phi\rangle|\psi\rangle\right).
$$
After applying the second Hadamard gate to the auxiliary qubit, the state becomes
$$
\frac{1}{2}|0\rangle\left(|\psi\rangle|\phi\rangle + |\phi\rangle|\psi\rangle\right)
+
\frac{1}{2}|1\rangle\left(|\psi\rangle|\phi\rangle – |\phi\rangle|\psi\rangle\right).
$$
Therefore, the probability of measuring the auxiliary qubit in state $0$ is
$$ \Pr[b=0] = \frac{1}{2}\left(1 + |\langle \psi|\phi\rangle|^2\right). $$
Similarly, the probability of measuring outcome $1$ is
$$ \Pr[b=1] = \frac{1}{2}\left(1 – |\langle \psi|\phi\rangle|^2\right). $$
Thus the squared overlap can be recovered from the probability of outcome $0$ as
$$ |\langle \psi|\phi\rangle|^2 = 2\Pr[b=0]-1. $$
Equivalently, it can be recovered from the probability of outcome $1$ as
$$ |\langle \psi|\phi\rangle|^2 = 1-2\Pr[b=1].$$
For mixed input states $\rho$ and $\sigma$, the same circuit gives
$$ \Pr[b=0] = \frac{1}{2}\left(1+\mathrm{Tr}(\rho\sigma)\right), $$
and
$$ \Pr[b=1] = \frac{1}{2}\left(1-\mathrm{Tr}(\rho\sigma)\right). $$
Therefore, repeated runs estimate
$$ \mathrm{Tr}(\rho\sigma) = 2\Pr[b=0]-1. $$
In the special case $\rho=\sigma$, the SWAP test estimates the purity of the state: $\mathrm{Tr}(\rho^2). $
To estimate the relevant overlap to additive error $\varepsilon$, the subroutine is repeated on fresh copies of the input states and the empirical frequency of outcome $0$ is used as an estimator.
The SWAP test has useful generalisations when one has asymmetric copy access to the two states being compared. One important example is the generalised SWAP test, or GSWAP test [5], which compares a single copy of one state with several copies of another reference state in one joint subroutine.
In a typical formulation, the GSWAP test takes as input one copy of a state $\rho$, $M$ copies of a reference pure state $|\psi\rangle$, and an ancilla register. It then performs a generalised controlled permutation test and measures the ancilla system to decide whether the input state matches the reference state. For $M=1$, the construction reduces to the ordinary SWAP test.
The acceptance probability can be written as
$$
\frac{1}{M+1}
+
\frac{M}{M+1}\langle \psi|\rho|\psi\rangle .
$$
Equivalently, writing the fidelity with the reference state as
$$
F^2 = \langle \psi|\rho|\psi\rangle ,
$$
one obtains
$$ \frac{1}{M+1}
+
\frac{M}{M+1}F^2 .
$$
Thus, as $M$ increases, the GSWAP test approaches an ideal projective test onto the reference state. This makes it useful in settings where a verifier has several stored copies of a reference state but receives only a single copy of a candidate state to be tested.
This generalised test appears in work on programmable projective measurements and has been used in quantum identification and quantum PUF protocols, where a node may need to compare a received quantum response against several stored copies of a valid reference response.
The quantum SWAP test is a basic quantum subroutine used to compare two quantum states. Given two input states, it checks if they are equal, and it estimates how close they are by measuring an auxiliary control qubit after a controlled-SWAP operation.
In quantum protocols, the SWAP test can be used as a local procedure inside a node whenever the protocol needs to compare two quantum registers, estimate an inner product, test equality of quantum states, estimate purity, or evaluate state overlap. It is especially useful when the states are not known classically and full quantum state tomography would be too expensive.
For pure states $|\\\psi\\\rangle$ and $|\\\phi\\\rangle$, the SWAP test estimates the squared overlap $|\\\langle \\\psi|\\\phi\\\rangle|^2$. For mixed states $\\\rho$ and $\\\sigma$, it estimates the Hilbert-Schmidt inner product $\\\mathrm{Tr}(\\\rho\\\sigma)$.
The subroutine can be described abstractly as follows.
No particular assumptions on the inputs or subroutine.
The test usually requires fresh copies of the input states for repeated runs. Estimating the overlap to high precision therefore requires multiple copies of the states.
Also the SWAP test has a one-sided error, meaning that if the two states are equal it always returns equality (outcome 0), while as if they are completely orthogonal, it gives a random outcome with probability 1/2.
For pure input states $|\\\psi\\\rangle$ and $|\\\phi\\\rangle$, the initial state is
$$
|0\\\rangle|\\\psi\\\rangle|\\\phi\\\rangle .
$$
After applying a Hadamard gate to the auxiliary qubit, the state becomes
$$
\\\frac{1}{\\\sqrt{2}}\\\left(|0\\\rangle|\\\psi\\\rangle|\\\phi\\\rangle + |1\\\rangle|\\\psi\\\rangle|\\\phi\\\rangle\\\right).
$$
The controlled-SWAP operation gives
$$
\\\frac{1}{\\\sqrt{2}}\\\left(|0\\\rangle|\\\psi\\\rangle|\\\phi\\\rangle + |1\\\rangle|\\\phi\\\rangle|\\\psi\\\rangle\\\right).
$$
After applying the second Hadamard gate to the auxiliary qubit, the state becomes
$$
\\\frac{1}{2}|0\\\rangle\\\left(|\\\psi\\\rangle|\\\phi\\\rangle + |\\\phi\\\rangle|\\\psi\\\rangle\\\right)
+
\\\frac{1}{2}|1\\\rangle\\\left(|\\\psi\\\rangle|\\\phi\\\rangle – |\\\phi\\\rangle|\\\psi\\\rangle\\\right).
$$
Therefore, the probability of measuring the auxiliary qubit in state $0$ is
$$ \\\Pr[b=0] = \\\frac{1}{2}\\\left(1 + |\\\langle \\\psi|\\\phi\\\rangle|^2\\\right). $$
Similarly, the probability of measuring outcome $1$ is
$$ \\\Pr[b=1] = \\\frac{1}{2}\\\left(1 – |\\\langle \\\psi|\\\phi\\\rangle|^2\\\right). $$
Thus the squared overlap can be recovered from the probability of outcome $0$ as
$$ |\\\langle \\\psi|\\\phi\\\rangle|^2 = 2\\\Pr[b=0]-1. $$
Equivalently, it can be recovered from the probability of outcome $1$ as
$$ |\\\langle \\\psi|\\\phi\\\rangle|^2 = 1-2\\\Pr[b=1].$$
For mixed input states $\\\rho$ and $\\\sigma$, the same circuit gives
$$ \\\Pr[b=0] = \\\frac{1}{2}\\\left(1+\\\mathrm{Tr}(\\\rho\\\sigma)\\\right), $$
and
$$ \\\Pr[b=1] = \\\frac{1}{2}\\\left(1-\\\mathrm{Tr}(\\\rho\\\sigma)\\\right). $$
Therefore, repeated runs estimate
$$ \\\mathrm{Tr}(\\\rho\\\sigma) = 2\\\Pr[b=0]-1. $$
In the special case $\\\rho=\\\sigma$, the SWAP test estimates the purity of the state: $\\\mathrm{Tr}(\\\rho^2). $
To estimate the relevant overlap to additive error $\\\varepsilon$, the subroutine is repeated on fresh copies of the input states and the empirical frequency of outcome $0$ is used as an estimator.
The SWAP test has useful generalisations when one has asymmetric copy access to the two states being compared. One important example is the generalised SWAP test, or GSWAP test [5], which compares a single copy of one state with several copies of another reference state in one joint subroutine.
In a typical formulation, the GSWAP test takes as input one copy of a state $\\\rho$, $M$ copies of a reference pure state $|\\\psi\\\rangle$, and an ancilla register. It then performs a generalised controlled permutation test and measures the ancilla system to decide whether the input state matches the reference state. For $M=1$, the construction reduces to the ordinary SWAP test.
The acceptance probability can be written as
$$
\\\frac{1}{M+1}
+
\\\frac{M}{M+1}\\\langle \\\psi|\\\rho|\\\psi\\\rangle .
$$
Equivalently, writing the fidelity with the reference state as
$$
F^2 = \\\langle \\\psi|\\\rho|\\\psi\\\rangle ,
$$
one obtains
$$ \\\frac{1}{M+1}
+
\\\frac{M}{M+1}F^2 .
$$
Thus, as $M$ increases, the GSWAP test approaches an ideal projective test onto the reference state. This makes it useful in settings where a verifier has several stored copies of a reference state but receives only a single copy of a candidate state to be tested.
This generalised test appears in work on programmable projective measurements and has been used in quantum identification and quantum PUF protocols, where a node may need to compare a received quantum response against several stored copies of a valid reference response.
To test equality of quantum states
To be added later
To be added later
No content has been added to this section, yet!
No content has been added to this section, yet!
To be added later
No content has been added to this section, yet!
No refs