Skip to content

Fix order of noise application Pauli propagation#161

Merged
david-pl merged 3 commits into
mainfrom
david/fix-pp-noise-order
Jun 26, 2026
Merged

Fix order of noise application Pauli propagation#161
david-pl merged 3 commits into
mainfrom
david/fix-pp-noise-order

Conversation

@david-pl

Copy link
Copy Markdown
Collaborator

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.

  • The most prominent point where this was an issue is in the documentation example for the TFIM trotter, we definitely should fix that.
  • Also fixed in everywhere else (even in tests etc. where it doesn't really matter) just to be consistent and so agents don't get confused.
  • Adds a test that compares small circuits to the exact density matrix forward propagation using a simple hand-rolled DM simulator based on numpy.

@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-06-26 08:03 UTC

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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)
@david-pl david-pl merged commit b11fe88 into main Jun 26, 2026
15 checks passed
@david-pl david-pl deleted the david/fix-pp-noise-order branch June 26, 2026 08:02
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.

2 participants