Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
5.25k stars 2.37k forks source link

Leverage ``quantum_info`` in ``StatevectorSimulatorPy`` #7670

Open Cryoris opened 2 years ago

Cryoris commented 2 years ago

What is the expected enhancement?

We previously discussed whether we can remove the BasicAer provider, see #4443, and concluded that we will still keep it for the time being. It might be good to make the statevector simulator in BasicAer use quantum_info.Statevector under the hood for two main reasons:

Since right now the Statevector does not support all the same instructions as BasicAer we could for instance only use the Statevector if the simulated circuit consists of unitary operations, or we have to directly extend the supported operation set of it (which would probably be a project on itself).

BasicAer's statevector vs quantum_infos statevector

Now the performance of the simulator does depend on the system specifications, e.g. @mtreinish and I obtained very different results using the Statevector class. These are some small benchmarks for 2-16 qubits circuits with different depth using the qiskit.circuit.library.EfficientSU2(num_qubits, reps=reps) circuit.

image

This was run on macOS 12.1 with a 2.3GHz i7 processor and 32 GB of RAM and Terra main @ 1ae663d80 (version 0.20.0), NumPy 1.19.0. Here, the relative speedups vary and range from ~4 times faster for the 16 qubit circuits to ~20 for the 2q systems.

kevinsung commented 2 years ago

As part of QAMP spring 2022, my mentee @alejomonbar will be tackling this issue.

alejomonbar commented 2 years ago

In the end, the most important function used by a circuit execution using the BasicAer backend is run_experiment. A state vector attribute will be updated depending on the set of experiment instructions, which can be unitary, SINGLE_QUBIT_GATES, id or u0, CX, reset, barrier, measure, and bfunc . The idea is to create a similar function that we called sample_circuit, but in this case, using the quantum_info package, for that package all the functions less bfunc are already implemented.

kevinsung commented 2 years ago

Thanks, @alejomonbar . Just to clarify, we did not have the time to fix this issue during QAMP. Someone else should feel free to pick this up.