# How does MCPhaseGate/MCU1Gate works internally in qiskit?

I was curious about the implementation of MCPhase/MCU1Gate and how it works without ancilla qubits. I ended up checking the code of the some auxiliary (?) function _gray_code_chain() but I couldn't understand much of it.

update: it seems that MCU1Gate is deprecated and MCPhase will substitute it - the code is the same anyway.

• Are you looking for how the gate is implemented with elementary ones? Feb 21, 2021 at 6:47
• Exactly @MartinVesely, I just updated the question. Thanks.
– 123
Feb 21, 2021 at 12:51

The function _gray_code_chain is a reference to the bit-string ordering algorithm. The application of the algorithm in multi-controlled-gate decomposition is explained in Quantum Circuits for General Multiqubit Gates, Mottonen, et. al and in Quantum Computation and Quantum Information, Nielsen & Chuang, section 4.5.2 p191.