Is it possible to create controlled gates with an exponent in Cirq? For example, a controlled $\sqrt Z$ gate.
Yes, it is possible to create controlled gates with an exponent in Cirq.
For the specific case of the Z gate, Cirq includes a dedicated CZ gate that can be raised to a power:
cs = cirq.CZ**0.5
cirq.ControlledGate works on any gate. It's a bit clunkier than the dedicated gates, but it does support being raised to a power (as long as the gate it is being applied to can be raised to a power). The following two lines are equivalent:
controlled_sqrt_y = cirq.ControlledGate(cirq.Y**0.5) controlled_sqrt_y = cirq.ControlledGate(cirq.Y)**0.5
You can also raise to a power after applying to qubits, which is syntactically convenient:
cs_on_ab = cirq.CZ(a, b)**0.5
Looking at the documentation and the GitHub, there is a something called
ControlledGate. This class is said to augment existing gates with a control qubit.
You can look at the test file.
I can see line 72 :
cxa = cirq.ControlledGate(cirq.X**cirq.Symbol('a'))
Could you try:
gate = cirq.ControlledGate(cirq.X**0.5) ?