-
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
Remove implicit assumption that Operations have Gates #3678
Comments
We don't assume that operations have gates; that's why the |
This is the current behavior for Separately, this is an example of the interface segregation principle: The example of this which prompted me to open this issue was serializable_gate_set.py, which uses |
It may be worth revisiting whether a subcircuit should really be modeled as an operation. An operation is plausibly something that's instantaneous, that plays out in a single moment. A subcircuit spans moments and runs in sequence in sync with the main circuit. Either way, seems like there should be something in the class hierarchy that distinguishes between instantaneous and sequential. Maybe an algebraic data type would be better here than subclassing? |
@daxfohl: Subcircuits as they are implemented today are just as "instantaneous" as any other operation. Consider this circuit:
There are two things to note about the second moment of the top-level circuit:
(These items are true even without explicit For more details on why |
Create a module-level function |
Since `Operation` provides a canonical way to get the untagged version of itself, we should use it instead of writing a new method to do the same thing. Using `op.untagged` in #3634 removes any residual blocking effects from #3678, although I'm still in favor of finding a proper resolution to #3678.
|
Is your feature request related to a use case or problem? Please describe.
The
Operation
has agate
property which is frequently used to identify its type. However, not allOperation
s areGateOperation
s, meaning that this field is not always populated.Until recently this has been a relatively minor problem, since the vast majority of
Operation
s areGateOperation
s. However, with the introduction ofCircuitOperation
(#3580) this issue is becoming more pronounced.Related issue: #3235.
Describe the solution you'd like
Remove
gate
field inOperation
and replace with aget_operator
abstract method, defined in implementations. This will require deprecating the field and replacing it across the Cirq repo.[optional] Describe alternatives/workarounds you've considered
What is the urgency from your perspective for this issue? Is it blocking important work?
P1 - I need this no later than the next release (end of quarter)
This confounds work on CircuitOperations, as they do not have a value in their
gate
field. Continuing work in that space without resolving this issue requires workarounds which will increase the cost of an eventual fix.The text was updated successfully, but these errors were encountered: