QuantumCircuitOpt.jl icon indicating copy to clipboard operation
QuantumCircuitOpt.jl copied to clipboard

Toffoli gates as elementary gates

Open AbhiDu96 opened this issue 10 months ago • 5 comments

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

AbhiDu96 avatar Apr 15 '24 10:04 AbhiDu96

@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.

harshangrjn avatar Apr 15 '24 15:04 harshangrjn

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.

AbhiDu96 avatar Apr 16 '24 11:04 AbhiDu96

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

harshangrjn avatar Apr 16 '24 13:04 harshangrjn

@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.

harshangrjn avatar May 24 '24 04:05 harshangrjn

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

AbhiDu96 avatar May 24 '24 10:05 AbhiDu96