quantumlib / Stim

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

Unable to run circuits with classical control with stimcirq #706

Closed pgoiporia closed 4 months ago

pgoiporia commented 4 months ago

I was trying to simulate this teleportation circuit (https://quantumai.google/cirq/build/classical_control#basic_conditions) with stimcirq.StimSampler and received the following error.

image

Is there any plan to support classical control in stimcirq?

Strilanc commented 4 months ago

This should work for Pauli gates. The issue here is that the gate you are controlling is Y**0.5, which is a Clifford gate. Stim circuits don't support classically controlled Clifford gates, and therefore stimcirq can't support this gate.

There are currently no plans to add support for classically controlled Clifford gates. They break the optimization that Stim uses to do simulations so quickly. As in, simulations literally get 1000x more expensive if you allow classically controlled Cliffords. So it really is a different sort of problem to solve.

So unfortunately the answer to your question is no, there aren't plans to fix this, and I'm going to close this as WONTFIX.

Note you can use the python-driven simulations, TableauSimulator or FlipSimulator, to apply Cliffords conditioned on previous measurement results. The TableauSimulator is the one that's 1000x slower. The FlipSimulator is fast, but can't tell you raw measurement results; only whether they were flipped.