Addition of controlled rotation gates
Would it be possible to add support for controlled rotation gates (CRx(gate), CRy(gate), CRz(gate)) in the braket.circuits.gate module?
class CRx(Gate):
r"""Controlled Rx gate.
Unitary matrix:
.. math:: \mathtt{CRx} = \begin{bmatrix}
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & \cos{(\phi/2)} & -i \sin{(\phi/2)} \\
0 & 0 & -i \sin{(\phi/2)} & \cos{(\phi/2)} \\
\end{bmatrix}.
"""
Thank you!
@mho291 Thanks for creating this issue! Just want to point out that you can do this today by passing a control parameter to the Rx gate. Something like:
Circuit().rx(1, 0.15, control=0)
Thank you @rmshaffer for pointing that out!
Let me provide a little more background to my query. I'm part of the Qibo team, and one of the recent developments in partnership with @speller26 and @licedric was the addition of BraketClientBackend to our cloud backends. We've been actively using it to run stuff on the Amazon Braket backends.
In another project, we use the Controlled-RX gate as an integral part of our circuit. In this case, BraketClientBackend can't be used because of the absence of the CRx gate in the braket.circuits.gate module.
We would appreciate if you could let us know if support can be added for controlled rotation gates. I am most happy to contribute as well. :)
@mho291 Ryan's suggestion should still actually work; you'll have to rework braket_translation to take in targets as well, but with that, you could just add a dispatch for CRx, perhaps something like
@_translate_op.register
def _(g: qibo_gates.RX, targets):
return Instruction(braket_gates.Rx(g.parameters[0]), targets[1], control=targets[0])