|q⟩ Bad Qubits

advanced · Programming · Advanced Circuit Construction & Transpilation

Gate Decomposition

A real quantum processor never exposes the textbook menu of gates. Each platform implements a small, fixed native gate set — perhaps arbitrary ZZ rotations, one calibrated XX-type rotation, and a single two-qubit entangler. Everything a programmer writes, from a Hadamard to a Quantum Fourier Transform, must ultimately be rewritten in those primitives before it can run. That rewriting is called gate decomposition, and it is the first job of any transpiler.

Why decomposition is always possible

Every single-qubit gate is a 2×22\times 2 unitary, and the ZXZ Euler decomposition guarantees that any such unitary UU factors as

U=eiδRz(α)Rx(β)Rz(γ),U = e^{i\delta}\, R_z(\alpha)\, R_x(\beta)\, R_z(\gamma),

for some real angles δ,α,β,γ\delta, \alpha, \beta, \gamma, where

Rz(θ)=eiθZ/2,Rx(θ)=eiθX/2.R_z(\theta) = e^{-i\theta Z/2}, \qquad R_x(\theta) = e^{-i\theta X/2}.

This is a statement about SU(2)SU(2): three Euler angles parameterize every rotation of the Bloch sphere, and the prefactor eiδe^{i\delta} accounts for the global phase that distinguishes U(2)U(2) from SU(2)SU(2). Because the global phase is physically unobservable, a transpiler is free to drop eiδe^{i\delta} — the remaining three rotations reproduce all measurable behaviour.

Decomposing the Hadamard

The Hadamard is the canonical example. Writing it as a rotation product,

H=eiπ/2Rz ⁣(π2)Rx ⁣(π2)Rz ⁣(π2).H = e^{i\pi/2}\, R_z\!\left(\tfrac{\pi}{2}\right)\, R_x\!\left(\tfrac{\pi}{2}\right)\, R_z\!\left(\tfrac{\pi}{2}\right).

You can confirm this on the Bloch sphere: HH is a 180180^\circ rotation about the axis (x^+z^)/2(\hat x + \hat z)/\sqrt 2, and the three-rotation sequence walks the same net rotation by composing a quarter turn about zz, a quarter turn about xx, and another quarter turn about zz.

Cost accounting

Decomposition is not free. A single logical gate can expand into several native ones, and the count matters because every physical gate carries error. A good decomposer minimizes the number of expensive operations — usually the two-qubit entangler — even if that means spending a few extra cheap single-qubit rotations. The angles produced are often irrational multiples of π\pi, which is exactly the difficulty the Solovay–Kitaev theorem (later in this module) addresses when the native set is discrete rather than continuous.

Try it

Rebuild the Hadamard using only RzR_z and RxR_x rotations — no h(). The grader checks the full single-qubit unitary up to global phase.

Run your code to see the quantum state.

Sign in on the full site to ask questions and join the discussion.