Circuit machinery#
Turns a Yao-style gate list into a JAX einsum, and caches the contraction path and the JIT-compiled closure. Every basis uses it.
Circuit machinery: einsum builder + JIT closure cache.
Shared by every basis. The builder converts a Yao-style gate list into a
JAX einsum (Hadamard-first sort + Yao little-endian ordering preserved).
The cache memoizes jnp.einsum_path results and the JIT’d closures.
Contents
Convert a gate sequence to (subscripts, tensors, shapes). |
|
Build a JIT-compiled stepped circuit closure. |
|
Contract pic through the circuit and reshape back to (2^m, 2^n). |
|
Return a jit-compiled einsum closure bound to fixed subscripts and shapes. |
|
Return |
|
One gate of a circuit program. |
|
2x2 compact representation of a 4x4 controlled-phase gate. |
|
Return the 2-qubit (2, 2, 2, 2)-shaped tensor matching the 4×4 controlled- phase gate diag(1, 1, 1, exp(iφ)). |
|
Extract |
|
True if |
|
Return indices of the LAST |