# Can the SWAP test only compare registers with the same number of qubits?

I'm using the SWAP test circuit for implementing a qubit registers comparison

From the documentation I could find I've understood it can be applied to input qubits |$$\alpha\rangle$$ and |$$\beta\rangle$$ of the same size.

Is that really a constraint? Or it can be also applied to general cases of qubits of different size?

## 2 Answers

Qubits can be only with a size of 2, which means a dimensionality of 2.

For $$|\alpha \rangle,|\beta\rangle$$ here, for the SWAP gate to make sense, they must be of the same dimensionality (in the operating Hilbert space), then only there is a meaningful correspondence for the SWAP to work.

In case if it happens that they are not (suppose one qubit and other qtrit), then the extra degrees of freedom of the qtrit would not take part in the algorithm governed by the Hamiltonian which mimics the SWAP gate.

Yes they should be the same size. Otherwise, if you use it for getting the inner product between them, it would not make sense they aren't.

• or even more simply, the SWAP operation does not make sense if they have different sizes – glS Feb 8 at 16:24