Skip to content

docs: tutorial reproducing Fig. 4a - codes under global rotations (closes #119)#160

Open
Ronit-Raj9 wants to merge 1 commit into
QuEraComputing:mainfrom
Ronit-Raj9:demo/global-rotations-fig4a
Open

docs: tutorial reproducing Fig. 4a - codes under global rotations (closes #119)#160
Ronit-Raj9 wants to merge 1 commit into
QuEraComputing:mainfrom
Ronit-Raj9:demo/global-rotations-fig4a

Conversation

@Ronit-Raj9

@Ronit-Raj9 Ronit-Raj9 commented Jun 10, 2026

Copy link
Copy Markdown

Summary

Adds docs/demos/global_rotations.ipynb, a tutorial that reproduces Fig. 4a of the linked Nature paper (Bluvstein et al., Nature 649, 39, 2026) using tsim, and wires it into the Tutorials nav.

A logical qubit is prepared in |+_L>, every physical qubit is rotated by the same R_Z(φ), and we track the logical-X projection and the X-stabilizer revival versus φ, for all four configurations of the figure:

  • 2D colour code [[7,1,3]] (Steane) - decoded logical Clifford plateaus at multiples of 90° (S, S†, Z).
  • 3D colour code [[15,1,3]] (Reed-Muller) - an additional plateau at multiples of 45° (T, T†, TS, (TS)†), the signature of its transversal non-Clifford T gate, with the stabilizers reviving there too.
  • Unentangled - 15 bare qubits in |+>^15 read out with the same Reed-Muller operators: <X_L> = cos^15(φ) collapses away from 0°/±180° and the stabilizers revive only at multiples of 180°.
  • 3D negative stabilizer - the Reed-Muller code with the four tetrahedron corners flipped (the paper's "incorrect stabilizer signs"): the curve falls onto the unentangled one, showing that the 45° plateau needs the correctly signed, genuinely entangled code state.

Reproduced figure

Fig. 4a reproduction with tsim

Following the paper's analysis: the encoded curves show the decoded (syndrome-postselected) logical projection, the two control curves are raw, and the bottom panel is the raw stabilizer revival - so the panels reproduce the published figure point for point (plateau positions, stabilizer revivals, and the green/grey controls hugging each other).

What's inside

  • Literal hypercube encoder (Ext. Data Fig. 10a / ref. 128). The notebook builds the actual encoding circuit - the transversal CNOT network E = ((1,0),(1,1))^⊗m with the quantum-Reed-Muller input pattern (|+> on low-weight rows, |0> on high-weight rows), punctured at the 0…0 corner - and verifies by statevector overlap (= 1.000000) that it prepares the same |+_L> as the stabilizer-defined encoder, for both [[7,1,3]] (3-cube) and [[15,1,3]] (4-cube). [[16,6,4]] is the same circuit without puncturing.
  • Encoders verified with stim.Circuit.flow_generators(), as the issue suggests.
  • tsim is the workhorse. A generic global rotation on the 15-qubit code is 15 non-Clifford rotations at once - tcount() and a ZX timeline diagram make that explicit, and tsim's stabilizer-rank sampler produces the data points on the decoded curves (open markers), including the ±45° transversal-T angles. A dense 2^15 statevector of the rotated diagram is out of reach, so an exact Clifford-statevector reference (stim + analytic diagonal rotation) cross-checks every curve, with a φ = 0 assertion guarding correctness.
  • Postselection / acceptance fraction. Implements the paper's stabilizer postselection, reports acceptance fractions, and uses it to recover the decoded staircase from the oscillating raw expectation - with a markdown explanation of why the raw and decoded curves differ.
  • Physics-as-tutorial markdown throughout: global rotations as transversal gates, triorthogonality and why only the 3D code has a T plateau, Eastin-Knill and how logical measurement circumvents it, and why logical magic requires in-block entanglement (CHSH 1.99(3)×√2 in the paper).

Tests & CI

  • Adds test/unit/demos/test_global_rotations.py (7 tests): encoder flow_generators, the hypercube ↔ stabilizer-encoder equivalence, the φ = 0 state, the Reed-Muller transversal-T plateau (and its absence for Steane), the negative-stabilizer control, and a tsim-sampler-vs-exact check on the 15-qubit code.
  • Verified locally: ruff, black, isort, pyright (0 errors) and pytest (7 passed) all green, and the notebook builds clean under mkdocs-jupyter (execute: true, allow_errors: false) in ~6 min on CPU, so CI re-executes and guards it.

Notes for review

  • Self-contained single notebook; no changes to src/.
  • Outputs are stripped to match the existing demos.
  • 3D Tsim markers are sampled at the Clifford / T angles (cheap even at 15 qubits); SAMPLE_SHOTS and the marker grids are exposed for heavier runs.

Closes #119.

@Ronit-Raj9 Ronit-Raj9 force-pushed the demo/global-rotations-fig4a branch from 8de4157 to d85a548 Compare June 10, 2026 20:02
@Ronit-Raj9 Ronit-Raj9 changed the title docs: tutorial reproducing Fig. 4a — codes under global rotations (closes #119) docs: tutorial reproducing Fig. 4a - codes under global rotations (closes #119) Jun 10, 2026
@Ronit-Raj9 Ronit-Raj9 force-pushed the demo/global-rotations-fig4a branch from d85a548 to 7311905 Compare June 10, 2026 20:15
Add docs/demos/global_rotations.ipynb reproducing Fig. 4a of Bluvstein
et al. (Nature 649, 39, 2026): quantum Reed-Muller codes of various
dimensionality under a global Z-rotation, computed with tsim.

- [[7,1,3]] Steane (2D colour), [[15,1,3]] Reed-Muller (3D colour) and a
  single unentangled qubit, plus the paper's negative-stabilizer control
  (the four tetrahedron corners flipped) that removes the 45-degree
  transversal-T plateau.
- Builds the literal hypercube encoding circuit of Extended Data Fig. 10a
  (E = ((1,0),(1,1))^{otimes m} with the QRM input pattern, punctured at
  the 0...0 corner) and verifies by statevector overlap (= 1.0) that it
  prepares the same |+_L> as the stabilizer encoder.
- tsim's stabilizer-rank sampler runs the 15-rotation 3D code; an exact
  Clifford-statevector reference cross-checks every curve; tcount() and a
  ZX timeline diagram surface the non-Clifford content.
- adds postselection with acceptance fractions, and a pytest
  (test/unit/demos/test_global_rotations.py) guarding the encoders, the
  hypercube equivalence and the transversal-T plateau.
- self-contained notebook, outputs stripped like the other demos, builds
  clean under mkdocs-jupyter (execute: true, allow_errors: false); ruff,
  black, isort, pyright and pytest all pass.

Closes QuEraComputing#119.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tutorial: Subjecting codes of various dimensionality to global rotations

1 participant