mimiqcircuits.decomposition.rules.solovay_kitaev¶
Solovay-Kitaev algorithm for approximating arbitrary unitaries with Clifford+T.
The Solovay-Kitaev algorithm recursively refines an initial approximation using group commutators, achieving ε-approximation with O(log^c(1/ε)) gates where c ≈ 3.97.
References
Dawson & Nielsen, “The Solovay-Kitaev algorithm” (2005)
Kitaev, Shen, Vyalyi, “Classical and Quantum Computation” (2002)
Functions
|
Construct an SU(2) matrix from rotation axis and angle. |
|
Extract the rotation angle θ from an SU(2) matrix U = exp(iθ n·σ/2). |
|
Extract the rotation axis n from an SU(2) matrix U = exp(iθ n·σ/2). |
|
Find the gate sequence in the ε-net that best approximates U. |
|
Find two orthonormal vectors v, w perpendicular to n. |
|
Convert a gate to a numpy matrix. |
|
Decompose an SU(2) matrix Δ (close to identity) into V and W. |
|
Generate an ε-net over SU(2) using Breadth-First Search. |
|
Get the basic Clifford+T gates for the epsilon-net. |
|
Get or initialize the Solovay-Kitaev lookup tables. |
|
Return the inverse of a gate sequence: (g₁ g₂ . |
|
Map an SU(2) matrix to a point in R^4 (the 3-sphere S³). |
|
Compute the Frobenius norm distance ||U - V||_F. |
|
Compute the unitary matrix for a gate sequence. |
|
Simplify a gate sequence by canceling adjacent gates. |
|
Approximate an SU(2) matrix using the Solovay-Kitaev algorithm. |
|
Project a 2x2 unitary matrix to SU(2) by removing the global phase. |
Classes
|
Cache entry for Solovay-Kitaev lookup tables. |
|
Rewrite rule that approximates single-qubit gates with Clifford+T by Solovay-Kitaev. |
- class SolovayKitaevRewrite(depth=3, simplify=True, net_max_depth=10, net_max_points=50000, net_min_dist=0.02)[source]¶
Bases:
RewriteRuleRewrite rule that approximates single-qubit gates with Clifford+T by Solovay-Kitaev.
The rule starts from the closest entry of a precomputed table (an epsilon-net) of short sequences of
H,T,T†,S,S†,X,YandZ, and refines itdepthtimes with group commutators. Refinements lower the error on average, not at every step, and each multiplies the length of the sequence by about 5. The approximation holds up to a global phase. For Z-rotations,GridSynthRewritegives much shorter sequences for the same error.- Parameters:
depth (int) – Number of refinements, at least 0 (default
3). With0the closest table entry is used as it is.simplify (bool) – Cancel and merge adjacent gates of the result, such as
Tfollowed byT†or twoS(defaultTrue).net_max_depth (int) – Longest sequence in the table (default
10).net_max_points (int) – Largest number of table entries (default
50000).net_min_dist (float) – Smallest distance between two table entries (default
0.02).
- Raises:
ValueError – If
depthis negative.
Supported Operations
GateRZ(λ),GateRY(θ)andGateRX(θ)GateU(θ, φ, λ, γ)
Only numeric parameters are matched; symbolic ones are not.
Examples
>>> from mimiqcircuits import * >>> # one refinement of the closest table entry >>> rule = SolovayKitaevRewrite(depth=1) >>> circ = rule.decompose_step(GateRZ(0.123), [0], [], []) >>> # the result only uses Clifford+T gates >>> {type(inst.operation) for inst in circ} <= {GateH, GateT, GateTDG, GateS, GateSDG, GateX, GateY, GateZ} True
Note
The table is built on first use, which takes a few seconds, and is then kept for later calls with the same
net_*settings.- decompose_step(op, qubits, bits, zvars)[source]¶
Approximate a single-qubit gate with Clifford+T gates.
- Parameters:
- Returns:
A new
Circuitwith the Clifford+T approximation. It can be empty when the gate is close to the identity.- Raises:
DecompositionError – If
matches()rejectsop.- Return type: