quantumlib / Stim

A fast stabilizer circuit library.
Apache License 2.0
310 stars 90 forks source link

Fix cirq-to-stim conversion not adding `TICK`s for multi-moment single-rep `CircuitOperation`s #728

Closed AlexBourassa closed 4 months ago

AlexBourassa commented 4 months ago

Currently in main when we convert a cirq circuit to stim with a CircuitOperation with a single repetition (or with flatten=True) no TICK instructions are inserted since the moments are removed in the cirq.decompose_once(op) command.

Strilanc commented 4 months ago

Can you give an example of a current bad output in the description of the PR?

AlexBourassa commented 4 months ago

Can you give an example of a current bad output in the description of the PR?

On main, the stim circuit from the unit test would be:

H 0 0 0 0
TICK

Whereas after this PR the output circuit is

H 0
TICK
H 0
TICK
H 0
TICK
H 0
TICK
AlexBourassa commented 4 months ago

@Strilanc I think this should be ready to go! (although some of the CI are failing, but I don't think this is related to my change?). Please take another look when you get a chance!

Strilanc commented 4 months ago

It was failing because you were using cirq.q which doesn't exist in the cirq version the tests install, to ensure backwards compatibility.