Quantum Computing

A Comprehensive Guide to Quantum Gates

In classical computing, we build every operation from simple binary logic gates like AND, OR, and NOT. In quantum computing, the role of logic gates is played by quantum gates – unitary transformations on one or more qubits. These are the elementary “moves” that a quantum computer can perform on quantum data. Just as classical gates compose to implement arbitrary Boolean functions, quantum gates compose to implement arbitrary unitary operations. However, quantum gates have striking differences from classical ones: they are reversible (all quantum gates correspond to invertible unitary matrices), they can create superposition and entanglement, and there are infinitely many possible single-qubit gates (since a qubit’s state is a continuous point on the Bloch sphere).

Let’s tour the most common quantum gates: we’ll start with single-qubit gates, including the Pauli gates, Hadamard, phase gates (S and T), and rotation gates, and then move to two-qubit gates like CNOT, controlled-phase, SWAP, and $i$SWAP, and finally three-qubit gates like the Toffoli and Fredkin.

Single-Qubit Gates: Manipulating One Qubit at a Time

A single qubit’s state can be visualized as a point on the Bloch sphere, and single-qubit gates correspond to rotations of this Bloch vector. These gates change the amplitudes and relative phase of the basis states $$|0\rangle$$ and $$|1\rangle$$. In matrix form, a single-qubit gate is a 2×2 unitary matrix. Here are the most important ones:

Pauli X, Y, Z gates

These are the quantum analogues of the classical NOT and related operations, and correspond to 180° rotations about the x, y, and z axes of the Bloch sphere. Their matrices (in the $${|0\rangle,|1\rangle}$$ basis) are: $$X = \begin{pmatrix}0 & 1\\ 1 & 0\end{pmatrix}$$, $$\quad Y = \begin{pmatrix}0 & -i\\ i & 0\end{pmatrix}$$, $$\quad Z = \begin{pmatrix}1 & 0\\ 0 & -1\end{pmatrix}$$. The X gate flips $$|0\rangle \leftrightarrow |1\rangle$$, acting just like a classical NOT on the computational basis. If a qubit is in state $$|0\rangle$$, $$X$$ will take it to $$|1\rangle$$, and vice versa. Geometrically, it’s a half-turn around the Bloch sphere’s X-axis, taking the “north pole” to the “south pole.” The Z gate flips the phase of the $$|1\rangle$$ state: $$Z|0\rangle = |0\rangle$$, $$Z|1\rangle = -|1\rangle$$. It’s a 180° rotation about the Z-axis, leaving the poles $$|0\rangle$$ and $$|1\rangle$$ in place but rotating the |1⟩ state vector to point in the opposite direction (assigning it a -1 phase). This earns Z the nickname “phase-flip” gate – if a qubit is in a superposition $$(\alpha|0\rangle + \beta|1\rangle)$$, Z transforms it to $$(\alpha|0\rangle – \beta|1\rangle)$$. The Y gate flips the state like X but also introduces a phase: $$Y|0\rangle = i|1\rangle$$, $$Y|1\rangle = -i|0\rangle$$. This is a 180° rotation about the Y-axis. Essentially, $$Y = i X Z$$ (up to a global phase $$i$$), combining a bit flip and a phase flip.

All Pauli gates are their own inverses (each squared is the identity), and they anti-commute with each other ($$XZ = -ZX$$, etc.) These properties are central in quantum error correction and stabilizer theory.

Use cases: X is used to flip qubit states (for example, to set a qubit to $$|1\rangle$$, you can apply X to $$|0\rangle$$). Z is used to apply a phase kick – it leaves $$|0\rangle$$ unchanged but can change the sign of the $$|1\rangle$$ component, which is useful in algorithms and forming controlled-Z gates. Y is less frequently used directly, but is important in certain operations or can be composed from X and Z. Bloch sphere visualization: X rotates the Bloch vector 180° around the x-axis (if the qubit was at the north pole |0⟩, X sends it to the south pole |1⟩). Z rotates 180° around the z-axis (so it sends the state on the equator at +X direction, |+⟩, to the state at −X direction, |−⟩, effectively swapping those, and similarly |+𝑖⟩ to |−𝑖⟩ on the Y-axis). Y rotates around the y-axis (sending |0⟩ to i|1⟩ etc., which on the sphere means pointing opposite in the complex plane).

Hadamard (H) gate

The Hadamard gate creates superposition and is one of the most widely used single-qubit gates. Its matrix is $$H = \frac{1}{\sqrt{2}}\begin{pmatrix}1 & 1\\ 1 & -1\end{pmatrix}$$. It maps $$|0\rangle$$ to $$|+\rangle := (|0\rangle+|1\rangle)/\sqrt{2}$$ and $$|1\rangle$$ to $$|-\rangle := (|0\rangle – |1\rangle)/\sqrt{2}$$. In effect, H takes a definitively-valued qubit and “splits” it into an equal superposition of 0 and 1 (up to a relative phase). Conversely, it also takes those plus/minus superposition states back to the computational basis ($$H|\pm\rangle = |0/1\rangle$$). Geometrically, H is a 180° rotation about the axis halfway between X and Z on the Bloch sphere. It thus swaps the roles of the X-basis and Z-basis. One can verify that $$HZH = X$$ and $$HXH = Z$$ – H conjugates a Z into an X and vice versa, which means applying an H before measuring in Z-basis is effectively a measurement in X-basis.

Hadamard is its own inverse (aside from a global phase, $$H^2 = I$$).

Use cases: H is used at the start of many algorithms to create uniform superpositions (e.g., in Grover’s algorithm, applying H to each of $$n$$ qubits yields a superposition of all $$2^n$$ basis states). It’s also used in interference steps – for example, in the simple Deutsch algorithm, H gates are used before and after a function call to create interference that reveals a global property of the function. In creating entanglement, a common pattern is H on one qubit followed by CNOT (this produces a Bell state, as we’ll see). H is also crucial in quantum error-correcting codes, as part of generating and measuring certain stabilizer states. Bloch sphere: H sends the north pole |0⟩ to the equator (pointing along +X direction) and |1⟩ to the equator (pointing along −X direction). It essentially reflects states through the X-Z diagonal plane. A neat view: if a qubit is on the equator (like |+⟩ or |−⟩), H will send it to one of the poles (|0⟩ or |1⟩). This shows how H toggles between superposition basis and computational basis.

Phase gates (S and T)

These are single-qubit gates that impart a specific phase shift to the $$|1\rangle$$ state. The S gate (also called the phase gate or $$P(\pi/2)$$) has matrix $$S = \begin{pmatrix}1 & 0\ 0 & i\end{pmatrix}$$. It leaves $|0\rangle$ unchanged and multiplies $$|1\rangle$$ by $$i$$ (a 90° phase rotation). Equivalently, it’s $$\pi/2$$ rotation around the Z-axis on the Bloch sphere. The T gate (also called the $$\pi/8$$ gate) has matrix $$T = \begin{pmatrix}1 & 0\ 0 & e^{i\pi/4}\end{pmatrix}$$. It’s a 45° phase shift on $$|1\rangle$$. Note that $$S^2 = Z$$ and $$T^2 = S$$ (and hence $$T^4 = Z$$). These relationships give S and T their alternate names: S is sometimes written as $$\sqrt{Z}$$ (since $$S^2 = Z$$), and T as $$\sqrt{S}$$ (or $$\sqrt[4]{Z}$$). Neither S nor T is Hermitian (unlike X, Y, Z, H which are their own inverses up to phase) – they are one-way phase rotations. The adjoint (inverse) gates are $$S^\dagger = \begin{pmatrix}1&0\0&-i\end{pmatrix}$$ and $$T^\dagger = \begin{pmatrix}1&0\0&e^{-i\pi/4}\end{pmatrix}$$. Use cases: S and T gates are critical in building arbitrary single-qubit rotations out of discrete gates. S is a Clifford gate (meaning if you only had Clifford gates like H, S, CNOT, the circuit is efficiently classically simulatable, but also useful for error correction). T is not a Clifford gate – and that’s exactly why it’s important. By adding the T gate to the set of Clifford gates, we get a universal set. In fact, ${H, T, CNOT}$ is a common universal gate set. The T gate’s 45° phase is what allows us to approximate any angle; circuits often count the number of T gates as a measure of complexity for error-corrected computation (since T is typically the most expensive gate in fault-tolerant implementations).

In algorithms, phase gates show up in phase kickback techniques. For example, the controlled-phase rotations in the Quantum Fourier Transform are essentially these $$P(\varphi)$$ gates. In quantum error correction, the T gate is the hardest to implement fault-tolerantly, usually requiring a process called magic state distillation. This reflects the fact that T is outside the Clifford group and thus not protected by many simple codes – it’s the “magic” ingredient enabling quantum advantage. S gate, on the other hand, is often easy to implement (e.g., it might just be a frame change in superconducting qubits). Bloch sphere: S and T rotate the state vector about the Z-axis. If a qubit is in state $$|+\rangle = (|0\rangle+|1\rangle)/\sqrt{2}$$ (on the equator at 0° phase), applying S will shift it to $$|+i\rangle = (|0\rangle + i|1\rangle)/\sqrt{2}$$ (on the equator at +90°). T would rotate it by 45°, to an intermediate point. If the qubit were at the poles (|0⟩ or |1⟩), these phase gates won’t change the visible state (they just add global phase or 180° phase to |1⟩ in case of Z which is a double S). So phase gates are “invisible” on computational basis states but crucial when states are superposed.

Rotation gates (Rx, Ry, Rz)

These denote continuous rotations about the Bloch sphere axes by a given angle. For example, $$R_x(\theta) = \exp(-i\theta X/2)$$ yields a rotation by angle θ around the X-axis: $$R_x(\theta) = \begin{pmatrix}\cos(\theta/2) & -i\sin(\theta/2)\\ -i\sin(\theta/2) & \cos(\theta/2)\end{pmatrix}$$. Similarly, $$R_z(\theta) = \begin{pmatrix}e^{-i\theta/2} & 0\ 0 & e^{i\theta/2}\end{pmatrix}$$ (which is a phase shift by θ on |1⟩ relative to |0⟩). Indeed $$R_z(\pi/2) = S$$ and $$R_z(\pi/4) = T$$ up to a global phase. $$R_y(\theta)$$ would be a rotation about Y. Rotation gates allow arbitrary single-qubit transformations. In practice, many quantum SDKs use a parameterized rotation gate (like RZ(φ) or a general U(θ,φ,λ) in IBM’s Qiskit which is essentially $$R_z(φ) R_x(θ) R_z(λ)$$). Use cases: Any single-qubit gate can be decomposed into rotations (Euler angles). For example, a general recipe is that any single-qubit unitary $$U$$ can be written as $$U = e^{i\alpha} R_z(\beta) R_y(\gamma) R_z(\delta)$$ for some angles (and global phase $$e^{i\alpha}$$ which doesn’t matter computationally). So having the ability to do arbitrary rotations (even just about two axes, like X and Z) is enough for single-qubit universality. Physical hardware often natively implements something like $$R_x(\theta)$$ or $$R_y(\theta)$$ by an analog pulse. In many superconducting qubit systems, fast $$R_z(\phi)$$ can be done as a software frame adjustment (no physical pulse needed) – effectively “free” and exact. So one strategy is: use $$R_z$$ and $$R_x$$ as needed to compile everything.

In algorithms, continuous rotations appear in variational circuits and QAOA, where gate angles are parameters to be optimized. For example, in a QAOA circuit, one might apply an $$R_x(\theta)$$ on each qubit as a mixing operation. These are not predetermined like $$\pi/4$$ but rather adjustable. Bloch sphere: $$R_n(\theta)$$ means rotate the state vector by θ around axis n. If the qubit is initially |0⟩ (north pole), an $$R_x(θ)$$ will move it toward |1⟩ in the XZ-plane. For small θ, it produces a small superposition. These rotation gates generalize the idea of X, Y, Z: indeed $$R_x(\pi) = X$$ (up to phase), $$R_y(\pi) = Y$$, $$R_z(\pi) = Z$$.

To summarize the single-qubit gates: X, Y, Z perform flips and define the axes of rotation. H creates and destroys superposition, acting as a “bridge” between X and Z bases. S and T impart well-defined phase shifts (with T being crucial for universality beyond the Clifford group). And rotation gates with arbitrary angles allow fine control. With these, one can build any single-qubit operation. Next, we turn to multi-qubit gates, which allow us to create correlations and entanglement between qubits.

Two-Qubit Gates: Entangling Operations

Multi-qubit gates act on two or more qubits at once. They are responsible for creating entanglement – something impossible with single-qubit gates alone. The most important two-qubit gate is the Controlled-NOT (CNOT), but there are others like Controlled-Z (CZ), SWAP, and $i$SWAP. Two-qubit gates are generally more challenging physically, but any quantum computer must implement at least one kind of two-qubit entangling gate, since without entanglement, a quantum computer offers no advantage over a classical one.

Controlled-NOT (CNOT) gate

This gate has two inputs: a control qubit and a target qubit. It performs an $$X$$ (NOT flip) on the target if and only if the control is $$|1\rangle$$; if the control is $$|0\rangle$$, it does nothing. In truth table form:$$|00\rangle \to |00\rangle$$ (control 0, target stays 0)$$|01\rangle \to |01\rangle$$ (control 0, target stays 1)$$|10\rangle \to |11\rangle$$ (control 1, target flips from 0 to 1)$$|11\rangle \to |10\rangle$$ (control 1, target flips from 1 to 0)We can summarize this as: $$|a, b\rangle \mapsto |a,, a\oplus b\rangle$$, where $$\oplus$$ is XOR. The first bit (qubit) $$a$$ is unchanged; the second bit becomes $$b$$ XOR $$a$$. In matrix form (with basis order $$|00\rangle,|01\rangle,|10\rangle,|11\rangle$$), CNOT is: $$\text{CNOT} = \begin{pmatrix} 1&0&0&0\\ 0&1&0&0\\ 0&0&0&1\\ 0&0&1&0 \end{pmatrix}$$, which indeed maps $$|10\rangle$$ to $$|11\rangle$$ and $$|11\rangle$$ to $$|10\rangle$$.

Entanglement: The CNOT is crucial because if the control qubit is in a superposition, CNOT generates entanglement. For example, start with control in $$|+\rangle = (|0\rangle+|1\rangle)/\sqrt{2}$$ and target in $$|0\rangle$$. The joint state is $$\frac{1}{\sqrt{2}}(|00\rangle + |10\rangle)$$. Now apply CNOT (control = first qubit). The $$|00\rangle$$ component stays $$|00\rangle$$ (since control is 0, no flip), and the $$|10\rangle$$ component becomes $$|11\rangle$$ (control 1 flips target). The resulting state is $$\frac{1}{\sqrt{2}}(|00\rangle + |11\rangle)$$, which is one of the Bell states – a maximally entangled pair. Neither qubit has a definite value on its own, but they are perfectly correlated. If you measured the first qubit, it’s 50/50 0 or 1, but whatever it is, the second qubit will be found the same. This state cannot be factored into a product of single-qubit states, demonstrating entanglement. CNOT (along with an H to prepare the superposition) is the standard way to produce such entangled pairs in experiments.

Classical analogy: If we treat $$|0\rangle$$ as bit 0 and $$|1\rangle$$ as bit 1, CNOT is like a controlled XOR gate: it flips the target bit if the control bit is 1. In reversible computing, the CNOT (also called the Feynman gate) is the basic two-bit gate since it’s reversible and can copy a bit onto another (if target starts at 0, CNOT will copy control’s value to target). In fact, the mapping $$(a,b)\to(a, a\oplus b)$$ can be seen as copying $$a$$ onto a target initialized to 0 (if $$b=0$$). However, quantum mechanically, we cannot clone an arbitrary unknown qubit state; CNOT can only copy a classical bit or entangle a quantum state – it doesn’t violate the no-cloning theorem because if the control is in superposition, the result is entanglement rather than two independent copies of information.

Use cases: CNOT is ubiquitous. Any multi-qubit quantum circuit typically uses CNOTs to entangle qubits. Many algorithms require entangling operations; for instance, in quantum adders, CNOTs are used for carry operations. In error correction, CNOTs copy syndrome information from data qubits to ancilla qubits. The Toffoli and other multi-control gates are built using multiple CNOTs. In fact, it’s known that {single-qubit gates + CNOT} is a universal gate set for quantum computing. That means any quantum operation can be composed from CNOT and one-qubit rotations. The Solovay-Kitaev theorem and other results ensure we can approximate any unitary to arbitrary accuracy with these. So, CNOT is as central to quantum circuits as NAND or XOR is to classical circuits.

Circuit symbol: A CNOT is drawn as a line connecting a ● (on the control qubit’s line) and an ⊕ (on the target’s line). The ⊕ indicates the target is flipped. Sometimes it’s labeled “CNOT” or “CX”. It’s worth noting that CNOT is its own inverse (apply it twice, it undoes itself). It’s also a Clifford gate.

Controlled-Z (CZ) gate

This is another common two-qubit gate, similar to CNOT but instead of flipping the target bit, it flips the target qubit’s phase (applies a Z) if the control is 1. In truth table terms, $$|11\rangle$$ gets a phase -1 (since Z on the target gives a – to $$|1\rangle$$), while $$|00\rangle,|01\rangle,|10\rangle$$ are unchanged. Matrix of CZ (in same basis order) is diag(1,1,1,-1). It is equivalent to CNOT up to conjugating by Hadamards on the target: $$CZ_{(c,t)} = H_t, CNOT_{(c,t)}, H_t$$. Conversely, $$CNOT = H_t, CZ_{(c,t)}, H_t$$. Many quantum hardware platforms (like some superconducting qubits) implement CZ natively because of how the interaction works, and convert to CNOT in software.

Entanglement: CZ also creates entanglement from superpositions. For example, if control is $$|+\rangle$$ and target $$|+\rangle$$, after CZ the state becomes $$\frac{1}{\sqrt{2}}(|00\rangle + |11\rangle)$$ (because $$|10\rangle$$ and $$|01\rangle$$ get a phase flip which in this case causes destructive cancellation for those terms, leaving only $$|00\rangle+|11\rangle$$). So CZ can produce the same Bell states as CNOT (just in different input conditions).

Use cases: CZ is often used in algorithms that are symmetric in 0/1 (since a CNOT has an asymmetry in control vs target roles, but CZ is symmetric aside from which qubit is control). For example, some error correction circuits prefer CZ for certain syndrome measurements. In quantum simulations, CZ gates appear in phase interaction terms. And in the quantum supremacy circuits by Google, a gate called “iSWAP-like” plus a partial CZ was used, essentially combining an entangling swap and a phase. If one has a CZ available, one can always sandwich it with H on target to get a CNOT as needed, so it’s often interchangeable in discussions of universal gate sets. Both CNOT and CZ are Clifford gates when considered with single-qubit Cliffords (H and S).

SWAP gate

SWAP simply exchanges the states of two qubits. It’s a three-controlled-NOT construction: $$\text{SWAP}(q_1,q_2) = CNOT(q_1,q_2); CNOT(q_2,q_1); CNOT(q_1,q_2)$$. In basis form: $$|a,b\rangle \to |b,a\rangle$$. The matrix is: $$\text{SWAP} = \begin{pmatrix} 1&0&0&0\\ 0&0&1&0\\ 0&1&0&0\\ 0&0&0&1 \end{pmatrix}$$, which indeed sends $$|01\rangle$$ to $$|10\rangle$$ (the 2nd and 3rd basis vector swap).

Use cases: The SWAP gate doesn’t create entanglement by itself (it just permutes qubits). But it’s vital in quantum computing when you need to move qubit states around. Real hardware often has a limited connectivity graph – SWAP gates are used to route qubits, effectively exchanging quantum data between two wire lines. For example, if qubit A needs to interact with qubit C but they’re not adjacent, the compiler might insert SWAPs to move the state of A over to an adjacent position. Each SWAP is three CNOTs, so it’s costly, but necessary for flexibility. In algorithms, SWAP can sometimes appear logically (e.g., swapping two registers), but usually it’s a tool for circuit mapping. Conceptually, SWAP is symmetric and its own inverse (swap twice = original). There is also a √SWAP gate (the square-root of SWAP) which is an entangling gate – applying √SWAP twice yields a full SWAP. √SWAP is universal with single qubit gates (because √SWAP is entangling). In some quantum dot systems, √SWAP is a naturally occurring gate. But standard circuit decomposition usually sticks with CNOT or CZ as the entangler and uses multiple of them for a SWAP if needed.

iSWAP gate

This gate swaps the two qubits and adds a phase of $$i$$ to the $$|01\rangle$$ and $$|10\rangle$$ terms that swap. Its matrix (in basis $$|00\rangle,|01\rangle,|10\rangle,|11\rangle$$) is: $$i\text{SWAP} = \begin{pmatrix} 1&0&0&0\\ 0&0&i&0\\ 0&i&0&0\\ 0&0&0&1 \end{pmatrix}$$, meaning $$|01\rangle \to i|10\rangle$$, $$|10\rangle \to i|01\rangle$$, and $$|00\rangle,|11\rangle$$ remain. Essentially, it’s like a SWAP but when 0 and 1 pass through each other, a phase $$i$$ is gained. The iSWAP is entangling (a single iSWAP can create entanglement from certain input states). In fact, a √iSWAP (square-root of iSWAP) is used as the two-qubit entangling gate in Google’s Sycamore processor (Sycamore gate is roughly √iSWAP plus a Z-phase). A full iSWAP gate is basically two √iSWAPs.

Use cases: Some physical interactions naturally implement iSWAP. For example, in superconducting qubits with capacitive coupling, an iSWAP operation (exchange of excitations) can occur. In ion traps, the Molmer-Sorensen gate is more akin to an XX interaction (which can be turned into something like iSWAP or √iSWAP with appropriate basis choice). The reason iSWAP has that $$i$$ phase is related to the physics of a SWAP operation arising from a Hamiltonian like $$H \propto (X \otimes X + Y \otimes Y)$$, which yields an iSWAP unitary. For quantum algorithm design, one typically doesn’t use iSWAP at the logical level – you’d convert iSWAP to CNOTs or vice versa – but knowing about it is important for understanding hardware gate sets. iSWAP is also a Clifford if combined appropriately with single-qubit rotations (actually, iSWAP itself is not Clifford because it includes an i-phase which is non-Clifford; however, $$(iSWAP)^2 = -SWAP$$ which is Clifford since SWAP is just permutation, global phase -1 aside). A related gate is the Controlled phase (CPHASE): applying a phase to |11⟩. Actually CZ is a CPHASE(π). A generic controlled phase CPHASE(θ) would do $$|11\rangle \to e^{iθ}|11\rangle$$. That’s like a partial CZ. These appear in QFT circuits with various θ. They can be built with a CNOT sandwiching a single-qubit Rz(θ).

In summary of two-qubit gates: CNOT (CX) is the workhorse for entanglement and universal computing. It has a clear classical interpretation and is used in everything from algorithmic oracles to error correction circuits. CZ is effectively the same in computational power, just a different form (phase flip instead of bit flip). SWAP is crucial for moving qubit states around and is composed of CNOTs. iSWAP (and √iSWAP) are hardware-friendly gates used in some architectures. All two-qubit entangling gates can be converted into each other with appropriate single-qubit rotations. Having at least one entangling two-qubit gate along with the set of single-qubit gates ensures the gate set is universal (able to approximate any unitary).

Controlled-Y (CY) Gate

The controlled-Y (CY) gate is a two-qubit operation with one control and one target qubit. It applies the Pauli-$$Y$$ transformation to the target if and only if the control qubit is in state $$|1\rangle$$. In other words, CY performs a bit-flip with an additional phase: it flips the target’s state ($$0\mapsto 1$$, $$1\mapsto 0$$) while introducing a $$90^\circ$$ phase difference between those outcomes. If the control is $$|0\rangle$$, the target is left unchanged, just as with a CNOT (controlled-X) gate but using the $$Y$$ operation instead of $$X$$.

Matrix: In the computational basis $$|00\rangle, |01\rangle, |10\rangle, |11\rangle$$ (control–target), the CY gate is represented by the 4×4 unitary matrix:

$$$
\mathrm{CY}=\begin{pmatrix}
1 & 0 & 0 & 0\\
0 & 1 & 0 & 0\\
0 & 0 & 0 & -i\\
0 & 0 & i & 0
\end{pmatrix}\
$$$

This matrix flips the $$|10\rangle$$ basis state to $$i|11\rangle$$ (phase $$+i$$) and $$|11\rangle$$ to $$-i|10\rangle$$, while $$|00\rangle$$ and $$|01\rangle$$ remain unchanged. The $$i$$ and $$-i$$ factors reflect the $$Y$$ gate’s effect (since $$Y|0\rangle = i|1\rangle$$ and $$Y|1\rangle = -i|0\rangle$$).

Entanglement: Like other controlled gates, CY can generate entanglement. For example, if the control qubit is prepared in a superposition $$|+\rangle = (|0\rangle+|1\rangle)/\sqrt{2}$$ and the target in $$|0\rangle$$, a CY operation will create an entangled state. Starting from $$\frac{1}{\sqrt{2}}(|00\rangle + |10\rangle) = \frac{1}{\sqrt{2}}(|00\rangle + |10\rangle)$$, applying CY (control = first qubit) yields $$\frac{1}{\sqrt{2}}(|00\rangle + i\,|11\rangle)$$. Up to a global phase, this is equivalent to a Bell pair (the relative phase $$i$$ does not change the entanglement). Thus CY, like CNOT and CZ, can produce correlated two-qubit states from product states.

Use cases: The CY gate is a less commonly used gate in circuits (since any controlled unitary can be decomposed to CNOT and single-qubit operations). However, it is conceptually important as an example of a controlled-Pauli operation beyond CNOT (CX) and CZ. In quantum algorithms or error correction, controlled-$$Y$$ operations sometimes appear when one needs to conditionally apply a bit-and-phase flip. For instance, certain error-correction routines that diagnose $$Y$$ errors can employ CY gates as part of syndrome extraction. Additionally, CY can always be synthesized from CNOT by basis changes: one implementation is to surround a CNOT with phase rotations on the target qubit (e.g. applying an $$S^\dagger$$ before and $$S$$ after the CNOT on the target effectively yields a CY gate, since $$S^\dagger X S = Y$$). This shows that CY is in the same family as other controlled gates and reinforces that any single-qubit operation can be controlled. In practice, most quantum SDKs (Qiskit, Cirq, etc.) include a built-in CY gate for convenience, even if it’s not as ubiquitous as CNOT.

Controlled-Phase (CPHASE) Gate

The controlled-phase gate, often denoted CP($$\theta$$) or simply CPHASE, is a two-qubit gate that imparts a conditional phase shift between the two qubits. It leaves computational basis states unchanged except for one case: when both the control and target are $$|1\rangle$$, the state’s phase is rotated by an angle $$\theta$$. Equivalently, if we label the qubits as control $$c$$ and target $$t$$, CP($$\theta$$) performs:

  • $$|c,t\rangle \to e^{i\theta}|c,t\rangle$$ only if $$c=t=1$$,
  • and acts as the identity on all other basis states.

Matrix: In the $${|00\rangle,|01\rangle,|10\rangle,|11\rangle}$$ basis,

$$$CP(θ)  =  diag(1, 1, 1, eiθ) $$$.

A diagonal matrix with the only phase $$e^{i\theta}$$ on the $$|11\rangle$$ entry. For example, a controlled-$$Z$$ is the special case $$\theta = \pi$$ (giving a −1 phase to $$|11\rangle$$), and a controlled-$$S$$ gate would be $$\theta = \pi/2$$ (a $$90^\circ$$ phase on $$|11\rangle$$). In fact, controlled-$$Z$$, controlled-$$S$$, and controlled-$$T$$ are all members of the CPHASE family for $$\theta=\pi,\;\pi/2,\;\pi/4$$ respectively.

Because the only effect is a phase on $$|11\rangle$$, the controlled-phase gate is symmetric with respect to control and target (sometimes it’s even called a “CZ($$\theta$$)” to emphasize this symmetry). Swapping the two qubits doesn’t change the operation – it simply means “apply phase $$\theta$$ if both qubits are 1.” In circuit diagrams, CPHASE is usually drawn as a control dot connected to a box or gate symbol with “$$\theta$$” inside, indicating the angle of the phase rotation.

Entanglement: Controlled-phase gates are entangling for most values of $$\theta$$. If the qubits start in a superposition, a CPHASE will correlate their amplitudes via phase. For instance, with both qubits in state $$|+\rangle = (|0\rangle+|1\rangle)/\sqrt{2}$$, a CP($$\theta$$) gate produces the state $$\frac{1}{2}(|00\rangle + |01\rangle + |10\rangle + e^{i\theta}|11\rangle)$$ – a generally entangled state (for $$\theta \neq 2\pi k$$). Notably, CP($$\pi$$) is equivalent (up to a conjugation by Hadamard on the target) to the CNOT: $$CZ(c,t)$$ can be turned into a CNOT by Hadamard on the target ($$CZ = H_t\,\mathrm{CNOT}\,H_t$$). More broadly, any CP($$\theta$$) can be implemented by a CNOT sandwiching a single-qubit $$R_z(\theta)$$ rotation on the target. Specifically, one decomposition is: apply CNOT, then an $$R_z(\theta)$$ on the target, then another CNOT. This sequence yields a phase $$\theta$$ on $$|11\rangle$$ while undoing other effects, thus realizing the controlled-phase gate.

Use cases: Controlled-phase gates are crucial in many quantum algorithms, especially those involving phase rotations and interference. A prime example is the Quantum Fourier Transform (QFT): the QFT circuit contains numerous controlled-phase rotations of varying angles (e.g., $$\pi/2, \pi/4, \pi/8,$$ etc.) between qubits. These gates create the delicate phase relationships needed for the Fourier transform on quantum states. In quantum phase estimation (and algorithms like Shor’s factoring), controlled-phase operations appear as well, encoding eigenphase information into relative qubit phases. Additionally, in quantum simulations or variational algorithms, a two-qubit phase gate like $$e^{-i \gamma Z\otimes Z}$$ (which is essentially a symmetric CPHASE) can represent an Ising $$ZZ$$ coupling for a duration proportional to $$\gamma$$. Many quantum hardware platforms natively support some form of controlled-phase: for example, superconducting processors often implement a $$CZ$$ gate as their basic two-qubit interaction, and partial-angle controlled-phase gates can be achieved by analog tuning of that interaction. Controlled-phase gates also play a role in certain oracles and error-correcting codes – for instance, an oracle that marks a particular two-qubit state $$|11\rangle$$ can be realized by a CZ (flipping the amplitude sign of $$|11\rangle$$), or more complex conditions by extended controlled-phase gates. In summary, CPHASE$$(\theta)$$ is a flexible entangling gate: by adjusting $$\theta$$, it ranges from no entanglement ($$\theta=0$$) to maximal entanglement ($$\theta=\pi$$ gives a CZ), and it is indispensable for algorithms requiring fine-grained phase control.

Square-Root-of-SWAP (√SWAP) Gate

The √SWAP gate is a two-qubit gate that performs “half” of the operation of a full SWAP. Recall, the SWAP gate exchanges two qubits’ states: $$|a,b\rangle \to |b,a\rangle$$. The √SWAP instead only partially swaps the states, creating a coherent superposition of swapped and not-swapped outcomes. Applying √SWAP twice in succession yields a full SWAP.

Matrix: One convenient way to express √SWAP is by its action on the basis. √SWAP leaves $$|00\rangle$$ and $$|11\rangle$$ unchanged (those states are symmetric under swapping). On the off-diagonal elements $$|01\rangle$$ and $$|10\rangle$$, √SWAP entangles them. In particular,

  • $$|01\rangle$$ (first qubit 0, second 1) is mapped to an equal superposition: $$\cos(\pi/4)|01\rangle + \sin(\pi/4)|10\rangle = \frac{1}{\sqrt{2}}(|01\rangle + |10\rangle)$$, up to a phase factor.
  • $$|10\rangle$$ is mapped to $$\frac{1}{\sqrt{2}}(|10\rangle + |01\rangle)$$ as well, acquiring the complementary phase.

A more precise unitary matrix for √SWAP is:

$$$
\sqrt{\mathrm{SWAP}}=\begin{pmatrix}
1 & 0 & 0 & 0\\
0 & \frac{1+i}{2} & \frac{1-i}{2} & 0\\
0 & \frac{1-i}{2} & \frac{1+i}{2} & 0\\
0 & 0 & 0 & 1
\end{pmatrix}\
$$$

Here the off-diagonal block is a 50/50 mix of $$|01\rangle$$ and $$|10\rangle$$ with appropriate phases (the $$\frac{1\pm i}{2}$$ factors). This form ensures that two of these in series produce the SWAP matrix (since $$\left(\frac{1+i}{2}\right)^2 = \frac{i}{2} + \frac{1}{2} = (0+1)$$ up to a phase, etc.). Another way to understand √SWAP is as a rotation in the two-dimensional subspace spanned by $${|01\rangle, |10\rangle}$$. A full SWAP is a 180° rotation exchanging those states; √SWAP is a 90° rotation. As a result, √SWAP creates superposition of $$|01\rangle$$ and $$|10\rangle$$ from either basis state.

Entanglement: √SWAP is an entangling gate, though notably it is not maximally entangling by itself. If you start with product basis states, one √SWAP will produce a partial entanglement. For instance, √SWAP acting on $$|01\rangle$$ yields $$\frac{1}{\sqrt{2}}(|01\rangle + |10\rangle)$$ (up to a known phase) – which is actually a Bell state aside from a phase factor. However, if the input states carry certain phases or different amplitudes, the entanglement generated might not reach the maximum possible entropy. In fact, to produce some maximally entangled states from certain product states, you may need more than one √SWAP application. An interesting consequence is that √SWAP alone cannot create a Bell pair from all initial product states without additional single-qubit gates – but it is still a universal entangler when combined with arbitrary 1-qubit operations. In general, √SWAP is universal together with single-qubit rotations: it’s known that the set {√SWAP, all single-qubit gates} can approximate any quantum computation. This universality arises because √SWAP, being entangling, breaks the limitation of single-qubit gates (which alone can’t produce entanglement).

Use cases: The √SWAP gate “arises naturally in systems that exploit exchange interaction”. In physical implementations like quantum dot spin qubits or certain neutral atom schemes, the native two-qubit interaction is an exchange coupling that continuously swaps the states of two qubits. By tuning the interaction time to half the duration of a full swap, the hardware essentially performs a √SWAP. For example, in some quantum dot experiments, the √SWAP is the fundamental two-qubit gate provided by the device’s physics. Google’s Sycamore processor used a variant of √SWAP (the “$$\sqrt{\mathrm{iSWAP}}$$” which is related, adding a phase) combined with a controlled-phase to achieve a rich entangling gate set. When compiling algorithms, if a architecture has √SWAP as an allowed gate, compilers will use multiple √SWAP gates to move qubit states around or to generate needed entanglement. (Since two √SWAPs in a row make a full SWAP, one can swap qubits in two steps, or create stronger correlations by repeating √SWAP interactions.) Moreover, √SWAP is sometimes easier to calibrate to high fidelity than a full SWAP, because it involves shorter interaction times and can avoid certain error resonances. In summary, √SWAP serves as a handy entangler and “routing” tool in systems with exchange coupling. It underscores a general principle: even a gate that is not maximally entangling can be leveraged (repeatedly or with other gates) to perform universal quantum computation.

(Side note: The iSWAP gate mentioned before is closely related to √SWAP. iSWAP swaps the qubits and adds a phase $$i$$ to $$|01\rangle$$ and $$|10\rangle$$ during the swap. In fact, $$\sqrt{\mathrm{iSWAP}}$$ is another entangling gate used in some superconducting qubit systems. √SWAP and √iSWAP are different gates but share the property of partial swapping. The choice of which gate a hardware uses depends on the underlying Hamiltonian: an $$XY$$-exchange interaction yields iSWAP, while a Heisenberg exchange yields a true SWAP. Regardless, the square-root thereof is entangling and often a natural primitive.)

Three-Qubit Gates: Toffoli, Fredkin, and CCZ

Three-qubit gates are less commonly used but important conceptually. The primary examples are the Toffoli gate (CCX) which is a controlled-controlled-NOT, and the Fredkin gate (CSWAP) which is a controlled-SWAP.

Toffoli (CCNOT) gate

The Toffoli has two control qubits and one target qubit. It flips the target bit if and only if both control qubits are 1. In other words, it implements the Boolean function $$target \leftarrow target \oplus (control_1 \wedge control_2)$$. Truth table snippet: it leaves states unchanged unless the first two qubits are $$|11\rangle$$, in which case $$|110\rangle \leftrightarrow |111\rangle$$ (flips the third qubit). The matrix is 8×8, but basically it’s identity on all basis states except that $$|110\rangle$$ goes to $$|111\rangle$$ and $$|111\rangle$$ goes to $$|110\rangle$$. The Toffoli gate is important because, if you restrict to just classical input states, it can function as a universal reversible logic gate (it’s a reversible version of AND with an extra output line). In fact, any classical circuit can be embedded in a quantum circuit using Toffoli gates and ancilla bits. Toffoli was introduced in the 1980s in the context of reversible computing.

Use cases: In quantum algorithms, Toffoli gates often appear when implementing classical arithmetic or Boolean functions within a quantum circuit. For instance, in Shor’s algorithm’s modular exponentiation circuit, Toffolis are used to perform controlled addition (they help compute carries in adders). Toffoli is also used in some error correction routines and in some oracles for Grover’s algorithm (where multiple control conditions need to be satisfied to flip a target “flag” qubit). Because Toffoli involves 3 qubits, it is typically decomposed into multiple one- and two-qubit gates in hardware. A standard decomposition uses 6 CNOT gates plus some single-qubit rotations (the optimal known uses 8 T gates as well, since Toffoli is non-Clifford when considered with no ancillas).

One possible breakdown: $$\text{Toffoli}(c_1,c_2;t)$$ can be done with an ancilla via a couple of CNOTs and T gates, or without ancilla using a specific sequence of CNOT, T, $$T^\dagger$$, and H gates. For practical circuits, minimizing Toffoli count or cost is a big part of quantum circuit optimization if implementing classical logic. Importantly, a Toffoli combined with single-qubit H gates is enough to get universality: it’s known that $${ \text{Toffoli}, H}$$ is a universal gate set. Intuitively, Toffoli can implement any classical reversible function, and H can create superpositions and interference. However, this is more of theoretical interest; actual fault-tolerant gate sets prefer Clifford+T over Toffoli because Toffoli is a heavier gate to do fault-tolerantly (it can be done via multiple T gates anyway).

Fredkin (CSWAP) gate

The Fredkin gate has one control and two target qubits. If the control qubit is 1, it swaps the other two qubits; if the control is 0, it does nothing. So it’s a controlled-SWAP. Like Toffoli, it’s a universal reversible gate for classical computing (since Fredkin can also be used to construct circuits; Fredkin and Toffoli are in fact equivalent in computational power – each can be built from the other with ancillas). However, Fredkin is not as “universal” in quantum sense because it’s in the class of “conservative” logic (it preserves the number of 1s). Fredkin’s truth: if control = 0, (q1,q2) stay as is; if control = 1, (q1,q2) are swapped. Matrix is 8×8, mostly identity except the sub-block where control=1 has a swap on the other two.

Use cases: Fredkin is less common in quantum algorithms. One place it conceptually appears is in certain quantum algorithms for sorting or for simulating reversible logic directly. Historically, Fredkin was proposed for reversible computing implementations (the Fredkin gate is named after Ed Fredkin). In the quantum realm, any Fredkin can be decomposed into CNOT and Toffoli gates (or CNOT and single-qubit gates) – for example, a Fredkin can be done with two Toffolis: use the control and one target to control a NOT on the other target, etc. Experimental demonstrations of Fredkin gates have been done in photonics and ion traps as a proof of concept. But it’s not used as often in mainstream quantum algorithm circuits compared to CNOT or Toffoli.

One thing to note: Fredkin (CSWAP) does not by itself generate entanglement if the two target qubits are both basis states (because swapping |ab⟩ vs |ba⟩ is just a permutation). But if the target qubits are in a superposition with each other, CSWAP can entangle the control with whether the two qubits are swapped or not. For example, $$\frac{1}{\sqrt{2}}(|0\rangle_c|01\rangle_{t1t2} + |1\rangle_c|01\rangle_{t1t2})$$ – actually that specific state wouldn’t change because swapping |01⟩ yields |10⟩ which for indistinguishable superposition might produce entanglement. In any case, Fredkin is not in the Clifford group (it’s as hard as Toffoli in terms of T-count).

Controlled-Controlled-Z (CCZ) Gate

The controlled-controlled-Z gate, or CCZ, is a three-qubit gate and can be viewed as the multi-qubit generalization of the CZ gate. It has two control qubits and one target qubit. CCZ applies a Pauli-$$Z$$ phase flip to the target qubit if and only if both control qubits are $$|1\rangle$$. In terms of basis states: the only basis state that picks up a phase change is $$|111\rangle$$ (controls $$c_1=1$$, $$c_2=1$$, target $$t=1$$), which acquires a phase of −1. All other computational basis states are left unchanged by CCZ. Another way to see it: CCZ performs a conditional CZ – the second control makes the first control’s CZ action contingent. Equivalently, it’s a Toffoli (CCX) gate but with $$Z$$ on the target instead of $$X$$.

Matrix: The CCZ is a 8×8 diagonal unitary (in the basis $$|000\rangle,|001\rangle,\dots,|111\rangle$$):

$$$
\mathrm{CCZ}=\mathrm{diag}(1,1,1,1,1,1,1,-1)
$$$

Where the −1 appears in the last position corresponding to $$|111\rangle$$. This reflects that CCZ does nothing to amplitudes except for a phase flip when all three qubits are 1. Because the target’s state is not flipped (only phased), one might not immediately “see” the effect on classical outputs – CCZ acting on classical 0/1 inputs produces no bit changes (just a global phase of −1 on the $$111$$ state, which doesn’t affect classical truth tables). This contrasts with the Toffoli gate, which does flip the target bit and thus implements a reversible AND. In fact, if we restrict to the computational basis, CCZ acts like the identity on bit values (phase changes are unobservable classically), whereas Toffoli is a nontrivial classical function. However, in quantum algorithms, that phase on $$|111\rangle$$ matters: it enables constructive or destructive interference based on a three-qubit condition.

Relation to Toffoli: Although CCZ and Toffoli have different effects (phase flip vs. bit flip), they are closely related. You can convert one into the other by conjugating with Hadamards on the target qubit. Specifically, CCZ = H (on target) → CCX (Toffoli) → H (on target). Applying Hadamard before and after turns an $$X$$ (bit flip) into a $$Z$$ (phase flip) on the target. So CCZ, Toffoli, and indeed any multi-controlled-$$U$$ gate can be inter-converted by similar basis rotations on the target. This means CCZ is just as powerful as Toffoli from a computational standpoint. In fact, CCZ is a non-Clifford gate, just like Toffoli, and can promote a set of Clifford gates to universality. For example, {H, S, CNOT} is not universal alone, but adding CCZ (or Toffoli or even a T gate) makes the gate set approximate any unitary. CCZ itself can be decomposed into multiple two-qubit and one-qubit gates (one known decomposition uses 4 T gates and 6 CNOTs, for instance), but in some quantum error-correcting codes CCZ can be implemented more directly (transversally), which makes it an interesting candidate for fault-tolerant circuits.

Use cases: CCZ gates appear in scenarios where a conditional phase based on two qubits is needed. A notable application is in certain quantum oracles and amplitude amplification routines. For instance, Grover’s search algorithm uses an “oracle” that marks the correct solution state by flipping its phase. If the solution is specified by $$n$$ bits, one can implement the oracle as an $$n$$-controlled-Z gate (flipping the phase of $$|x_1x_2…x_n = 11…1\rangle$$ if that corresponds to the target state). For $$n=2$$, that’s exactly a CCZ: it flips the amplitude of $$|11t\rangle$$ (with $$t$$ an ancilla initialized to 1) to indicate a marked item. More concretely, imagine we want to apply a −1 phase only when qubit A and qubit B are both 1 – we can achieve that by using CCZ with qubit A and B as controls and preparing the target in $$|1\rangle$$ (the target picks up the phase flip, acting as a flag). This trick is used in multi-qubit phase kickback constructions. Beyond oracles, CCZ (and more general multi-controlled phase gates) have been considered in proposals for quantum chemistry algorithms and Hamiltonian encodings, where a three-body interaction phase might need to be simulated.

Another important use of CCZ is in certain quantum error-correcting code operations. For example, in some versions of magic-state distillation or in 3D color codes, a CCZ gate between three qubits can be implemented transversely (i.e. by independent operations on physical qubits from three code blocks), which is advantageous for fault-tolerance. This is a bit beyond scope, but it highlights that CCZ can sometimes be easier to implement fault-tolerantly than Toffoli. Indeed, CCZ is sometimes called a “phase Toffoli” or a triply-controlled phase-flip, emphasizing its role as a phase gate rather than a logic gate.

Summary: CCZ is less frequently seen than Toffoli in simple algorithm textbooks, because classically it doesn’t compute a new bit (so it’s not useful for reversible logic on its own). However, quantum mechanically it is just as powerful for creating complex entanglement and interference conditions. It joins the ranks of T and Toffoli as a key non-Clifford gate that extends the power of quantum circuits beyond the easily classically simulable regime. Whenever you need to condition an operation on two separate qubits being 1 simultaneously, you have the choice between flipping a third qubit (Toffoli) or flipping a phase (CCZ). The original guide covered Toffoli (CCX) in detail; adding CCZ completes the picture by covering the phase-flip counterpart. In practice, you could use a Toffoli plus an extra Hadamard on the target to get CCZ, but if a circuit naturally lives in the phase domain (like many algorithms do), using CCZ directly is more natural. It’s one more tool in the quantum toolbox for multi-qubit control.

Multi-Control Generalization: Although CCZ is defined with two controls, the concept extends to any number of controls. For example, a controlled-controlled-controlled-Z on four qubits would flip the phase of $$|1111\rangle$$ by −1 (and do nothing to other states). In general, an $$m$$-controlled-Z (sometimes notated $$C^{m}Z$$) will put a phase of −1 on the all-$$1$$ state of $$m+1$$ qubits. These are even less likely to appear explicitly (because for large $$m$$ they are costly to implement), but logically they serve to mark a conjunction of $$m$$ conditions by a phase flip. Many algorithms use such multi-control phase flips in oracles (often implemented with ancillae and multiple CCZ gates). The CCZ gate is simply the $$m=2$$ case. Its inclusion in our expanded guide underlines the principle that quantum gates can naturally extend to control multiple qubits, and each additional control adds another layer of conditional logic (at the cost of requiring more complex decompositions into elementary gates).


Clifford Gates

What Are Clifford Gates?

In quantum computing, Clifford gates are a special subset of quantum logic gates that play a dual role: they are powerful enough to create superposition, entanglement, and enable error correction, yet by themselves they don’t enable full quantum computational advantage. A circuit made only of Clifford gates (also called a Clifford circuit) can be efficiently simulated on a classical computer. This means that while Clifford circuits can perform many quantum operations, they never get “too quantum” to replicate with ordinary computation – a property formalized by the Gottesman-Knill theorem. Common examples of Clifford gates include the Pauli gates (X, Y, Z), the Hadamard (H), the phase gate S (a 90° $$Z$$-rotation), and the two-qubit CNOT (Controlled-NOT). In fact, the Clifford Group on qubits is generated by just H, S, and CNOT. Using only these gates (plus trivial single-qubit phases), one can construct any Clifford operation on any number of qubits. However, no matter how many Clifford gates we compose, we cannot achieve certain transformations needed for universal quantum computation – notably, we can’t produce arbitrary angles of rotation beyond 90° increments or implement gates like the $$T$$ gate (45° $$Z$$-rotation) without introducing non-Clifford elements.

Clifford gates are important because they are highly structured and “stabilizer-friendly.” They preserve the nice mathematical properties of certain quantum states. For example, if a quantum state can be described as the +1 eigenstate of some set of Pauli operators (a stabilizer state), then applying only Clifford gates will map it to another state that is still an eigenstate of some (possibly different) Pauli operators. In other words, Clifford operations always transform Pauli operators to Pauli operators under conjugation. This invariance is why Clifford-only circuits can be tracked efficiently: instead of keeping track of exponentially many amplitudes, we can just keep track of how a set of Pauli stabilizers evolves. Many quantum error-correcting codes (the stabilizer codes) leverage this – their encoding, decoding, and error syndrome measurements consist of Clifford operations, ensuring errors (often modeled as Paulis) propagate in a predictable way that the code can correct. Clifford gates are also easy to implement fault-tolerantly in many architectures, since their symmetric structure often means they don’t amplify certain errors. In summary, Clifford gates are “safe” operations that are classically simulatable and form the backbone of stabilizer techniques (crucial in quantum error correction and benchmarking), but by themselves they are not computationally universal.

The Clifford Group and Stabilizer Formalism

Formally, the Clifford group on n qubits is defined as the set of all unitary operators that normalize the Pauli group. This means that if $$C$$ is a Clifford unitary and $$P$$ is any Pauli operator (like $$X, Y, Z$$ on any qubit, or any tensor product of such on multiple qubits), then $$C P C^\dagger$$ is again a Pauli operator (possibly with an overall phase of $$\pm 1$$ or $$\pm i$$). Equivalently, Clifford gates are exactly those that “send Paulis to Paulis” under conjugation. The single-qubit Clifford group consists of 24 elements (up to global phase), generated by $$H$$ and $$S$$ (plus the identity), which effectively correspond to 90° rotations mapping the Bloch sphere axes to each other. Multi-qubit Cliffords include all products of single-qubit Clifford ops and CNOT (or any controlled-Pauli operation that is equivalent to CNOT by local Cliffords). For instance, CNOT and CZ are Clifford gates – they map tensor-product Pauli operators to other tensor-product Pauli operators (e.g. $$X \otimes I$$ might map to $$X\otimes X$$ under conjugation by a CNOT). A SWAP gate, which merely swaps two qubits’ states, is also a Clifford (it corresponds to just permuting qubit wires, hence permuting Paulis). Because of this Pauli-to-Pauli mapping property, Clifford circuits have a powerful but restrictive structure: they take computational-basis states to stabilizer states (states that can be defined by $$n$$ independent Pauli stabilizers). Any state reachable by a Clifford circuit from $$|0\ldots0\rangle$$ is a stabilizer state, which has an efficient description (it’s specified by its $$2^n$$-element stabilizer group rather than $$2^n$$ amplitudes). The stabilizer formalism exploits this fact by representing an $$n$$-qubit Clifford operation as an update on a set of $$2n$$ binary variables (often visualized as a tableau) instead of a $$2^n \times 2^n$$ matrix. This is why a classical computer can simulate thousands of qubits through Clifford circuits tractably – we only track how stabilizers transform.

Because Clifford gates preserve stabilizer states and map errors to errors within the Pauli framework, they are indispensable for quantum error correction routines. For example, syndrome extraction circuits in the popular Shor and Steane codes consist solely of Clifford gates, ensuring that error propagation doesn’t produce complex superpositions of errors. Clifford operations are also widely used in randomized benchmarking protocols (they form a nice group for averaging out noise). However, a crucial limitation is that Clifford gates alone cannot produce “magic” states needed for a quantum speedup. In technical terms, the set of Clifford operations has efficient classical simulation and fails to be approximate universal. Adding any one gate outside the Clifford group – a non-Clifford gate – is what unlocks universal quantum computing. The smallest example is adding the $$T$$ gate (also called $$\pi/8$$ gate): $${H, S, \mathsf{CNOT}}$$ by itself is classically simulatable, but $${H, S, \mathsf{CNOT}, T}$$ can approximate any unitary operation. In fact, $$T$$ is often called a magic gate because injecting $$T$$ states into a Clifford-only circuit provides the non-Clifford resource that elevates the circuit to universal computational power. Other examples of non-Clifford operations include the Toffoli and CCZ gates – each of these, when added to Clifford gates, similarly makes the gate set universal. This distinction between Clifford vs. non-Clifford underlies much of quantum circuit complexity theory and fault-tolerant computing: Cliffords are easy to implement and error-correct, while non-Cliffords are powerful but typically more costly (e.g. implementing a Toffoli or $$T$$ fault-tolerantly requires multiple ancillary states and operations like magic state distillation).

Clifford vs. Non-Clifford: Classification of Common Gates

Now that we understand what the Clifford group is, we can categorize the common gates discussed in this guide as Clifford or non-Clifford:

  • Pauli X, Y, Z: Clifford. These $$180^\circ$$ flips about the Bloch axes are in the Clifford group. They map computational basis states among themselves and map Pauli operators to $$\pm$$Paulis (indeed, the Paulis are themselves elements of the Clifford group. For example, $$XZX = -Z$$, etc. Pauli gates are essential stabilizer operations in quantum error correction.
  • Hadamard (H): Clifford. The H gate swaps the $$X$$ and $$Z$$ bases (sending $$X$$ to $$Z$$ and vice versa under conjugation). It’s one of the generators of the Clifford group. Applying $$H$$ before or after other operations often changes $$X$$-type to $$Z$$-type operations, which is a hallmark of Clifford behavior.
  • Phase gate (S = $$P(\pi/2)$$): Clifford. The $$S$$ gate is a $$90^\circ$$ phase rotation about $$Z$$ (matrix diag(1, i)). Two $$S$$ gates make a $$Z$$ ($$S^2 = Z$$). $$S$$ is a Clifford generator; it sends $$X$$ to $$Y$$ (up to a phase), thus mapping Pauli axes in a closed way. Its inverse $$S^\dagger$$ (-90° phase) is also Clifford.
  • $$T$$ gate ($$P(\pi/4)$$): Non-Clifford. The $$T$$ is a 45° $$Z$$-axis rotation (matrix diag(1, $$e^{i\pi/4}$$)). Unlike $$S$$, it does not map $$X$$ to a Pauli – for instance, $$T X T^\dagger$$ yields a Pauli rotated by 45°, which is not a Pauli operator. $$T$$ is the smallest-angle single-qubit rotation commonly considered, and it lies outside the Clifford group. This gate is crucial for universality; adding $$T$$ to Cliffords makes a universal set. (Its adjoint $$T^\dagger$$ is also non-Clifford for the same reason.)
  • Rotation gates $$R_x(\theta), R_y(\theta), R_z(\theta)$$: Clifford only for special angles. In general, an arbitrary rotation is non-Clifford unless $$\theta$$ is a multiple of $$90^\circ$$. For example, $$R_z(\pi/2)$$ equals the $$S$$ gate (Clifford), and $$R_z(\pi)$$ equals $$Z$$ (Clifford), but $$R_z(\pi/4)$$ is the $$T$$ gate (non-Clifford). So continuous rotations are outside the Clifford set except at those discrete increments. Quantum hardware often provides rotations as native gates (which are non-Clifford unless restricted to $$\pi/2$$ pulses).
  • CNOT (CX): Clifford. The controlled-NOT gate is a two-qubit Clifford operation. It conjugates Pauli $$X$$ on the target into a two-qubit Pauli $$X \otimes X$$ (if control is involved) and maps a $$Z$$ on the control into $$Z\otimes Z$$ (up to phase) on both qubits, etc. CNOT, together with $$H$$ and $$S$$, generates all other Cliffords. It’s indispensable for entanglement and used in stabilizer circuits to copy Pauli eigenstates to ancillas (for syndrome extraction).
  • Controlled-Z (CZ): Clifford. A CZ gate flips the phase of $$|11\rangle$$ (a controlled phase of $$\pi$$). CZ is locally equivalent to CNOT (conjugating CNOT by H on the target yields CZ), so it’s also a Clifford. Many hardware systems natively implement CZ and treat CNOT as a derived gate; this works fine since both are Clifford and inter-convertible by single-qubit Cliffords.
  • SWAP: Clifford. The SWAP gate exchanges two qubits. It can be broken down into three CNOTs (SWAP = CNOT$${12}$$, CNOT$${21}$$, CNOT$$_{12}$$), so it’s definitely in the Clifford group. SWAP just permutes qubit positions and thus permutes any Pauli operator set trivially. It introduces no new phase or angle – thus it’s as classically simulatable as doing no gate at all (just relabeling qubits).
  • $$i$$SWAP: Non-Clifford (as a gate). The $$i$$SWAP gate swaps two qubits and adds a phase of $$i$$ (90°) to the $$|01\rangle$$ and $$|10\rangle$$ terms that get exchanged. This added phase takes $$i$$SWAP out of the Clifford group – essentially, $$i$$SWAP is a SWAP with a non-Clifford phase twist. (Notably, $$(i\text{SWAP})^2 = $$ SWAP up to a global phase, so two consecutive $$i$$SWAPs are Clifford-equivalent to a plain SWAP.) In practice, $$i$$SWAP and its fractional versions are common in hardware, but a single $$i$$SWAP operation cannot be composed from just H, S, and CNOT without using at least one $$T$$-like rotation to account for the $$i$$ phase.
  • √iSWAP (square-root of iSWAP): Non-Clifford. This is a partial entangling gate (used, for example, in Google’s Sycamore processor) equal to an $$i$$SWAP taken to the 1/2 power. It produces entanglement with a 45° swap angle. Since $$i$$SWAP is already non-Clifford, its square root is certainly non-Clifford (in fact it’s “halfway” entangling). √iSWAP combined with single-qubit rotations forms a universal entangling gate set for certain hardware, but by itself it’s outside the Clifford class.
  • Controlled-Phase gates, CP(θ): Non-Clifford in general. A controlled-phase gate applies a phase $$e^{i\theta}$$ to $$|11\rangle$$ (with $$θ = π$$ giving CZ). For arbitrary angles $$θ$$ (like $$π/4$$ or $$π/8$$), CPHASE(θ) is not Clifford because it’s equivalent to introducing a fractional $$Z$$-rotation controlled on another qubit. One can implement CPHASE(θ) by sandwiching a single-qubit $$R_z(θ)$$ between CNOTs – but as noted, unless $$θ$$ is a multiple of 90°, that $$R_z(θ)$$ is non-Clifford. Only for special cases like $$θ = π$$ (giving CZ, which is Clifford) or $$θ = π/2$$ (giving a controlled-$$S$$ gate) do we get a Clifford operation. In general, Controlled-$$S$$ (CP($$π/2$$)) is non-Clifford, since it effectively uses a $$T$$-gate in its decomposition.
  • Controlled-Y (CY): Clifford. A controlled-$$Y$$ gate applies a Pauli $$Y$$ on the target when the control is 1. Although not as commonly listed as a primitive, CY is equivalent to applying a controlled-X (CNOT) conjugated by an $$S$$ on the target qubit. In fact, $$Y = S X S^\dagger$$ (up to a phase), so one construction is: apply $$S^\dagger$$ on target, then CNOT, then $$S$$ on target. This means CY can be built from Clifford gates, hence it is itself a Clifford operation.
  • Toffoli (CCX): Non-Clifford. The Toffoli gate (doubly-controlled NOT) is a three-qubit gate that flips a target qubit if both control qubits are 1. Toffoli is famous as a universal classical reversible gate, but quantumly it lies outside the Clifford group. It can be decomposed into Clifford gates plus eight $$T$$ gates in a optimal fault-tolerant implementation, which indicates its non-Clifford nature. In other words, you need those non-Clifford $$T$$ phases to synthesize CCX. Consequently, Toffoli (or its relative CCZ) is often used as a benchmark of non-Clifford “cost” in circuits (counting how many $$T$$ gates it needs).
  • CCZ (controlled-controlled-Z): Non-Clifford. This is the three-qubit gate that applies a $$Z$$ on a target qubit conditioned on two controls (or equivalently flips the phase of $$|111\rangle$$). CCZ is essentially the Toffoli gate in the $$Z$$ basis (up to Hadamards on the target), so it is also outside the Clifford group. In fact, adding either Toffoli or CCZ to the Clifford set is enough to make it universal. Like the Toffoli, a CCZ can be broken down into multiple $$T$$ gates if one only has Clifford operations available.
  • Fredkin (CSWAP): Non-Clifford. The Fredkin gate is a controlled-SWAP: if the control is 1, it swaps the other two qubits. Fredkin is not Clifford – it has a similar complexity to Toffoli in terms of requiring $$T$$ gates to implement. It does not preserve the Pauli stabilizer structure (except in trivial cases), and indeed it’s stated to be “as hard as Toffoli” for fault-tolerant implementations. In practice, Fredkin is rarely used in algorithms, but if needed, it’s synthesized using multiple non-Clifford operations.

In summary, Clifford gates (like X, Y, Z, H, S, CNOT, CZ, SWAP, etc.) are those that preserve the Pauli/stabilizer structure and are not by themselves computationally universal. Non-Clifford gates (like T, CCX, CCZ, and other fractional rotations) are the “magic” ingredients that, when added to Cliffords, unlock the full power of quantum computing. The interplay between easy-to-simulate Clifford operations and hard-to-simulate non-Cliffords is central to quantum circuit design, optimization, and error correction in the quest for practical quantum computers.

Universality of Gate Sets

Universal gate set means a set of gates from which one can approximate any unitary transformation on $$n$$ qubits to any desired accuracy. In classical logic, {NAND} is universal for boolean functions. In quantum, no single-qubit gate (finite set) can be exactly universal because there’s a continuum of unitaries – but a combination of discrete gates can be approximately universal. A common universal set is {H, T, CNOT}. Here H and T generate arbitrary single-qubit unitaries (H and T can approximate any rotation since T gives 45° increments of phase), and CNOT provides entanglement to expand to multi-qubit operations. Another perspective: Clifford gates alone (generated by H, S, CNOT) are not universal because they can be efficiently simulated classically. The addition of any one non-Clifford gate (like T or CCZ or Toffoli) makes the set universal. This is why T is called the magic gate for universality – it breaks out of the Clifford constraint. The Solovay-Kitaev theorem guarantees that even a small set of gates that generate a dense subgroup (like {H,T} for single qubit) will allow approximation of any target gate with polynomial overhead in log(1/ε).

Alternate universal sets: {X, Z, √X (or H), CNOT} works as well. {RX(π/2), RZ(π/2), CNOT} is another common choice (IBM’s basis is typically U1, U2, U3 which are combinations of rotations, plus CNOT). As mentioned, {Toffoli, H} is universal (though not used in practice for synthesis). Even a single three-qubit gate can be universal: the Deutsch gate (a certain 3-qubit continuous family) is known to be universal by itself. But in standard models, we stick to two-qubit entanglers and one-qubit rotations.

From a practical standpoint, gate universality means we can compile high-level algorithms to the specific primitive gates a hardware supports. For example, Google’s Sycamore uses √iSWAP and CZ; IBM uses CNOT and U3 (arbitrary single). Both are universal sets. Another example: {CZ, H, T} is universal as well (since CZ and CNOT are interchangeable by H on target).

Which gates are universal? – Strictly speaking, no finite set of exactly implemented gates can produce every possible unitary exactly, but sets like {H, T, CNOT} are approximate universal (arbitrary precision). If one allows continuous parameters, {Rz(θ), Rx(π/2), CNOT} is exactly universal because Rz(θ) is a continuous family.

Why universality matters: It means any quantum algorithm can be expressed with those gates. For example, Shor’s algorithm or Grover’s algorithm ultimately can be broken down to sequences of H, T, and CNOT (lots of them!). This is analogous to how any classical computation can be broken into AND, OR, NOT gates.

In conclusion, quantum gates are the language through which quantum algorithms are expressed. Single-qubit gates allow us to prepare superpositions and manipulate phases. Multi-qubit gates allow us to create entanglement and conditional operations. The interplay of these gates leads to rich phenomena like interference and entangled states that give quantum computers their edge. Understanding common gates like the Pauli rotations, Hadamard, CNOT, etc., is fundamental for designing and reading quantum circuits. And knowing that a certain small set of gates is universal reassures us that we don’t need an endless zoo of gates – just a well-chosen “basis” and we can build anything. As quantum hardware matures, the specific native gate sets might differ (one machine might naturally do CZ, another iSWAP), but since all these sets are universal, they can all execute the same quantum algorithms with suitable compilation. Quantum gates thus form the toolkit for all quantum computation, much like logic gates do for classical computation.

Marin Ivezic

I am the Founder of Applied Quantum (AppliedQuantum.com), a research-driven consulting firm empowering organizations to seize quantum opportunities and proactively defend against quantum threats. A former quantum entrepreneur, I’ve previously served as a Fortune Global 500 CISO, CTO, Big 4 partner, and leader at Accenture and IBM. Throughout my career, I’ve specialized in managing emerging tech risks, building and leading innovation labs focused on quantum security, AI security, and cyber-kinetic risks for global corporations, governments, and defense agencies. I regularly share insights on quantum technologies and emerging-tech cybersecurity at PostQuantum.com.
Share via
Copy link
Powered by Social Snap