Implement asymmetric loss channel - #136
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Implements an approximate asymmetric (state-dependent) single-qubit loss channel for the generalized tableau backend, wiring it through Rust traits and the Python bindings, with new unit tests validating basic and statistical behavior.
Changes:
- Add
AsymmetricLossChanneltrait and export it fromppvm-traits. - Implement
asymmetric_loss_channelforGeneralizedTableauusing a non-destructivez_expectation()helper. - Expose the new channel through the PyO3 interface + Python wrapper, and add Rust/Python tests for correctness and statistics.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
crates/ppvm-traits/src/traits/noise.rs |
Introduces the AsymmetricLossChannel trait API. |
crates/ppvm-traits/src/traits/mod.rs |
Re-exports AsymmetricLossChannel for downstream use. |
crates/ppvm-tableau/src/measure.rs |
Adds GeneralizedTableau::z_expectation() used to compute state-dependent loss probability. |
crates/ppvm-tableau/src/noise.rs |
Implements the asymmetric loss channel and adds Rust tests for z_expectation + loss behavior. |
crates/ppvm-python-native/src/interface_tableau.rs |
Exposes asymmetric_loss_channel through the PyO3 native interface. |
crates/ppvm-python-native/ppvm_python_native.pyi |
Adds the new method to Python type stubs. |
ppvm-python/src/ppvm/generalized_tableau.py |
Adds the Python wrapper method and user-facing docstring. |
ppvm-python/test/generalized_tableau/test_loss.py |
Adds Python tests for asymmetric-loss semantics and statistics. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+204
to
+210
| // State-dependent loss probability from the populations pop0/pop1. | ||
| let z = self.z_expectation(addr0); | ||
| let p_tot = p0.to_f64().unwrap() * 0.5 * (1.0 + z) + p1.to_f64().unwrap() * 0.5 * (1.0 - z); | ||
|
|
||
| if p_tot < self.tableau.rng.random::<f64>() { | ||
| return; | ||
| } |
| .. note:: | ||
| This is the trajectory *approximation* of the loss channel. It is | ||
| exact for the loss statistics and in the symmetric limit | ||
| ``p0 == p1`` (where it matches :meth:`loss_channel`), but it does |
|
…c-loss # Conflicts: # crates/ppvm-python-native/src/interface_tableau.rs # ppvm-python/src/ppvm/_core.pyi
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 #39.
Note, that this is an approximate version: we'd actually have to redistribute populations (apply$K_0$ from #39) in order to fully capture the resulting statistics. However, that is a non-Clifford operation and would scale exponentially. So, for now, we approximate that part as leaving a qubit that survives the channel unchanged.