Skip to content

feat(ppvm-tableau-2): hybrid stabilizer simulator over an inverse tableau - #298

Merged
david-pl merged 60 commits into
david/ppvm-pauli-kernelsfrom
david/ppvm-tableau-2
Nov 19, 2026
Merged

david-pl merged 60 commits into
david/ppvm-pauli-kernelsfrom
david/ppvm-tableau-2

Conversation

@david-pl

Copy link
Copy Markdown
Collaborator

Stacked on #297 (ppvm-pauli-kernels). Review that first; this PR's diff is against its branch.

Adds ppvm-tableau-2, a hybrid stabilizer simulator: |ψ⟩ = C |χ⟩, an inverse tableau for the Clifford C plus the state |χ⟩ of the virtual qubits, kept in a representation that can be swapped out. The crate is publish = false for now.

What's in it

  • InverseTableau
    • Physical gates fused into one pass over the rows.
    • Changes of basis on virtual qubits.
    • Measurement and reset.
    • Batched measure_many, which runs on a column-major copy when there are many random outcomes.
  • VirtualState trait, with ActiveDormant<DenseState> as its implementation. It keeps amplitudes only for the active virtual qubits: non-Clifford gates activate them and measurements retire them.
  • GeneralizedTableau<V>
    • Clifford gates, T, Pauli rotations, U3, and Pauli noise.
    • Measurement with active qubits.
    • Loss, leakage and leakage reduction, correlated loss, and asymmetric loss with its survival back-action.
    • fork and Display.
  • Hot path for pure stabilizer states. With no active qubits, measure and measure_many run on the tableau alone.
  • ppvm-traits-2: adds the leakage channel traits.

Testing

tests/dense_matrix.rs checks the simulator against exact dense matrices and state vectors, sharing no Pauli code with the tableau:

  • tableau rows match C† X_q C and C† Z_q C;
  • measurement probabilities and the post-measurement state match a state vector, including after rotations;
  • asymmetric loss matches its Kraus operators.

Benchmarks (noise-free Stim memory circuits, µs per shot, arm64)

Harnesses live in benches/stim-compare. Stim is a native -march=native build of its TableauSimulator.

circuit Stim InverseTableau GeneralizedTableau
surface d7 38.5 39.6 41.3
surface d15 691 782 777
surface d31 20463 14294 14716
repetition d75 170 186 198
color d25 2460 2025 2040

On the clifft-bench workloads (noise included), GeneralizedTableau is 0.13–0.45× the time of the current ppvm-tableau on main.

Known gap: on the repetition code every outcome is deterministic, and InverseTableau::measure_many reads each target's row once more just to decide whether to batch.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.2
Preview removed because the pull request was closed.
2026-11-19 13:23 UTC

@Roger-luo
Roger-luo added this pull request to stack #300 November 16, 2026 17:49
@david-pl
david-pl force-pushed the david/ppvm-tableau-2 branch 2 times, most recently from dbc5be5 to c617aac Compare November 17, 2026 13:05
@david-pl
david-pl marked this pull request as ready for review November 17, 2026 13:05

@rafaelha rafaelha left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good to me!

I mostly had my agent do some performance review, suggestions are inline.

circuit (p = 1e-3) ppvm (PR) [µs/shot] + inline fixes [µs/shot] speedup
surface d5 27 19 1.4×
surface d11 371 268 1.4×
surface d17 1,889 1,475 1.3×
repetition d101 970 498 1.9×
surface d17, 1% loss 220,872 30,522 7.2×

Some additional follow up one could look into (not blocking):

  1. Gate throughput. On a CX + H brickwork, ppvm takes 1.4× Stim's time at n = 640 and 1.8× at n = 2048 (2.4× with a default x86-64 build). row_product is about half of noiseless surface d17, which runs ~1.5–1.6× slower than Stim on this machine, unlike the arm64 numbers in the description.
  2. Batched measurement. In noiseless surface d17, the transposes take ~19% and the column scan in iz_x_support another ~18%. ppvm's 64×64 transposes are ~2.5× slower than Stim's, and Stim skips already-determined targets before scanning.
  3. Loss events. Each lost qubit costs a full one-qubit collapse (~66 µs at d17). After the batching fix, that's most of the remaining 29 ms/shot at 1% loss. Faster transposes would let these use the column-major path.

