-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Classical control #4631
Classical control #4631
Conversation
Use control keys in circuit construction to block controlled gates "earliest" append method from falling back to before the measurement.
…n due to failing tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good. I think the only remaining items are the discussion on what to call this operation (to be covered at Cirq sync today) and the "controlled CircuitOp which contains a measurement" test case. After these are done, we can merge.
It looks like |
We still need to confirm with the internal error-correction team on the name, but either way I think those methods are still reasonable names. |
def __init__( | ||
self, | ||
sub_operation: 'cirq.Operation', | ||
conditions: Sequence[Union[str, 'cirq.MeasurementKey']], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the meaning of multiple conditions and measurement keys that correspond to more than one value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add some documentation here.
Multiple conditions are treated as and
, so chaining op.with_conditions('a', 'b').with_conditions('c', 'd')
is equivalent to op.with_conditions('a', 'b', 'c', 'd')
.
If a measurement was of multiple qubits, all zeros is considered False, anything else is considered True.
There's a subsequent PR that will allow sympy expressions to be conditions, like 'mkey1 | mkey2'
, or 'mkey1 > 20'
. That will enable or
conditions, and measurements-with-multiple-qubits to be used as ints,
Between the Cirq sync and internal review, |
@95-martin-orion I went ahead and updated the function names to I added tests for subcircuits with control keys based on external measurements as well. They work, but I wouldn't say they're supported yet. As you can see in the tests, they require special handling during construction, since the control_keys protocol doesn't yet expose unbound control keys of subcircuits, so the logic in append doesn't detect the key conflict and pushes that subcircuit to the first moment by default. That is all taken care of in the scope PR. Also I promised Dave some pydocs above. I'll add those. |
Pydocs, added. Ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes LGTM. Pinging @dabacon for his input on the docstrings, otherwise this is ready to go.
Going ahead with merge to keep these moving. |
Sits on top of quantumlib#4627 Creates `ConditionalOperation` class and executes operations conditionally upon the classical bits. Most of this is done in commit quantumlib@06883d5. Reimplements quantum teleportation example based off this class. Parts 8, 9, 10 of https://tinyurl.com/cirq-feedforward.
Sits on top of quantumlib#4627 Creates `ConditionalOperation` class and executes operations conditionally upon the classical bits. Most of this is done in commit quantumlib@06883d5. Reimplements quantum teleportation example based off this class. Parts 8, 9, 10 of https://tinyurl.com/cirq-feedforward.
Sits on top of #4627
Creates
ConditionalOperation
class and executes operations conditionally upon the classical bits. Most of this is done in commit 06883d5.Reimplements quantum teleportation example based off this class.
Parts 8, 9, 10 of https://tinyurl.com/cirq-feedforward.