Uh oh!
There was an error while loading. Please reload this page.
Faster weight calculation - #126
Conversation
There was a problem hiding this comment.
Pull request overview
Improves ppvm-runtime truncation performance by speeding up Pauli “weight” computation (hot in MaxPauliWeight/MaxLossWeight truncation) and by skipping retain passes entirely when the truncation is effectively disabled via a sentinel. Adds Rust/Python/Julia benchmarks to reproduce/track the regression described in the PR.
Changes:
- Optimized
PauliWordTrait::weight()(and lossy variants) to popcount directly over raw storage bytes usingbytemuck. - Avoided unnecessary
retain()passes whenMaxPauliWeight(usize::MAX)/MaxLossWeight(usize::MAX)is used to opt out of those truncations. - Added benchmarking coverage (Criterion bench + pytest-benchmark + Julia mirrors) and wired pytest-benchmark into the Python dev environment.
Reviewed changes
Copilot reviewed 16 out of 18 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
crates/ppvm-runtime/src/word/data.rs | Fast popcount-based Pauli weight computation over raw storage bytes. |
crates/ppvm-runtime/src/loss/data.rs | Same optimization for lossy words (weight + loss_weight). |
crates/ppvm-runtime/src/strategy.rs | Early-return optimization when max-weight truncation is disabled via usize::MAX. |
crates/ppvm-runtime/src/traits/coefficient.rs | Adds #[inline] hints to cutoff methods used during truncation retains. |
crates/ppvm-runtime/benches/trotter.rs | Updates trotter benchmark strategy to match Python binding configuration and thread settings. |
crates/ppvm-runtime/benches/truncation-weight.rs | New Criterion micro-benchmark focusing on truncation strategy costs. |
crates/ppvm-runtime/Cargo.toml | Registers the new truncation-weight benchmark target. |
ppvm-python/pyproject.toml | Adds pytest-benchmark to the dev group and disables benchmarking by default via pytest addopts. |
ppvm-python/uv.lock | Lockfile update for pytest-benchmark (and its dependency py-cpuinfo). |
ppvm-python/test/benchmarks/test_trotter.py | New pytest-benchmark mirror of the Rust trotter bench for Python bindings. |
ppvm-python/demo/trotter_ladder.py | New pedagogical/demo script showing a truncation-controlled ladder Trotter example. |
ppvm-python/demo/stim_demo.py | New demo script for running/sampling Stim programs via Python bindings. |
julia-benchmarks/benches/truncation-weight.jl | Julia-side mirror of the new Rust truncation-weight benchmark. |
julia-benchmarks/benches/trotter.jl | Adjusts gate order to better align with Heisenberg vs Schrödinger ordering assumptions. |
julia-benchmarks/benches/random-circuit.jl | Aligns circuit construction/benchmark semantics with the Rust benchmark (no truncation). |
julia-benchmarks/benches/gates.jl | Minor adjustments to which qubits are targeted by rotation benchmarks. |
julia-benchmarks/xy_ladder_msd.jl | New Julia script for MSD XY-ladder benchmark comparison vs ppvm. |
julia-benchmarks/Manifest.toml | Large lockfile update to support the Julia benchmark additions/updates. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
|
…shim Brings the bytemuck-based weight() speedup + early-return for uncapped MaxPauliWeight (and the rest of #126) into the Lindblad branch. Conflicts resolved: keep stim_demo.py (byte-identical to lindblad-shim's stim_msd.py rename); regenerate uv.lock against the merged pyproject. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…merging Brings the bytemuck-based weight() speedup + early-return for uncapped MaxPauliWeight (and the rest of #126) into the symmetry-merging branch. Conflicts resolved: keep stim_demo.py (byte-identical to the stim_msd.py rename); regenerate uv.lock against the merged pyproject. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The expm serial/parallel SpMV parity test built `ExpmOpts { tol,
parallel_threshold }` without the `max_krylov_m` field, so `cargo test`
failed to compile the ppvm-lindblad test target (pre-existing on
lindblad-shim, surfaced when running the full suite after merging #126).
The whole Rust workspace test suite now passes.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
Benchmarking trotter including a
MaxPauliWeighttruncation strategy showed a major regression. This PR usesbytemuckto bypass thebitvecmethods and directly computes the weight from the total&[u8]slices of bits.