quantumlib / Cirq

A Python framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits.
Apache License 2.0
4.24k stars 1.01k forks source link

Deep map_operations doesn't preserve CircuitOperation tags #6504

Closed zchen088 closed 6 months ago

zchen088 commented 6 months ago

Description of the issue When calling map_operations with deep=True, tags on FrozenCircuits inside CircuitOperations are not preserved.

How to reproduce the issue


c = cirq.Circuit.from_moments(cirq.FrozenCircuit().with_tags("asdf"))
print(c[0].operations[0].circuit.tags)

mapped = cirq.map_operations(c, lambda x, idx: x, deep=True)[0].operations[0].circuit.tags
print(mapped[0].operations[0].circuit.tags)
put long logs in details blocks *like this*

Cirq version '1.4.0.dev20240220200443'

zchen088 commented 6 months ago

I think I see the issue. In this line, https://github.com/quantumlib/Cirq/blob/main/cirq-core/cirq/transformers/transformer_primitives.py#L174, we need to add with_tags(*op.untagged.circuit.tags). Unfortunately I'm not setup to develop on Cirq at the moment...