projects/guix·blob kernel-updates · refs

432 lines · 14.1 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 gexp)
43 #:use-module (guix git-download)
44 #:use-module ((guix licenses) #:prefix license:)
45 #:use-module (guix packages))
46
47
48
49(define %cirq-version "1.7.0")
50
51(define %cirq-home-page "https://quantumai.google/cirq")
52
53(define %cirq-license license:asl2.0)
54
55;; Cirq source provides multiple Python packages all them share the same
56;; version.
57(define %cirq-source
58 (origin
59 (method git-fetch)
60 (uri (git-reference
61 (url "https://github.com/quantumlib/Cirq")
62 (commit (string-append "v" %cirq-version))))
63 (file-name (git-file-name "python-cirq" %cirq-version))
64 (sha256
65 (base32 "1bd8bsigfq9f00420bxj4snpcp4kr8x54y8kjx62a5q46diq231q"))))
66
67(define-public python-cirq-aqt
68 (package
69 (name "python-cirq-aqt")
70 (version %cirq-version)
71 (source %cirq-source)
72 (build-system pyproject-build-system)
73 (arguments
74 (list
75 #:tests? #f ;no tests
76 #:phases
77 #~(modify-phases %standard-phases
78 (add-after 'unpack 'chdir
79 (lambda _
80 (chdir "cirq-aqt"))))))
81 (native-inputs
82 (list python-setuptools))
83 (propagated-inputs
84 (list python-cirq-core
85 python-requests))
86 (home-page %cirq-home-page)
87 (synopsis "Cirq-AQT integration module")
88 (description
89 "This package provides an interface that allows Cirq quantum algorithms
90to run on quantum computers made by @url{https://www.aqt.eu/, Alpine Quantum
91Technologies GmbH}.")
92 (license %cirq-license)))
93
94(define-public python-cirq-core
95 (package
96 (name "python-cirq-core")
97 (version %cirq-version)
98 (source %cirq-source)
99 (build-system pyproject-build-system)
100 (arguments
101 (list
102 #:test-flags
103 ;; As seen in project's CI, the full test suite is huge.
104 #~(list "--ignore=cirq/contrib")
105 #:phases
106 #~(modify-phases %standard-phases
107 (add-after 'unpack 'chdir
108 (lambda _
109 (chdir "cirq-core")))
110 (add-before 'sanity-check 'pre-check
111 (lambda _
112 (setenv "HOME" "/tmp")
113 (setenv "NUMBA_CACHE_DIR" "/tmp"))))))
114 (native-inputs
115 (list python-freezegun
116 python-ipython
117 python-ply
118 python-pylatex
119 python-pytest
120 python-pytest-benchmark
121 python-setuptools))
122 (propagated-inputs
123 (list python-attrs
124 python-duet
125 python-matplotlib
126 python-networkx
127 python-numpy
128 python-pandas
129 python-quimb
130 python-scipy
131 python-scikit-learn
132 python-sortedcontainers
133 python-sympy
134 python-tqdm))
135 (home-page %cirq-home-page)
136 (synopsis "Framework for creating, editing, and running NISQ circuits.")
137 (description
138 "This package provides a Python framework for creating, editing, and
139running Noisy Intermediate-Scale Quantum (NISQ) circuits. Built-in simulators
140are provided for running quantum algorithms. Algorithms can also be run on a
141variety of commercial quantum computing platforms by installing additional
142integrations.")
143 (license %cirq-license)))
144
145(define-public python-cirq-google
146 (package
147 (name "python-cirq-google")
148 (version %cirq-version)
149 (source %cirq-source)
150 (build-system pyproject-build-system)
151 (arguments
152 (list
153 #:phases
154 #~(modify-phases %standard-phases
155 (add-after 'unpack 'chdir
156 (lambda _
157 (chdir "cirq-google"))))))
158 (native-inputs
159 (list python-setuptools))
160 (propagated-inputs
161 (list python-cirq-core
162 python-google-api-core
163 python-proto-plus
164 python-protobuf-6
165 python-typedunits))
166 (home-page %cirq-home-page)
167 (synopsis "Interface to Google's Quantum Computing Service")
168 (description
169 "This package provides an interface for Cirq to Google's Quantum Computing
170Service.")
171 (license %cirq-license)))
172
173(define-public python-quimb
174 (package
175 (name "python-quimb")
176 (version "1.14.0")
177 (source
178 (origin
179 (method git-fetch)
180 (uri (git-reference
181 (url "https://github.com/jcmgray/quimb")
182 (commit (string-append "v" version))))
183 (file-name (git-file-name name version))
184 (sha256
185 (base32 "13h57cq183nb73j83jc2lrlcyy4km3d297arbps17wawq04wwyiv"))))
186 (build-system pyproject-build-system)
187 (arguments
188 (list
189 ;; tests: 4300 passed, 508 skipped, 85 warnings
190 #:test-flags
191 ;; See: <https://github.com/jcmgray/quimb/issues/354>.
192 #~(list "--ignore=tests/test_tensor/test_tn1d/test_compress.py")
193 #:phases
194 #~(modify-phases %standard-phases
195 ;; QUIMB_NUM_THREAD_WORKERS is read from the environment and
196 ;; must be set otherwise some tests will fail since a default
197 ;; value is not provided in all cases.
198 (add-before 'check 'set-env
199 (lambda _
200 (setenv "QUIMB_NUM_THREAD_WORKERS" "1"))))))
201 (native-inputs
202 (list python-hatch-vcs
203 python-hatchling
204 python-pytest))
205 (propagated-inputs
206 (list python-autoray
207 python-cotengra
208 python-cytoolz
209 python-numba
210 python-numpy
211 python-psutil
212 python-scipy
213 python-tqdm))
214 (home-page "https://quimb.readthedocs.io")
215 (synopsis "Library for quantum information and many-body calculations")
216 (description
217 "This package provides a fast Python libray for performing quantum
218information and many-body calculations, focusing primarily on tensor
219networks.")
220 (license license:asl2.0)))
221
222(define-public python-symmray
223 (package
224 (name "python-symmray")
225 (version "0.4.0")
226 (source
227 (origin
228 (method git-fetch)
229 (uri (git-reference
230 (url "https://github.com/jcmgray/symmray")
231 (commit (string-append "v" version))))
232 (file-name (git-file-name name version))
233 (sha256
234 (base32 "1zrb873jfh43k290i36lapvlhp7i5lx39p40yj2jia2ddjg9f7cg"))))
235 (build-system pyproject-build-system)
236 (arguments
237 (list
238 #:phases
239 #~(modify-phases %standard-phases
240 (add-before 'check 'set-env
241 (lambda _
242 (setenv "SYMMRAY_DEBUG" "1")
243 (setenv "NUMBA_CACHE_DIR" "/tmp"))))))
244 (native-inputs
245 (list python-cotengra
246 python-einops
247 python-hatch-vcs
248 python-hatchling
249 python-numpy
250 python-pytest
251 python-quimb))
252 (propagated-inputs
253 (list python-autoray))
254 (home-page "https://symmray.readthedocs.io")
255 (synopsis "Minimal block sparse symmetric and fermionic tensor library")
256 (description
257 "Package @code{symmray} is minimal library for block sparse, abelian
258symmetric and fermionic arrays, designed to look as much as possible like
259standard ndarrays, whose blocks can be backed by @code{numpy}, @code{torch} or
260any other @code{autoray} compatible library.
261
262This library was developed in part for the work:
263
264Fermionic tensor network contraction for arbitrary geometries - Yang Gao,
265Huanchen Zhai, Johnnie Gray, Ruojing Peng, Gunhee Park, Wen-Yuan Liu, Eirik
266F. Kjønstad, Garnet Kin-Lic Chan -
267@url{https://doi.org/10.1103/PhysRevResearch.7.023193}.")
268 (license license:asl2.0)))
269
270(define-public sbcl-rpcq
271 (package
272 (name "sbcl-rpcq")
273 (version "3.10.0")
274 (source
275 (origin
276 (method git-fetch)
277 (uri (git-reference
278 (url "https://github.com/rigetti/rpcq")
279 (commit (string-append "v" version))))
280 (file-name (git-file-name "cl-rpcq" version))
281 (sha256
282 (base32 "1bvppxlacvp0pfdbpn7ls1zxd127jacl225ds7lph5s8f8cyvf17"))))
283 (build-system asdf-build-system/sbcl)
284 (arguments
285 (list
286 ;; TODO: https://github.com/rigetti/rpcq/issues/161
287 #:tests? #f))
288 (native-inputs (list sbcl-fiasco))
289 (inputs
290 (list sbcl-alexandria
291 sbcl-bordeaux-threads
292 sbcl-cl-messagepack
293 sbcl-cl-ppcre
294 sbcl-cl-syslog
295 sbcl-flexi-streams
296 sbcl-local-time
297 sbcl-parse-float
298 sbcl-pzmq
299 sbcl-trivial-backtrace
300 sbcl-uuid
301 sbcl-yason))
302 (synopsis "RPC framework for Rigetti Quantum Cloud Services")
303 (description
304 "This package provides the asynchronous RPC client-server framework and
305message specification for Rigetti Quantum Cloud Services (QCS). It implements
306an efficient transport protocol by using ZeroMQ (ZMQ) sockets and MessagePack
307(msgpack) serialization.")
308 (home-page "https://github.com/rigetti/rpcq")
309 (license license:asl2.0)))
310
311(define-public cl-rpcq
312 (sbcl-package->cl-source-package sbcl-rpcq))
313
314(define-public sbcl-cl-quil
315 (package
316 (name "sbcl-cl-quil")
317 (version "1.26.0")
318 (source
319 (origin
320 (method git-fetch)
321 (uri (git-reference
322 (url "https://github.com/quil-lang/quilc")
323 (commit (string-append "v" version))))
324 (file-name (git-file-name "cl-quil" version))
325 (sha256
326 (base32 "1s99lk456sw9hhsx5cf3x9r97iw9s3ydqsd94zz3bjnq77wmkhz5"))))
327 (build-system asdf-build-system/sbcl)
328 (arguments
329 (list
330 ;; Requires cyclic dependency with qvm
331 #:tests? #f))
332 (inputs
333 (list sbcl-abstract-classes
334 sbcl-alexa
335 sbcl-alexandria
336 sbcl-cl-algebraic-data-type
337 sbcl-cl-grnm
338 sbcl-cl-heap
339 sbcl-cl-permutation
340 sbcl-cl-yacc
341 sbcl-global-vars
342 sbcl-magicl
343 sbcl-optima
344 sbcl-parse-float
345 sbcl-queues
346 sbcl-salza2
347 sbcl-split-sequence
348 sbcl-trivial-garbage
349 sbcl-yason))
350 (synopsis "The optimizing Quil compiler")
351 (description
352 "Quil is the quantum instruction language, originally developed at
353Rigetti Computing. In Quil quantum algorithms are expressed using Quil's
354standard gates and instructions")
355 (home-page "https://github.com/quil-lang/quilc")
356 (license license:asl2.0)))
357
358(define-public cl-quil
359 (sbcl-package->cl-source-package sbcl-cl-quil))
360
361(define-public sbcl-qvm
362 (package
363 (name "sbcl-qvm")
364 (version "1.17.2")
365 (source
366 (origin
367 (method git-fetch)
368 (uri (git-reference
369 (url "https://github.com/quil-lang/qvm")
370 (commit (string-append "v" version))))
371 (file-name (git-file-name "cl-qvm" version))
372 (sha256
373 (base32 "1cvmkqfcy7rv5jlim4kh4dvqhd3jk6mw1kwrphaqghjymrf72yp8"))))
374 (build-system asdf-build-system/sbcl)
375 (outputs '("out" "bin"))
376 (inputs
377 (list sbcl-abstract-classes
378 sbcl-alexandria
379 sbcl-cffi
380 sbcl-cl-quil
381 sbcl-global-vars
382 sbcl-ieee-floats
383 sbcl-lparallel
384 sbcl-magicl
385 sbcl-mt19937
386 sbcl-static-vectors
387 sbcl-trivial-features
388 sbcl-trivial-garbage
389
390 ;; qvm-app
391 sbcl-cl-syslog
392 sbcl-command-line-arguments
393 sbcl-hunchentoot
394 sbcl-slime-swank
395 sbcl-trivial-benchmark))
396 (arguments
397 (list
398 #:asd-systems ''("qvm" "qvm-app")
399 #:tests? #f
400 #:phases
401 #~(modify-phases %standard-phases
402 (add-after 'unpack 'remove-git-dependency
403 (lambda _
404 (substitute* "app/src/qvm-app-version.lisp"
405 (("\\(git-hash '#:qvm-app\\)")
406 "\"unknown\""))))
407 (add-after 'unpack 'fix-build
408 (lambda _
409 ;; Don't use symbol that doesn't exists in swank 2.31.
410 (substitute* "app/src/entry-point.lisp"
411 (("\\(defvar swank:\\*use-dedicated-output-stream\\*\\)")
412 "")
413 (("\\(setf swank:\\*use-dedicated-output-stream\\* nil\\)")
414 ""))))
415 (add-after 'create-asdf-configuration 'build-program
416 (lambda* (#:key outputs #:allow-other-keys)
417 (build-program (string-append (assoc-ref outputs "bin")
418 "/bin/qvm")
419 outputs
420 #:dependencies '("qvm-app")
421 #:entry-program '((qvm-app::asdf-entry-point))
422 #:compress? #t))))))
423 (synopsis "Quil simulator")
424 (description
425 "This is the official Quil-Lang Quantum Virtual Machine (QVM),
426a flexible and efficient simulator for Quil.")
427 (home-page "https://github.com/quil-lang/qvm")
428 (license (list license:asl2.0
429 license:agpl3))))
430
431(define-public cl-qvm
432 (sbcl-package->cl-source-package sbcl-qvm))