Exchanges the quantum states of two qubits.
The SWAP gate does exactly what its name says: it exchanges the complete quantum states of two qubits. If qubit A is in state |ψ⟩ and qubit B is in state |φ⟩, after SWAP, qubit A holds |φ⟩ and qubit B holds |ψ⟩. This includes all amplitudes, phases, and entanglement relationships. SWAP is especially important in hardware where not all qubits can interact directly — you need to move quantum states around to bring them next to each other.
SWAP exchanges the computational basis states of two qubits: |ab⟩ → |ba⟩. It can be decomposed into three CNOT gates: CNOT(1,2)·CNOT(2,1)·CNOT(1,2). SWAP preserves entanglement structure — it simply relabels which physical qubit holds which logical state. The gate is symmetric and its own inverse (SWAP² = I).
Qubit roles swap in the output distribution.
Exchanges the Bloch vectors of two qubits. Each qubit ends up with the other’s full state, including phase and purity.
SWAP might seem trivially classical, but it matters because it preserves quantum information perfectly — amplitudes, phases, and entanglement all transfer intact.
Real quantum hardware has limited connectivity between qubits. SWAP gates are how you move quantum information to where it needs to be. Minimizing SWAP overhead is a major challenge in quantum circuit compilation.
Does applying SWAP to two qubits create entanglement?