qiskit icon indicating copy to clipboard operation
qiskit copied to clipboard

Organize the synthesis library of multi-controlled gates

Open ShellyGarion opened this issue 1 year ago • 3 comments

What should we add?

Currently the synthesis methods of the multi-controlled gates are part of their definition. We would like to have a single MCXGate() class, and an HLS plugin that checks the number of clean or dirty ancillas, and chooses the optimal synthesis method (see https://github.com/Qiskit/qiskit/pull/12729).

The synthesis library will therefore include a new section Multi-controlled gates synthesis which will include the following functions:

  • [x] synth_mcx_no_ancillas - the current definition of the MCXGate
  • [x] synth_mcx_one_clean_ancilla - the current definition of the MCXRecursiveGate
  • [x] synth_mcx_n_dirty_ancillas - the current definition of the MCVChainGate
  • [x] synth_mcx_graysynth_no_ancillas - the current definition of the MCXGrayCode (and the internal MCU1Gate). Note that the number of CX gates grows exponentially in the number of qubits.
  • [ ] synth_mcp_no_ancillas - the current definition if the MCPhaseGate
  • [ ] synth_mcp_graysynth_no_ancillas - the current definition of the MCXGrayCode (and the internal MCU1Gate). Only for parametrized gates. Note that the number of CX gates grows exponentially in the number of qubits.
  • [ ] synth_mcmt_no_ancillas - the current definition of the MCMTGate
  • [ ] synth_mcmt_n_clean_ancillas - the current definition of the MCMTVChainGate
  • [ ] synth_mcrx_no_ancillas - the current synthesis of the mcrx method
  • [ ] synth_mcry_no_ancillas - the current synthesis of the mcrx method
  • [ ] synth_mcrz_no_ancillas - the current synthesis of the mcrz method

The following classes will be deprecated in Qiskit 2.0:

The following classes will remain in the circuit library (including synthesis methods with ancillas when applicable):

Question: Should we add the gates MCRX, MCRY and MCRZ to the circuit library? See the discussion in https://github.com/Qiskit/qiskit/issues/12048

### Tasks
- [ ] https://github.com/Qiskit/qiskit/pull/12904
- [ ] https://github.com/Qiskit/qiskit/pull/12961

ShellyGarion avatar Jul 31 '24 11:07 ShellyGarion

Regarding naming: Since there could be multiple methods that use no ancillas, would it make sense to use unique names for the methods, like in e.g. the linear function synthesis?

Regarding MCRX/Y/Z classes: I'd say no, since that opens the door to having a class for each multi-controlled gate. Instead I think we should just have AnnotatedOperations that the high-level synthesis calls the correct synthesis function for.

Cryoris avatar Jul 31 '24 11:07 Cryoris

Since there could be multiple methods that use no ancillas, would it make sense to use unique names for the methods, like in e.g. the linear function synthesis?

Yes. we could add the initials of the author names to the synthesis methods (also relevant for methods that use ancillas)

ShellyGarion avatar Jul 31 '24 11:07 ShellyGarion

Regarding the mcrx, mcry and mcrz methods (copying the relevant paragraph of #12048):

  1. The angles should be of type ParameterValueType (not only float).
  2. Add ctrl_state parameter (like in MCXGate or mcx method).
  3. The control method of the rx, ry and rz gates, should call the relevant synthesis methods of mcrx, mcry and mcrz.

ShellyGarion avatar Jul 31 '24 11:07 ShellyGarion