rrmeister / pyQuEST

Python interface for the Quantum Exact Simulation Toolkit (QuEST)
MIT License
16 stars 4 forks source link

Consistent behavior for CCX, CCY and CCZ #7

Open TerraVenil opened 2 weeks ago

TerraVenil commented 2 weeks ago

Hi. Have noticed that CCX and CCY are not supported but CCZ is working well.

image

Just curious is anything specific with adding support for CCX and CCY as well?

TysonRayJones commented 1 week ago

Hi Oleksii,

Just adding some info while Richard is flat-out at the moment. CCX could principally be added immediately (wrapping QuEST's multiControlledMultiQubitNot), though QuEST currently only supports singly-controlled Pauli Y.

But either way, QuEST is currently undergoing a substantial refactor (watch v4 progress here hehe) which will enable a new multi-controlled multi-target Pauli tensor function (see demo implementation here). pyQuEST can then wrap this function to support CCY (as well as e.g. CCCXYZYX hehe).

The QuEST refactor itself could take another month, and updating pyQuEST may be another few weeks thereafter (since some of the API and typing will change). So fingers crossed, you can expect the facility by August!

As for right now, you should be able to define your own generic gate U with the Pauli X or Y matrices and apply it with any number of control qubits. This will be slower than a bespoke function, but not prohibitively so.

Hope this helps!

TerraVenil commented 1 week ago

Hi @TysonRayJones, Thank you for your response and I hope @rrmeister is also doing well. Yes, you are definitely right that for any unitary gate that is missing in pyQuEST we can use general purpose gate U but I hope in the future the list of supported gates will be increasing. 😎 For now, by following suggested approach a few gates were added among them CH, Tdg, Sdg, CCX, CSWAP and more...

rrmeister commented 1 week ago

Hi Oleksii,

thanks very much for your comments. As @TysonRayJones already elaborated, the lack of dedicated operators is almost always due to the QuEST backend not supporting those with bespoke functions (CCX being the exception here, it has been added to QuEST after the initial pyQuEST implementation and I overlooked it when it was added). I will leave this Issue open to remind myself of adding the CCX gate, but as @TysonRayJones said, it will probably get a re-write anyway when QuEST v4 is released.

For the future, any gate requests (like the ones at the end of your last comment) are better placed in the QuEST repo, from where they will propagate to the pyQuEST interface once implemented (if I don't overlook them ehehe). I will therefore close this Issue once CCX is implemented and only add gates once they are available in QuEST.

Cheers! Richard