Skip to content

Add loss policies to NoiseConfig to express different kinds of behavior on lost qubits#3302

Open
orpuente-MS wants to merge 21 commits into
mainfrom
oscarpuente/qubit-loss-policies
Open

Add loss policies to NoiseConfig to express different kinds of behavior on lost qubits#3302
orpuente-MS wants to merge 21 commits into
mainfrom
oscarpuente/qubit-loss-policies

Conversation

@orpuente-MS

Copy link
Copy Markdown
Contributor

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.

from qdk.simulation import NoiseConfig, LossPolicy
qir = ...

noise = NoiseConfig() 
noise.cz.on_loss  = LossPolicy.SKIP               # if one of the qubits is lost, skip the unitary
noise.cx.on_loss  = LossPolicy.PROPAGATE          # if one of the qubits is lost, loose the other one
noise.rxx.on_loss = LossPolicy.DEGRADE            # degrade to a single qubit gate: rx
noise.ryy.on_loss = LossPolicy.RESIDUAL_S_DAGGER  # apply an S_DAG to the remaining qubits
noise.rzz.on_loss = LossPolicy.APPLY_ANYWAY       # apply unitary anyways

# Works with all simulator types, in any profile.
run_qir(qir, shots=100, noise=noise, type="clifford")

@orpuente-MS orpuente-MS marked this pull request as ready for review June 12, 2026 20:01
Comment thread source/qdk_package/tests/test_simulators_gates_noisy.py Outdated
@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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Mmh, maybe the behavior here should be:

  • SKIP doesn't apply the unitary nor exchanges loss flags.
  • APPLY_ANYWAY applies the unitary and exchanges the loss flags.

@orpuente-MS orpuente-MS Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Degrade is meant to express the current behavior of Rxx, Ryy, and Rzz in our simulators, and doesn't make much sense for CX, CY, CZ, or SWAP. For example, what is the degradation of physically swapping two qubits in a neutral atom machine? Or what is the degradation of virtually relabeling two qubits?

About RESIDUAL_S_DAGGER, if we apply the unitary, we are changing the state of the two qubits in the simulator; if we don't swap the loss flags after that, we now have access to the state of a lost qubit, which doesn't seem right.

Comment thread source/simulators/src/gpu_full_state_simulator/common.wgsl
Comment thread source/simulators/src/gpu_full_state_simulator/common.wgsl Outdated
Comment thread source/simulators/src/gpu_full_state_simulator/gpu_context.rs Outdated
Comment thread source/simulators/src/cpu_full_state_simulator.rs Outdated
Comment thread source/simulators/src/stabilizer_simulator.rs Outdated
Comment thread source/simulators/src/gpu_full_state_simulator/common.wgsl Outdated
Comment thread source/simulators/src/gpu_full_state_simulator/common.wgsl Outdated
Comment thread source/qdk_package/tests/test_clifford_simulator.py Dismissed
Comment thread source/qdk_package/tests/test_clifford_simulator.py Dismissed
Comment thread source/qdk_package/tests/test_sparse_simulator.py Dismissed
Comment thread source/qdk_package/tests/test_sparse_simulator.py Dismissed
Comment thread source/qdk_package/qdk/_native.pyi Outdated
// 3. An exchange of information by doing three CX.
//
// This method is concerned with the kinds (1) and (2), since (3)
// gets decomposed into other instructions before making it to the simulator.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should definitely doc these assumption, else I can see the behavior/assumptions being confusing to some users.

Comment thread source/simulators/src/cpu_full_state_simulator.rs Outdated
Comment thread source/simulators/src/cpu_full_state_simulator.rs Outdated
Comment thread source/simulators/src/stabilizer_simulator.rs Outdated
Comment thread source/simulators/src/stabilizer_simulator.rs Outdated
Comment thread source/simulators/src/stabilizer_simulator.rs
self.state.apply_permutation(&[1, 0], &[q1, q2]);
self.residual_s_dagger(lost_qubit);
self.loss.swap(q1, q2);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should it still also apply the swap if the loss policy is ResidualSDagger and not ApplyAnyway?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In this case I think it makes sense. I don't see any reason why a relabel or physical exchange of atoms would completely skip because one of the qubits is lost.

Comment thread source/simulators/src/gpu_full_state_simulator/simulator_base.wgsl Outdated
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.

3 participants