- Compilation/
Gridsynth: Ross-Selinger synthesis
Gridsynth: Ross-Selinger synthesis
Gridsynth, i.e., the Ross-Selinger synthesis, is one of the first number theoretic algorithms for optimally compiling arbitrary single-qubit Z-rotations into the universal \text{Clifford}+T := \{H, S, T, X, Y, Z\} gate set without using auxiliary qubits [1].
While legacy constructive techniques like the Solovay-Kitaev algorithm approximate gates with an unoptimized T-count scaling of \mathcal{O}(\log^c(1/\epsilon)) for c \approx 3.97, gridsynth guarantees strict asymptotic scaling that directly minimizes non-Clifford gate overhead:
\text{T-count} = 3\log_2(1/\epsilon) + \mathcal{O}(\log(\log(1/\epsilon))),
and classical computation overhead of \mathcal{O}(\mathrm{polylog}(1/\epsilon)) in time complexity, allowing modern compilers to quickly synthesize phase angles to high precision [1].
Inputs
- Arbitrary single-qubit rotation operator R_Z(\theta) or phase shift.
- Target error tolerance \epsilon > 0.
Outputs
- An optimized sequence of discrete Clifford+T gates that approximates the target operation within the specified \epsilon.
Example: Decomposing Single Rotation Operators
To decompose an isolated single-qubit rotation operator down to a Clifford+T gate set, you can use qp.ops.rs_decomposition [2].
import pennylane as qp
import numpy as np
# Define a target RZ rotation operator
phi = np.pi / 5
target_op = qp.RZ(phi, wires=0)
# Synthesize the operator to the Clifford+T sequence
compiled_sequence = qp.ops.rs_decomposition(
target_op,
epsilon=1e-3,
max_search_trials=20
)
num_t_gates = sum(1 for gate in compiled_sequence if isinstance(gate, qp.T))
compiled_mat = qp.prod(*compiled_sequence).matrix()
op_norm = np.linalg.norm(target_op.matrix() - compiled_mat, ord=2)
print(f"Synthesized gate sequence: {compiled_sequence}")
print(f"Number of T-gates: {num_t_gates}")
print(f"Approximation error: {op_norm}")
Synthesized gate sequence: [H(0), T(0), S(0), H(0), T(0), S(0), H(0), T(0), S(0), H(0), T(0), H(0), T(0), H(0), T(0), H(0), T(0), S(0), H(0), T(0), H(0), T(0), S(0), H(0), T(0), S(0), H(0), T(0), H(0), T(0), H(0), T(0), S(0), H(0), T(0), S(0), H(0), T(0), H(0), T(0), S(0), H(0), T(0), S(0), H(0), T(0), S(0), H(0), T(0), H(0), T(0), H(0), T(0), H(0), T(0), S(0), H(0), T(0), S(0), H(0), T(0), H(0), T(0), H(0), T(0), S(0), H(0), T(0), H(0), T(0), S(0), H(0), T(0), S(0), H(0), T(0), S(0), H(0), T(0), H(0), T(0), Adjoint(S(0)), H(0), GlobalPhase(array(4.71238898), wires=[])]
Number of T-gates: 32
Approximation error: 0.0007478841155
Typical Usage: Circuit-Wide Compilation Pipeline
In practical compilation passes, you rarely synthesize individual gates in isolation. Instead, discretization is done as an automated step across entire circuits. In PennyLane, this structure transformation is handled by the qp.transforms.clifford_t_decomposition transform pass using method="gridsynth". It deploys one-qubit and two-qubit synthesis to reduce complex gates down to standard primitives, including Cliffords and Pauli rotations, and then seamlessly hands off the latter to gridsynth for final Clifford+T translation.
import pennylane as qp
dev = qp.device("default.qubit", wires=2)
@qp.transforms.clifford_t_decomposition(epsilon=1e-3, method="gridsynth")
@qp.qnode(dev)
def compiled_quantum_circuit(angle):
qp.Hadamard(wires=0)
qp.RZ(angle, wires=0)
qp.CNOT(wires=[0, 1])
return qp.state()
print(qp.draw(compiled_quantum_circuit, level=1)(0.628))
0: ──H─╭●──T──H──T──S──H──T──H──T──S──H──T──H──T──H──T──H──T──S──H──T──H──T──H ···
1: ────╰X───────────────────────────────────────────────────────────────────── ···
0: ··· ──T──H──T──S──H──T──S──H──T──H──T──S──H──T──H──T──S──H──T──H──T──S──H ···
1: ··· ───────────────────────────────────────────────────────────────────── ···
0: ··· ──T──S──H──T──S──H──T──H──T──H──T──S──H──T──H──T──H──T──H──T──S──H──T ···
1: ··· ───────────────────────────────────────────────────────────────────── ···
0: ··· ──H──T──H──T──H──T──H──T──H──T──X─╭GlobalPhase(0.79)─┤ State
1: ··· ──────────────────────────────────╰GlobalPhase(0.79)─┤ State
References
[1] N. J. Ross and Peter Selinger, Optimal ancilla-free Clifford+T approximation of z-rotations. arXiv preprint arXiv:1403.2975, (2014).
[2] PennyLane, Ross-Selinger Decomposition (rs_decomposition). PennyLane Documentation. Retrieved from docs.pennylane.ai, (2026).
Cite this page
@misc{PennyLane-Gridsynth,
title = "Gridsynth: Ross-Selinger synthesis",
author = "Utkarsh Azad",
year = "2026",
howpublished = "\url{https://pennylane.ai/compilation/gridsynth}",
}
Page author(s)
Utkarsh Azad
Utkarsh is a quantum physicist and computer scientist. He currently works as a senior quantum scientist at Xanadu. When he's not untangling qubits there, you'll find him observing fractals and writing poetry.