Comment on lines +48 to +59
/// With no active and no lost qubits, the whole batch runs on the
/// tableau's `measure_many`; otherwise one target at a time.
fn measure_many(&mut self, targets: &[usize]) -> Vec<Option<bool>> {
if !self.state.is_zero() || targets.iter().any(|&q| self.is_lost(q)) {
return targets.iter().map(|&q| self.measure(q)).collect();
}
let mut outcomes = vec![false; targets.len()];
let rng = &mut self.rng;
self.tableau
.measure_many(targets, || rng.random(), &mut outcomes);
outcomes.into_iter().map(Some).collect()
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

With loss, one lost target sends the whole instruction down the one-qubit-at-a-time path, and that dominates lossy circuits. Batching the live targets brings surface d17 with 1% loss from 221 to 29 ms/shot (d11: 4.6 → 2.3 ms):

Suggested change
/// With no active and no lost qubits, the whole batch runs on the
/// tableau's `measure_many`; otherwise one target at a time.
fn measure_many(&mut self, targets: &[usize]) -> Vec<Option<bool>> {
if !self.state.is_zero() || targets.iter().any(|&q| self.is_lost(q)) {
return targets.iter().map(|&q| self.measure(q)).collect();
}
let mut outcomes = vec![false; targets.len()];
let rng = &mut self.rng;
self.tableau
.measure_many(targets, || rng.random(), &mut outcomes);
outcomes.into_iter().map(Some).collect()
}
/// With no active qubits, the live targets run as one batch on the
/// tableau's `measure_many` and lost ones give `None`; otherwise one target
/// at a time.
fn measure_many(&mut self, targets: &[usize]) -> Vec<Option<bool>> {
if !self.state.is_zero() {
return targets.iter().map(|&q| self.measure(q)).collect();
}
let live: Vec<usize> = targets
.iter()
.copied()
.filter(|&q| !self.is_lost(q))
.collect();
let mut outcomes = vec![false; live.len()];
let rng = &mut self.rng;
self.tableau
.measure_many(&live, || rng.random(), &mut outcomes);
let mut outcomes = outcomes.into_iter();
targets
.iter()
.map(|&q| (!self.is_lost(q)).then(|| outcomes.next().unwrap()))
.collect()
}

impl<V: VirtualState> GeneralizedTableau<V> {
/// Draw event `k` with probability `probabilities[k]`, or `None` with the
/// remaining probability. Uses one random number.
pub(super) fn draw(&mut self, probabilities: &[f64]) -> Option<usize> {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Noise draws one random number per target, plus a scan over the probabilities. That's 24–44% of the runtime on noisy memory circuits, while Stim's noise is nearly free because it skips straight to the next error. Overriding the *_many trait methods with skip sampling and calling them once per instruction made surface d17 22% faster and repetition d101 49% faster in a quick prototype:

let log_q = (1.0 - p).ln(); // p = total error probability
let mut i = 0;
loop {
    let skip = ((1.0 - self.rng.random::<f64>()).ln() / log_q).floor();
    if !(skip < (targets.len() - i) as f64) {
        break;
    }
    i += skip as usize;
    // apply one Pauli, drawn from p_k / p, to targets[i]
    i += 1;
}

loss_channel could use the same.

Comment on lines +130 to +140
let norm: f64 = self.amplitudes.iter().map(|a| a.norm_sqr()).sum();
// ⟨φ|P|φ⟩ = Σ_α conj(φ[α ⊕ x]) · c(α) · φ[α], real for Hermitian P.
let expectation: f64 = self
.amplitudes
.iter()
.enumerate()
.map(|(alpha, amp)| {
(self.amplitudes[alpha ^ x].conj() * pauli_factor(p, alpha) * amp).re
})
.sum();
[0.5 * (norm + expectation), 0.5 * (norm - expectation)]

@rafaelha rafaelha Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Near an eigenstate of P, 0.5 * (norm ± ⟨P⟩) can come out at about −1e-16, which trips the p >= 0 debug assert in draw via asymmetric_loss_channel (333 of 2,000 such states panicked in a debug build). Summing the projected norms directly keeps both weights non-negative:

Suggested change
let norm: f64 = self.amplitudes.iter().map(|a| a.norm_sqr()).sum();
// ⟨φ|P|φ⟩ = Σ_α conj(φ[α ⊕ x]) · c(α) · φ[α], real for Hermitian P.
let expectation: f64 = self
.amplitudes
.iter()
.enumerate()
.map(|(alpha, amp)| {
(self.amplitudes[alpha ^ x].conj() * pauli_factor(p, alpha) * amp).re
})
.sum();
[0.5 * (norm + expectation), 0.5 * (norm - expectation)]
// ‖½(1 ± P)φ‖² summed directly, with (Pφ)[α] = c(α ⊕ x) · φ[α ⊕ x]: never
// negative, and an impossible branch stays O(ε²) instead of ±ε.
let (mut plus, mut minus) = (0.0, 0.0);
for (alpha, &amp) in self.amplitudes.iter().enumerate() {
let p_amp = pauli_factor(p, alpha ^ x) * self.amplitudes[alpha ^ x];
plus += (amp + p_amp).norm_sqr();
minus += (amp - p_amp).norm_sqr();
}
[0.25 * plus, 0.25 * minus]

impl ApplyGateRule for InverseTableau {
type B = bool;

fn apply1(&mut self, q: usize, rule: impl Fn(bool, bool) -> ([bool; 2], bool)) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Minor, non-blocking: #297 documents that B = bool impls call rule exactly once per gate, but this one calls it 2× (4× in apply2). Nothing breaks today, since Phased can't wrap a tableau. Maybe let Phased compute the flip itself, as its apply_sign1 already does, and drop that paragraph from the trait doc?

Possible diff for #297
--- a/crates/ppvm-phased-pauli-word-2/src/clifford.rs
+++ b/crates/ppvm-phased-pauli-word-2/src/clifford.rs
@@ -11,4 +11,2 @@
 
-use std::cell::Cell;
-
 use ppvm_traits_2::{ApplyGateRule, PauliBits, Phase, loss::LossInfo};
@@ -26,5 +24,4 @@ impl<W> Phased<W> {
 
-/// A word that skips a gate (e.g. on a lost site) never calls the rule, so the
-/// recorded flip stays `false` and the phase is untouched. This relies on `W`
-/// calling the rule once per applied gate, as `ApplyGateRule` requires.
+/// The flip is computed here from the word's bits, after the same loss check
+/// the word makes, so it does not depend on how often the word calls the rule.
 impl<W> ApplyGateRule for Phased<W>
@@ -37,9 +34,8 @@ where
     fn apply1(&mut self, q: usize, rule: impl Fn(bool, bool) -> ([bool; 2], bool)) {
-        let flip = Cell::new(false);
-        self.word.apply1(q, |x, z| {
-            let out = rule(x, z);
-            flip.set(out.1);
-            out
-        });
-        self.flip_sign_if(flip.get());
+        if self.word.is_lost(q) {
+            return;
+        }
+        let (_, flip) = rule(self.word.x_bit(q), self.word.z_bit(q));
+        self.word.apply1(q, rule);
+        self.flip_sign_if(flip);
     }
@@ -48,9 +44,9 @@ where
     fn apply2(&mut self, a: usize, b: usize, rule: impl Fn([bool; 4]) -> ([bool; 4], bool)) {
-        let flip = Cell::new(false);
-        self.word.apply2(a, b, |bits| {
-            let out = rule(bits);
-            flip.set(out.1);
-            out
-        });
-        self.flip_sign_if(flip.get());
+        if self.word.is_lost(a) || self.word.is_lost(b) {
+            return;
+        }
+        let w = &self.word;
+        let (_, flip) = rule([w.x_bit(a), w.z_bit(a), w.x_bit(b), w.z_bit(b)]);
+        self.word.apply2(a, b, rule);
+        self.flip_sign_if(flip);
     }
--- a/crates/ppvm-traits-2/src/gates/apply_gate_rule.rs
+++ b/crates/ppvm-traits-2/src/gates/apply_gate_rule.rs
@@ -29,7 +29,2 @@ use super::Clifford;
 ///
-/// With `B = bool`, `apply1` and `apply2` must call `rule` exactly once if they
-/// apply the gate, and not at all if they skip it (e.g. on a lost site). Check
-/// for loss before calling `rule`. Wrappers such as `Phased` take the sign flip
-/// from that one call, so an extra or early call gives a wrong sign.
-///
 /// Implementing this trait gives [`Clifford`] through the blanket impl, so a

self.rewrite_rows(&[a, b], &images);
}

fn apply_sign1(&mut self, q: usize, rule: impl Fn(bool, bool) -> ([bool; 2], bool)) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Minor: apply_sign1 doesn't check q, so on 4 qubits z(5) silently flips iz(1)'s sign, and measure(1) of |0000⟩ then returns 1.

Suggested change
fn apply_sign1(&mut self, q: usize, rule: impl Fn(bool, bool) -> ([bool; 2], bool)) {
fn apply_sign1(&mut self, q: usize, rule: impl Fn(bool, bool) -> ([bool; 2], bool)) {
assert!(q < self.n, "qubit {q} out of range");

ix/iz in data.rs only debug_assert too (in release ix(4) returns iz(0)), so the same assert! would help there.

@rafaelha rafaelha left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Would it also make sense to drop the benchmark .stim files** and run gen.py when benchmarking to make the diff smaller

@david-pl
david-pl force-pushed the david/ppvm-tableau-2 branch from c617aac to 67eade4 Compare November 18, 2026 07:45
@david-pl

Copy link
Copy Markdown
Collaborator Author

@rafaelha thanks for all the input. I think I addressed all relevant problems.

@rafaelha rafaelha left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks David, everything I raised is in and checks out on my side: tests pass, the state-vector fuzz still agrees, and the asymmetric-loss and out-of-range repros are fixed.

Compared with the version I reviewed (µs/shot, p = 1e-3, same machine):

circuit before now
surface d11 371 255
surface d17 1,888 1,293
repetition d101 964 503
surface d17, 1% loss 220,664 27,952

LGTM!

@JonhasA JonhasA left a comment

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.

LGTM, just some comments

/// Built by [`Rotation::collapse`] so that `V† P V = ±Z_pivot` and the
/// measured branch leaves `pivot` in `|0⟩`; one place decides the gates.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct Rotation {

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.

Rather than rotation, can this be called RotationCollapse to better catch its intent?

RotationOne, RotationOneBatch, RotationTwo, RotationTwoBatch, TGate, TwoQubitPauliError,
U3Gate,
};
pub use loss::{LossState, LossySite};

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.

Probably should add a comment to the Clifford trait, as it still expresses that gates are applied strictly only in the Heisenberg picture, whereas this PR also uses the Clifford trait for forward state evolution.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Technically, we are using Heisenberg rules here since we are tracking the inverse tableau. But the gate order is Schrodinger picture, so might be confusing. I'm changing the doc to say that it updates Paulis according to Heisenberg picture conjugation, which is accurate for both.

let targets = &pools.measured[at..at + len];
for (m, &q) in s.measure_many(targets).into_iter().zip(targets) {
let m = m.unwrap_or(false);
if reset && m {

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.

Could we call s.reset(q) whenever reset is true, instead of conditionally applying X? For a lost qubit, measure() returns None, which becomes false here, so the reset is skipped and the qubit remains lost. Subsequent gates then continue to skip it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch!

@david-pl
david-pl force-pushed the david/ppvm-tableau-2 branch from b7d6b4a to a696875 Compare November 19, 2026 10:05
david-pl and others added 18 commits November 19, 2026 14:06
InverseTableau stores C⁻¹ as packed rows with one sign bit each, with u64
words behind a private alias. Physical gates go through ApplyGateRule
(B = bool): the rule evaluated on the gate's generators names the rows to
multiply with row_product. Checked against Heisenberg propagation of
Phased<PauliWord> and the commutation invariant.

Widen the ApplyGateRule docs to types that apply a rule other than by
updating each held Pauli.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Recombine the rows a gate touches in one loop over word indices, in place:
new words at an index depend only on old words at that index. Removes the
per-gate scratch buffer and copies, and skips rows a gate leaves unchanged.

Name the rule's output an Image, document the derivation, and check every
gate on all 11520 two-qubit Cliffords against dense gate matrices.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
get_bit / flip_bit take a slice and a bit index, so the word/bit split lives
in one place. The per-word product of an image's factor rows moves into
Image::multiply, flattening recombine.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
change_basis1 / change_basis2 apply C ← C·V: every row R becomes V† R V,
by running the kernel rule on each row's bits in the gate's columns (the
strided layout). Used later by localization, measurement collapse and reset.
Checked against dense matrices on all two-qubit Cliffords, commutation with
physical gates, and the commutation invariant.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
data (storage, row reads, placement of rows), bitword (the storage word),
physical (C ← G·C) and virtual_side (C ← C·V), with shared test helpers in a
cfg(test) module. mod.rs and lib.rs only declare and re-export. No behaviour
change.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
measure(q, coin) reads O = iz_q: deterministic from its sign without X bits,
otherwise Stim's collapse on the lowest X bit via change_basis. The caller
supplies the coin. Checked against a dense state vector after every gate,
measurement and reset.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Read row signs directly, find a row's kind by comparison instead of dividing
by n, and hand out disjoint row slices through one checked helper
(rows_mut). The clifft-bench d=7 surface code goes from 135 to 108 µs/shot.

Add the run_stim example (any Stim circuit's gates, measurements and resets,
one shot at a time), scripts to fetch clifft-bench circuits and summarize
samply profiles, and the batched variants to the design.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Matches physical.rs. `virtual` is a reserved keyword, so the module is
declared as r#virtual.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…rtual_gates

Avoids the reserved keyword `virtual` and keeps the two names a pair.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
fan_out(pivot, cx_targets, cz_targets, last) applies C ← C·V for a CX/CZ
fan-out plus a final one-qubit gate in one pass over the rows, equal to the
separate changes of basis. measure computes the reduced observable from row
iz_q alone and collapses with a single fan-out. The d=7 surface code goes
from 108 to 86 µs/shot.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Per-operation costs at the d=7 surface code's size: per-shot overhead,
physical CX, and random measure-reset with and without per-instruction
batching. Seeded generator included.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
When every changed row is itself times rows that keep their bits (CX, CZ, S,
√X and inverses), multiply with row_product in place instead of the fused
per-word pass. CX at 118 qubits goes from 31 to 24 ns.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
4096 gates drawn uniformly from all 13 Clifford gates (own seed, so the
other circuits are unchanged), to check that gate optimizations are not
tuned to CX alone.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Represent an image's factors as a u8 mask, write the pattern checks as plain
integer loops, build images and phases without std::array::from_fn, and
track sign changes instead of re-reading rows whose image contains them.
The pattern then folds per gate: CX at 118 qubits goes from 24 to 11 ns (a
hand-written CX: 10 ns), all 13 gates mixed from 16 to 10 ns, the d=7
surface code from 78 to 50 µs/shot.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
qubit_rows_mut takes the gate's qubits and checks only that they are in
range and distinct (3 comparisons for a two-qubit gate instead of 10 for
four rows); distinct qubits own distinct rows, so the unsafe slicing stays
sound. CX at 118 qubits goes from 11.4 to 10.2 ns, mixed gates from 9.8 to
8.9 ns.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
change_basis1/2 and fan_out visit rows through for_each_row: explicit
per-block rows as fixed-length slices instead of an offsets iterator, sign
flips collected in a register and written once per 64 rows, and no target
Vec allocations. A random measure-reset at 118 qubits goes from ~720 to
~510 ns; the d=7 surface code from 48 to 40 µs/shot.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
measure_many measures a list of qubits in order (a plain loop for now, so
the batched path has an API and a reference); the run_stim harness hands
each M/MR instruction to it. InverseTableau gets CliffordBatch with the
default loops, since gates on different qubits share no work.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
david-pl and others added 26 commits November 19, 2026 14:06
LeakageChannel pins a qubit to |0⟩ or |1⟩ with p0 / p1 and marks it
leaked; ResetLeakageChannel returns it as live |0⟩. Qubit status is now
a plain Vec<QubitStatus> instead of two masks and a count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mod.rs keeps the module list and the re-export. Fields and the helpers
shared by the sibling modules become pub(super).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
p = [p_LL, p_LQ, p_LN]: with one of the pair already lost the other is
lost with p_LN; otherwise one draw picks both, either named one, or none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The qubit is lost from |m⟩ with probability p_m·P(m); otherwise the
survival Kraus operator K₀ = a·I + b·Z_q is applied through the T-gate
path and the state renormalized (#249). Checked against the Kraus
operators on random three-qubit states.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
K₀ is then proportional to I, so the renormalized state is unchanged;
rotating would activate an axis on a qubit in superposition for nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
InverseTableau prints its rows as signed Pauli strings, DenseState its
nonzero amplitudes, ActiveDormant the virtual qubit of each axis, and
GeneralizedTableau combines them with the lost and leaked qubits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It depends on the unpublished ppvm-traits-2 and ppvm-pauli-kernels, so it
cannot be published; without a version it stays out of release-plz's
workspace version bumps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the pivot's X bit a constant, the CX and CZ rules fold so rows
without it touch no target. LLVM did this split only in some callers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With no active and no lost qubits, measure_many runs on the tableau's
batched measurement; run_clifft keeps each Z-basis instruction together.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…bits

One lost target sent the whole instruction down the one-qubit-at-a-time
path. Now the live targets run as one tableau batch and lost ones give
`None`. Surface d17 with 1% loss per gate: 16.2 -> 7.4 ms/shot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Applies a loss channel with probability p to each target after every
gate; a lost qubit's measurement is recorded as 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`0.5 * (norm ± ⟨P⟩)` could round to about -1e-16 near an eigenstate of
P, tripping the `p >= 0` debug assert in `draw`. Sum ‖½(1 ± P)φ‖²
directly instead, so an impossible branch stays O(ε²).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`apply_sign1` did not check `q`, so on 4 qubits `z(5)` flipped `iz(1)`'s
sign; `ix`/`iz` only checked in debug builds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…iners

The inverse tableau evaluates `rule` on the gate's generators, several
times per gate, which the doc already allows above; the "exactly once"
rule only binds containers that `Phased` can wrap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`pauli_error_many`, `x/y/z_error_many` and `depolarize1_many` jump
straight to the next error with a geometric skip instead of drawing one
random number per target.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`two_qubit_pauli_error_many` and `depolarize2_many` skip straight to the
next pair with an error, as the one-qubit channels do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each noise instruction becomes one `pauli_error_many` or
`depolarize2_many` call instead of one call per target, so the harness
uses skip sampling. Surface d17 at p = 1e-3: 1.36 -> 1.18 ms/shot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`transpose_64x64` runs each pass on four side-by-side column blocks, so
the compiler vectorizes across them, and `from_rows`/`write_rows` gather
a row's words for the group together. Noiseless surface d17:
1.19 -> 1.09 ms/shot; with 1% loss 7.8 -> 7.0 ms/shot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…pport

The scan built two slices per column and read the Z bit too; now it steps
over word `q / 64` of each column's X bits. Noiseless surface d17:
1.09 -> 0.97 ms/shot; 118-qubit mr_batched 0.26 -> 0.20 ms/shot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@david-pl
david-pl force-pushed the david/ppvm-tableau-2 branch from a696875 to 7bb9f38 Compare November 19, 2026 13:06
@david-pl
david-pl enabled stacked auto-merge (squash) November 19, 2026 13:06
@david-pl
david-pl merged commit 466ff0b into main Nov 19, 2026
22 checks passed
@david-pl
david-pl deleted the david/ppvm-tableau-2 branch November 19, 2026 13:22
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.

3 participants