Moment allows conflicting measurements
Description of the issue
Moment constructor checks for conflicting ops on qubits but not on measurement keys.
How to reproduce the issue
m = cirq.Moment(
cirq.measure(cirq.NamedQubit('q1'), key='a'),
cirq.measure(cirq.NamedQubit('q2'), key='a'),
cirq.X(cirq.NamedQubit('q3')).with_classical_controls('a')
)
print(cirq.Circuit(m))
┌───┐
q1: ────M──────
║
q2: ────╫M─────
║║
q3: ────╫╫X────
║║║
a: ═════@@^════
└───┘
Note: multiple classical controls should be able to depend on the same measurement key within a moment; just multiple measurements, or measurement+control on the same key should not be allowed in one moment.
Cirq version v1.0
Looks like a bug. We should fix for a bug fix release 1.0.1
I think we should allow the repeated measurement keys in a moment, since operations are ordered within in a moment there's not ambiguity about which operation will write first into the output array for the given key. But the classical control being used in the same moment is a problem.
@maffoo an aside, from a HW perspective should we allow a qubit to be used as a control for multiple operations in the same moment? i.e. logically CX(0, 1) and CCX(0, 2, 3) can run in parallel. We don't currently allow them to appear in the same moment though. Is that restriction worth removing, or would HW be unable to support that anyway?
I think it'd be fine to allow multiple gates that use a given control bit in the same moment.
Closing due to lack of activity