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

Allow to add tags for the moment #6435

Open BichengYing opened 8 months ago

BichengYing commented 8 months ago

Is your feature request related to a use case or problem? Please describe.

Several tag annotations such as loop, pad, alignment is natural in the moment-level. However, we cannot do that for it as the alternative, we just use cirq.Moment(cirq.CircuitOperation(cirq.FrozenCircuit(ops).with_tags(tag))), which is quite unnecessary. We already support tags on cirq.Operation and cirq.Circuit, so might be natural to support them on moments, which are the one piece of intermediate structure. Moments are already immutable, so adding tags would be fairly natural.

Describe the solution you'd like

It is kinda of straightforward to add it if there is no particular concern in it.

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

BichengYing commented 8 months ago

Had discussions in the Cirq-Cync. This sounds reasonable and it should behave similar as the cirq.FrozenCircuit with tags. Just a few points should be kept in mind: 1. Hash value of moment. (we should make the moment with different tags different). 2. make sure the tags with moment is immutable and if we create a new moment or new tags from the existing one, it should create an entire new one.