5

I have a question about the implementation of the controlled unitary $e^{iAt}$, from the paper Demonstration of a Quantum Circuit Design Methodology for Multiple Regression, using the Qiskit framework.

In this paper, a $4\times 4$ Hermitian matrix $A$ is transformed into $4\times 4$ unitary and then decomposed by applying the GLOA algorithm. I'm not interested in this particular example but rather in general implementation of the arbitrary unitary by using Qiskit. However, it is convenient to use this case as an example. In this paper, we have a series of controlled $4\times4$ unitary operators implemented according to the phase estimation algorithm. Since the resulting circuit is given in the paper, I have successfully implemented the unitary but I have a difficult time to apply the controlled action of the given unitary in Qiskit framework.

In other words, how can I implement a controlled unitary for some arbitrary $A$? Should I use a given circuit from the paper and apply control to each gate in the circuit or there is another way?

Sanchayan Dutta
  • 18,015
  • 8
  • 50
  • 112
ljubab
  • 53
  • 5

1 Answers1

4

Disclaimer: I'm the one that wrote the code of the 4x4 HHL.


Controlling a quantum gate $U$ can be achieved by controlling each of the $U_i$ gates that are composing $U$.

For the specific example you are considering, the implementation is available online. Some remarks about the code:

  1. I think the code is not up to date with the last version of Qiskit. I did not re-tested recently. The code should be compatible with Qiskit 0.6.1 as written in the requirements.txt file.
  2. The implementation of the controlled unitary is available here.
  3. The controls are not really explicit, but you can see that each gate used in the implementation of the unitary is controlled by the same qubit.
  4. Everything in the above implementation has been hand-tuned. You will probably not be able to understand the generic algorithms to control an arbitrary gate with the code.

In the general case, controlling an arbitrary gate may be programmatically quite hard. For example, in order to control a $Z$ gate (and so to perform a controlled-$Z$), you will probably end up decomposing the controlled-$Z$ gate as 2 $H$ gates around a controlled-$X$. Another example is how do you implement a multi-controlled-$X$ gate. There are known algorithms, but they should be implemented beforehand.

End note: if you want to discuss about the implementation, feel free to contact me at the mail address at the end of the README.

Adrien Suau
  • 5,366
  • 22
  • 59