quantumlib / Stim

A fast stabilizer circuit library.
Apache License 2.0
338 stars 97 forks source link

Add backward-propagating flows to crumble #665

Open ghost opened 11 months ago

ghost commented 11 months ago

A good starting option might just be a global control to choose whether flows propagate forwards or backwards in time.

A more general version might involve having two or more marker states, such that each marker can choose whether to propagate forwards or backwards, and gives purple bar errors when those states are violated.

Strilanc commented 11 months ago

I think what I want to do is to have some kind of notation, like:

# propagate reset forwards
RX(1,2,t=3) -> ?

# propagate measurement backwards
? -> MX(1,2,t=5)

# propagate free-standing flip forwards (note half integer time)
Y(1,2,t=3.5) -> ?

# try to form a detector, show error otherwise
RX(1,2,t=3) -> MX(1,2,t=5)

# try form a detector; infer the resets
auto -> MX(1,2,t=5) MX(1,2,t=10)

# try form a detector; infer the measurements [somehow]
RX(1,2,t=3) RX(1,2,t=8) -> auto

and once I have a notation for it, I can make a UI for that notation. Like you could pick which ones to show.

ghost commented 11 months ago

That sounds great to me, esp if we can hook in detectors in the circuit for debugging what we're actually making, esp inferring the resets from the measurements. For inferring the measurements from the resets, we could provide a heuristic like trying to minimize the overall size of the resulting region?

In the meantime, I would appreciate a global flip the propagation direction button, as I'm doing that a reasonable amount by hand by reversing the circuit; how hard would it be to just toggle the direction of the flow mechanics? Any pointers?

Strilanc commented 11 months ago

I think the key method is PropagatedPauliFrames.fromCircuit. If you add a boolean go_backwards to that method, and feed that boolean in from where the method is called from, it should be enough? You'll probably find yourself being dragged into inverting gate flows in order to compute the layer by layer result.

There is, separately, a more performant class in-the-works which is https://github.com/quantumlib/Stim/blob/main/glue/crumble/circuit/pauli_frame.js but it's not integrated yet. Don't get distracted by it.