Computing Library › Quantum Logic Gates
Quantum Logic Gates

SWAP Gate

The SWAP gate exchanges the states of two qubits — essential for routing information across hardware where qubits aren't all connected.

Matrix

Unitary matrix
1000001001000001

Circuit symbol

Kronos motion — thermal gate

Action on basis states

inputoutput
|01⟩|10⟩
|10⟩|01⟩

How it works

SWAP = three CNOTs. On hardware with limited connectivity, chains of SWAPs move a logical qubit next to its partner before a two-qubit gate — the dominant overhead the transpiler tries to minimize.

In code (Qiskit)

python
qc = QuantumCircuit(2)
qc.swap(0, 1)
two-qubitCliffordrouting