-
Notifications
You must be signed in to change notification settings - Fork 982
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
Removing noise model check in Simulator initialization #4216
Conversation
…t to include noise model from simple_noise_from_calibration_metrics
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
@googlebot I signed it! |
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.
Please merge the master branch back into this one.
result1 = simulator.run(circuit, repetitions=50) | ||
result2 = simulator.run(circuit, repetitions=50) | ||
|
||
assert result1 != result2 |
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.
I suppose for this PR we just want to verify that the simulator accepts the noise model, as opposed to raising an exception. However, we can make the test more useful by checking that the measurement falls into an interval (which ideally would be verified by a calculation independent of the code under test).
cirq.Simulator(noise=cirq.amplitude_damp(0.5)) | ||
def test_noise_model(): | ||
q = cirq.LineQubit(0) | ||
circuit = cirq.Circuit(cirq.I(q), cirq.measure(q)) |
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.
There is a class of bugs that make sum(result.measurements['0'])[0]
equal to zero exactly (e.g. one such bug is the simulator accepting but ignoring the noise). These bugs would pass undetected by the test.
Suggestion: Replace identity with cirq.H(q)
and change the assert to something like
assert 40 <= sum(result.measurements['0'])[0] < 60
Feel free to use tighter bounds, I just made those up. They should be gapped away from zero on the left and away from 100 on the right, though.
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.
thanks for the suggestion, I just updated it!
Addresses issue quantumlib#4170 by removing NOISE_MODEL_LIKE check in sparse_simulator.py and updates tests accordingly.
Addresses issue #4170 by removing NOISE_MODEL_LIKE check in sparse_simulator.py and updates tests accordingly.