by Strilanc · 9y ago · 0 comments
result = measure q
Forgetting to use that was the source of the bug in the post. The code should have read `if measure qubit`.'Caught you peeking' depends on what you mean. Measurement has effects that matter, and you can check for those effects. You run the circuit many times, collect statistics, and thereby figure out what the black box is doing. But there's no primitive operation like "is qubit not measured".
The tricky thing is that measurement isn't always associated with a single qubit. For example, consider:
if q1 != q2:
apply H to q1
This code will cause some decoherence, because we need q1's original value to uncompute the condition but we changed it. But that decoherence isn't specifically associated with just q1, it will also hit q2 because the thing we decohered was the parity between the two.Now you could detect this happening at runtime, sometimes. The ancilla holding the condition value fails to uncompute consistently, so it will sometimes end up ON. The runtime could notice that ON ancilla and warn you that an ancilla failed to uncompute, but there could be many many actions in between that ancilla being computed and uncomputed. It's hard to figure out which action or combination of actions is the problem, and it's hard to figure out what exactly was decohered. Plus this check is only probabilistic; decoherence is a property of the program not the ancilla's final state. Decoherence still happened if the ancilla ended up OFF but could have ended up ON.