Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leverage quantum_info in StatevectorSimulatorPy #7670

Open
Cryoris opened this issue Feb 16, 2022 · 3 comments
Open

Leverage quantum_info in StatevectorSimulatorPy #7670

Cryoris opened this issue Feb 16, 2022 · 3 comments
Labels
type: enhancement It's working, but needs polishing

Comments

@Cryoris
Copy link
Contributor

Cryoris commented Feb 16, 2022

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:

  • (probably the more important reason!) quantum_info is a module we're further developing and making BasicAer depend on it might (1) push us to add more features like supporting classical instructions and (2) make it easier to remove BasicAer in the end
  • the Statevector can be much faster than the current statevector simulator in BasicAer (see below) and speeding it up would be great both for users and us (as several tests use BasicAer)

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 @ 1ae663d (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
Copy link
Contributor

kevinsung commented Mar 14, 2022

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

@alejomonbar
Copy link
Contributor

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
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement It's working, but needs polishing
Projects
None yet
Development

No branches or pull requests

3 participants