Repository navigation
Change semantics of reset to also reset loss and leakage - #287
Merged
Merged
Conversation
…et_state - MR/MRX/MRY now read out first (lost -> None, leaked -> pinned bit), then do a full reset like R, so lost / leaked qubits come back live. - New I_ERROR[reset_state] tag maps to ResetState::reset_state, which resets live qubits only. - Python: reset_state on GeneralizedTableau and GeneralizedTableauSum. - Document the new reset semantics in the ppvm-usage skill. Refs #283 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Reuse the true readout outcome to flip live qubits back to |0>, then reset loss and leakage, instead of a full `reset` that measures again. Refs #283 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The API table incorrectly marks reset_state as unavailable for Python GeneralizedTableau and needs to reflect the support added by this PR.
1 open issue
What changed in this PR
This PR addresses #283 by making standard resets recover lost and leaked qubits, while preserving the previous behavior through reset_state across the simulator APIs.
Changes:
- Splits full resets from state-only resets and adds word-level reset support for Pauli propagation.
- Exposes
reset_statethrough Python bindings and the Stim parser/executor. - Adds regression tests and updates usage documentation.
| File | Description |
|---|---|
skills/ppvm-usage/SKILL.md |
Documents full and state-only resets. |
ppvm-python/test/generalized_tableau/test_loss.py |
Tests Python reset recovery and state-only behavior. |
ppvm-python/src/ppvm/generalized_tableau.py |
Exposes and documents reset_state. |
ppvm-python/src/ppvm/generalized_tableau_sum.py |
Adds state-only resets for tableau sums. |
ppvm-python/src/ppvm/_core.pyi |
Declares native reset_state methods. |
crates/stim-parser/tests/proptest_ast.rs |
Includes state resets in property tests. |
crates/stim-parser/src/print/mod.rs |
Prints the reset_state extension. |
crates/stim-parser/src/pipeline/lower.rs |
Parses and validates the new reset tag. |
crates/stim-parser/src/instructions/mod.rs |
Updates supported-tag documentation. |
crates/stim-parser/src/ast/extended.rs |
Adds the state-reset instruction variant. |
crates/ppvm-traits/src/traits/reset.rs |
Defines state-only and word-level reset traits. |
crates/ppvm-traits/src/traits/mod.rs |
Exports the new reset traits. |
crates/ppvm-traits/src/traits/map.rs |
Adds one-to-many map accumulation. |
crates/ppvm-traits/src/map/hashmap.rs |
Implements sequential one-to-many accumulation. |
crates/ppvm-traits/src/map/dashmap.rs |
Implements parallel one-to-many accumulation. |
crates/ppvm-traits-2/src/lib.rs |
Exports ResetState at the crate root. |
crates/ppvm-traits-2/src/gates/mod.rs |
Re-exports the state-reset trait. |
crates/ppvm-traits-2/src/gates/measure.rs |
Separates full and state-only reset contracts. |
crates/ppvm-tableau/tests/gates.rs |
Tests full versus state-only lost-qubit resets. |
crates/ppvm-tableau/src/noise.rs |
Uses state resets internally and tests recovery. |
crates/ppvm-tableau/src/gates/reset.rs |
Implements full loss and leakage recovery. |
crates/ppvm-tableau-sum/tests/sampler_vs_pure.rs |
Checks reset consistency between backends. |
crates/ppvm-tableau-sum/src/gates/reset.rs |
Separates state reset from loss recovery. |
crates/ppvm-stim/tests/executor.rs |
Tests Stim reset and measurement-reset behavior. |
crates/ppvm-stim/src/validate.rs |
Accepts the state-reset instruction. |
crates/ppvm-stim/src/executor.rs |
Executes state resets and updates measurement-reset recovery. |
crates/ppvm-stim/benches/stim-circuits.rs |
Counts targets of state-reset instructions. |
crates/ppvm-python-native/src/interface_tableau.rs |
Binds tableau state resets to Python. |
crates/ppvm-python-native/src/interface_tableau_sum.rs |
Binds tableau-sum state resets to Python. |
crates/ppvm-pauli-word/src/word/data.rs |
Implements ordinary Pauli-word resets. |
crates/ppvm-pauli-word/src/loss/data.rs |
Implements lossy Pauli-word reset expansion. |
crates/ppvm-pauli-sum/src/sum/reset.rs |
Implements full reset propagation and regression tests. |
Review effort: Balanced
Contributor
|
david-pl
enabled auto-merge (squash)
November 9, 2026 09:00
Merged
david-pl
pushed a commit
that referenced
this pull request
Nov 9, 2026
## 🤖 New release
* `ppvm-traits`: 0.2.1 -> 0.3.0 (⚠ API breaking changes)
* `ppvm-pauli-word`: 0.2.1 -> 0.3.0 (✓ API compatible changes)
* `ppvm-pauli-sum`: 0.2.1 -> 0.3.0 (✓ API compatible changes)
* `ppvm-sym`: 0.2.1 -> 0.3.0
* `ppvm-tableau`: 0.2.1 -> 0.3.0 (✓ API compatible changes)
* `stim-parser`: 0.2.1 -> 0.3.0 (⚠ API breaking changes)
* `ppvm-stim`: 0.2.1 -> 0.3.0 (✓ API compatible changes)
* `ppvm-tableau-sum`: 0.2.1 -> 0.3.0 (✓ API compatible changes)
* `vihaco-circuit-isa`: 0.2.1 -> 0.3.0
* `ppvm-vihaco`: 0.2.1 -> 0.3.0
* `ppvm-tui`: 0.2.1 -> 0.3.0
* `ppvm-cli`: 0.2.1 -> 0.3.0
### ⚠ `ppvm-traits` breaking changes
```text
--- failure trait_added_supertrait: non-sealed trait added new supertraits ---
Description:
A non-sealed trait added one or more supertraits, which breaks downstream implementations of the trait
ref: https://doc.rust-lang.org/cargo/reference/semver.html#generic-bounds-tighten
impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.50.0/src/lints/trait_added_supertrait.ron
Failed in:
trait ppvm_traits::traits::Reset gained ResetState in file /tmp/.tmpOuypqr/ppvm/crates/ppvm-traits/src/traits/reset.rs:31
trait ppvm_traits::prelude::Reset gained ResetState in file /tmp/.tmpOuypqr/ppvm/crates/ppvm-traits/src/traits/reset.rs:31
trait ppvm_traits::Reset gained ResetState in file /tmp/.tmpOuypqr/ppvm/crates/ppvm-traits/src/traits/reset.rs:31
--- failure trait_method_added: pub trait method added ---
Description:
A non-sealed public trait added a new method without a default implementation, which breaks downstream implementations of the trait
ref: https://doc.rust-lang.org/cargo/reference/semver.html#trait-new-item-no-default
impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.50.0/src/lints/trait_method_added.ron
Failed in:
trait method ppvm_traits::traits::ACMapAddAssign::map_flat_add_assign in file /tmp/.tmpOuypqr/ppvm/crates/ppvm-traits/src/traits/map.rs:55
trait method ppvm_traits::prelude::ACMapAddAssign::map_flat_add_assign in file /tmp/.tmpOuypqr/ppvm/crates/ppvm-traits/src/traits/map.rs:55
trait method ppvm_traits::ACMapAddAssign::map_flat_add_assign in file /tmp/.tmpOuypqr/ppvm/crates/ppvm-traits/src/traits/map.rs:55
```
### ⚠ `stim-parser` breaking changes
```text
--- failure enum_variant_added: enum variant added on exhaustive enum ---
Description:
A publicly-visible enum without #[non_exhaustive] has a new variant.
ref: https://doc.rust-lang.org/cargo/reference/semver.html#enum-variant-new
impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.50.0/src/lints/enum_variant_added.ron
Failed in:
variant ExtendedInstruction:ResetState in /tmp/.tmpOuypqr/ppvm/crates/stim-parser/src/ast/extended.rs:67
variant ExtendedInstruction:ResetState in /tmp/.tmpOuypqr/ppvm/crates/stim-parser/src/ast/extended.rs:67
variant ExtendedInstruction:ResetState in /tmp/.tmpOuypqr/ppvm/crates/stim-parser/src/ast/extended.rs:67
```
<details><summary><i><b>Changelog</b></i></summary><p>
## `ppvm-cli`
<blockquote>
##
[0.3.0](v0.2.1...v0.3.0)
- 2026-11-09
### Other
- Change semantics of reset to also reset loss and leakage
([#287](#287))
</blockquote>
</p></details>
---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

Closes #283.
I had to add a new trait to implement the reset at the word-level. Otherwise, this would have led to conflicting implementations on
PauliSum<T>.