Repository navigation
[codex] Specialize ppvm-runtime depolarizing noise fast paths - #54
Conversation
|
There was a problem hiding this comment.
Pull request overview
This PR optimizes ppvm-runtime depolarizing/noise hot paths to reduce per-term branching and setup overhead, and records the autotuning results used to select the kept optimization.
Changes:
- Specialized single-qubit
pauli_error/depolarizescaling via bit-based Pauli classification with precomputed factors. - Replaced
depolarize2’s 15-entry probability expansion with the closed-form two-qubit depolarizing scaling factor. - Added autotune logs/metrics documenting kept vs. discarded iterations.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| docs/autotune/runtime-micro-overall/metric.toml | Captures baseline and iteration medians for the overall runtime microbenchmarks. |
| docs/autotune/runtime-micro-overall/log.md | Documents hypotheses, outcomes, and the rationale for keeping the noise specialization. |
| crates/ppvm-runtime/src/sum/noise.rs | Implements faster single-/two-qubit depolarizing paths using bit-based Pauli checks and closed-form scaling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| fn pauli_error(&mut self, addr0: usize, p: [<T as Config>::Coeff; 3]) { | ||
| self.scale(|k, v| { | ||
| match k.get(addr0) { | ||
| Pauli::I => {} | ||
| Pauli::X => { | ||
| *v *= 1.0f64 - 2.0f64 * p[1].clone() - 2.0f64 * p[2].clone(); | ||
| } | ||
| Pauli::Y => { | ||
| *v *= 1.0f64 - 2.0f64 * p[0].clone() - 2.0f64 * p[2].clone(); | ||
| } | ||
| Pauli::Z => { | ||
| *v *= 1.0f64 - 2.0f64 * p[0].clone() - 2.0f64 * p[1].clone(); | ||
| } | ||
| Pauli::L => {} | ||
| }; | ||
| let x_factor = 1.0f64 - 2.0f64 * p[1].clone() - 2.0f64 * p[2].clone(); | ||
| let z_factor = 1.0f64 - 2.0f64 * p[0].clone() - 2.0f64 * p[1].clone(); | ||
| let y_factor = 1.0f64 - 2.0f64 * p[0].clone() - 2.0f64 * p[2].clone(); |
There was a problem hiding this comment.
pauli_error behavior was refactored to rely on bit-based Pauli classification (pauli_code + get_lbit), but there is no unit test that directly exercises PauliError::pauli_error (unlike depolarize / depolarize2). Adding a regression test that checks the scaling for I/X/Y/Z (and that L is unchanged) would help catch any future mismatches between the bit encoding and the Pauli enum mapping.
There was a problem hiding this comment.
@copilot apply changes based on this feedback
There was a problem hiding this comment.
Added a regression test test_pauli_error in crates/ppvm-runtime/tests/noise.rs (commit 050cb02) that verifies the coefficient scaling for each Pauli at the target qubit:
- I: coefficient unchanged
- X: scales by
1 - 2*py - 2*pz - Y: scales by
1 - 2*px - 2*pz - Z: scales by
1 - 2*px - 2*py - L: coefficient unchanged (lost qubit is skipped via the
get_lbitguard)
…/Y/Z/L Agent-Logs-Url: https://github.com/QuEraComputing/ppvm/sessions/d6ff2071-dad1-4ef7-aa02-0816c94bc793 Co-authored-by: Roger-luo <8445510+Roger-luo@users.noreply.github.com>
Summary
ppvm-runtimesingle-qubit noise scaling to use bit-based Pauli classification with precomputed factorsdepolarize2's generic 15-entry probability expansion with the closed-form uniform two-qubit depolarizing factordocs/autotune/runtime-micro-overall/Why
The
ppvm-runtimemicrobenchmark suite showed the noise group as a meaningful opportunity for end-to-end improvement. The kept change removes avoidable branching and coefficient setup from the depolarizing paths while preserving the existing generic two-qubit Pauli-error implementation.Benchmark Notes
Fresh
cargo bench -p ppvm-runtime --bench micro -- --noploton a clean branch based onorigin/mainproduced these representative medians:noise/pauli_error:279.81 ns -> 187.02 nsnoise/depolarize:272.73 ns -> 187.85 nsnoise/depolarize2:509.21 ns -> 242.33 nsnoise/two_qubit_pauli_error:523.07 ns -> 447.96 nsnoise/amplitude_damping:524.70 ns -> 473.04 nsValidation
cargo test -p ppvm-runtimecargo bench -p ppvm-runtime --bench micro -- --noplot