Skip to content

Apply two-qubit gate noise to every pair of a batched command - #808

Open
ciaranra wants to merge 1 commit into
devfrom
noise-batched-two-qubit-pairs
Open

ciaranra wants to merge 1 commit into
devfrom
noise-batched-two-qubit-pairs

Conversation

@ciaranra

Copy link
Copy Markdown
Member

Closes #791. Closes #792.

Problem

A two-qubit gate command in a ByteMessage can carry several pairs in one flattened qubits slice. Three noise models treated such a command as if it held one pair:

The workspace sweep found the same shape in exp/pecos-eeg/src/noise.rs (UniformNoise::noise_after_gate injected noise for the first pair only) and in two pecos-neo channels (TwoQubitChannel::handle_after_gate, PerGatePauliChannel::apply_after_gate).

Change

Every site now iterates qubits.as_chunks::<2>() and draws, faults, and judges leakage per pair. A single-pair command is byte-for-byte unchanged, including RNG consumption; the existing pinned-byte tests are untouched and still pass. CCX keeps its current behaviour (one draw on its first two qubits), pinned by a new test rather than silently changed.

Not in this PR

Splitting batched commands per pair inside the pecos-neo runner was implemented and then reverted: the independent review reproduced that it changes what crosstalk and correlated channels observe. Per-pair SkipGate suppression in neo needs a batch-preserving design and is tracked as #807.

Tests

  • Batched vs consecutive single-pair commands from identically seeded models must produce identical output at p2 = 0.5 over 32 seeds, followed by a further command to detect RNG-stream drift (engines and neo).
  • General noise: one leaked qubit in CX[(0,1),(2,3)] suppresses only (0,1); (2,3) survives and receives its own noise; seepage is pair-local.
  • EEG: batched injections equal the concatenation of per-pair injections.
  • Mutation-checked: sharing the occurrence draw across pairs, reusing the first pair's Pauli, and restoring the whole-command leakage check each make the new tests fail.

Verification

cargo test -p pecos-engines -p pecos-neo -p pecos-eeg --no-fail-fast (1852 passed), cargo clippy --locked ... --all-targets -- -D warnings and cargo fmt --check on the three crates, all clean.

How this was produced

Implemented by OpenAI gpt-6-astra (Codex CLI 0.154.0) from a task packet written by Claude Fable 5.1 in Claude Code; Claude reviewed every hunk, re-ran all verification itself, and sent findings back for fix rounds. An independent Codex review arm with no access to the implementation session also reviewed the diff. Posted at the maintainer's request.

@ciaranra
ciaranra force-pushed the noise-batched-two-qubit-pairs branch from 27fe4e7 to c6f5c29 Compare September 20, 2026 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant