Add loss policies to NoiseConfig to express different kinds of behavior on lost qubits#3302
Open
orpuente-MS wants to merge 1 commit into
Open
Add loss policies to NoiseConfig to express different kinds of behavior on lost qubits#3302orpuente-MS wants to merge 1 commit into
NoiseConfig to express different kinds of behavior on lost qubits#3302orpuente-MS wants to merge 1 commit into
Conversation
billti
reviewed
Jun 13, 2026
| # | ||
| # These exercise the per-gate `NoiseConfig.<gate>.on_loss` behavior. The | ||
| # `on_loss` policy is honored by the cpu (full-state) and clifford (stabilizer) | ||
| # simulators, so these tests are parametrized over just those two. |
Member
There was a problem hiding this comment.
Is this correct? Looks like GPU is included below.
billti
reviewed
Jun 13, 2026
| @pytest.mark.parametrize("sim_type", LOSS_POLICY_SIM_TYPES) | ||
| def test_on_loss_swap_skip_keeps_state_but_swaps_loss_flag(sim_type): | ||
| # Overriding `swap.on_loss` to SKIP skips the SWAP unitary, but the loss | ||
| # flag is still exchanged. qs[0] keeps its reset |0> and qs[1] becomes lost. |
Member
There was a problem hiding this comment.
This one is interesting. Worth discussing more. Seems odd you would skip the unitary (which swaps the state) but still swap which is lost. Not sure if that would be physically possible.
billti
reviewed
Jun 13, 2026
| // Loss policy values. These are stamped onto a gate op's `q3` field by the host | ||
| // (see `LossPolicy::as_u32` on the Rust side) and tell the shader how to handle | ||
| // the gate when one of its operands is lost. `0` means "no policy stamped", | ||
| // which the shader treats the same as SKIP. |
Member
There was a problem hiding this comment.
When I was looking at the enum I was wondering why the default value (0) wasn't skip. Is there a reason to start at 1 and leave 0 undefined/no-policy?
billti
reviewed
Jun 13, 2026
| if (shot.qubit_state[q1].heat == -1.0) { | ||
| return true; | ||
| } | ||
| let is_2q = (op.id == OPID_CX || op.id == OPID_CY || op.id == OPID_CZ || |
Member
There was a problem hiding this comment.
You already have is_1q_op defined (line 74). Can you just negate that? For now we only have 1q and 2q ops.
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.
With this change, users are able to specify how gates should behave if at least one of their qubit operands is lost. Below is a comprehensive example, showing all 5 loss policies.