-
Notifications
You must be signed in to change notification settings - Fork 1
Refactor & simplify noise dialect #512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
☂️ Python Coverage
Overall Coverage
New Files
Modified Files
|
| assert all(0 <= x <= 1 for x in probs), "Invalid Pauli error probabilities" | ||
|
|
||
| for control, target in zip(controls, targets): | ||
| which = interp.rng_state.choice(self.two_pauli_choices, p=probs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe with this we can close the issue #505
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, yeah I kept that in mind here. This already fixes it.
weinbe58
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This simplifies the noise dialect a lot. I also cut down the supported semantics, so we now only support one- and two-qubit noise channels. Effectively, we now only have the following statements:
SingleQubitPauliChannelTwoQubitPauliChannelDepolarizeDepolarize2QubitLossTechnically,
Depolarize(2)andSingle(Two)QubitPauliChannelare redundant in that you can always rewriteDepolarizeto the other channel. But I didn't want to burden the squin to stim pass with matching that (you'd need to look at runtime values of probabilities to make sure things are symmetric) when rewriting toDepolarize. At the same time, we need the asymmetric versions for cirq lowering.One thing I realized: going the same stdlib approach as for the native and the clifford dialects, we end up needing
broadcastagain. And I didn't want to havesquin.channel.broadcast.depolarizeand similar things. So, for now, I just imported everything to the top level again, which means we havesquin.depolarizeandsquin.broadcast.depolarize.FYI @johnzl-777 I renamed the STIM tests, so they'll be skipped in the CI. If this gets merged before you get to the re-implementation of the squin to stim pass, keep that in mind.
Finally, I want to point out that it's not really possible to make the linter happy when going through a stdlib function that includes a list of probabilities, specifically
two_qubit_pauli_channel. The problem is, that the linter complains that[0.01, 0.02, ...]isn't anilist, but it's really lowered to one (the linter just doesn't know), so changing the type hint in the stdlib function tolist[float]errors since it's a kernel. That said, we need some special handling anyway to improve the API here (see also #341 ). But let's do this in another PR.