diff --git a/app-ng/src/package.lisp b/app-ng/src/package.lisp index a87de108..9361d9bc 100644 --- a/app-ng/src/package.lisp +++ b/app-ng/src/package.lisp @@ -6,6 +6,7 @@ (defpackage #:qvm-app-ng (:use #:cl #:qvm) + (:local-nicknames (#:quil #:cl-quil)) ;; job.lisp (:export diff --git a/app-ng/tests/test-rpc-api.lisp b/app-ng/tests/test-rpc-api.lisp index 13fe0aaa..5bdf5988 100644 --- a/app-ng/tests/test-rpc-api.lisp +++ b/app-ng/tests/test-rpc-api.lisp @@ -37,8 +37,8 @@ :collect (string-downcase k) :collect v)) (defun plist->json (plist) - (with-output-to-string (*standard-output*) - (yason:encode-plist (plist-lowercase-keys plist)))) + (with-output-to-string (s) + (yason:encode-plist (plist-lowercase-keys plist) s))) (defun plist->hash-table (plist &key (test 'equal)) "Like ALEXANDRIA:PLIST-HASH-TABLE but with TEST defaulting to EQUAL. @@ -228,8 +228,8 @@ Invalid persistent QVM token. Expected a v4 UUID. Got \"5e2e05f0-f91c-5f02-96ef- :qvm-token "5e2e05f0-f91c-4f02-96ef-361ffc55a0fa") :status 500 :response-callback (response-error-checker "QVM RPC Error: Internal Server Error -Failed to find persistent QVM #1=5e2e05f0-f91c-4f02-96ef-361ffc55a0fa -Failed to find key #1# in SAFETY-HASH"))))) +Failed to find persistent QVM 5e2e05f0-f91c-4f02-96ef-361ffc55a0fa +Failed to find key 5e2e05f0-f91c-4f02-96ef-361ffc55a0fa in SAFETY-HASH"))))) (deftest test-rpc-api-404 () "Requests for URIs other than \"/\" or for non-existent RPC methods return 404 Not Found." diff --git a/app/src/api/expectation.lisp b/app/src/api/expectation.lisp index fd230c6d..017faf52 100644 --- a/app/src/api/expectation.lisp +++ b/app/src/api/expectation.lisp @@ -99,9 +99,9 @@ amplitudes in PREPARED-STATE." ;; to apply the transpose to OP-MATRIX below, since it is ;; generally smaller. Thus we compute tr(Q^T ρ^T) = tr((ρ Q)^T) = tr(ρ Q) = tr(Q ρ). (let ((op-matrix (magicl:transpose - (quil::parsed-program-to-logical-matrix op))) + (cl-quil::parsed-program-to-logical-matrix op))) (density-matrix (magicl:from-array prepared-state (list rows cols) :type '(complex double-float)))) (reduce #'+ (magicl:diag - (quil::matrix-rescale-and-multiply op-matrix density-matrix)))))) + (cl-quil::matrix-rescale-and-multiply op-matrix density-matrix)))))) diff --git a/app/src/debugger.lisp b/app/src/debugger.lisp index 462ba437..1cc1c164 100644 --- a/app/src/debugger.lisp +++ b/app/src/debugger.lisp @@ -2,12 +2,7 @@ ;;;; ;;;; Author: Juan M. Bello-Rivas -(defpackage #:qvm-app.debugger - (:use #:common-lisp #:qvm-app) - (:export #:debugger) - (:import-from #:alexandria #:assoc-value #:once-only)) - -(in-package #:qvm-app.debugger) +(in-package #:qvm-app/debugger) (defparameter *threshold* (* 1e3 double-float-epsilon) "Smallest amplitude that can be printed.") @@ -145,7 +140,7 @@ Run the next instruction and stop." ((program-finished-p) (format t "Finished program execution.~%")) (t - (format t "~/quil:instruction-fmt/~%" (qvm::current-instruction *qvm*)) + (format t "~/cl-quil:instruction-fmt/~%" (qvm::current-instruction *qvm*)) (setf *qvm* (qvm:transition *qvm* (qvm::current-instruction *qvm*))) (when *display* (print-amplitudes))))) @@ -166,7 +161,7 @@ Resume program execution from the current instruction." :until (or (program-finished-p) breakpoint-p) :do (setf *qvm* (qvm:transition *qvm* (qvm::current-instruction *qvm*))) :finally (when breakpoint-p - (format t "Stopping at breakpoint in instruction ~D:~%~/quil:instruction-fmt/~%" + (format t "Stopping at breakpoint in instruction ~D:~%~/cl-quil:instruction-fmt/~%" pc (qvm::current-instruction *qvm*))) (return *qvm*))))) @@ -176,13 +171,13 @@ Resume program execution from the current instruction." Load a program and instantiate a suitable QVM." (unless filename (error "File name not specified.")) - (let* ((program (quil:read-quil-file (string-trim " " filename))) - (number-of-qubits (quil:qubits-needed program))) + (let* ((program (cl-quil:read-quil-file (string-trim " " filename))) + (number-of-qubits (cl-quil:qubits-needed program))) (format t "Read ~A using ~D qubits.~%" filename number-of-qubits) (setf *source-filename* filename *qvm* (qvm:make-qvm number-of-qubits :classical-memory-model (qvm:memory-descriptors-to-qvm-memory-model - (quil:parsed-program-memory-definitions program))) + (cl-quil:parsed-program-memory-definitions program))) *breakpoints* nil) (qvm:load-program *qvm* program))) diff --git a/app/src/entry-point.lisp b/app/src/entry-point.lisp index af1e027f..17f097b0 100644 --- a/app/src/entry-point.lisp +++ b/app/src/entry-point.lisp @@ -530,7 +530,7 @@ Copyright (c) 2016-2019 Rigetti Computing.~2%") (start-server-app host port)) ;; Interactive debugger mode. - (debugger (qvm-app.debugger:debugger)) + (debugger (qvm-app/debugger:debugger)) ;; Batch mode. (t diff --git a/app/src/package.lisp b/app/src/package.lisp index fbfb87af..f06f43ea 100644 --- a/app/src/package.lisp +++ b/app/src/package.lisp @@ -3,4 +3,10 @@ ;;;; Author: Robert Smith (defpackage #:qvm-app - (:use #:cl #:qvm)) + (:use #:cl #:qvm) + (:local-nicknames (#:quil #:cl-quil/frontend))) + +(defpackage #:qvm-app/debugger + (:use #:cl #:qvm-app) + (:export #:debugger) + (:import-from #:alexandria #:assoc-value #:once-only)) diff --git a/app/tests/package.lisp b/app/tests/package.lisp index 4da9a92d..f1105311 100644 --- a/app/tests/package.lisp +++ b/app/tests/package.lisp @@ -4,6 +4,7 @@ (fiasco:define-test-package #:qvm-app-tests (:use #:qvm-app) + (:local-nicknames (#:quil #:cl-quil)) ;; suite.lisp (:export diff --git a/bench/quil-files.lisp b/bench/quil-files.lisp index 110e94a1..7052e3b0 100644 --- a/bench/quil-files.lisp +++ b/bench/quil-files.lisp @@ -10,7 +10,7 @@ (defun timed-run (file) "Load the Quil file designated by FILE and time its execution." - (let ((quil::*allow-unresolved-applications* t)) + (let ((cl-quil::*allow-unresolved-applications* t)) (let* ((program (cl-quil:read-quil-file (merge-pathnames file *bench-files-directory*))) (qvm (qvm:make-qvm (cl-quil:qubits-needed program)))) diff --git a/examples/qaoa.lisp b/examples/qaoa.lisp index bc339a50..6b173f60 100644 --- a/examples/qaoa.lisp +++ b/examples/qaoa.lisp @@ -16,32 +16,32 @@ COST-HAM should consist of commuting Pauli terms only. (This is *not* checked.)" (check-type p (integer 1)) ;; Every Pauli in COST-HAM should have the same number of qubits. - (let* ((n (cl-quil.clifford:num-qubits - (alexandria:extremum cost-ham #'> :key #'cl-quil.clifford:num-qubits))) - (quil (quil:parse-quil (format nil "DECLARE beta REAL[~D]; DECLARE gamma REAL[~D]" p p))) + (let* ((n (cl-quil/clifford:num-qubits + (alexandria:extremum cost-ham #'> :key #'cl-quil/clifford:num-qubits))) + (quil (cl-quil:parse-quil (format nil "DECLARE beta REAL[~D]; DECLARE gamma REAL[~D]" p p))) ;; Parameters - (betas (loop :for i :below p :collect (quil:mref "beta" i))) - (gammas (loop :for i :below p :collect (quil:mref "gamma" i))) + (betas (loop :for i :below p :collect (cl-quil:mref "beta" i))) + (gammas (loop :for i :below p :collect (cl-quil:mref "gamma" i))) ;; Hamiltonian (driver-ham (loop :for q :below n - :collect (cl-quil.clifford:embed cl-quil.clifford:+X+ n (list q)))) - (isns (quil:with-inst () + :collect (cl-quil/clifford:embed cl-quil/clifford:+X+ n (list q)))) + (isns (cl-quil:with-inst () ;; Initialize (dotimes (q n) - (quil:inst "H" () q)) + (cl-quil:inst "H" () q)) (loop :for beta :in betas :for gamma :in gammas :do - (let ((beta (quil::make-delayed-expression nil nil beta)) - (gamma (quil::make-delayed-expression nil nil gamma))) + (let ((beta (cl-quil::make-delayed-expression nil nil beta)) + (gamma (cl-quil::make-delayed-expression nil nil gamma))) ;; Cost. All the terms are assumed to commute. (dolist (pauli cost-ham) - (mapc #'quil:inst (cl-quil.clifford::exp-pauli pauli gamma))) + (mapc #'cl-quil:inst (cl-quil/clifford::exp-pauli pauli gamma))) ;; Driver (dolist (pauli driver-ham) - (mapc #'quil:inst (cl-quil.clifford::exp-pauli pauli beta)))))))) - (setf (quil:parsed-program-executable-code quil) (coerce isns 'simple-vector)) + (mapc #'cl-quil:inst (cl-quil/clifford::exp-pauli pauli beta)))))))) + (setf (cl-quil:parsed-program-executable-code quil) (coerce isns 'simple-vector)) (values quil betas gammas))) (defun maxcut (graph) @@ -50,9 +50,9 @@ COST-HAM should consist of commuting Pauli terms only. (This is *not* checked.)" GRAPH should be a list of edges, each represented as a pair (A B) of integer vertices." (loop :with n := (1+ (loop :for (from to) :in graph :maximize (max from to))) - :with ZZ := (cl-quil.clifford:pauli-from-string "ZZ") + :with ZZ := (cl-quil/clifford:pauli-from-string "ZZ") :for vertex :in graph - :collect (cl-quil.clifford:embed ZZ n vertex))) + :collect (cl-quil/clifford:embed ZZ n vertex))) (defun complete-graph (n) "Build a complete graph of N vertices." @@ -93,7 +93,7 @@ After FILE is created, one may plot the data with gnuplot. The following command (finish-output))) (out "writing program") (multiple-value-bind (program betas gammas) (qaoa 1 (maxcut graph)) - (let* ((n (quil:qubits-needed program)) + (let* ((n (cl-quil:qubits-needed program)) (beta (first betas)) (gamma (first gammas)) (qvm (qvm:make-qvm n))) @@ -130,7 +130,7 @@ After FILE is created, one may plot the data with gnuplot. The following command (defun produce-qvm-for-qaoa-problem (graph) (multiple-value-bind (program betas gammas) (qaoa 1 (maxcut graph)) - (let* ((n (quil:qubits-needed program)) + (let* ((n (cl-quil:qubits-needed program)) (qvm (qvm:make-qvm n))) (qvm:load-program qvm program :supersede-memory-subsystem t) ;(qvm::enable-all-qvm-optimizations) diff --git a/examples/qft.lisp b/examples/qft.lisp index c5e08904..286995cc 100644 --- a/examples/qft.lisp +++ b/examples/qft.lisp @@ -14,42 +14,42 @@ (loop :for i :below (floor n 2) :for qs :in qubits :for qe :in (reverse qubits) - :collect (make-instance 'quil:gate-application - :operator #.(quil:named-operator "SWAP") - :name-resolution (quil:lookup-standard-gate "SWAP") - :arguments (list (quil:qubit qs) - (quil:qubit qe))))))) + :collect (make-instance 'cl-quil:gate-application + :operator #.(cl-quil:named-operator "SWAP") + :name-resolution (cl-quil:lookup-standard-gate "SWAP") + :arguments (list (cl-quil:qubit qs) + (cl-quil:qubit qe))))))) (defun qft-circuit (qubits) "Generate the QFT circuit on the given qubits." (labels ((qft (qubits) (destructuring-bind (q . qs) qubits (if (null qs) - (list (make-instance 'quil:gate-application - :operator #. (quil:named-operator "H") - :name-resolution (quil:lookup-standard-gate "H") - :arguments (list (quil:qubit q)))) + (list (make-instance 'cl-quil:gate-application + :operator #. (cl-quil:named-operator "H") + :name-resolution (cl-quil:lookup-standard-gate "H") + :arguments (list (cl-quil:qubit q)))) (let ((cR nil)) (loop :with n := (1+ (length qs)) :for i :from (1- n) :downto 1 :for qi :in qs :for angle := (qvm:flonum (/ pi (expt 2 (- n i)))) :do (push (make-instance - 'quil:gate-application - :operator #.(quil:named-operator "CPHASE") - :name-resolution (quil:lookup-standard-gate "CPHASE") - :parameters (list (quil:constant angle)) - :arguments (list (quil:qubit q) - (quil:qubit qi))) + 'cl-quil:gate-application + :operator #.(cl-quil:named-operator "CPHASE") + :name-resolution (cl-quil:lookup-standard-gate "CPHASE") + :parameters (list (cl-quil:constant angle)) + :arguments (list (cl-quil:qubit q) + (cl-quil:qubit qi))) cR)) (append (qft qs) cR - (list (make-instance 'quil:gate-application - :operator #. (quil:named-operator "H") - :name-resolution (quil:lookup-standard-gate "H") - :arguments (list (quil:qubit q)))))))))) - (make-instance 'quil:parsed-program + (list (make-instance 'cl-quil:gate-application + :operator #. (cl-quil:named-operator "H") + :name-resolution (cl-quil:lookup-standard-gate "H") + :arguments (list (cl-quil:qubit q)))))))))) + (make-instance 'cl-quil:parsed-program :gate-definitions nil :circuit-definitions nil :executable-code diff --git a/examples/vqe.lisp b/examples/vqe.lisp index df424030..a396103b 100644 --- a/examples/vqe.lisp +++ b/examples/vqe.lisp @@ -202,21 +202,21 @@ DEFCIRCUIT ANSATZ: 0.18620984259247159d0)) "Coefficients of the Pauli operators present in the Hamiltonian.") -(defparameter *operators* (mapcar #'quil:parse-quil '("I 0" - "Z 0" - "Z 1" - "Z 2" - "Z 3" - "Z 0; Z 1" - "Y 0; X 1; X 2; Y 3" - "X 0; X 1; Y 2; Y 3" - "Y 0; Y 1; X 2; X 3" - "X 0; Y 1; Y 2; X 3" - "Z 0; Z 2" - "Z 0; Z 3" - "Z 1; Z 2" - "Z 1; Z 3" - "Z 2; Z 3")) +(defparameter *operators* (mapcar #'cl-quil:parse-quil '("I 0" + "Z 0" + "Z 1" + "Z 2" + "Z 3" + "Z 0; Z 1" + "Y 0; X 1; X 2; Y 3" + "X 0; X 1; Y 2; Y 3" + "Y 0; Y 1; X 2; X 3" + "X 0; Y 1; Y 2; X 3" + "Z 0; Z 2" + "Z 0; Z 3" + "Z 1; Z 2" + "Z 1; Z 3" + "Z 2; Z 3")) "Pauli operators in the Hamiltonian.") (defparameter *initial-thetas* #(0.0d0 -0.036014483d0) @@ -242,7 +242,7 @@ DEFCIRCUIT ANSATZ: "Return a new HAMILTONIAN with an extra term of the form COEFFICIENT times OPERATOR." (declare (type hamiltonian hamiltonian) (type qvm:flonum coefficient) - (type quil:parsed-program operator operator)) + (type cl-quil:parsed-program operator operator)) (make-instance 'hamiltonian :coefficients (cons coefficient (slot-value hamiltonian 'coefficients)) :operators (cons operator (slot-value hamiltonian 'operators)))) @@ -304,7 +304,7 @@ DEFCIRCUIT ANSATZ: (flet ((objective-function (thetas) "Compute the energy based on the values of THETAS." (loop :with quil := (format nil "DECLARE theta REAL[2]~%~A~%~A~%~A~%" reference-state ansatz (make-ansatz-string thetas)) - :with state-prep := (quil:parse-quil quil) + :with state-prep := (cl-quil:parse-quil quil) :with expectations := (qvm-app::perform-expectation 'qvm-app::pure-state state-prep operators number-of-qubits) :for u :of-type qvm:flonum :in coefficients :for v :of-type qvm:flonum :in expectations @@ -320,7 +320,7 @@ In other words, we return a program implementing the operator A(θ₂)† A(θ (slot-value vqe-problem 'ansatz) (make-ansatz-string thetas-1) (make-ansatz-string thetas-2 :dagger dagger)))) - (quil:parse-quil quil))) + (cl-quil:parse-quil quil))) (defun find-inverse-ansatz (vqe-problem thetas initial-values) "Let A = A(θ) be the ANSATZ determined by THETAS. Return the value of η that maximizes ⟨0|A(η) A(θ)|0⟩. @@ -329,6 +329,6 @@ The value of η is used to implement the penalty term in the deflation method. I (let ((number-of-qubits (slot-value vqe-problem 'number-of-qubits))) (flet ((objective-function (etas) (let ((operators (list (make-penalty-term vqe-problem thetas etas :dagger nil))) - (empty-state-prep (quil:parse-quil "DECLARE theta REAL[2]"))) + (empty-state-prep (cl-quil:parse-quil "DECLARE theta REAL[2]"))) (first (qvm-app::perform-expectation 'qvm-app::pure-state empty-state-prep operators number-of-qubits))))) (cl-grnm:grnm-optimize #'objective-function initial-values)))) diff --git a/src/classical-memory-mixin.lisp b/src/classical-memory-mixin.lisp index 24815c8f..9aa70f6c 100644 --- a/src/classical-memory-mixin.lisp +++ b/src/classical-memory-mixin.lisp @@ -36,7 +36,7 @@ :classical-memory-subsystem (make-instance 'qvm:classical-memory-subsystem) :wait-function 'warning-wait-function ;; XXX FIXME: To be superseded by some notion of environments. - :gate-definitions (copy-hash-table cl-quil.frontend::**default-gate-definitions**)) + :gate-definitions (copy-hash-table cl-quil/frontend::**default-gate-definitions**)) (:metaclass abstract-class) (:documentation "A mixin for quantum abstract machines making use of a classical memory subsystem and a program vector.")) diff --git a/src/package.lisp b/src/package.lisp index 2c3cfb87..762859fc 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -10,8 +10,7 @@ (:shadowing-import-from #:mt19937 #:random) - #+(or sbcl ecl ccl) - (:local-nicknames (:quil :cl-quil.frontend)) + (:local-nicknames (#:quil #:cl-quil/frontend)) ;; config.lisp (:export diff --git a/src/stabilizer-qvm.lisp b/src/stabilizer-qvm.lisp index 2c95c474..72698e1c 100644 --- a/src/stabilizer-qvm.lisp +++ b/src/stabilizer-qvm.lisp @@ -14,7 +14,7 @@ "Map string gate name to a CLIFFORD object.") (global-vars:define-global-var **clifford-operations** - (quil.clifford:make-clifford-hash-table) + (cl-quil/clifford:make-clifford-hash-table) "Map a CLIFFORD to a compiled tableau function.") (defclass stabilizer-qvm (classical-memory-mixin) @@ -26,13 +26,13 @@ (check-type num-qubits unsigned-byte) (check-type classical-memory-model quil:memory-model) (make-instance 'stabilizer-qvm - :tableau (cl-quil.clifford::make-tableau-zero-state num-qubits) + :tableau (cl-quil/clifford::make-tableau-zero-state num-qubits) :classical-memory-subsystem (make-instance 'classical-memory-subsystem :classical-memory-model classical-memory-model))) (defmethod number-of-qubits ((qvm stabilizer-qvm)) - (cl-quil.clifford::tableau-qubits (stabilizer-qvm-tableau qvm))) + (cl-quil/clifford::tableau-qubits (stabilizer-qvm-tableau qvm))) (defun gate-application-to-clifford (gate-app) (check-type gate-app quil:gate-application) @@ -43,17 +43,17 @@ (gethash name **cliffords**) (unless exists? (setf (gethash name **cliffords**) - (quil.clifford:matrix-to-clifford + (cl-quil/clifford:matrix-to-clifford (quil:gate-matrix (pull-teeth-to-get-a-gate gate-app)))) (setf clifford (gethash name **cliffords**))) clifford))) - (t (quil.clifford:matrix-to-clifford + (t (cl-quil/clifford:matrix-to-clifford (quil:gate-matrix (pull-teeth-to-get-a-gate gate-app)))))) (defun compile-clifford (c &key (cache t)) - (check-type c quil.clifford:clifford) + (check-type c cl-quil/clifford:clifford) (multiple-value-bind (compiled exists?) (gethash c **clifford-operations**) (cond @@ -61,7 +61,7 @@ (t (when *transition-verbose* (format *trace-output* "~&; compiling Clifford gate...~%")) - (let ((compiled (compile-lambda (cl-quil.clifford::compile-tableau-operation c)))) + (let ((compiled (compile-lambda (cl-quil/clifford::compile-tableau-operation c)))) (when cache (setf (gethash c **clifford-operations**) compiled)) compiled))))) @@ -70,10 +70,10 @@ ;;;;;;;;;;;;;;;;;;;;;;;;; TRANSITION Methods ;;;;;;;;;;;;;;;;;;;;;;;;; (defmethod measure ((qvm stabilizer-qvm) q) - (values qvm (cl-quil.clifford::tableau-measure (stabilizer-qvm-tableau qvm) q))) + (values qvm (cl-quil/clifford::tableau-measure (stabilizer-qvm-tableau qvm) q))) (defmethod transition ((qvm stabilizer-qvm) (instr quil:reset)) - (cl-quil.clifford::zero-out-tableau (stabilizer-qvm-tableau qvm)) + (cl-quil/clifford::zero-out-tableau (stabilizer-qvm-tableau qvm)) (incf (pc qvm)) qvm) @@ -104,7 +104,7 @@ (qubits (mapcar #'quil:qubit-index (quil:application-arguments instr)))) ;; Do some error checking. (let ((given-qubits (length qubits)) - (expected-qubits (quil.clifford:num-qubits clifford))) + (expected-qubits (cl-quil/clifford:num-qubits clifford))) (unless (= given-qubits expected-qubits) (error 'invalid-instruction-encountered :instruction instr @@ -132,12 +132,12 @@ (defmethod print-object ((o clifford-application) stream) (print-unreadable-object (o stream :type t :identity t) - (format stream "~Dq" (quil.clifford:num-qubits + (format stream "~Dq" (cl-quil/clifford:num-qubits (clifford-application-clifford o))))) (defun make-clifford-application (clifford &rest qubits) - (check-type clifford quil.clifford:clifford) - (assert (= (quil.clifford:num-qubits clifford) (length qubits))) + (check-type clifford cl-quil/clifford:clifford) + (assert (= (cl-quil/clifford:num-qubits clifford) (length qubits))) (make-instance 'clifford-application :clifford clifford :arguments (mapcar #'quil:qubit qubits))) @@ -161,7 +161,7 @@ (let ((arity (random-range 1 (1+ max-clifford-arity)))) (setf (aref code i) (apply #'make-clifford-application - (cl-quil.clifford:random-clifford arity) + (cl-quil/clifford:random-clifford arity) (loop :for q :from (1- arity) :downto 0 :collect q))))) (when measure (dotimes (i num-qubits) @@ -177,7 +177,7 @@ (qubits (mapcar #'quil:qubit-index (quil:application-arguments instr)))) ;; Do some error checking. (let ((given-qubits (length qubits)) - (expected-qubits (quil.clifford:num-qubits clifford))) + (expected-qubits (cl-quil/clifford:num-qubits clifford))) (unless (= given-qubits expected-qubits) (error 'invalid-instruction-encountered :instruction instr @@ -194,6 +194,6 @@ (defmethod transition ((qvm pure-state-qvm) (instr clifford-application)) (transition qvm (make-instance 'quil:gate-application :operator (quil:named-operator "dummy") - :gate (make-instance 'quil:simple-gate :matrix (cl-quil.clifford::clifford-to-matrix (clifford-application-clifford instr))) + :gate (make-instance 'quil:simple-gate :matrix (cl-quil/clifford::clifford-to-matrix (clifford-application-clifford instr))) :parameters nil :arguments (quil:application-arguments instr)))) diff --git a/tests/package.lisp b/tests/package.lisp index 15e67940..fd58dd99 100644 --- a/tests/package.lisp +++ b/tests/package.lisp @@ -4,8 +4,7 @@ (fiasco:define-test-package #:qvm-tests (:use #:qvm) - #+(or sbcl ecl ccl) - (:local-nicknames (:quil :cl-quil.frontend)) + (:local-nicknames (#:quil #:cl-quil/frontend)) ;; suite.lisp (:export diff --git a/tests/stabilizer-qvm-tests.lisp b/tests/stabilizer-qvm-tests.lisp index 45b7223f..d07da2e9 100644 --- a/tests/stabilizer-qvm-tests.lisp +++ b/tests/stabilizer-qvm-tests.lisp @@ -13,7 +13,7 @@ (stab-qvm (qvm::make-stabilizer-qvm 10))) (is (every #'quil::double~ (qvm::amplitudes pure-qvm) - (cl-quil.clifford::tableau-wavefunction (qvm::stabilizer-qvm-tableau stab-qvm)))))) + (cl-quil/clifford::tableau-wavefunction (qvm::stabilizer-qvm-tableau stab-qvm)))))) (deftest test-stabilizer-bell-state () (let ((pure-qvm (qvm::make-qvm 2)) @@ -25,7 +25,7 @@ S 1"))) (test-quickrun stab-qvm program) (is (every #'quil::double~ (qvm::amplitudes pure-qvm) - (cl-quil.clifford::tableau-wavefunction (qvm::stabilizer-qvm-tableau stab-qvm)))))) + (cl-quil/clifford::tableau-wavefunction (qvm::stabilizer-qvm-tableau stab-qvm)))))) (deftest test-stabilizer-nonclifford () (let ((pure-qvm (qvm::make-qvm 2)) @@ -38,55 +38,55 @@ S 1"))) (deftest test-random-qvm-vs-chp-small () (let ((n 3)) (dotimes (i 100) - (multiple-value-bind (chp-code quil-code) (cl-quil.clifford::random-chp-and-quil n 3) + (multiple-value-bind (chp-code quil-code) (cl-quil/clifford::random-chp-and-quil n 3) (let ((pure-qvm (qvm::make-qvm n)) - (chp-tab (cl-quil.clifford::make-tableau-zero-state n))) + (chp-tab (cl-quil/clifford::make-tableau-zero-state n))) (test-quickrun pure-qvm (cl-quil:parse-quil quil-code)) - (cl-quil.clifford::interpret-chp chp-code chp-tab :silent t) - (is (cl-quil.clifford::global-phase~ + (cl-quil/clifford::interpret-chp chp-code chp-tab :silent t) + (is (cl-quil/clifford::global-phase~ (qvm::amplitudes pure-qvm) - (cl-quil.clifford::tableau-wavefunction chp-tab)))))))) + (cl-quil/clifford::tableau-wavefunction chp-tab)))))))) (deftest test-random-qvm-vs-chp-medium () (let ((n 10)) (dotimes (i 100) - (multiple-value-bind (chp-code quil-code) (cl-quil.clifford::random-chp-and-quil n 50) + (multiple-value-bind (chp-code quil-code) (cl-quil/clifford::random-chp-and-quil n 50) (let ((pure-qvm (qvm::make-qvm n)) - (chp-tab (cl-quil.clifford::make-tableau-zero-state n))) + (chp-tab (cl-quil/clifford::make-tableau-zero-state n))) (test-quickrun pure-qvm (cl-quil:parse-quil quil-code)) - (cl-quil.clifford::interpret-chp chp-code chp-tab :silent t) - (is (cl-quil.clifford::global-phase~ + (cl-quil/clifford::interpret-chp chp-code chp-tab :silent t) + (is (cl-quil/clifford::global-phase~ (qvm::amplitudes pure-qvm) - (cl-quil.clifford::tableau-wavefunction chp-tab)))))))) + (cl-quil/clifford::tableau-wavefunction chp-tab)))))))) (deftest test-random-qvm-vs-chp-large () (let ((n 15)) (dotimes (i 50) - (multiple-value-bind (chp-code quil-code) (cl-quil.clifford::random-chp-and-quil n 100) + (multiple-value-bind (chp-code quil-code) (cl-quil/clifford::random-chp-and-quil n 100) (let* ((pure-qvm (qvm::make-qvm n)) - (chp-tab (cl-quil.clifford::make-tableau-zero-state n))) + (chp-tab (cl-quil/clifford::make-tableau-zero-state n))) (test-quickrun pure-qvm (cl-quil:parse-quil quil-code)) - (cl-quil.clifford::interpret-chp chp-code chp-tab :silent t) - (is (cl-quil.clifford::global-phase~ + (cl-quil/clifford::interpret-chp chp-code chp-tab :silent t) + (is (cl-quil/clifford::global-phase~ (qvm::amplitudes pure-qvm) - (cl-quil.clifford::tableau-wavefunction chp-tab)))))))) + (cl-quil/clifford::tableau-wavefunction chp-tab)))))))) (deftest test-random-stabilizer-vs-chp () (let ((n 10)) (dotimes (i 200) - (multiple-value-bind (chp-code quil-code) (cl-quil.clifford::random-chp-and-quil n 10) + (multiple-value-bind (chp-code quil-code) (cl-quil/clifford::random-chp-and-quil n 10) (let* ((qvm (qvm::make-stabilizer-qvm n)) - (tab (cl-quil.clifford::make-tableau-zero-state n))) + (tab (cl-quil/clifford::make-tableau-zero-state n))) (test-quickrun qvm (cl-quil:parse-quil quil-code)) - (cl-quil.clifford::interpret-chp chp-code tab :silent t) + (cl-quil/clifford::interpret-chp chp-code tab :silent t) ;; Print the error-causing program (unless (every #'quil::double~ - (cl-quil.clifford::tableau-wavefunction (qvm::stabilizer-qvm-tableau qvm)) - (cl-quil.clifford::tableau-wavefunction tab)) + (cl-quil/clifford::tableau-wavefunction (qvm::stabilizer-qvm-tableau qvm)) + (cl-quil/clifford::tableau-wavefunction tab)) (format t "~%~A~%" quil-code)) (is (every #'quil::double~ - (cl-quil.clifford::tableau-wavefunction (qvm::stabilizer-qvm-tableau qvm)) - (cl-quil.clifford::tableau-wavefunction tab)))))))) + (cl-quil/clifford::tableau-wavefunction (qvm::stabilizer-qvm-tableau qvm)) + (cl-quil/clifford::tableau-wavefunction tab)))))))) (deftest test-one-qubit-one-clifford () (dotimes (i 100) @@ -96,9 +96,9 @@ S 1"))) (program (qvm::random-clifford-program 1 1 n))) (test-quickrun pure-qvm program) (test-quickrun stab-qvm program) - (is (cl-quil.clifford::global-phase~ + (is (cl-quil/clifford::global-phase~ (qvm::amplitudes pure-qvm) - (cl-quil.clifford::tableau-wavefunction (qvm::stabilizer-qvm-tableau stab-qvm))))))) + (cl-quil/clifford::tableau-wavefunction (qvm::stabilizer-qvm-tableau stab-qvm))))))) (deftest test-two-qubit-one-clifford () (dotimes (i 100) @@ -108,9 +108,9 @@ S 1"))) (program (qvm::random-clifford-program 1 2 n))) (test-quickrun pure-qvm program) (test-quickrun stab-qvm program) - (is (cl-quil.clifford::global-phase~ + (is (cl-quil/clifford::global-phase~ (qvm::amplitudes pure-qvm) - (cl-quil.clifford::tableau-wavefunction (qvm::stabilizer-qvm-tableau stab-qvm))))))) + (cl-quil/clifford::tableau-wavefunction (qvm::stabilizer-qvm-tableau stab-qvm))))))) (deftest test-one-qubit-two-clifford () (dotimes (i 100) @@ -120,9 +120,9 @@ S 1"))) (program (qvm::random-clifford-program 2 1 n))) (test-quickrun pure-qvm program) (test-quickrun stab-qvm program) - (is (cl-quil.clifford::global-phase~ + (is (cl-quil/clifford::global-phase~ (qvm::amplitudes pure-qvm) - (cl-quil.clifford::tableau-wavefunction (qvm::stabilizer-qvm-tableau stab-qvm))))))) + (cl-quil/clifford::tableau-wavefunction (qvm::stabilizer-qvm-tableau stab-qvm))))))) (deftest test-two-qubit-two-clifford () (dotimes (i 100) @@ -132,9 +132,9 @@ S 1"))) (program (qvm::random-clifford-program 2 2 n))) (test-quickrun pure-qvm program) (test-quickrun stab-qvm program) - (is (cl-quil.clifford::global-phase~ + (is (cl-quil/clifford::global-phase~ (qvm::amplitudes pure-qvm) - (cl-quil.clifford::tableau-wavefunction (qvm::stabilizer-qvm-tableau stab-qvm))))))) + (cl-quil/clifford::tableau-wavefunction (qvm::stabilizer-qvm-tableau stab-qvm))))))) (deftest test-hella-random-cliffords () (dotimes (i 100) @@ -144,14 +144,14 @@ S 1"))) (program (qvm::random-clifford-program 10 5 n))) (test-quickrun pure-qvm program) (test-quickrun stab-qvm program) - (is (cl-quil.clifford::global-phase~ + (is (cl-quil/clifford::global-phase~ (qvm::amplitudes pure-qvm) - (cl-quil.clifford::tableau-wavefunction (qvm::stabilizer-qvm-tableau stab-qvm))))))) + (cl-quil/clifford::tableau-wavefunction (qvm::stabilizer-qvm-tableau stab-qvm))))))) (deftest test-clifford-matrix-conversions () (loop :for i :from 1 :to 4 :do (loop :repeat 100 - :for c := (cl-quil.clifford::random-clifford i) - :for m := (cl-quil.clifford::clifford-to-matrix c) - :for d := (cl-quil.clifford::matrix-to-clifford m) - :do (is (cl-quil.clifford::clifford= c d))))) + :for c := (cl-quil/clifford::random-clifford i) + :for m := (cl-quil/clifford::clifford-to-matrix c) + :for d := (cl-quil/clifford::matrix-to-clifford m) + :do (is (cl-quil/clifford::clifford= c d)))))