quantum-gate-swap
Table of Contents
SWAP Gate
SWAP exchanges the states of two qubits. If qubit 1 is in state $|a\rangle$ and qubit 2 is in state $|b\rangle$, after SWAP they exchange.
Matrix:
$$\text{SWAP} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix}$$
Action: $|ab\rangle \to |ba\rangle$ (swap basis state labels).
Properties
- Self-inverse: $\text{SWAP}^2 = I$
- Symmetric: swaps two qubits
- Reduces to identity on identical qubits (trivial for two copies of same state)
Decomposition
SWAP can be built from three CNOT gates:
$$\text{SWAP} = \text{CX}_{01} \text{CX}_{10} \text{CX}_{01}$$
This decomposition is commonly used since CNOT is more readily available.
Uses
- Qubit mapping: adjust layout to match hardware connectivity; move qubits closer for two-qubit gates
- Limited connectivity: enable operations between distant qubits on sparse graphs (at cost of extra gates)
- Circuit reordering: logically swap qubits to reduce circuit depth
- Quantum simulation: SWAP networks simulate particle dynamics on lattice geometries
Trade-offs
- Expensive: requires 3 CNOT gates (vs 1 for controlled operations)
- Avoidance: redesign algorithms to avoid SWAP via gate reordering
- Necessary: chips like 1D chains require SWAPs to implement arbitrary algorithms
Implementation
- Superconducting qubits: three CNOT pulses; gate time ~60–300 ns; some platforms have dedicated SWAP
- Trapped ions: composed from CX gates
- Cost note: dedicated SWAP implementations faster than three CNOTs
quantum-gate-swap.md · Last modified: by 127.0.0.1
