Multi_control_cz gate

I want to build a diffuser and an oracle so that's why I wanted a multi control cz gate but I looked everywhere I didn't get any

  • 2
    $\begingroup$ Welcome to QCSE. The question is how to add a CCCCZ to your circuit or on how graphically make it appear? $\endgroup$
    – Mauricio
    Commented Sep 12, 2022 at 10:04

2 Answers 2


You have to make your own gate.If you want to adda $\underbrace{\mathrm{C}\cdots\mathrm{C}}_{n-1}\mathrm{Z}$-gate to a circuit, first you have to create it. You can do so using:

from qiskit import QuantumCircuit
from qiskit.circuit.library import MCMT
c3z= MCMT('cz',n-1,1)

Here I use $n=3$ for CCZ, $n=4$ for CCCZ and so on (select $n=9$ to reproduce the picture you added). The result is

q_0: ─■─
q_1: ─■─
q_2: ─■─

Now you can create a circuit and add it using .compose method indicating where do you want the qubits. Here is an example:



q_0: ┤ H ├─■─
     └───┘ │ 
q_1: ──────■─
q_2: ──────┼─
q_3: ──────■─

Another option would be to log into your IBMQ account and access the Composer. There the drag and drop interface allows you to add additional controls with drag and drop or a right click. It also generates the code for the circuit that you have built on the right hand side.

I have not yet tried to integrate the code generated by the Composer in a Jupyter Notebook, but if a direct copy-paste does not work I know that you can click the button that says 'open in quantum-lab' and this will take the circuit and transfer it to the Compiler where after running the code it provides you with a widget to continue to manipulate your circuit. At the bottom of the widget is a button, 'create a cell and syncronize the circuit qiskit code output', which will turn your circuit directly into the code that you need.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.