2
$\begingroup$

In Qiskit, there are explicit transpile (where a circuit is transpiled to primitive gates) and backend.run (where the circuit is executed in either statevector simulation or real hardware) steps. What would be the equivalent in Cirq? In Cirq, you only have 1 API of simulator.simulate().

Note: I am executing my circuit multiple times under various parameters in a hybrid quantum-classical feedback loop algorithm. And so, using sweep is not possible.

$\endgroup$
2
  • 1
    $\begingroup$ Welcome to QCSE! Some feedback on your question: Ideally, the post would explain what transpile and backend.rundo in order to make the question self-contained. At minimum it should provide links, though these are discouraged since they can become dead reducing the future value of the post. As it stands, the post shifts the burden of figuring out what it is you're trying to do in cirq on the readers which further reduces its future value and your current chances of getting an answer. $\endgroup$ Aug 9, 2022 at 3:39
  • $\begingroup$ Thank you for the feedback. I have added permalinks to the functions, and added elaboration for what they did. $\endgroup$
    – pcr
    Aug 9, 2022 at 7:32

1 Answer 1

0
$\begingroup$

You could play around with Cirq's transformers. Each transformer is a potential compilation step, such as decomposition into target gatesets, mapping/routing, and hardware-specific optimizations. There are several built-in transformers (including cirq.optimize_for_target_gateset, which may help with the transpilation into primitive gates that you mentioned), and you can also define your own custom transformers if you want something more complex.

See also this previous question on stackexchange.

$\endgroup$
1
  • $\begingroup$ Thank you for the answer. Looks like there are several in the Cirq repo: cz_gateset.py, sqrt_iswap_gateset.py, sycamore_gateset.py, ionq_gateset.py, and pasqal_gateset.py. I tried cirq.optimize_for_target_gateset(circuit, gateset=ionq_gateset.IonQTargetGateset()), and this step alone is >45x slower than doing simulator.simulate() on the original circuit. $\endgroup$
    – pcr
    Aug 10, 2022 at 5:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.