Closed sophiaponte closed 4 years ago
what I just changed:
cflonum-vector
for trial-amplitudes
if necessary, to avoid extra memory usage.a few more smol TODOs:
M-x whitespace
and M-x indent
everything [DONE]allocation
for trial-amplitudes
on pure states, but this should be a minor change regardless [follow up PR]make-xx-qvm
s for all the qvms [follow up PR]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.
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.
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
andDENSITY-MATRIX-STATE
classes and modifies the existing qvm classes to be compatible with both state types. In large part, this was done by replacing theAMPLITUDES
slot of the different qvms with aSTATE
slot, and modifying theTRANSITION
,MEASURE
, andAPPLY-STATE
functions to specialize on theSTATE
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 thedensity-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.
state-representation.lisp
[created] : This file contains theDENSITY-MATRIX-STATE
andPURE-STATE
classes.qvm.lisp
[modified] : I added an abstract classBASE-QVM
to serve as the base class for all qvms. The slots of this class include the number of qubits,state
, compiled program, and superoperator definitions. I modified thepure-state-qvm
to operate on aPURE-STATE
state. I also modified thePURE-STATE-QVM
to be compatible with user defined superoperator definitions (they are applied stochastically in the same way that "noisy" kraus operators are).mixed-state-qvm.lisp
[created] : This file implements a qvm that can operate on both pure and mixed quantum states. This qvm has a DENSITY-MATRIX-STATE state. This qvm can also be used with user defined superoperator definitions.apply-gate.lisp
[modified] : I modified theAPPLY-GATE
generic method to specialize on thestate
as well as thegate
type. This way, theTRANSITION
methods of the different qvm's don't need to do additional logic determine which type of state is being dealt with. TheAPPLY-NOISE
(kraus operator) functions were also changed to specialize on thestate
.transition.lisp
[modified] : I made ainstr:gate-application
TRANSITION
method forBASE-QVM
. This method is used bypure-state-qvm
,mixed-state-qvm
,channel-qvm
andbasic-noise-qvm
. The state specialization inapply-gate
greatly simplified the transition logic for the different qvms, so they now either just use thebase-qvm
gate-application transition or implement:before
/:after
methods.measurement.lisp
[modified] : I created ameasure
andmeasure-all
methods for the additional classes, and modified some of the measurement functionality to specialize onstate
type.channel-qvm.lisp
+basic-noise-qvm.lisp
[modified]: These QVMs were modified to take eitherPURE-STATE
s orDENSITY-MATRIX-STATE
s as arguments. They also now accept user defined superoperator definitions.density-qvm.lisp
[modified] : MadeDENSITY-QVM
compatible withDENSITY-MATRIX-STATE
. The functionality ofDENSITY-QVM
is replaced byMIXED-STATE-QVM
and the noisy qvms.noisy-qvm.lisp + depolarizing-noise.lisp
[modified] : Made theNOISY-QVM
andDEPOLARIZING-QVM
compatible withDENSITY-MATRIX-STATE
.