mimiqcircuits.decomposition.rules.gridsynth¶
Ross–Selinger gridsynth: Clifford+T approximation of Z-rotations.
The synthesis itself is implemented in Rust in the mimiqcircuits._core
extension.
References
N. J. Ross and P. Selinger, “Optimal ancilla-free Clifford+T approximation of z-rotations”, Quantum Inf. Comput. 16, 901 (2016), arXiv:1403.2975.
Classes
|
Rewrite rule that approximates |
- class mimiqcircuits.decomposition.rules.gridsynth.GridSynthRewrite(epsilon=1e-10, seed=0)[source]¶
Bases:
RewriteRuleRewrite rule that approximates
GateRZwith a Clifford+T sequence, using the Ross–Selinger gridsynth algorithm.For
GateRZ(λ)the rule emits a sequence ofGateH,GateS,GateSDG,GateZ,GateTandGateXwhose unitaryVsatisfiesmin_φ ‖RZ(λ) − e^{iφ}V‖ ≤ epsilonin operator norm. The approximation holds up to a global phase, which is dropped. The T-count is about3·log₂(1/epsilon)and, except for rare failures of the integer factoring step, optimal among ancilla-free Clifford+T circuits with this error. Angles that are multiples ofπ/4give their exact short decomposition.The factoring step is randomized. For a fixed
seed, the same angle and tolerance always give the same sequence. Results are cached per angle, since circuits often repeat the same rotation.The synthesis runs in the compiled
mimiqcircuits._coreextension without holding the GIL, so several threads can synthesize in parallel.- Parameters:
- Raises:
ValueError – If
epsilonorseedis out of range.TypeError – If
epsilonis not a real number orseedis not an integer.
- Supported operations:
GateRZ(λ)with a numeric angleλ.
Symbolic angles are not matched.
GateRX,GateRYandGateUmust first be reduced to Z-rotations, for example withZYZRewriteandToZRotationRewrite.CliffordTBasisdoes this and uses this rule by default.Example
>>> from mimiqcircuits import GateRZ, GateT >>> from mimiqcircuits.decomposition import GridSynthRewrite >>> def tcount(c): ... return sum(isinstance(i.operation, GateT) for i in c) >>> # Approximate one rotation to the default tolerance 1e-10 >>> circ = GridSynthRewrite().decompose_step(GateRZ(0.123), [0], [], []) >>> # A coarser tolerance gives fewer T gates >>> coarse = GridSynthRewrite(epsilon=1e-4).decompose_step(GateRZ(0.123), [0], [], []) >>> tcount(coarse) < tcount(circ) True
References
N. J. Ross and P. Selinger, “Optimal ancilla-free Clifford+T approximation of z-rotations”, Quantum Inf. Comput. 16, 901 (2016), arXiv:1403.2975.
- decompose_step(op, qubits, bits, zvars)[source]¶
Decompose the Z-rotation into Clifford+T gates.
- Parameters:
- Returns:
A Circuit containing the Clifford+T approximation.
- Raises:
DecompositionError – If the operation is not a numeric
GateRZ.ValueError – If the angle is not finite.
- Return type:
- __init__(epsilon=1e-10, seed=0)¶