Closed dariavh closed 12 months ago
That would be amazing!
What would be great to add a small test alongside (in tests/test_simulator_backends.py
). E.g.
import importlib
HAS_GOOGLE = importlib.util.find_spec('cirq_google')
@pytest.mark.skipif(condition=HAS_GOOGLE, reason="cirq_google not installed")
def test_cirq_google_devices():
some tests
and in the same way, including the HAS_GOOGLE
in src/tequila/simulators/simulator_cirq.py in order to throw a meaningful error message if someone tries to use the devides that need the cirq_google package installed.
Hi Jakob,
It seems that a lot has changed in the cirq
package over the last years. The Foxtail
and Bristlecone
devices are deprecated, see 0.14.0 release for the full list. The optimized_for_sycamore()
method is deprecated as well and is replaced by optimize_for_target_gateset()
that can e.g. optimize an abstract circuit in cirq
to gates that are compatible on the Google Sycamore devices.
I am currently working out the details, but I would refactor the build_device_circuit
method in simulator_cirq.py
as:
if isinstance(device, cirq.Device):
if device in [cirq_google.Sycamore, cirq_google.Sycamore23]:
try:
circuit = cirq.optimize_for_target_gateset(circuit=c, gateset=cirq_google.SycamoreTargetGateset())
except ValueError:
raise TequilaCirqException('could not optimize for device={}'.format(device))
else:
### under construction (potentially on other branches)
raise TequilaException('Only Sycamore and Sycamore23 devices currently functional. Sorry!')
Looks good to me!
would suggest the following error handling, then the original Exception from cirq is also displayed (often useful)
except ValueError as E:
original_message = str(E)
raise TequilaCirqException('original message:\n{}\n\ncould not optimize for device={}'.format(original_message,device))
Describe the bug When trying to use the
sycamore
device for simulating my wavefunction, I get the errorAttributeError: module 'cirq' has no attribute 'google'
because thecirq.google
module has been moved into its own modulecirq_google
.To Reproduce Steps to reproduce the behavior:
Computer (please complete the following information):
Additional context I think the bugfix would consist of renaming all
cirq.google
references tocirq_google
(need to check thoroughly) and adding thecirq_google
package to the optional backends list in therequirements.txt
. I can provide this in a new PR if you want?