← Atlas

Gates · Two-qubit gate

SWAP gate

A routing primitive that exchanges two qubit states and makes hardware connectivity explicit.

Exact & formalUpdated

View frozen graph

A small worked example, computed in your browser. It is not a result from this record's papers.

SWAP exchanges two qubits

Two qubits, with qubit 0 set to |1⟩ and qubit 1 left at |0⟩, so there is something to exchange.

q0q1Step 1 of 2 · XXStep 2 of 2 · SWAPSWAP

Step 1 of 2 · X

Probability of each outcome after this step

  • 01100%
  1. Sets qubit 0 to |1⟩. Read the outcome right to left: character 0 of the bitstring is the highest-numbered qubit, so this reads 01.

    The whole state moves from 00 to 01 — one certain outcome before, one certain outcome after, no superposition either side.

  2. Exchanges the two qubits entirely. On hardware this is rarely a gate of its own — it is three CXs, and moving a qubit across a chip is the main cost a router is trying to avoid.

    The whole state moves from 01 to 10 — one certain outcome before, one certain outcome after, no superposition either side.

Readout The register reads 10: what qubit 0 held is now on qubit 1. Nothing is in superposition on either side of this gate, which is exactly why the whole state simply moves from one outcome to another.

Open in Studio
  • Steps1
  • Wires2
  • Qubits2
  • Depth1 native / 3 CX
  • Outcomesstates exchanged
  • Papers1

Quantum vs classical

Classical baseline

Use a classical state-vector or matrix simulation at the same width, precision, and measurement objective.

Quantum claim

The quantum record demonstrates a state or operator behavior; it does not make classical simulation or communication costs disappear.

How to compare

Compare fidelity, samples, gate depth, noise, memory, and the cost of preparing and reading the state.

References

Exact & formal
  • Basis-state truth table
  • Textbook / standard citation
Method
Apply SWAP to all four computational-basis inputs and compare output labels.
Result
Pass · q[0] and q[1] exchange states without changing amplitudes.
OpenQASM 3 standard gate set ↗
Kind
curated reference
Reviewed by
Leona Quantum curation pass
License
CC BY 4.0-compatible reference metadata
routingtwo qubitconnectivity

Atlas stars stay in the public catalog. Saving this entry to your workspace starts an unstarred private copy.