# How can we construct a control-control y-rotation (CCRy) gate in Qiskit?

Qiskit has a CRy gate, however I couldn't find a CCRy (double control Ry) gate implementation. How can we construct the CCRy circuit given below in Qiskit without any ancillary qubits?

Edit: A quick note on another solution, when using the mcry gate to perform control-control y-rotation. I had been initializing quantum circuits via:

from qiskit.circuit import QuantumCircuit

circ = QuantumCircuit(4, 4)
circ.mcry(q_controls=[0, 1], q_target=2, q_ancillae=None) # Gives error saying q_target needs to be a qubit


As shown in the linked solution, one needs to define quantum registers and pass those objects as parameters to the quantum circuit to avoid this issue. In general, this makes me wonder if the latter is a better practice than what I had been doing previously (shown above).

There is no CCRy gate in the library but there is the multi-controlled multi-target gate (MCMT) class that you can use. Or, you could also do it as follow:

from qiskit import QuantumCircuit,QuantumRegister
from qiskit.circuit.library.standard_gates import RYGate
from qiskit.circuit import Parameter
import matplotlib.pyplot as plt
qr=QuantumRegister(3)
circ=QuantumCircuit(qr)
a=Parameter('a') # You can replace a with your choice of angle here
CCRY=RYGate(a).control(2)
circ.append(CCRY,qr)
print(circ)

q0:   ────■────
│
q1:   ────■────
┌───┴───┐
q2:   ┤ RY(a) ├
└───────┘


• Thank you very much! That's extremely helpful. Commented Feb 25, 2021 at 2:55
• Nice. I suppose CCRY may be a little better name for CCCRY. Commented Feb 25, 2021 at 2:57
• @AdamZalcman Ha! I was using it for something else where I had 3 control qubits.... forgot to change the name back. :) Commented Feb 25, 2021 at 3:10
• @FaiyazHasan No problem!! Glad I can help. Welcome to QCSE. Commented Feb 25, 2021 at 3:11