# Why is implementation of controlled Hadamard on IBM Q so complex?

With reference to question how to implement CCH gate I easily realized that CH gate can be implemented with $$\mathrm{Ry}$$ gates and $$\mathrm{CNOT}$$ followingly:

Note $$\theta = \frac{\pi}{4}$$ for first $$Ry$$ gate and $$\theta = -\frac{\pi}{4}$$ for second one.

However, when I put $$\mathrm{CH}$$ gate implemented on IBM Q to circuit, a transpiled circuit has this form:

So, the first circuit has only two one qubit gates whereas the second one has six such gates. If I understand it correctly, any single qubit gate is on IBM Q eventually replaced by $$\mathrm{U3}$$ gate with respective parameters.

It seems to me that the second circuit is unnecessary complex.

Is there any reason why to implement $$\mathrm{CH}$$ gate in such way or am I missing something?

• Where are you getting this transpiled circuit from? When I run your initial circuit against the IBMQ simulator, the transpiled circuit contains 2 U3 gates, as expected. – met927 Jan 6 at 17:40
• @met927: Yes, I see the same in this case. But try to put controlled Hadamard (CH gate) instead and run the code. The transpiled code will be as in the second figure. – Martin Vesely Jan 6 at 17:45
• I think this is most likely to do with the way the transpilation is being done rather than the way the gate is implemented on the hardware. I imagine in that scenario they are unrolling to a basis that is not the standard u1, u2 and u3 gates, rather it contains those gates shown. I am not sure why this would be though. – met927 Jan 6 at 17:59
• I think this is also to do with how things are transpiled for the simulator, if you execute the circuit on a real device it is transpiled to u2 gates. – met927 Jan 6 at 18:04
• @met927: I see, just tried also on real quantum processor. Thanks for clues. – Martin Vesely Jan 6 at 19:01

• On simulator, the $$\mathrm{CH}$$ gate is transpiled to the circuit shown above
• On real quantum processor, the gate is implemented with two $$\mathrm{U2}$$ gates and $$\mathrm{CNOT}$$ (i.e. like in the first figure in the answer)
Overall, the $$\mathrm{CH}$$ gate implementation on IBM Quantum is efficient.