harshangrjn / QuantumCircuitOpt.jl

A Julia/JuMP Package for Optimal Quantum Circuit Design
Other
56 stars 15 forks source link

Toffoli gates as elementary gates #70

Open AbhiDu96 opened 5 months ago

AbhiDu96 commented 5 months ago

Can Toffoli gates be included as elementary gates to synthesize 4 and 5 multi-controlled unitary gates? I am thinking of something similar to what you have currently, i.e., "CNOT_1_2" and "CV_1_2". So something like "Tof_1_2_3" and "Too_1_3_2" where the first two indices denote the control qubits and the last qubit denotes the target qubit.

Thanks

harshangrjn commented 5 months ago

@AbhiDu96, not at this point. Though, that would be a valuable addition to the package. Would you like to do a PR for including 3 qubit Toffoli gates? Currently, global phase gates are the only multi-qubit gates supported.

AbhiDu96 commented 5 months ago

Hi @harshangrjn , thanks a lot for the quick response. I would be happy to do a PR for the 3-qubit Toffoli gate. It would certainly help a lot with my own project.

harshangrjn commented 5 months ago

Thanks! Once you make a working PR, I shall add the necessary unit tests and other mods to make it compatible.

harshangrjn commented 4 months ago

@AbhiDu96 In PR #71 , multi_controlled_gate in src/utility.jl now addresses the support for multi-controlled gates with any single-q target gate. For a multi-control Toffoli 3-q Toffoli, its

QCOpt.multi_controlled_gate(QCOpt.XGate(), [1,2], 3, 3)

Yet to make the bridge to be able to support these gates as elementary_gates. Let me know if you have any suggestions/thoughts.

AbhiDu96 commented 4 months ago

Hi @harshangrjn the modified code looks good. I tried it out, and it works. You can add it as an elementary gate.