Skip to content

[qec] Move lattice-surgery Stim rounds behind StimRoundEmitter - #525

Merged
cursor[bot] merged 1 commit into
mainfrom
cursor/stim-round-emitter-9f6a
Oct 1, 2026
Merged

cursor[bot] merged 1 commit into
mainfrom
cursor/stim-round-emitter-9f6a

Conversation

@arniber21

@arniber21 arniber21 commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

Partial slice of #473. Lattice-surgery Stim rounds move out of the match inside emit_stim_lattice_surgery_cx and behind StimRoundEmitter. lattice_round_emitter is the only match that selects an impl. A new round kind is a new impl plus one registry arm.

Issue 473 stays open. emit_stim_single_block_memory is still about 170 lines. emit_stim_lattice_surgery_cx is still about 155 lines: the header, reset, and observable assembly stay in the circuit builder.

Behavior

  • Stim text for repetition d=3, surface d=3 (Z and X), and lattice-surgery CX d=3 matches the checked-in gold files byte for byte.
  • Construct, memory, measure-logical, rough merge, smooth merge, split, ancilla measure, frame update, and magic consumption each go through an impl. Magic T, T†, and CCZ share one comment-shaped impl.
  • Single-block memory Stim is unchanged. JSON experiment emit is unchanged.

Out of scope

  • Shrinking every Stim-emit function under about 80 lines
  • Turning single-block memory rounds into this trait
Open in Web Open in Cursor 

Each lattice-surgery round kind now emits through a StimRoundEmitter impl.
lattice_round_emitter is the only match that selects one. Checked-in Stim
gold stays byte-identical.

Issue 473 stays open. Single-block memory Stim is still one function, and
the lattice-surgery builder is still over 80 lines.

Co-authored-by: Arnab Ghosh <ag2583@cornell.edu>
@vercel

vercel Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
quon Ready Ready Preview Oct 1, 2026 5:34am UTC

/// Select the impl for `kind`.
///
/// This match is the registry. Emit logic for a kind lives on its impl.
pub(crate) fn lattice_round_emitter(kind: RoundKind) -> &'static dyn StimRoundEmitter {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve. I would merge this slice.

lattice_round_emitter is a registry: each arm returns a different StimRoundEmitter impl, and emit_stim_lattice_surgery_cx calls emit on that &dyn StimRoundEmitter. Construct, memory, measure-logical, rough merge, smooth merge, split, ancilla measure, frame update, and magic consumption each have an impl. The schedule walk does not match on RoundKind.

stim_structure_matches_checked_in_gold locks repetition d=3, surface d=3 Z, surface d=3 X, and lattice-surgery CX against the checked-in files. The registry test covers every RoundKind, and MarkerEmit appends through the trait. This file has no unwrap or expect outside #[cfg(test)]. The PR body and commit say issue 473 stays open; there is no Fixes/Closes/Resolves keyword.

Left on 473, as this PR already says: emit_stim_single_block_memory is still 172 lines and does not use the trait, and emit_stim_lattice_surgery_cx is still 156 lines because the header, reset, and observable assembly stay in the builder. A new RoundKind is still one arm in this function.

@cursor
cursor Bot marked this pull request as ready for review October 1, 2026 05:39
@cursor
cursor Bot merged commit 6df736c into main Oct 1, 2026
22 of 23 checks passed

This branch was successfully deployed

1 active deployment
Preview — 73034fb3 Deployed Oct 1, 2026 by vercel[bot]
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