qiboteam / qibo

A framework for quantum computing
https://qibo.science
Apache License 2.0
284 stars 55 forks source link

CNOT gate decomposition should be implemented #1421

Open csookim opened 3 weeks ago

csookim commented 3 weeks ago

@sorewachigauyo Paul mentioned that an unroller is needed to decompose the circuit using CNOT, GPI2, RZ, Z, and M. To achieve this, CNOT should be included as a native gate.

Here are the tasks to consider:

I believe cnot_dec can be implemented based on the existing cz_dec.

alecandido commented 3 weeks ago

Pay attention: often CZ, iSWAP, and CNOT are alternative to each other.

_translate_two_qubit_gates() is now hard-coding that the interactions are only carried on by CZ and iSWAP https://github.com/qiboteam/qibo/blob/8fb9af92c8ee4049d6575571ab33edd756196f2d/src/qibo/transpiler/unroller.py#L205-L207 and this is for sure not sufficient.

But it is not even that modular: it would be better to label interacting gates where they are defined (i.e. in the NativeGates class, by using non-trivial values), and then associate different actions (so, functions) to the specified set of interacting gates. If you can make such that a single unroller can work for all the possible native two-qubit gates combinations, so much the better (the amount of combinations explodes as a power set, though it's unlikely to have much more than these three gates in the short term - but that was also the reasoning behind hard-coding the previous two).

csookim commented 3 weeks ago

@alecandido Thank you for your reply. Since CNOT is needed for the upcoming chip test at CQT, I made minimal updates to enable using CNOT as a native gate for a simple circuit consisting of CZ, CNOT, SWAP, and 1q gates. Is this ok for the new PR?

alecandido commented 3 weeks ago

@alecandido Thank you for your reply. Since CNOT is needed for the upcoming chip test at CQT, I made minimal updates to enable using CNOT as a native gate for a simple circuit consisting of CZ, CNOT, SWAP, and 1q gates. Is this ok for the new PR?

If you need that urgently, for sure :)

However, we should schedule some time also for taking proper care of the unroller. If not immediately, whenever we can.