Site Tools


swap-gate

Table of Contents

SWAP gate

SWAP gate is a two-qubit gate that exchanges the states of its two qubits. It is symmetric — neither qubit plays the role of control or target — and it is its own inverse: .

Decomposition into CX gates

SWAP can be decomposed into three CX gates in alternating directions:

This is important in hardware where qubit connectivity is limited. When two qubits that need to interact are not physically adjacent, SWAP gates are inserted to route them together — at a cost of three CXs each. Minimizing SWAP overhead is a key concern in quantum circuit compilation.

Square root of SWAP

The gate satisfies . Unlike SWAP itself, can create entanglement, and together with arbitrary single-qubit gates it forms a universal gate set. It is native to several spin-qubit hardware architectures.

List of code implementations

swap-gate.md · Last modified: