Computing Library › Quantum Logic Gates
Quantum Logic Gates

Parity Gates

Gates that compute or phase according to the parity of a set of qubits, central to error-correction stabilizer checks.

Definition

A parity gate acts on the parity — the XOR — of several qubits rather than on their individual values. The simplest is CNOT, which writes the parity of control and target into the target. Chains of CNOTs into a common ancilla compute the parity of many qubits, and phase-parity gates like RZZ apply a phase set by that parity.

Parity computation with CNOTs

Kronos motion — error correction

A cascade CNOT(q1→a), CNOT(q2→a), ..., CNOT(qk→a) leaves the ancilla a holding q1 ⊕ q2 ⊕ ... ⊕ qk. Measuring the ancilla reveals the joint parity without revealing individual bit values — the defining feature of a stabilizer parity check that detects errors without collapsing the encoded information.

q1q2q3parity
0000
1100
1010
1111

Phase-parity gates

RZZ(θ) applies a phase depending on two-qubit Z-parity, and its multi-qubit generalization exp(-i θ Z⊗Z⊗...⊗Z / 2) phases by the parity of a whole string. These are compiled as a CNOT ladder that gathers parity onto one qubit, a single-qubit RZ, then the reversed ladder. See RZZ.

python
# multi-qubit ZZ...Z phase as CNOT ladder + RZ
# for i in 1..k-1: cnot(q[i] -> q[k])
# rz(theta) on q[k]
# for i in k-1..1: cnot(q[i] -> q[k])
def parity_ladder_cnots(k):
    return 2*(k-1)

Role in error correction

Stabilizer codes are defined by commuting parity operators — X-parity and Z-parity checks on plaquettes and stars in the surface code. Every syndrome-extraction round is a set of parity-gate measurements. The parity language ties directly to the Pauli group. See Pauli group and controlled-phase.