I am trying to use the circuit composer of the IBM QE. I am doing the inverse QFT on 3 qubits and therefore need a control on T and S dagger gates, but it won't let me.

Does anyone know why or know a way around it? I've been stuck on this for a while now and have no idea what to do. Thanks

  • $\begingroup$ I think it is a present limitation of the composer UI. You can try quirk: algassert.com/quirk $\endgroup$
    – midor
    Commented Jan 19, 2021 at 13:48

3 Answers 3


I am not sure why, but you cannot add controls to $T$ or $S$ (and their inverses) in the composer. What you can do is instead use the Phase gate (which you can add a control to) and set these angles for identical behaviour:

  • $P(\pi/2) = S$
  • $P(\pi/4) = T$
  • $P(-\pi/2) = S^\dagger$
  • $P(-\pi/4) = T^\dagger$
  • 2
    $\begingroup$ Just note that U3 can help as well. It also has controlled version and it is the most general gate on IBM Q. $\endgroup$ Commented Jan 19, 2021 at 12:33

A way around :)

Controlled-$P$ version for any $P$ phase gate. Note that as is mentioned in the previous answer $P(\pi/2) = S$, $P(\pi/4) = T$ and $P^\dagger (a) = P(-a)$. The circuit for controlled-$P(a)$ looks like this

where q[0] is the control qubit. The proof:

$$ I P(a/2) \big[|0\rangle \langle 0|I + |1\rangle \langle 1| X \big] I P(-a/2) \big[|0\rangle \langle 0|I + |1\rangle \langle 1| X \big] P(a/2) I = \\ ={|0\rangle \langle 0|I + |1\rangle \langle 1| e^{a/2} P(a/2) X P(-a/2) X} = \\ = |0\rangle \langle 0|I + |1\rangle \langle 1| P(a) = \text{cotrolled-}P(a) $$

where I have omitted the $\otimes$ sign (e.g. $I P = I \otimes P$).

Like was mentioned in the previous answer one can add control to the $P$ gate in IBM QE circuit composer without using the decomposition of controlled-$P$ shown here.


To add on top of @Davit answer. Suppose you want to do certain operations, in this case is Controlled-S or Controlled-T, and it is not directly implement on the circuit composer. But you want to use the circuit composer to have better visualization of the circuit. What you can do is to create these gate directly in Qiskit and decompose to OpenQASM code, which then you can import it directly to the circuit composer.

Here is an example:

Suppose we want to create Controlled-S gate, then we can just use the Quantum Lab to create this gate as follow:

from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
from numpy import pi
qreg_q = QuantumRegister(1, 'q')
creg_c = ClassicalRegister(1, 'c' )
circuit = QuantumCircuit(qreg_q)

q_0: ┤ S ├

This is just to create the S gate. We then can create the Controlled-S gate by

xs_gate = circuit.to_gate()
cxs_gate = xs_gate.control()
qreg_q = QuantumRegister(2, 'q')
creg_c = ClassicalRegister(2, 'c')
circuit = QuantumCircuit(qreg_q)
circuit.append(cxs_gate, [0,1])

q_0: ──────■──────
q_1: ┤ circuit23 ├

Now we can decompose this circuit into elementary gates as:

qasm_circuit = circuit.decompose()
print( qasm_circuit )

q_0: ┤ P(π/4) ├──■───────────────────■──────────────
q_1: ┤ P(π/4) ├┤ X ├┤ U(0,0,-π/4) ├┤ X ├┤ U(0,0,0) ├

You can see that the above circuit is similar to what Davit suggested. Now you can convert this circuit into OpenQASM using:


which will output:

include "qelib1.inc";
qreg q[2];
p(pi/4) q[0];
p(pi/4) q[1];
cx q[0],q[1];
u(0,0,-pi/4) q[1];
cx q[0],q[1];
u(0,0,0) q[1];

Now you can take this and import it to your circuit composer under the OpenQASM Code editor

enter image description here


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.