-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Allow noise on sparse simulator #3829
Conversation
Commented on #2432: certain types of noise must be rejected by the sparse simulator. This will need tests for each type of noise described in that comment (current test covers "noise gates" only). |
Based on the test, it looks like a global phase difference is introduced in decomposition. This isn't inherently bad behavior, but that test in particular requires global phase to be preserved. I think the correct way to handle this is to pass a custom
|
Got it, thanks! |
@95-martin-orion so I replaced I'm actually ready to call this PR "done" from my perspective. I know there's discussion around doing some pre-analysis of the noise, but a few things there. First, I think it's going to be cumbersome, as it would require a whole design, implementation, and integration of a Either way, do you have an example of what would be channel noise and mixture noise, so I can add test cases for them? IDK really what those terms mean. |
This is a fair point. I'd say the primary difference is that noise type is easier to identify than general simulability, as each gate can be checked for noise type independently of the rest of the circuit. The motive to do this check for noise is fail-fast behavior: since large simulations can take a long time (on the order of minutes), we try to pre-check wherever possible. I don't think a noise check would represent a significant fraction of the simulation time, but if that's what you're seeing then we can leave it up to the simulator to identify the error.
Sure. As a preface: all gates can be represented as mixtures and all mixtures can be represented channels, but these relations don't work in reverse. As a result, Cirq will accept e.g. From
It should be possible to use these directly as the |
Sounds good. One other thing I wanted to check: in the |
Gate noise is (generally) unitary; mixture and channel noise is not. In general, anything for which |
@95-martin-orion I think this is ready for re-review. |
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.
_has_(unitary|mixture)_
on the noise model fits just right. LGTM!
@smitsanghavi @tonybruguier if you want to add noise support to clifford or mps simulators, this PR can be a template to do so. It ended up being only a couple lines of code. |
My understanding is that the Clifford simulator should not support any noise. Unless there is a class of noise models that have a stabilizer effect that I'm not aware of. @Strilanc to confirm. |
will this work with GateSubstitutionNoiseModel https://github.com/quantumlib/Cirq/blob/master/cirq/devices/noise_model.py#L247 for simulating coherent error (like an overrotation or something) |
The noise model in sparse simulator has to have a unitary or mixture representation. Passing in a noise model without
However one easy workaround would be to create a child class for your particular gate substitution noise model, and hard-code that to provide the |
Actually, you could add an optional constructor arguments |
So it only needs |
Fixes #2432
Adds optional noise parameter to
Simulator.__init__
. If this is deemed a valid approach, we can do this with the other simulators too.Note, that's a big if. I don't have enough background to understand whether this approach makes sense.