Add CY and CCY gates
Is your feature request related to a use case or problem? Please explain
I noticed the issue when reviewing the qelib1.inc PR and while working on controlled gate decomposition. Since Y's don't have dedicated CY or CCY, they are parsed from qelib as Controlled(Y). In the controlled gate tests, anything with a controlled Y gate ends up requiring brute force to decompose, while CX and CZ decompose much more concisely. This is workable, but would be improved if Y had its own dedicated set of related gates.
Describe the solution you would prefer
X and Z have dedicated control gates CX, CCX, CZ, CCZ, whereas Y doesn't. Add these, and have YPowGate.controlled() return those when applicable. Also update 'cy' in QasmParser to return the CY gate.
How urgent is this for you? Is it blocking important work?
P3 – I'm not really blocked by it; it's an idea I'm proposing based on principle
Discussed in Cirq Cynq 2025-06-11: yeah, looks reasonable.
Per cirq cync: We should probably add CY and CCY gates. I don't see why not. It might be nice to find out what cirq currently decomposes CY into.
Controlled-Y currently decomposes to the following.
0: ─────────────S────────────────────@───────────────────────────────────@───────────────────────────
│ │
1: ─────────────Z───────────Y^-0.5───@───Y^0.5───S^-1───Y^0.5───Y^-0.5───@───Y^0.5───Y^-0.5───S^-1───
For a proper CY gate, by symmetry with CX, I'd expect you could start with CX's decompose method, swap the Y**0.5's for X**-0.5's, so end up with something like the following. The unitary of this should be the same as the above.
def _decompose_(self, qubits):
c, t = qubits
yield XPowGate(exponent=0.5).on(t)
yield cirq.CZPowGate(exponent=self._exponent, global_shift=self.global_shift).on(c, t)
yield XPowGate(exponent=-0.5).on(t)
CCY's decomposition should be identical, except with a CCZPowGate in the middle (and two control qubits of course).
Most of CY could be done in a similar manner; copy from CX and swap X's and Y's with a sign change. For the eigencomponents, you can see CX's are the same as X's plus a prefix for the control qubit; I expect CY's would be Y's plus the same prefix.
Hi, I see that this issue is marked as good for learning. I have some basic knowledge about cirq & quantum gates, but would love to dive deeper. Maybe I could work on it?