projects/guix·blob ruby-team · refs

326 lines · 10.8 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(define-module (gnu packages quantum)
22 #:use-module (gnu packages)
23 #:use-module (gnu packages check)
24 #:use-module (gnu packages lisp-check)
25 #:use-module (gnu packages lisp-xyz)
26 #:use-module (gnu packages machine-learning)
27 #:use-module (gnu packages python-build)
28 #:use-module (gnu packages python-check)
29 #:use-module (gnu packages python-science)
30 #:use-module (gnu packages python-xyz)
31 #:use-module (guix build-system asdf)
32 #:use-module (guix build-system pyproject)
33 #:use-module (guix gexp)
34 #:use-module (guix git-download)
35 #:use-module ((guix licenses) #:prefix license:)
36 #:use-module (guix packages))
37
38;;; Commentary:
39;;;
40;;; Quantum computing and tensor operation module. For quantum mechanics
41;;; select (gnu packages physics) module.
42;;;
43;;; Code:
44
45
46(define %cirq-version "1.7.0")
47
48(define %cirq-home-page "https://quantumai.google/cirq")
49
50(define %cirq-license license:asl2.0)
51
52;; Cirq source provides multiple Python packages all them share the same
53;; version.
54(define %cirq-source
55 (origin
56 (method git-fetch)
57 (uri (git-reference
58 (url "https://github.com/quantumlib/Cirq")
59 (commit (string-append "v" %cirq-version))))
60 (file-name (git-file-name "python-cirq" %cirq-version))
61 (sha256
62 (base32 "1bd8bsigfq9f00420bxj4snpcp4kr8x54y8kjx62a5q46diq231q"))))
63
64(define-public python-cirq-core
65 (package
66 (name "python-cirq-core")
67 (version %cirq-version)
68 (source %cirq-source)
69 (build-system pyproject-build-system)
70 (arguments
71 (list
72 #:test-flags
73 ;; As seen in project's CI, the full test suite is huge.
74 #~(list "--ignore=cirq/contrib")
75 #:phases
76 #~(modify-phases %standard-phases
77 (add-after 'unpack 'chdir
78 (lambda _
79 (chdir "cirq-core")))
80 (add-before 'sanity-check 'pre-check
81 (lambda _
82 (setenv "HOME" "/tmp")
83 (setenv "NUMBA_CACHE_DIR" "/tmp"))))))
84 (native-inputs
85 (list python-freezegun
86 python-ipython
87 python-ply
88 python-pylatex
89 python-pytest
90 python-pytest-benchmark
91 python-setuptools))
92 (propagated-inputs
93 (list python-attrs
94 python-duet
95 python-matplotlib
96 python-networkx
97 python-numpy
98 python-pandas
99 python-quimb
100 python-scipy
101 python-scikit-learn
102 python-sortedcontainers
103 python-sympy
104 python-tqdm))
105 (home-page %cirq-home-page)
106 (synopsis "Framework for creating, editing, and running NISQ circuits.")
107 (description
108 "This package provides a Python framework for creating, editing, and
109running Noisy Intermediate-Scale Quantum (NISQ) circuits. Built-in simulators
110are provided for running quantum algorithms. Algorithms can also be run on a
111variety of commercial quantum computing platforms by installing additional
112integrations.")
113 (license %cirq-license)))
114
115(define-public python-quimb
116 (package
117 (name "python-quimb")
118 (version "1.14.0")
119 (source
120 (origin
121 (method git-fetch)
122 (uri (git-reference
123 (url "https://github.com/jcmgray/quimb")
124 (commit (string-append "v" version))))
125 (file-name (git-file-name name version))
126 (sha256
127 (base32 "13h57cq183nb73j83jc2lrlcyy4km3d297arbps17wawq04wwyiv"))))
128 (build-system pyproject-build-system)
129 (arguments
130 (list
131 ;; tests: 4300 passed, 508 skipped, 85 warnings
132 #:test-flags
133 ;; See: <https://github.com/jcmgray/quimb/issues/354>.
134 #~(list "--ignore=tests/test_tensor/test_tn1d/test_compress.py")
135 #:phases
136 #~(modify-phases %standard-phases
137 ;; QUIMB_NUM_THREAD_WORKERS is read from the environment and
138 ;; must be set otherwise some tests will fail since a default
139 ;; value is not provided in all cases.
140 (add-before 'check 'set-env
141 (lambda _
142 (setenv "QUIMB_NUM_THREAD_WORKERS" "1"))))))
143 (native-inputs
144 (list python-hatch-vcs
145 python-hatchling
146 python-pytest))
147 (propagated-inputs
148 (list python-autoray
149 python-cotengra
150 python-cytoolz
151 python-numba
152 python-numpy
153 python-psutil
154 python-scipy
155 python-tqdm))
156 (home-page "https://quimb.readthedocs.io")
157 (synopsis "Library for quantum information and many-body calculations")
158 (description
159 "This package provides a fast Python libray for performing quantum
160information and many-body calculations, focusing primarily on tensor
161networks.")
162 (license license:asl2.0)))
163
164(define-public sbcl-rpcq
165 (package
166 (name "sbcl-rpcq")
167 (version "3.10.0")
168 (source
169 (origin
170 (method git-fetch)
171 (uri (git-reference
172 (url "https://github.com/rigetti/rpcq")
173 (commit (string-append "v" version))))
174 (file-name (git-file-name "cl-rpcq" version))
175 (sha256
176 (base32 "1bvppxlacvp0pfdbpn7ls1zxd127jacl225ds7lph5s8f8cyvf17"))))
177 (build-system asdf-build-system/sbcl)
178 (arguments
179 (list
180 ;; TODO: https://github.com/rigetti/rpcq/issues/161
181 #:tests? #f))
182 (native-inputs (list sbcl-fiasco))
183 (inputs
184 (list sbcl-alexandria
185 sbcl-bordeaux-threads
186 sbcl-cl-messagepack
187 sbcl-cl-ppcre
188 sbcl-cl-syslog
189 sbcl-flexi-streams
190 sbcl-local-time
191 sbcl-parse-float
192 sbcl-pzmq
193 sbcl-trivial-backtrace
194 sbcl-uuid
195 sbcl-yason))
196 (synopsis "RPC framework for Rigetti Quantum Cloud Services")
197 (description
198 "This package provides the asynchronous RPC client-server framework and
199message specification for Rigetti Quantum Cloud Services (QCS). It implements
200an efficient transport protocol by using ZeroMQ (ZMQ) sockets and MessagePack
201(msgpack) serialization.")
202 (home-page "https://github.com/rigetti/rpcq")
203 (license license:asl2.0)))
204
205(define-public cl-rpcq
206 (sbcl-package->cl-source-package sbcl-rpcq))
207
208(define-public sbcl-cl-quil
209 (package
210 (name "sbcl-cl-quil")
211 (version "1.26.0")
212 (source
213 (origin
214 (method git-fetch)
215 (uri (git-reference
216 (url "https://github.com/quil-lang/quilc")
217 (commit (string-append "v" version))))
218 (file-name (git-file-name "cl-quil" version))
219 (sha256
220 (base32 "1s99lk456sw9hhsx5cf3x9r97iw9s3ydqsd94zz3bjnq77wmkhz5"))))
221 (build-system asdf-build-system/sbcl)
222 (arguments
223 (list
224 ;; Requires cyclic dependency with qvm
225 #:tests? #f))
226 (inputs
227 (list sbcl-abstract-classes
228 sbcl-alexa
229 sbcl-alexandria
230 sbcl-cl-algebraic-data-type
231 sbcl-cl-grnm
232 sbcl-cl-heap
233 sbcl-cl-permutation
234 sbcl-cl-yacc
235 sbcl-global-vars
236 sbcl-magicl
237 sbcl-optima
238 sbcl-parse-float
239 sbcl-queues
240 sbcl-salza2
241 sbcl-split-sequence
242 sbcl-trivial-garbage
243 sbcl-yason))
244 (synopsis "The optimizing Quil compiler")
245 (description
246 "Quil is the quantum instruction language, originally developed at
247Rigetti Computing. In Quil quantum algorithms are expressed using Quil's
248standard gates and instructions")
249 (home-page "https://github.com/quil-lang/quilc")
250 (license license:asl2.0)))
251
252(define-public cl-quil
253 (sbcl-package->cl-source-package sbcl-cl-quil))
254
255(define-public sbcl-qvm
256 (package
257 (name "sbcl-qvm")
258 (version "1.17.2")
259 (source
260 (origin
261 (method git-fetch)
262 (uri (git-reference
263 (url "https://github.com/quil-lang/qvm")
264 (commit (string-append "v" version))))
265 (file-name (git-file-name "cl-qvm" version))
266 (sha256
267 (base32 "1cvmkqfcy7rv5jlim4kh4dvqhd3jk6mw1kwrphaqghjymrf72yp8"))))
268 (build-system asdf-build-system/sbcl)
269 (outputs '("out" "bin"))
270 (inputs
271 (list sbcl-abstract-classes
272 sbcl-alexandria
273 sbcl-cffi
274 sbcl-cl-quil
275 sbcl-global-vars
276 sbcl-ieee-floats
277 sbcl-lparallel
278 sbcl-magicl
279 sbcl-mt19937
280 sbcl-static-vectors
281 sbcl-trivial-features
282 sbcl-trivial-garbage
283
284 ;; qvm-app
285 sbcl-cl-syslog
286 sbcl-command-line-arguments
287 sbcl-hunchentoot
288 sbcl-slime-swank
289 sbcl-trivial-benchmark))
290 (arguments
291 (list
292 #:asd-systems ''("qvm" "qvm-app")
293 #:tests? #f
294 #:phases
295 #~(modify-phases %standard-phases
296 (add-after 'unpack 'remove-git-dependency
297 (lambda _
298 (substitute* "app/src/qvm-app-version.lisp"
299 (("\\(git-hash '#:qvm-app\\)")
300 "\"unknown\""))))
301 (add-after 'unpack 'fix-build
302 (lambda _
303 ;; Don't use symbol that doesn't exists in swank 2.31.
304 (substitute* "app/src/entry-point.lisp"
305 (("\\(defvar swank:\\*use-dedicated-output-stream\\*\\)")
306 "")
307 (("\\(setf swank:\\*use-dedicated-output-stream\\* nil\\)")
308 ""))))
309 (add-after 'create-asdf-configuration 'build-program
310 (lambda* (#:key outputs #:allow-other-keys)
311 (build-program (string-append (assoc-ref outputs "bin")
312 "/bin/qvm")
313 outputs
314 #:dependencies '("qvm-app")
315 #:entry-program '((qvm-app::asdf-entry-point))
316 #:compress? #t))))))
317 (synopsis "Quil simulator")
318 (description
319 "This is the official Quil-Lang Quantum Virtual Machine (QVM),
320a flexible and efficient simulator for Quil.")
321 (home-page "https://github.com/quil-lang/qvm")
322 (license (list license:asl2.0
323 license:agpl3))))
324
325(define-public cl-qvm
326 (sbcl-package->cl-source-package sbcl-qvm))