Skip to content

Minor bugfixes and cleanup in recent noise_model.py additions - #526

Merged
perlinm merged 8 commits into
mainfrom
gates
Jul 9, 2026
Merged

Minor bugfixes and cleanup in recent noise_model.py additions#526
perlinm merged 8 commits into
mainfrom
gates

Conversation

@perlinm

@perlinm perlinm commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

@acasta-yhliu this should fix your issue here

Summary

This PR improves the NoiseRule / NoiseModel API in noise_model.py.

Unified Mapping-form after semantics. NoiseRule(after={"X": 0.1, "IZ": 0.05}) now uses Pauli-string keys, consistent with PauliChannel and NoiseModel. Previously the mapping used stim gate-name keys ("X_ERROR", "DEPOLARIZE1", etc.), which was inconsistent with every other place in the API accepting a Mapping. Old gate-name keys now raise a clear ValueError.

Widened clifford_1q_error / clifford_2q_error. Both now accept float | PauliChannel | Mapping[str, float] | NoiseRule | None, matching the types already accepted by clifford_nq_error.

Scalar depolarizing noise routes through PauliChannel. A scalar float like clifford_2q_error=0.01 now internally constructs PauliChannel.depolarizing(k, p). This fixes a bug where immunize_gates=False on a partially-immune gate raised an error even for plain depolarizing noise, since the channel can now be correctly conditioned via PauliChannel.conditioned_on.

@perlinm
perlinm merged commit e9bb133 into main Jul 9, 2026
3 checks passed
@perlinm
perlinm deleted the gates branch July 9, 2026 02:48
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.

1 participant