-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Simplify decomposition of controlled eigengates with global phase #7238
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
Comments
I spent some time looking into this and I have several questions:
|
Your other PR should mitigate the second concern. It'll decompose to its canonical form, which is a Z with parameterized exponent. The first concern might be a blocker though. It definitely doesn't make sense to factor out the phase of a rotation gate. Open to ideas. |
I found that |
Yeah I guess it's either opt-out or opt-in, but each subclass that opts will have to specify that itself. I can't think of a clever way to get around it, or at least not a good one. |
Initial thoughts:
I think both problems are solvable. For 1, EigenGate could define a default |
Thank you for the suggestions! Please see #7291 for my attempt to address this issue. I think there is no nice solution here, so I am fine if the PR is not accepted. |
I think it's a good start. This assumes that the issue itself gets approved. I think primarily see if you can get rid of the type check. If it's not possible, I think that indicates this may be a step in the wrong direction anyway. If it's possible, then that adds some weight to this being a worthwhile change. |
Oh, backing up a little, I found the documentation here states that the decomposition should terminate in a Pauli, CZ, or global phase. https://github.com/quantumlib/Cirq/blob/main/cirq-core/cirq/protocols/decompose_protocol.py#L98 Given that, it seems like the best approach here would be to instrument the Paulis and CZ each with a A shared |
Discussed in Cirq Cynq 2025-04-30: accepting the issue. Needs more investigation of the operations involved. |
Describe your design idea/issue
The gate
cirq.XPowGate(global_shift=0.22).controlled()
decomposes toBut it's easy to see that
cirq.XPowGate(global_shift=0.22).controlled()
can be broken down into a regularX
gate plus aGlobalPhaseGate(0.22)
, with the same control applied to each. The controlledX
is therefore justCX
, which has a defined decomposition to[Y, CZ, Y]
, and a controlled phase gate is equivalent to aZ**phase
. Therefore,cirq.XPowGate(global_shift=0.22).controlled()
is logically equivalent to and probably should decompose toThis similarly happens with other controlled instances of
EigenGate
with global phases, whereControlledGate._decompose_
sends them through the raw numeric matrix reduction transformers, instead of just factoring out the phase first.An approach to solve this could be
EigenGate._decompose_
that factors out any phase into its own gate. i.e. it returns a phase-free EigenGate and a separate global phase gate.ControlledGate._decompose_
, move the matrix transformer option to be the last option to try (after attempting the decomposition of the subgate). This would allow the controlled phased gate to decompose into a controlled unphased gate plus a controlled global phase, which generally will be simpler to decompose further from there.The text was updated successfully, but these errors were encountered: