Clifford2native
Decompose composite squin Cliffords into the neutral-atom native gate set.
Gemini runs three primitives: a rotation R(axis_angle, rotation_angle), a
Rz(angle), and an entangling CZ. Seven squin Clifford statements map
onto one of those one-to-one --
====================== ==========================
squin statement neutral-atom primitive
====================== ==========================
X R(0, 1/2)
Y R(1/4, 1/2)
Z Rz(1/2)
S / S_adj Rz(+/- 1/4)
SqrtX / adj R(0, +/- 1/4)
SqrtY / adj R(1/4, +/- 1/4)
CZ CZ
====================== ==========================
-- while H, CX, CY and Swap are composites that have to be
expanded first.
Upstream SquinToNative does expand them, but inside the
bloqade.native standard-library kernels (broadcast.cy and friends), one
level below squin. Anything the composites expand to is therefore invisible to
squin-statement rewrites, which is how logical squin.cy ended up as
Zbar(control) . CY: the Steane transversal correction had no SqrtX
statement to flip, because cy's two sqrt(X) layers only existed inside the
native kernel (QuEraComputing/bloqade-internal#404).
This rule performs the same expansion at the statement level instead, so
every gate the hardware will actually run is visible as squin IR before
SquinToNative turns it into rotations. The decompositions below are the
ones in bloqade.native.stdlib.broadcast; keep them in sync.
DecomposeCliffordToNative
Bases: RewriteRule
flowchart TD
bloqade.lanes.rewrite.clifford2native.DecomposeCliffordToNative[DecomposeCliffordToNative]
click bloqade.lanes.rewrite.clifford2native.DecomposeCliffordToNative href "" "bloqade.lanes.rewrite.clifford2native.DecomposeCliffordToNative"
Expand H, CX, CY and Swap into the squin Clifford
statements that lower one-to-one onto Gemini's native gate set.
Idempotent: the expansions only emit statements the rule does not match.
Ordering
The _hadamard / _controlled_* / _swap helpers return their
statements in circuit order -- element 0 runs first -- and _expand
preserves that order in the IR.
Their docstrings state the identity as an operator product, which reads the other way round, right to left. So
CX = sqrt(Y) . CZ . sqrt(Y)^dag (operator product)
is emitted as, and appears in the IR as,
sqrt_y_adj(targets); cz(controls, targets); sqrt_y(targets)
The two are reverses of each other by convention, not by accident: the conjugator adjacent to the ket in the product is the gate applied first. Read the formula when you want to check the conjugation direction, and the returned list when you want to know what the hardware runs.