Skip to content

Commit c6a6de3

Browse files
author
David, Mark H
committed
introduce chip preparation step before running any benchmarks
1 parent 4e4bef7 commit c6a6de3

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

benchmarking/quilc-perf.lisp

+27-5
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,14 @@
7575
'(:fully-connected :linear))
7676

7777
(defun build-benchmark-chip (nq type)
78-
(ecase type
79-
(:fully-connected
80-
(cl-quil::build-nq-fully-connected-chip nq))
81-
(:linear
82-
(cl-quil::build-nq-linear-chip nq))))
78+
(let ((chip-spec
79+
(ecase type
80+
(:fully-connected
81+
(cl-quil::build-nq-fully-connected-chip nq))
82+
(:linear
83+
(cl-quil::build-nq-linear-chip nq)))))
84+
(prepare-chip-for-benchmarking chip-spec)
85+
chip-spec))
8386

8487
(defun build-benchmark-program (nq type)
8588
(ecase type
@@ -173,6 +176,25 @@
173176

174177

175178

179+
(defun get-epsilon-program ()
180+
"Get a 'null' or 'nop' program, i.e., the most minimal program that
181+
makes the compiler go through its paces, e.g., doing any warming or
182+
caching that may take considerable time and that would normally be
183+
avoided on subsequent runs. For now, the program is merely \"I 0\"."
184+
(quil:parse "I 0"))
185+
186+
(defun prepare-chip-for-benchmarking (chip-spec)
187+
"Do normal preparations for chip benchmarking, namely, by doing a
188+
compilation on a minimal program, which presumably may result in
189+
'warming up' and/or caching. The idea is to NOT have time for this
190+
dominate the results of the first program benchmarked."
191+
(do-one-quilc-perf-run (get-epsilon-program) chip-spec))
192+
193+
;; Consider moving the above function (or some variant) to cl-quil and
194+
;; then making it a standard or optional part of building a chip
195+
;; and/or at least calling it from places, e.g., from the app.
196+
197+
176198
(defun benchmark-one-quilc-perf (nq program-type chip-type)
177199
(let* ((program (get-or-build-benchmark-program nq program-type))
178200
(chip (get-or-build-benchmark-chip nq chip-type)))

0 commit comments

Comments
 (0)