Fix order of noise application Pauli propagation#161
Merged
Conversation
|
There was a problem hiding this comment.
Pull request overview
Fixes a widespread ordering mistake in Heisenberg-picture Pauli propagation: when a physical circuit is “gate → noise”, the corresponding PauliSum call order (which propagates observables backward) must be “noise → gate”. The PR updates examples/docs/benches accordingly and adds a Python test that cross-checks PauliSum against an exact numpy density-matrix + Kraus simulation.
Changes:
- Reordered noise-channel calls to precede their associated gates across docs, skills examples, Rust examples, and benchmarks.
- Updated the Trotter regression test circuit (and golden value) to reflect correct gate/noise ordering.
- Added a Python correctness test that validates ordering and rotation-angle conventions vs an exact density-matrix reference.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| skills/ppvm-usage/SKILL.md | Fixes the noise/gate call order in the skill’s canonical PauliSum example. |
| skills/ppvm-usage/examples/python/noise_truncation.py | Updates the runnable skill example to apply noise before gates in Heisenberg order. |
| ppvm-python/test/test_heisenberg_ordering.py | Adds a density-matrix reference test to validate ordering + angle-sign conventions. |
| ppvm-python/test/benchmarks/test_trotter.py | Updates the Python benchmark’s Trotter op ordering to match correct Heisenberg semantics. |
| examples/trotter.rs | Updates the Rust example Trotter loop to apply noise before gates in propagation order. |
| docs/notebooks/trotter.py | Fixes the documentation notebook’s noisy Trotter step ordering (including loss/noise placement). |
| crates/ppvm-pauli-sum/tests/trotter.rs | Updates the end-to-end Trotter regression test sequence and golden constant for correct ordering. |
| crates/ppvm-pauli-sum/examples/trotter_storage_cliff.rs | Applies corrected noise-before-gate ordering in the example workload. |
| crates/ppvm-pauli-sum/examples/trotter_qubit_sweep.rs | Applies corrected noise-before-gate ordering in the sweep example. |
| crates/ppvm-pauli-sum/examples/hash_quality.rs | Applies corrected noise-before-gate ordering in the hash-quality investigation example. |
| crates/ppvm-pauli-sum/benches/trotter.rs | Fixes benchmark operation ordering and truncation comment consistency (“per operation”). |
| crates/ppvm-pauli-sum/benches/trotter-scaling.rs | Mirrors the corrected operation ordering in the scaling benchmark. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
45
to
49
| # gates default to truncate=True, i.e. truncate after every gate | ||
| # application, to stay consistent with the Rust benchmark / PP.jl. | ||
| for _ in range(steps): | ||
| for i in range(N_QUBITS): | ||
| state.rx(i, theta=theta_x) | ||
| state.pauli_error(i, p=NOISE) |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Small mistake that was spread throughout large parts of the examples: for actual Heisenberg propagation, we need to apply a noise channel that comes after a gate in the circuit, before applying the gate when propagating an observable via
PauliSum.