projects/guix·blob javascript-team · refs

524 lines · 17.6 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2024 Michal Atlas <[email protected]>
3;;; Copyright © 2024, 2025 Guillaume Le Vaillant <[email protected]>
4;;; Copyright © 2026 Spencer King <[email protected]>
5;;;
6;;; This file is part of GNU Guix.
7;;;
8;;; GNU Guix is free software; you can redistribute it and/or modify it
9;;; under the terms of the GNU General Public License as published by
10;;; the Free Software Foundation; either version 3 of the License, or (at
11;;; your option) any later version.
12;;;
13;;; GNU Guix is distributed in the hope that it will be useful, but
14;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16;;; GNU General Public License for more details.
17;;;
18;;; You should have received a copy of the GNU General Public License
19;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20
21;;; Commentary:
22;;;
23;;; Quantum computing and tensor operation module. For quantum mechanics
24;;; select (gnu packages physics) module.
25;;;
26;;; Code:
27
28(define-module (gnu packages quantum)
29 #:use-module (gnu packages)
30 #:use-module (gnu packages check)
31 #:use-module (gnu packages lisp-check)
32 #:use-module (gnu packages lisp-xyz)
33 #:use-module (gnu packages machine-learning)
34 #:use-module (gnu packages protobuf)
35 #:use-module (gnu packages python-build)
36 #:use-module (gnu packages python-check)
37 #:use-module (gnu packages python-science)
38 #:use-module (gnu packages python-web)
39 #:use-module (gnu packages python-xyz)
40 #:use-module (guix build-system asdf)
41 #:use-module (guix build-system pyproject)
42 #:use-module (guix build-system cmake)
43 #:use-module (guix gexp)
44 #:use-module (guix git-download)
45 #:use-module ((guix licenses) #:prefix license:)
46 #:use-module (guix packages)
47 #:use-module (guix utils))
48
49
50
51(define %cirq-version "1.7.0")
52
53(define %cirq-home-page "https://quantumai.google/cirq")
54
55(define %cirq-license license:asl2.0)
56
57;; Cirq source provides multiple Python packages all them share the same
58;; version.
59(define %cirq-source
60 (origin
61 (method git-fetch)
62 (uri (git-reference
63 (url "https://github.com/quantumlib/Cirq")
64 (commit (string-append "v" %cirq-version))))
65 (file-name (git-file-name "python-cirq" %cirq-version))
66 (sha256
67 (base32 "1bd8bsigfq9f00420bxj4snpcp4kr8x54y8kjx62a5q46diq231q"))))
68
69(define-public python-cirq-aqt
70 (package
71 (name "python-cirq-aqt")
72 (version %cirq-version)
73 (source %cirq-source)
74 (build-system pyproject-build-system)
75 (arguments
76 (list
77 #:tests? #f ;no tests
78 #:phases
79 #~(modify-phases %standard-phases
80 (add-after 'unpack 'chdir
81 (lambda _
82 (chdir "cirq-aqt"))))))
83 (native-inputs
84 (list python-setuptools))
85 (propagated-inputs
86 (list python-cirq-core
87 python-requests))
88 (home-page %cirq-home-page)
89 (synopsis "Cirq-AQT integration module")
90 (description
91 "This package provides an interface that allows Cirq quantum algorithms
92to run on quantum computers made by @url{https://www.aqt.eu/, Alpine Quantum
93Technologies GmbH}.")
94 (license %cirq-license)))
95
96(define-public python-cirq-core
97 (package
98 (name "python-cirq-core")
99 (version %cirq-version)
100 (source %cirq-source)
101 (build-system pyproject-build-system)
102 (arguments
103 (list
104 #:test-flags
105 ;; As seen in project's CI, the full test suite is huge.
106 #~(list "--ignore=cirq/contrib")
107 #:phases
108 #~(modify-phases %standard-phases
109 (add-after 'unpack 'chdir
110 (lambda _
111 (chdir "cirq-core")))
112 (add-before 'sanity-check 'pre-check
113 (lambda _
114 (setenv "HOME" "/tmp")
115 (setenv "NUMBA_CACHE_DIR" "/tmp"))))))
116 (native-inputs
117 (list python-freezegun
118 python-ipython
119 python-ply
120 python-pylatex
121 python-pytest
122 python-pytest-benchmark
123 python-setuptools))
124 (propagated-inputs
125 (list python-attrs
126 python-duet
127 python-matplotlib
128 python-networkx
129 python-numpy
130 python-pandas
131 python-quimb
132 python-scipy
133 python-scikit-learn
134 python-sortedcontainers
135 python-sympy
136 python-tqdm))
137 (home-page %cirq-home-page)
138 (synopsis "Framework for creating, editing, and running NISQ circuits.")
139 (description
140 "This package provides a Python framework for creating, editing, and
141running Noisy Intermediate-Scale Quantum (NISQ) circuits. Built-in simulators
142are provided for running quantum algorithms. Algorithms can also be run on a
143variety of commercial quantum computing platforms by installing additional
144integrations.")
145 (license %cirq-license)))
146
147(define-public python-cirq-google
148 (package
149 (name "python-cirq-google")
150 (version %cirq-version)
151 (source %cirq-source)
152 (build-system pyproject-build-system)
153 (arguments
154 (list
155 #:phases
156 #~(modify-phases %standard-phases
157 (add-after 'unpack 'chdir
158 (lambda _
159 (chdir "cirq-google"))))))
160 (native-inputs
161 (list python-setuptools))
162 (propagated-inputs
163 (list python-cirq-core
164 python-google-api-core
165 python-proto-plus
166 python-protobuf-6
167 python-typedunits))
168 (home-page %cirq-home-page)
169 (synopsis "Interface to Google's Quantum Computing Service")
170 (description
171 "This package provides an interface for Cirq to Google's Quantum Computing
172Service.")
173 (license %cirq-license)))
174
175(define-public python-cirq-ionq
176 (package
177 (name "python-cirq-ionq")
178 (version %cirq-version)
179 (source %cirq-source)
180 (build-system pyproject-build-system)
181 (arguments
182 (list
183 #:tests? #f ;no tests
184 #:phases
185 #~(modify-phases %standard-phases
186 (add-after 'unpack 'chdir
187 (lambda _
188 (chdir "cirq-ionq"))))))
189 (native-inputs
190 (list python-setuptools))
191 (propagated-inputs
192 (list python-cirq-core
193 python-requests))
194 (home-page %cirq-home-page)
195 (synopsis
196 "Cirq package to simulate and connect to IonQ quantum computers")
197 (description
198 "This is the Cirq-IonQ integration module. It provides an interface that
199allows Cirq quantum algorithms to run on quantum computers made by IonQ Inc.")
200 (license %cirq-license)))
201
202(define-public python-quimb
203 (package
204 (name "python-quimb")
205 (version "1.14.0")
206 (source
207 (origin
208 (method git-fetch)
209 (uri (git-reference
210 (url "https://github.com/jcmgray/quimb")
211 (commit (string-append "v" version))))
212 (file-name (git-file-name name version))
213 (sha256
214 (base32 "13h57cq183nb73j83jc2lrlcyy4km3d297arbps17wawq04wwyiv"))))
215 (build-system pyproject-build-system)
216 (arguments
217 (list
218 ;; tests: 4300 passed, 508 skipped, 85 warnings
219 #:test-flags
220 ;; See: <https://github.com/jcmgray/quimb/issues/354>.
221 #~(list "--ignore=tests/test_tensor/test_tn1d/test_compress.py")
222 #:phases
223 #~(modify-phases %standard-phases
224 ;; QUIMB_NUM_THREAD_WORKERS is read from the environment and
225 ;; must be set otherwise some tests will fail since a default
226 ;; value is not provided in all cases.
227 (add-before 'check 'set-env
228 (lambda _
229 (setenv "QUIMB_NUM_THREAD_WORKERS" "1"))))))
230 (native-inputs
231 (list python-hatch-vcs
232 python-hatchling
233 python-pytest))
234 (propagated-inputs
235 (list python-autoray
236 python-cotengra
237 python-cytoolz
238 python-numba
239 python-numpy
240 python-psutil
241 python-scipy
242 python-tqdm))
243 (home-page "https://quimb.readthedocs.io")
244 (synopsis "Library for quantum information and many-body calculations")
245 (description
246 "This package provides a fast Python libray for performing quantum
247information and many-body calculations, focusing primarily on tensor
248networks.")
249 (license license:asl2.0)))
250
251(define-public python-symmray
252 (package
253 (name "python-symmray")
254 (version "0.4.0")
255 (source
256 (origin
257 (method git-fetch)
258 (uri (git-reference
259 (url "https://github.com/jcmgray/symmray")
260 (commit (string-append "v" version))))
261 (file-name (git-file-name name version))
262 (sha256
263 (base32 "1zrb873jfh43k290i36lapvlhp7i5lx39p40yj2jia2ddjg9f7cg"))))
264 (build-system pyproject-build-system)
265 (arguments
266 (list
267 #:phases
268 #~(modify-phases %standard-phases
269 (add-before 'check 'set-env
270 (lambda _
271 (setenv "SYMMRAY_DEBUG" "1")
272 (setenv "NUMBA_CACHE_DIR" "/tmp"))))))
273 (native-inputs
274 (list python-cotengra
275 python-einops
276 python-hatch-vcs
277 python-hatchling
278 python-numpy
279 python-pytest
280 python-quimb))
281 (propagated-inputs
282 (list python-autoray))
283 (home-page "https://symmray.readthedocs.io")
284 (synopsis "Minimal block sparse symmetric and fermionic tensor library")
285 (description
286 "Package @code{symmray} is minimal library for block sparse, abelian
287symmetric and fermionic arrays, designed to look as much as possible like
288standard ndarrays, whose blocks can be backed by @code{numpy}, @code{torch} or
289any other @code{autoray} compatible library.
290
291This library was developed in part for the work:
292
293Fermionic tensor network contraction for arbitrary geometries - Yang Gao,
294Huanchen Zhai, Johnnie Gray, Ruojing Peng, Gunhee Park, Wen-Yuan Liu, Eirik
295F. Kjønstad, Garnet Kin-Lic Chan -
296@url{https://doi.org/10.1103/PhysRevResearch.7.023193}.")
297 (license license:asl2.0)))
298
299(define-public sbcl-rpcq
300 (package
301 (name "sbcl-rpcq")
302 (version "3.10.0")
303 (source
304 (origin
305 (method git-fetch)
306 (uri (git-reference
307 (url "https://github.com/rigetti/rpcq")
308 (commit (string-append "v" version))))
309 (file-name (git-file-name "cl-rpcq" version))
310 (sha256
311 (base32 "1bvppxlacvp0pfdbpn7ls1zxd127jacl225ds7lph5s8f8cyvf17"))))
312 (build-system asdf-build-system/sbcl)
313 (arguments
314 (list
315 ;; TODO: https://github.com/rigetti/rpcq/issues/161
316 #:tests? #f))
317 (native-inputs (list sbcl-fiasco))
318 (inputs
319 (list sbcl-alexandria
320 sbcl-bordeaux-threads
321 sbcl-cl-messagepack
322 sbcl-cl-ppcre
323 sbcl-cl-syslog
324 sbcl-flexi-streams
325 sbcl-local-time
326 sbcl-parse-float
327 sbcl-pzmq
328 sbcl-trivial-backtrace
329 sbcl-uuid
330 sbcl-yason))
331 (synopsis "RPC framework for Rigetti Quantum Cloud Services")
332 (description
333 "This package provides the asynchronous RPC client-server framework and
334message specification for Rigetti Quantum Cloud Services (QCS). It implements
335an efficient transport protocol by using ZeroMQ (ZMQ) sockets and MessagePack
336(msgpack) serialization.")
337 (home-page "https://github.com/rigetti/rpcq")
338 (license license:asl2.0)))
339
340(define-public cl-rpcq
341 (sbcl-package->cl-source-package sbcl-rpcq))
342
343(define-public sbcl-cl-quil
344 (package
345 (name "sbcl-cl-quil")
346 (version "1.26.0")
347 (source
348 (origin
349 (method git-fetch)
350 (uri (git-reference
351 (url "https://github.com/quil-lang/quilc")
352 (commit (string-append "v" version))))
353 (file-name (git-file-name "cl-quil" version))
354 (sha256
355 (base32 "1s99lk456sw9hhsx5cf3x9r97iw9s3ydqsd94zz3bjnq77wmkhz5"))))
356 (build-system asdf-build-system/sbcl)
357 (arguments
358 (list
359 ;; Requires cyclic dependency with qvm
360 #:tests? #f))
361 (inputs
362 (list sbcl-abstract-classes
363 sbcl-alexa
364 sbcl-alexandria
365 sbcl-cl-algebraic-data-type
366 sbcl-cl-grnm
367 sbcl-cl-heap
368 sbcl-cl-permutation
369 sbcl-cl-yacc
370 sbcl-global-vars
371 sbcl-magicl
372 sbcl-optima
373 sbcl-parse-float
374 sbcl-queues
375 sbcl-salza2
376 sbcl-split-sequence
377 sbcl-trivial-garbage
378 sbcl-yason))
379 (synopsis "The optimizing Quil compiler")
380 (description
381 "Quil is the quantum instruction language, originally developed at
382Rigetti Computing. In Quil quantum algorithms are expressed using Quil's
383standard gates and instructions")
384 (home-page "https://github.com/quil-lang/quilc")
385 (license license:asl2.0)))
386
387(define-public cl-quil
388 (sbcl-package->cl-source-package sbcl-cl-quil))
389
390(define-public sbcl-qvm
391 (package
392 (name "sbcl-qvm")
393 (version "1.17.2")
394 (source
395 (origin
396 (method git-fetch)
397 (uri (git-reference
398 (url "https://github.com/quil-lang/qvm")
399 (commit (string-append "v" version))))
400 (file-name (git-file-name "cl-qvm" version))
401 (sha256
402 (base32 "1cvmkqfcy7rv5jlim4kh4dvqhd3jk6mw1kwrphaqghjymrf72yp8"))))
403 (build-system asdf-build-system/sbcl)
404 (outputs '("out" "bin"))
405 (inputs
406 (list sbcl-abstract-classes
407 sbcl-alexandria
408 sbcl-cffi
409 sbcl-cl-quil
410 sbcl-global-vars
411 sbcl-ieee-floats
412 sbcl-lparallel
413 sbcl-magicl
414 sbcl-mt19937
415 sbcl-static-vectors
416 sbcl-trivial-features
417 sbcl-trivial-garbage
418
419 ;; qvm-app
420 sbcl-cl-syslog
421 sbcl-command-line-arguments
422 sbcl-hunchentoot
423 sbcl-slime-swank
424 sbcl-trivial-benchmark))
425 (arguments
426 (list
427 #:asd-systems ''("qvm" "qvm-app")
428 #:tests? #f
429 #:phases
430 #~(modify-phases %standard-phases
431 (add-after 'unpack 'remove-git-dependency
432 (lambda _
433 (substitute* "app/src/qvm-app-version.lisp"
434 (("\\(git-hash '#:qvm-app\\)")
435 "\"unknown\""))))
436 (add-after 'unpack 'fix-build
437 (lambda _
438 ;; Don't use symbol that doesn't exists in swank 2.31.
439 (substitute* "app/src/entry-point.lisp"
440 (("\\(defvar swank:\\*use-dedicated-output-stream\\*\\)")
441 "")
442 (("\\(setf swank:\\*use-dedicated-output-stream\\* nil\\)")
443 ""))))
444 (add-after 'create-asdf-configuration 'build-program
445 (lambda* (#:key outputs #:allow-other-keys)
446 (build-program (string-append (assoc-ref outputs "bin")
447 "/bin/qvm")
448 outputs
449 #:dependencies '("qvm-app")
450 #:entry-program '((qvm-app::asdf-entry-point))
451 #:compress? #t))))))
452 (synopsis "Quil simulator")
453 (description
454 "This is the official Quil-Lang Quantum Virtual Machine (QVM),
455a flexible and efficient simulator for Quil.")
456 (home-page "https://github.com/quil-lang/qvm")
457 (license (list license:asl2.0
458 license:agpl3))))
459
460(define-public cl-qvm
461 (sbcl-package->cl-source-package sbcl-qvm))
462
463(define-public stim
464 (package
465 (name "stim")
466 (version "1.16.0")
467 (source
468 (origin
469 (method git-fetch)
470 (uri (git-reference
471 (url "https://github.com/quantumlib/Stim")
472 (commit (string-append "v" version))))
473 (file-name (git-file-name name version))
474 (sha256
475 (base32 "02qw118y5fw9fjpn7c5xwh80gkj814pfmkff8y4drqp36qd6v8rk"))))
476 (build-system cmake-build-system)
477 (arguments
478 ;; Not providing a -DSIMD_WIDTH option defaults to using
479 ;; -march=native, which would correspond to the build machine
480 ;; On x86-64 less than 128 causes test ErrorAnalyzer.too_many_symptoms
481 ;; to fail due to a rounding error.
482 (list
483 #:configure-flags
484 #~(list #$(if (target-x86-64?)
485 "-DSIMD_WIDTH=128"
486 "-DSIMD_WIDTH=64"))
487 #:phases
488 #~(modify-phases %standard-phases
489 (add-before 'check 'increase-resource-limits
490 (lambda* (#:key tests? #:allow-other-keys)
491 (when tests?
492 ;; XXX: Copied from ungoogled-chromium. Try increasing the
493 ;; soft resource limit of max open files to 2048, or equal to
494 ;; the hard limit, whichever is lower.
495 (call-with-values (lambda () (getrlimit 'nofile))
496 (lambda (soft hard)
497 (when (and soft (< soft 2048))
498 (if hard
499 (setrlimit 'nofile (min hard 2048) hard)
500 (setrlimit 'nofile 2048 #f))
501 (format #t
502 "increased maximum number of open files from ~d to ~d~%"
503 soft (if hard (min hard 2048) 2048))))))))
504 (replace 'check
505 (lambda* (#:key tests? #:allow-other-keys)
506 (when tests?
507 ;; The test suite expects to find testdata/ relative
508 ;; to the current working directory
509 (let ((test-bin (string-append (getcwd) "/out/stim_test")))
510 (with-directory-excursion "../source"
511 (invoke test-bin)))))))))
512 (native-inputs (list googletest))
513 (home-page "https://github.com/quantumlib/Stim")
514 (synopsis "Fast stabilizer circuit library")
515 (description
516 "This package provides a tool for high performance simulation and
517analysis of quantum stabilizer circuits, especially quantum error
518correction (QEC) circuits.")
519 ;; Upstream supports the following compiler options:
520 ;; 64-bit (native): -DSIMD_WIDTH=64
521 ;; SSE: -DSIMD_WIDTH=128
522 ;; AVX: -DSIMD_WIDTH=256
523 (properties '((tunable? . #t)))
524 (license license:asl2.0)))