Skip to content

Implement asymmetric loss channel - #136

Merged
Roger-luo merged 2 commits into
mainfrom
david/asymmetric-loss
Jun 23, 2026
Merged

Implement asymmetric loss channel#136
Roger-luo merged 2 commits into
mainfrom
david/asymmetric-loss

Conversation

@david-pl

Copy link
Copy Markdown
Collaborator

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.

Copilot AI review requested due to automatic review settings June 22, 2026 14:00

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.

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 AsymmetricLossChannel trait and export it from ppvm-traits.
  • Implement asymmetric_loss_channel for GeneralizedTableau using a non-destructive z_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
@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-06-23 05:45 UTC

…c-loss

# Conflicts:
#	crates/ppvm-python-native/src/interface_tableau.rs
#	ppvm-python/src/ppvm/_core.pyi
@Roger-luo
Roger-luo enabled auto-merge (squash) June 23, 2026 05:37
@Roger-luo
Roger-luo merged commit b4dcf8a into main Jun 23, 2026
12 checks passed
@Roger-luo
Roger-luo deleted the david/asymmetric-loss branch June 23, 2026 05:44
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.

Asymmetric loss

3 participants