docs/hardware/pasqal/getting_started.ipynb fails to execute in Google Colab #6655
Labels
good first issue
This issue can be resolved by someone who is not familiar with the codebase. A good starting issue.
kind/bug-report
Something doesn't seem to work.
triage/accepted
there is consensus amongst maintainers that this is a real bug or a reasonable feature to add
Description of the issue
The cirq-pasqal getting_started.ipynb notebook calls cirq.optimize_for_target_gateset which should produce a circuit that validates w/r to pasqal device, but this fails when run on https://colab.research.google.com/ notebook.
The same notebook passes if run on a local Debian Linux OS. This seems to be cause by different round-off errors of the CPUs, which lead to differing optimized circuits.
The root cause appears to be that
cirq.optimize_for_target_gateset
does not ensure that for PasqalGateset the newcircuit has single-operation moments, they just happen to be so for getting_started.ipynb with a favorable round-off errors.
The optimization may also produce a moment with 2 operations, which fails validation as follows:
How to reproduce the issue
Create and run fresh colab at https://colab.research.google.com
(0, 0): ───@───Z───@───
│ │
(1, 0): ───@───────┼───
│
(2, 0): ───────────X───
OPTIMIZED
(0, 0): ───@───Z──────────────────@───Z─────────────────────
│ │
(1, 0): ───@──────────────────────┼─────────────────────────
│
(2, 0): ───────────PhX(0.5)^0.5───@───PhX(-0.5)^0.5───Z^0───
VALIDATION
ValueError Traceback (most recent call last)
in <cell line: 28>()
26
27 print("\nVALIDATION\n")
---> 28 p_device.validate_circuit(pasqal_circuit)
2 frames
/usr/local/lib/python3.10/dist-packages/cirq_pasqal/pasqal_device.py in validate_circuit(self, circuit)
137 ValueError: If the given circuit can't be run on this device
138 """
--> 139 super().validate_circuit(circuit)
140
141 # Measurements must be in the last non-empty moment
/usr/local/lib/python3.10/dist-packages/cirq/devices/device.py in validate_circuit(self, circuit)
84 """
85 for moment in circuit:
---> 86 self.validate_moment(moment)
87
88 def validate_moment(self, moment: 'cirq.Moment') -> None:
/usr/local/lib/python3.10/dist-packages/cirq_pasqal/pasqal_device.py in validate_moment(self, moment)
233 for operation in moment:
234 if not isinstance(operation.gate, cirq.MeasurementGate):
--> 235 raise ValueError("Cannot do simultaneous gates. Use cirq.InsertStrategy.NEW.")
236
237 def minimal_distance(self) -> float:
ValueError: Cannot do simultaneous gates. Use cirq.InsertStrategy.NEW.
Cirq version
1.4.1
The text was updated successfully, but these errors were encountered: