-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Update Gate.control
method to return AnnotatedOperation
#11082
Comments
If the goal is to ultimately handle controlled gate translation in the transpiler can't |
Some of the intention is that there's a difference between a higher-level "abstract" control on an inner gate (useful for optimisations) and a "concrete" gate that a backend might use natively. It's questionable to me whether |
Thanks @ewinston, @jakelishman, these are all very good comments. I feel that always returning I think that having specialized classes for special gates is a good idea even when the gates don't end up being natively supported by the backend. For instance, if we had a special synthesis technique for CSwapGates, then keeping a gate as a CSwapGate would allow to apply that synthesis technique through high-level synthesis plugin mechanism. |
One more comment, I feel that having gate-specific "control" methods like we have right now is also a good idea, with SwapGate knowing that its 1-controlled version is a CSwapGate, or MCX gate knowing that it's arbitrarily-controlled-version is also a MCX gate. However, I am not 100% sure when exactly this information is already used in Qiskit. As far as I understand, adding "control" to a quantum circuit only uses |
What should we add?
Continuing the saga of supporting annotated operations in Qiskit, we should update the
Gate.control()
method to returnAnnotatedOperation
instead of aControlledGate
and in particular to avoid eagerly constructing the controlled gate's definition.Note that for classes that are derived from
Gate
and that implement thecontrol
method, this said implemented method should be used.Examples:
SwapGate().control(1)
should still produceCSwapGate
,SwapGate.control(2)
(which ended up calling thecontrol
method of its parent classGate
) should produceAnnotatedGate
instead ofControlledGate
.There are several immediate problems that I don't know how to handle correctly:
.control()
to a gate and expects to see aControlledGate
in return. Additionally,gate.control()
acceptslabel
as an argument whileAnnotatedOperation
s do not have labels.QuantumCircuit
to handle the case that not everything is anInstruction
(in particular, not everyOperation
may have fields such asbase_class
,label
,params
, etc.)Suggestions?
E.g., maybe we should not try to replace
.control
but define some new method?The text was updated successfully, but these errors were encountered: