Cirq
Cirq copied to clipboard
Propagate tags to components of CircuitOperation
Is your feature request related to a use case or problem? Please describe.
Context: #3580 (CircuitOperation)
The default behavior of TaggedOperation
is to drop tags during decomposition. This is intentional, as the meaning carried by ceratin tags on an operation does not necessarily apply to all components of its decomposition.
Describe the solution you'd like
When tags are applied to a CircuitOperation
, those tags are intended to apply to all operations in the circuit it contains. Decomposing a tagged CircuitOperation
should propagate its tags to its immediate children. (If those are subsequently decomposed, the tags can then be dropped as usual.)
This is useful for reducing serialization size of tag-heavy circuits: operations with shared tags can be wrapped in a CircuitOperation
, with the tags applied to the wrapper instead of to each individual operation.
[optional] Describe alternatives/workarounds you've considered
We could instead define a "meta-tag" that identifies tags to preserve across decomposition. This could be useful if we find other cases where tags ought to be propagated.
What is the urgency from your perspective for this issue? Is it blocking important work?
P2 - we should do it in the next couple of quarters
Child of #3235
I think this should be after 1.0. Do you agree @95-martin-orion ?
If we do this post-1.0 it needs to be an opt-in feature, but otherwise I think after is reasonable.