quil-lang / qvm

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

State Representation for QVM #215

Closed sophiaponte closed 4 years ago

sophiaponte commented 4 years ago

This PR decouples the notion of "state representation" from the qvm. The QVM currently supports the two simulation modes of quantum states: pure states, or wavefunctions (amplitudes) and density matrices. Before this PR, density matrix state simulations were restricted to only the DENSITY-QVM. This PR implementsPURE-STATE and DENSITY-MATRIX-STATE classes and modifies the existing qvm classes to be compatible with both state types. In large part, this was done by replacing the AMPLITUDES slot of the different qvms with a STATE slot, and modifying the TRANSITION, MEASURE, and APPLY-STATE functions to specialize on the STATE of the qvm to address both pure state and density matrix states. Additionally, I modified the QVMs to work with user defined superoperators, which are written in to quil programs via the ADD-KRAUS pragma. Previously, only the density-matrix-qvm accepted user defined superoperators.

Since this PR touches a ton of different files, I'll list here the general changes I made to each file.

sophiaponte commented 4 years ago

what I just changed:

a few more smol TODOs:

appleby commented 4 years ago

qvm-app-ng related generic functions that @appleby suggested

If you haven't already implemented it, maybe hold off on this one. Maybe this should just continue to live in qvm-app-ng. In any case, should be a minimal change and can be done in a follow on PR.

sophiaponte commented 4 years ago

Tests are failing when loading qvm-tests because #:CL-QUIL does not match version 1.13.1, required by #<SYSTEM "qvm-examples"> I am assuming I should change the CL-QUIL version in the Dockerfile, as the failure happens after
$ docker run --rm --entrypoint=make rigetti/qvm:${CI_COMMIT_SHORT_SHA} test-lib DISABLE_SHARED_MEMORY_QVM_TESTS=1 RIGETTI_LISP_LIBRARY_HOME=/src

Update: changing the Dockerfile quilc version to 1.13.1 fixed this.