Ensure simulator runs circuit compatible with a provided noise model's properties#8139
Ensure simulator runs circuit compatible with a provided noise model's properties#8139Acciaccatura wants to merge 12 commits into
Conversation
|
question - this change seems to be blocked on a Docstring test failure, specifically this one: however when checking the expected gateset of the noise properties from this processor myself, it seems its failure is working as intended according to my implementation: >>> import cirq_google
>>> cal = cirq_google.engine.load_median_device_calibration("rainbow")
>>> noise_props = cirq_google.engine.noise_properties_from_calibration(cal, gate_times_ns="legacy\
")
>>> print(noise_props.expected_gates())
{<class 'cirq.ops.measurement_gate.MeasurementGate'>, <class 'cirq.ops.swap_gates.ISwapPowGate'>, <class 'cirq.ops.fsim_gate.FSimGate'>, <class 'cirq.ops.common_gates.ZPowGate'>, <class 'cirq.ops.fsim_gate.PhasedFSimGate'>, <class 'cirq.ops.common_gates.CZPowGate'>, <class 'cirq.ops.phased_x_z_gate.PhasedXZGate'>, <class 'cirq_google.ops.sycamore_gate.SycamoreGate'>, <class 'cirq.ops.common_channels.ResetChannel'>}(i.e. my implementation assumes |
| import cirq | ||
|
|
||
| TStepResultBase = TypeVar('TStepResultBase', bound='StepResultBase') | ||
| TStepResultBase = TypeVar("TStepResultBase", bound="StepResultBase") |
There was a problem hiding this comment.
lots of modifications to this file due to running ruff format.
There was a problem hiding this comment.
Please revert. Use check/format-incremental for formatting instead.
There was a problem hiding this comment.
sure, will do - fixed!
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8139 +/- ##
==========================================
- Coverage 99.60% 99.60% -0.01%
==========================================
Files 1118 1118
Lines 101061 101102 +41
==========================================
+ Hits 100661 100701 +40
- Misses 400 401 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
|
||
| unexpected_qubits = [cirq.GridQubit(2, 2)] | ||
|
|
||
| class TestNoiseProperties(devices.SuperconductingQubitsNoiseProperties): |
There was a problem hiding this comment.
the TestNoiseProperties created for this test might not make sense from a QC point of view just because of my limited domain knowledge - feel free to re-implement to something more sensible if this is a concern!
| import cirq | ||
|
|
||
| TStepResultBase = TypeVar('TStepResultBase', bound='StepResultBase') | ||
| TStepResultBase = TypeVar("TStepResultBase", bound="StepResultBase") |
There was a problem hiding this comment.
sure, will do - fixed!
When provided a
NoiseModelFromNoisePropertiesnoise model to simulate, ensure the circuit uses qubits and gates that are compatible with the noise properties. At a slightly lower level:NoiseModelFromNoisePropertiesexposes its underlyingNoisePropertiesas a public property.SimulatorBasewill check to make sure all the gates and qubits used by the circuit are permitted under anyNoisePropertiesfrom the associatedNoiseModelFromNoiseProperties.SuperconductingQubitsNoisePropertiescontainsexpected_qubitsorexpected_gates, so the code is currently hardcoded to this class. I'm uncertain if Cirq has any plans on genericizing this behavior toNoiseProperties.fixes #6608