Add loss policies to NoiseConfig to express different kinds of behavior on lost qubits#3302
Add loss policies to NoiseConfig to express different kinds of behavior on lost qubits#3302orpuente-MS wants to merge 12 commits into
NoiseConfig to express different kinds of behavior on lost qubits#3302Conversation
| @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. |
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.
There was a problem hiding this comment.
Mmh, maybe the behavior here should be:
SKIPdoesn't apply the unitary nor exchanges loss flags.APPLY_ANYWAYapplies the unitary and exchanges the loss flags.
There was a problem hiding this comment.
I came up with a simple principle: no matter the policy, we should never recover a qubit that was lost. Following this rule of thumb, I created the following table describing the behavior of SWAP under each policy:
| Policy | apply unitary | exchange loss flags | extra behavior |
|---|---|---|---|
| SKIP | no | no | no |
| PROPAGATE | no | no | loose other qubit |
| DEGRADE | no | no | no |
| RESIDUAL_S_DAGGER | yes | yes | apply S_ADJ to survivor |
| APPLY_ANYWAY | yes | yes | no |
There was a problem hiding this comment.
That table doesn't look right. You do apply the unitary for DEGRADE I thought, just to the other qubit. And 'exchange loss flags' being 'yes' on RESIDUAL_S_DAGGER seems wrong.
| self.state.apply_unitary(UnitaryOp::ControlledX, &[q2, q1]); | ||
| } | ||
| } | ||
| } else { |
There was a problem hiding this comment.
In a number of these, you're not applying idle noise on the other qubit.
Also, for ApplyAnyway (which we should discuss further as it doesn't make much sense to me), should you also be applying idle noise anyway to the lost qubits?
There was a problem hiding this comment.
Added the missing idle noise applications.
We can discuss removing the ApplyAnyway policy.
… remaining qubits
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.