In Cirq, quantum circuit consists of moments, which in turn consists of operations. This is different from Qiskit/OpenQASM, which doesn’t have the concept of moments. What is the design philosophy behind the moment-based quantum circuit? What are the advantages and disadvantages of it?

As a result of moments, one can insert operations in different moments using different insert strategies. It seems to me the earliest insert strategy is always preferred, which is the same as Qiskit/OpenQASM. What are the use cases for different insert strategies?


1 Answer 1


What is the design philosophy behind the moment-based quantum circuit? What are the advantages and disadvantages of it?

The basic idea is that we wanted to give users more control over what will actually happen on hardware. Whether or not two gates are run in parallel is really important information when dealing with noise (e.g. it determines total runtime), so it's important for users to be able to determine-whether that's happening and also control-if that's happening.

The philosophy of giving more control isn't limited to moments. Cirq also requires users to specify specific qubits (no implicit placement), and to use the native gateset of whatever device they are targeting (no implicit decomposition). The important thing is that you should be able to have a clear concrete idea of what will actually happen on the device.

Cirq also has the concept of a "schedule", which has even more control over timing. But ironically we've found that users don't want to use it, and programmers don't like consuming it. So we're actually cutting that next version.

The list-of-moments structure seems to be a nice sweet spot in terms of flexibility, ease of production, and ease of consumption. You can certainly put the abstraction boundary in other places, but that's where we've found ourselves pulled towards.

It seems to me the earliest insert strategy is always preferred

It's a good rule of thumb, which is why it's the default. But it's not always optimal. For example, hardware may perform best when circuits are stratified into layers of single-qubit gates and layers of two-qubit gates (but never a layer with both single and two qubit gates). So even if you can move a single qubit operation earlier, that may result in it being in the same layer as two qubit operations. Moving it would not be a fatal mistake, the circuit would still run, but it might be slightly noisier. There are lots of "little things" like that when dealing with hardware.

  • $\begingroup$ Thanks for the detailed answer! Giving programmers more control is a good approach, but it makes Cirq more intimidating at the start, compared to Qiskit. I think it would be nice to design it in a way that is easy to pick up but difficult to master, like Nintendo games :). Of course it is easier said than done. And to be fair my knowledge of Cirq is limited to the one-day Bootcamp I attended two days ago. I need to play with it a bit more to make any concrete comments. All in all, it’s great to see different approaches! $\endgroup$ Nov 22, 2019 at 10:32
  • $\begingroup$ @HuangJunye What makes Cirq more intimidating to start with compared to Qiksit? You don't need to know about moments to create quantum circuits. Starting with Cirq is pretty similar to starting with Qiskit. $\endgroup$ Nov 22, 2019 at 14:44
  • $\begingroup$ @VictoryOmole Sorry I didn't make it clearer. It's not just about the moments. It's all other additional controls that Cirq allows that makes it more overwhelming. It could be due to the way I was taught in the bootcamp: drive.google.com/file/d/1PtoWiE6R2odszgldlPspvm4ihj5_CgKQ/view As a beginner, I don't think I need to know about advanced features like "insert strategy", "custom gate", "gate decomposition" first. At least I have never encountered these features in Qiskit (maybe it doesn't have). I feel having more options to start with is intimidating. $\endgroup$ Nov 22, 2019 at 15:29
  • 1
    $\begingroup$ @HuangJunye Thanks, that's useful feedback. If they send out a post bootcamp survey, be sure to mention it. $\endgroup$ Nov 22, 2019 at 17:35

Your Answer

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

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