Qiskit / qiskit-aer

Aer is a high performance simulator for quantum circuits that includes noise models
https://qiskit.github.io/qiskit-aer/
Apache License 2.0
481 stars 358 forks source link

Add support for various gates in the MPS simulator #1008

Closed yaelbh closed 3 years ago

yaelbh commented 3 years ago

What is the expected behavior?

There are a bunch of gates that the MPS simulator does not support, although other Aer simulators support them. The task is to complete the support in the MPS simulator. See also related issue #1004.

yaelbh commented 3 years ago

List of gates currently supported by the MPS simulator:

{"id", "x",  "y", "z", "s",  "sdg", "h",  "t",   "tdg",  "p", "u1",
   "u2", "u3", "u", "U", "CX", "cx",  "cz", "cp", "cu1", "swap", "ccx"}

For the statevector simulator:

     "cy",     "cp",      "cu1", "cu2",  "cu3",  "swap", "id",   "p",
     "x",      "y",       "z",   "h",    "s",    "sdg",  "t",    "tdg",
     "r",      "rx",      "ry",  "rz",   "rxx",  "ryy",  "rzz",  "rzx",
     "ccx",    "cswap",   "mcx", "mcy",  "mcz",  "mcu1", "mcu2", "mcu3",
     "mcswap", "mcphase", "mcr", "mcrx", "mcry", "mcry", "sx",   "csx",
     "mcsx",   "delay", "pauli"}

To do:

yaelbh commented 3 years ago

As in the statevector simulator, maybe also here we will implement mc gates, and then other gates (some of them are already supported) will become a special case. For example, x, cx, ccx, etc., can also call mcx. Not sure though about it, since with the MPS we also have to handle swaps.

yaelbh commented 3 years ago

I see that mcx is already implemented in the MPS simulator, but it appears to apply only to 3 qubits. I don't know (will check) what happens if the user tries more qubits. x and cx are each implemented separately. Other mc's are not supported.

yaelbh commented 3 years ago

Although mcx (for 3 qubits) is implemented, it is not in the list of gates. Therefore a user cannot use it directly. It's just ccx, which is in the list of gates.

yaelbh commented 3 years ago

I see that some gates are deprecated. I won't add support to them.

yaelbh commented 3 years ago

Working on it now

yaelbh commented 3 years ago

Repeating https://github.com/Qiskit/qiskit-aer/issues/1008#issuecomment-720289414, but this time taking the list of gates supported by each simulator from qasm_simulator.py, employing a couple of changes from #1076, and excluding deprecated gates and non-existing gates (#1070):

List of gates currently supported by the MPS simulator:

'u', 'p', 'cp', 'cx', 'cz', 'id', 'x', 'y', 'z', 'h', 's', 'sdg', 'sx', 't', 'tdg', 'swap', 'ccx', 'unitary', 'roerror', 'delay', 'r', 'rx', 'ry', 'rz', 'rxx', 'ryy', 'rzz', 'rzx'

For the statevector simulator:

'u', 'p', 'r', 'rx', 'ry', 'rz', 'id', 'x', 'y', 'z', 'h', 's', 'sdg', 'sx', 't', 'tdg', 'swap', 'cx', 'cy', 'cz', 'csx', 'cp', 'rxx', 'ryy', 'rzz', 'rzx', 'ccx', 'cswap', 'mcx', 'mcphase', 'unitary', 'diagonal', 'multiplexer', 'initialize', 'kraus', 'roerror', 'delay', 'pauli', 'mcx_gray'

To do:

yaelbh commented 3 years ago

Multi-controlled gates: since they require contraction with many qubits, it is not clear whether their direct application is more efficient than transpilation to 2-qubit gates. Therefore I don't think we should implement them in the MPS simulator.

yaelbh commented 3 years ago

Closing because done in #1088.