Skip to content

Create global-rotation QEC code tutorial#156

Open
shalini9894 wants to merge 2 commits into
QuEraComputing:mainfrom
shalini9894:global-rotation-QEC-Code-tutorial
Open

Create global-rotation QEC code tutorial#156
shalini9894 wants to merge 2 commits into
QuEraComputing:mainfrom
shalini9894:global-rotation-QEC-Code-tutorial

Conversation

@shalini9894

@shalini9894 shalini9894 commented Jun 5, 2026

Copy link
Copy Markdown

Summary

This PR adds a tutorial notebook for issue #119:

  • adds ‘docs/demos/global_rotations_qec_codes.ipynb‘

  • wires the notebook into the Tutorials section of ‘mkdocs.yml‘

  • verifies the Tsim ‘R_Z(alpha)‘ angle convention with a one-qubit check

  • simulates the unentangled 15-qubit baseline, the ‘[[7,1,3]]‘ Steane / 2D colour- code curve, and the ‘[[15,1,3]]‘ Reed-Muller / 3D colour-code curve

  • includes a wrong-stabilizer-sign 3D control

  • uses Stim flow checks for stabilizer and logical-operator verification

  • keeps the default notebook deterministic and documentation-build safe

  • includes optional finite-shot sampling and optional CuPy dense-vector code paths for Colab experiments

Scientific scope

The notebook is an ideal Tsim tutorial calculation inspired by Fig. 4a of the linked Nature paper. It does not reproduce the experiment’s raw data, atom-layout encoder, hardware noise, lookup-table decoder, acceptance filtering, loss post selection, or purity/stabilizer normalization pipeline.

Validation

  • executed the notebook from a clean kernel
  • checked Tsim ‘R_Z(alpha)‘ against the analytic one-qubit convention
  • checked Steane encoder logical/stabilizer flows with Stim
  • checked Reed-Muller CSS ranks, commutation relations, logical anticommutation, preparation flows, and T-angle response
  • checked selected full Tsim global-RZ circuits against the diagonal dense-vector implementation
  • ran formatting checks for the notebook.

AI Disclosure:

I used AI tools to understand how to formulate this issue into a tutorial notebook after reading the research paper.
Global_phase_rotation

## Summary
This PR adds a tutorial notebook for issue QuEraComputing#119:
- adds ‘docs/demos/global_rotations_qec_codes.ipynb‘
- wires the notebook into the Tutorials section of ‘mkdocs.yml‘
- verifies the Tsim ‘R_Z(alpha)‘ angle convention with a one-qubit check

- simulates the unentangled 15-qubit baseline, the ‘[[7,1,3]]‘ Steane / 2D colour-
code curve, and the ‘[[15,1,3]]‘ Reed-Muller / 3D colour-code curve

- includes a wrong-stabilizer-sign 3D control
- uses Stim flow checks for stabilizer and logical-operator verification
- keeps the default notebook deterministic and documentation-build safe
- includes optional finite-shot sampling and optional CuPy dense-vector code paths
for Colab experiments

## Scientific scope
The notebook is an ideal Tsim tutorial calculation inspired by Fig. 4a of the linked
Nature paper. It does not reproduce the experiment’s raw data, atom-layout
encoder, hardware noise, lookup-table decoder, acceptance filtering, loss
postselection, or purity/stabilizer normalization pipeline.
## Validation
- executed the notebook from a clean kernel
- checked Tsim ‘R_Z(alpha)‘ against the analytic one-qubit convention
- checked Steane encoder logical/stabilizer flows with Stim
- checked Reed-Muller CSS ranks, commutation relations, logical anticommutation,
preparation flows, and T-angle response
- checked selected full Tsim global-RZ circuits against the diagonal dense-vector
implementation
- ran formatting checks for the notebook
@rafaelha

rafaelha commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

Hi, thanks for the submission! This looks great! However, I think something is wrong with the 3D code, red curve. I would have expected plateaus around T/T_dag/S/S_dag, just like the experimental data from the paper.

@shalini9894

Copy link
Copy Markdown
Author

Hi @rafaelha , Please give me sometime I will rectify this asap.

Thanks. This deploy-preview failure was due to the notebook importing `SteaneEncoder` from `tsim.utils.encoder` while the PR branch did not yet define that encoder in `src/tsim/utils/encoder.py`.

I added a small `SteaneEncoder` class beside the existing encoder utilities. It uses the same `[[7,1,3]]` Steane circuit convention as the notebook, with stabilizer supports `0123`, `1245`, `2346`, logical support `015`, and encoding qubit `6`. The final `Z 5 1` sign correction is included so the all-positive `|+_L>` preparation passes the Stim stabilizer/logical flow checks.

I also verified:
- `from tsim.utils.encoder import SteaneEncoder`
- Stim logical input-to-output flows
- Stim prepared-state stabilizer/logical flows
- the notebook execution path

This should fix the deploy preview import error.

I also worked on creating the 3D code much closer to the original experimental data in Fig. 4a.
@shalini9894

shalini9894 commented Jun 6, 2026

Copy link
Copy Markdown
Author

Hi @rafaelha, I have updated the code and now the graph looks very much closer to the original Fig.4a. Please have a look. Also I added a new class for SteaneEncoder since the checks were failing and it was failing due to import error. I recitifed that. So, it should work now. Please confirm. Here is the graph. Fixes #119
global_rotations_fig4a_corrected

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.

2 participants