Cirq icon indicating copy to clipboard operation
Cirq copied to clipboard

Propagate tags to components of CircuitOperation

Open 95-martin-orion opened this issue 4 years ago • 3 comments

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

95-martin-orion avatar Dec 16 '20 21:12 95-martin-orion

Child of #3235

95-martin-orion avatar Dec 18 '20 00:12 95-martin-orion

I think this should be after 1.0. Do you agree @95-martin-orion ?

dstrain115 avatar Mar 28 '22 22:03 dstrain115

If we do this post-1.0 it needs to be an opt-in feature, but otherwise I think after is reasonable.

95-martin-orion avatar Mar 28 '22 22:03 95-martin-orion