I want to have a gate with two measurements as its controls. I tried to look for either a straight-forward way:

CX rec[-1] rec[-2] 2

or to use a DETECTOR for it, but I couldn't find anything.

Is there a way to implement it without using multiple CX gates?

  • $\begingroup$ You are looking for classically multi-controlled gate support in stim I think. I understand "gates with multiple control qubits" in your title question as asking for a Toffoli or $CCZ$ gate for example, which cannot be supported by stim as far as I can tell. $\endgroup$
    – AG47
    Commented Apr 8 at 12:08

1 Answer 1


Stim circuits don't support multi-control gates, even when one or both of the controls is classical.

You can use stim's tableau simulator or flip simulator to implement arbitrary classical controls via if statements in your Python code driving the simulator.

The underlying reason for this restriction is that it ensures the Tanner graph of the circuit is deterministic and polynomial in size. Allowing doubly controlled Paulis can create detectors whose detecting regions aren't stabilizer flows. I won't claim that isn't useful, it probably is, but it's complicated and I still don't understand it well enough to realistically support it as a use case.

Doubly controlled Paulis also break or complicate the flip simulator concept for efficiently breeding more samples from a reference sample. I think it requires the reference sample to be noiseless and feedbackless, with feedback treated like "honorary errors" in the flip simulation.


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.