Skip to main content

controlled_gate_decomposition_lines

Return a Clifford+T decomposition for a controlled-controlled gate.

decode_t_user_tag

Return the user tag attached to an encoded T-family gate tag.

encode_t_tag

Encode a T-family gate tag while preserving an optional user tag.

enriched_stim_error

Improve stim parse errors for tsim-specific gates. When stim raises a ‘Gate not found’ error for a gate that should have been converted by shorthand_to_stim, this searches the converted text for the unconverted usage and returns a more helpful error message.

shorthand_to_stim

Convert tsim shorthand syntax to valid stim instructions. Converts: CCZ 0 1 2 → Clifford+T decomposition of CCZ CCX 0 1 2 → Clifford+T decomposition of CCX/Toffoli T 0 1 → S[T] 0 1 T_DAG 0 1 → S_DAG[T] 0 1 TPP X0Y1 → SPP[T] X0Y1 TPP_DAG X0Y1 → SPP_DAG[T] X0Y1 R_Z(0.3) 0 → I[R_Z(theta=0.3pi)] 0 R_X(0.25) 0 → I[R_X(theta=0.25pi)] 0 R_Y(-0.5) 0 → I[R_Y(theta=-0.5pi)] 0 R_XX(0.5) 0 1 → SPP[R_PAULI(theta=0.5pi)] X0X1 R_YY(0.5) 0 1 → SPP[R_PAULI(theta=0.5pi)] Y0Y1 R_ZZ(0.5) 0 1 → SPP[R_PAULI(theta=0.5pi)] Z0Z1 R_PAULI(0.3) X0Y1 → SPP[R_PAULI(theta=0.3pi)] X0Y1 U3(0.3, 0.24, 0.49) 0 → I[U3(theta=0.3pi, phi=0.24pi, lambda=0.49*pi)] 0

stim_to_shorthand

Convert expanded stim annotations back to tsim shorthand. Rewrites:
  • I[U3(theta=θpi, phi=φpi, lambda=λ*pi)] → U3(θ, φ, λ)
  • I[R_X(theta=α*pi)] / I[R_Y(…)] / I[R_Z(…)] → R_X(α) / R_Y(α) / R_Z(α)
  • SPP[R_PAULI(theta=αpi)] P0P1 → R_PP(α) 0 1 (P ∈ {X, Y, Z})
  • SPP[R_PAULI(theta=αpi)] X0Y1 → R_PAULI(α) X0*Y1
  • SPP[T] → TPP
  • SPP_DAG[T] → TPP_DAG
  • S[T] → T
  • S_DAG[T] → T_DAG