Repository navigation
Batch versions of all clifford gates #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
8dd9693
Add a benchmark for batched gates as baseline
david-pl 1e6308a
Implement batched versions for all gates
david-pl 01ec3ef
Use smallvec so build_masks works beyond 512 qubits
david-pl 87b5328
Forward STIM to batched gates
david-pl fa38442
Better batching of CNOT
david-pl dba1bee
Also proper batching for CZ and CY
david-pl e590951
Bench with CZ fused
david-pl 4af26dd
Merge branch 'main' into david/99-batch-gates
Roger-luo da93cd5
Potential fix for pull request finding
Roger-luo c85a94d
Address some minor comments
david-pl 520c477
Merge branch 'main' into david/99-batch-gates
david-pl 61f5646
Merge remote-tracking branch 'origin/main' into david/99-batch-gates
Roger-luo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| // SPDX-FileCopyrightText: 2026 The PPVM Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| //! Run the distance-30 surface-code memory circuit in `surface_d30.stim` | ||
| //! against a [`GeneralizedTableau`]. | ||
| //! | ||
| //! The circuit is pure Clifford (resets, H, CX, measurements, plus | ||
| //! depolarizing / X noise), so no non-Clifford branching occurs and a plain | ||
| //! `usize` branch index suffices. Its 1889 qubits need `ceil(1889 / 8) = 237` | ||
| //! bytes per Pauli word, hence the `<237>` in the config. | ||
|
|
||
| use std::time::Instant; | ||
|
|
||
| use bnum::types::U2048; | ||
| use ppvm_runtime::config::indexmap::ByteFxHashF64; | ||
| use ppvm_stim::{parse_extended, sample}; | ||
| use ppvm_tableau::prelude::*; | ||
|
|
||
| type Tab = GeneralizedTableau<ByteFxHashF64<237>, U2048>; | ||
|
|
||
| const N_QUBITS: usize = 1889; | ||
| const SHOTS: usize = 12; | ||
|
|
||
| fn main() -> Result<(), ppvm_stim::Error> { | ||
| // The .stim file sits next to this example; embed it at compile time. | ||
| let prog = parse_extended(include_str!("surface_d30.stim"))?; | ||
| println!( | ||
| "parsed {} measurement records over {N_QUBITS} qubits", | ||
| prog.measurement_count() | ||
| ); | ||
|
|
||
| // Parse once, build a fresh tableau per shot via the factory closure. | ||
| let start = Instant::now(); | ||
| let shots = sample(&prog, SHOTS, || Tab::new(N_QUBITS, 1e-10))?; | ||
| let elapsed = start.elapsed(); | ||
|
|
||
| for (i, shot) in shots.iter().enumerate() { | ||
| let ones = shot.iter().filter(|&&b| b == Some(true)).count(); | ||
| println!("shot {i}: {ones} ones / {} measurements", shot.len()); | ||
| } | ||
| println!( | ||
| "{SHOTS} shots in {elapsed:.2?} ({:.2?}/shot)", | ||
| elapsed / SHOTS as u32 | ||
| ); | ||
| Ok(()) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.