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

axis_angle_to_su2(axis, theta)

Construct an SU(2) matrix from rotation axis and angle.

extract_rotation_angle(U)

Extract the rotation angle θ from an SU(2) matrix U = exp(iθ n·σ/2).

extract_rotation_axis(U)

Extract the rotation axis n from an SU(2) matrix U = exp(iθ n·σ/2).

find_nearest_in_net(U, cache)

Find the gate sequence in the ε-net that best approximates U.

find_orthogonal_axes(n)

Find two orthonormal vectors v, w perpendicular to n.

gate_to_matrix(gate)

Convert a gate to a numpy matrix.

gc_decompose(delta)

Decompose an SU(2) matrix Δ (close to identity) into V and W.

generate_epsilon_net(basis_gates[, ...])

Generate an ε-net over SU(2) using Breadth-First Search.

get_basic_gates()

Get the basic Clifford+T gates for the epsilon-net.

get_sk_cache(basis_gates[, max_depth, ...])

Get or initialize the Solovay-Kitaev lookup tables.

invert_sequence(gates)

Return the inverse of a gate sequence: (g₁ g₂ .

matrix_to_point(U)

Map an SU(2) matrix to a point in R^4 (the 3-sphere S³).

operator_norm_distance(U, V)

Compute the Frobenius norm distance ||U - V||_F.

sequence_to_matrix(gates)

Compute the unitary matrix for a gate sequence.

simplify_sequence(gates)

Simplify a gate sequence by canceling adjacent gates.

sk_approximate(U, depth, basis_gates, cache)

Approximate an SU(2) matrix using the Solovay-Kitaev algorithm.

to_su2(U)

Project a 2x2 unitary matrix to SU(2) by removing the global phase.

Classes

SKCacheEntry(net_tree, net_sequences, ...)

Cache entry for Solovay-Kitaev lookup tables.

SolovayKitaevRewrite([depth, simplify, ...])

Rewrite rule using the Solovay-Kitaev algorithm.

class mimiqcircuits.decomposition.rules.solovay_kitaev.SolovayKitaevRewrite(depth=3, simplify=True, net_max_depth=10, net_max_points=50000, net_min_dist=0.02)[source]

Bases: RewriteRule

Rewrite rule using the Solovay-Kitaev algorithm.

Approximates arbitrary single-qubit unitaries using a sequence of Clifford+T gates. The algorithm recursively refines an initial approximation using group commutators, achieving ε-approximation with O(log^c(1/ε)) gates.

Parameters:
  • depth (int) – Recursion depth (default: 3). Higher = better precision, more gates.

  • simplify (bool) – Whether to simplify the resulting sequence (default: True).

  • net_max_depth (int) – Maximum depth for epsilon-net generation (default: 15).

  • net_max_points (int) – Maximum points in epsilon-net (default: 100,000).

  • net_min_dist (float) – Minimum distance between epsilon-net points (default: 0.01).

Supported operations:
  • GateRZ(λ): Z-rotation by angle λ

  • GateRY(θ): Y-rotation by angle θ

  • GateRX(θ): X-rotation by angle θ

  • GateU(θ, φ, λ, γ): General single-qubit unitary

Symbolic parameters are NOT supported.

Example

>>> from mimiqcircuits import GateRZ
>>> from mimiqcircuits.decomposition import SolovayKitaevRewrite
>>> rule = SolovayKitaevRewrite(depth=0)
>>> circ = rule.decompose_step(GateRZ(0.123), [0], [], [])

Note

The first call may be slow due to epsilon-net generation. Subsequent calls reuse the cached net.

depth: int = 3
simplify: bool = True
net_max_depth: int = 10
net_max_points: int = 50000
net_min_dist: float = 0.02
matches(op)[source]

Check if this rule can decompose the operation.

Matches single-qubit rotations with concrete (non-symbolic) angles.

Parameters:

op (Operation) – The operation to check.

Returns:

True if this rule can decompose the operation.

Return type:

bool

decompose_step(op, qubits, bits, zvars)[source]

Decompose the operation using Solovay-Kitaev.

Parameters:
  • op (Operation) – The operation to decompose.

  • qubits (Sequence[int]) – Qubit indices for the operation.

  • bits (Sequence[int]) – Classical bit indices (unused).

  • zvars (Sequence[int]) – Z-variable indices (unused).

Returns:

A Circuit containing the Clifford+T approximation.

Raises:

DecompositionError – If the operation cannot be decomposed.

Return type:

Circuit

__init__(depth=3, simplify=True, net_max_depth=10, net_max_points=50000, net_min_dist=0.02)