quil-lang / qvm

The high-performance and featureful Quil simulator.
Other
411 stars 57 forks source link

Speed-up and decrease memory consumption in QVM #173

Open jmbr opened 5 years ago

jmbr commented 5 years ago

Each time apply-matrix-operator is called in order to apply a given gate, magicl-matrix-to-quantum-operator copies the relevant matrix into a newly-allocated array and then calls matrix-multiply to evaluate the matrix vector product. This linear algebra operation is entirely done on the Lisp side instead of using the underlying BLAS implementation (which is highly optimized by the hardware vendor --i.e., Intel, Apple, etc.).

I suggest:

  1. using foreign storage for the matrices and the wavefunction (e.g., using static-vectors), and
  2. using the underlying BLAS routines instead of the current code

I anticipate that, by doing so, we could significantly boost the performance of QVM and decrease consing by avoiding unnecessary allocations/copies (see https://github.com/rigetti/magicl/pull/60) when computing gate applications.