Skip to content

Change semantics of reset to also reset loss and leakage - #287

Merged
david-pl merged 6 commits into
mainfrom
david/reset-everything
Nov 9, 2026
Merged

david-pl merged 6 commits into
mainfrom
david/reset-everything

Conversation

@david-pl

@david-pl david-pl commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

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>.

david-pl and others added 4 commits November 6, 2026 16:44
…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>
Copilot AI balanced review requested due to automatic review settings November 6, 2026 18:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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_state through 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

Comment thread skills/ppvm-usage/SKILL.md Resolved
Copilot AI balanced review requested due to automatic review settings November 6, 2026 19:01
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.2
Preview removed because the pull request was closed.
2026-11-09 09:03 UTC

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The availability table incorrectly marks reset_state as unsupported in Python, obscuring the newly exposed state-only reset API.

1 open issue

Review effort: Balanced

@JonhasA JonhasA left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Copilot AI balanced review requested due to automatic review settings November 9, 2026 08:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The review has no active issues requiring changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@david-pl
david-pl enabled auto-merge (squash) November 9, 2026 09:00
@david-pl
david-pl merged commit d231c3c into main Nov 9, 2026
15 checks passed
@david-pl
david-pl deleted the david/reset-everything branch November 9, 2026 09:03
@github-actions github-actions Bot mentioned this pull request Nov 9, 2026
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>
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.

Change semantics of reset

3 participants