Skip to content

Commit

Permalink
clean up nicknames
Browse files Browse the repository at this point in the history
  • Loading branch information
stylewarning committed Jul 26, 2022
1 parent ddb22de commit d8ad5f7
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 36 deletions.
2 changes: 1 addition & 1 deletion app-ng/src/handlers.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ Return a JSON-RESPONSE that contains a HASH-TABLE of the contents of the memory
(run-program-on-persistent-qvm qvm-token compiled-quil addresses)
(run-program-on-qvm (make-requested-qvm simulation-method
allocation-method
(quil:qubits-needed compiled-quil)
(cl-quil:qubits-needed compiled-quil)
gate-noise
measurement-noise)
compiled-quil
Expand Down
1 change: 1 addition & 0 deletions app-ng/src/package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

(defpackage #:qvm-app-ng
(:use #:cl #:qvm)
(:local-nicknames (#:quil #:cl-quil))

;; job.lisp
(:export
Expand Down
6 changes: 3 additions & 3 deletions app-ng/src/validators.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ Return T if MEMORY-CONTENTS is a HASH-TABLE whose keys are STRINGs denoting DECL
(flet ((no-includes (path)
(user-input-error
"Invalid Quil string. INCLUDE is disabled. Refusing to include ~A" path)))
(let ((quil:*resolve-include-pathname* #'no-includes)
(quil::*allow-unresolved-applications* t))
(quil:parse-quil string))))
(let ((cl-quil:*resolve-include-pathname* #'no-includes)
(cl-quil::*allow-unresolved-applications* t))
(cl-quil:parse-quil string))))

(defun parse-pauli-noise (noise)
(unless (and (alexandria:proper-list-p noise)
Expand Down
1 change: 1 addition & 0 deletions app-ng/tests/package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@

(fiasco:define-test-package #:qvm-app-ng-tests
(:use #:qvm-app-ng)
(:local-nicknames (#:quil #:cl-quil))
(:export
#:run-qvm-app-ng-tests))
10 changes: 5 additions & 5 deletions app/src/debugger.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,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)))))
Expand All @@ -166,7 +166,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*)))))

Expand All @@ -176,13 +176,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)))

Expand Down
3 changes: 2 additions & 1 deletion app/src/package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
;;;; Author: Robert Smith

(defpackage #:qvm-app
(:use #:cl #:qvm))
(:use #:cl #:qvm)
(:local-nicknames (#:quil #:cl-quil)))
1 change: 1 addition & 0 deletions app/tests/package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

(fiasco:define-test-package #:qvm-app-tests
(:use #:qvm-app)
(:local-nicknames (#:quil #:cl-quil))

;; suite.lisp
(:export
Expand Down
2 changes: 1 addition & 1 deletion bench/quil-files.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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))))
Expand Down
2 changes: 1 addition & 1 deletion dqvm/src/transition.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
(multiple-value-prog1 (qvm::measuring-gc (gc-time bytes-alloc) (call-next-method))
;; (format-log :debug "~A" qvm)

(format-log :debug "Transition ~/quil:instruction-fmt/ took ~D ms (gc: ~D ms; alloc: ~D bytes)"
(format-log :debug "Transition ~/cl-quil:instruction-fmt/ took ~D ms (gc: ~D ms; alloc: ~D bytes)"
instr
(round (* (/ 1000 internal-time-units-per-second)
(- (get-internal-real-time) start)))
Expand Down
2 changes: 1 addition & 1 deletion dqvm/src/utilities.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

(defun instruction->string (instruction)
"Return string representation of INSTRUCTION."
(format nil "~/quil:instruction-fmt/" instruction))
(format nil "~/cl-quil:instruction-fmt/" instruction))

(defun string->instruction (string)
"Return instruction corresponding to STRING."
Expand Down
1 change: 1 addition & 0 deletions examples/package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

(defpackage #:qvm-examples
(:use #:cl #:qvm)
(:local-nicknames (#:quil #:cl-quil))

;; qft.lisp
(:export
Expand Down
2 changes: 1 addition & 1 deletion src/compile-gate.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ This function will compile new ones on-demand."
(:metaclass abstract-class))

(defmethod quil::print-instruction-generic ((instr compiled-instruction) stream)
(format stream "compiled{ ~/quil:instruction-fmt/ }" (source-instruction instr))
(format stream "compiled{ ~/cl-quil:instruction-fmt/ }" (source-instruction instr))
nil)

(defclass compiled-gate-application (compiled-instruction quil:gate-application)
Expand Down
4 changes: 2 additions & 2 deletions src/package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
(:shadowing-import-from #:mt19937
#:random)

#+(or sbcl ecl ccl)
(:local-nicknames (:quil :cl-quil.frontend))
(:local-nicknames (#:quil #:cl-quil.frontend)
(#:clifford #:cl-quil.clifford))

;; config.lisp
(:export
Expand Down
40 changes: 20 additions & 20 deletions src/stabilizer-qvm.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
(clifford:make-clifford-hash-table)
"Map a CLIFFORD to a compiled tableau function.")

(defclass stabilizer-qvm (classical-memory-mixin)
Expand All @@ -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 (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)))
(clifford::tableau-qubits (stabilizer-qvm-tableau qvm)))

(defun gate-application-to-clifford (gate-app)
(check-type gate-app quil:gate-application)
Expand All @@ -43,25 +43,25 @@
(gethash name **cliffords**)
(unless exists?
(setf (gethash name **cliffords**)
(quil.clifford:matrix-to-clifford
(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 (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 clifford:clifford)
(multiple-value-bind (compiled exists?)
(gethash c **clifford-operations**)
(cond
(exists? compiled)
(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 (clifford::compile-tableau-operation c))))
(when cache
(setf (gethash c **clifford-operations**) compiled))
compiled)))))
Expand All @@ -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 (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))
(clifford::zero-out-tableau (stabilizer-qvm-tableau qvm))
(incf (pc qvm))
qvm)

Expand Down Expand Up @@ -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 (clifford:num-qubits clifford)))
(unless (= given-qubits expected-qubits)
(error 'invalid-instruction-encountered
:instruction instr
Expand All @@ -127,17 +127,17 @@
(:documentation "A gate application that's actually a Clifford."))

(defmethod quil::print-instruction-generic ((instr clifford-application) stream)
(format stream "<clifford>~{ ~/quil:instruction-fmt/~}"
(format stream "<clifford>~{ ~/cl-quil:instruction-fmt/~}"
(quil:application-arguments instr)))

(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" (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 clifford:clifford)
(assert (= (clifford:num-qubits clifford) (length qubits)))
(make-instance 'clifford-application :clifford clifford
:arguments (mapcar #'quil:qubit qubits)))

Expand All @@ -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)
(clifford:random-clifford arity)
(loop :for q :from (1- arity) :downto 0 :collect q)))))
(when measure
(dotimes (i num-qubits)
Expand All @@ -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 (clifford:num-qubits clifford)))
(unless (= given-qubits expected-qubits)
(error 'invalid-instruction-encountered
:instruction instr
Expand All @@ -193,7 +193,7 @@

(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)))
:parameters nil
:arguments (quil:application-arguments instr))))
:operator (quil:named-operator "dummy")
:gate (make-instance 'quil:simple-gate :matrix (clifford::clifford-to-matrix (clifford-application-clifford instr)))
:parameters nil
:arguments (quil:application-arguments instr))))

0 comments on commit d8ad5f7

Please sign in to comment.