projects/guix·blob javascript-team · refs

7520 lines · 301.3 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2015-2026 Ricardo Wurmus <[email protected]>
3;;; Copyright © 2016, 2020-2024 Efraim Flashner <[email protected]>
4;;; Copyright © 2016, 2017, 2020 Marius Bakke <[email protected]>
5;;; Copyright © 2016 Hartmut Goebel <[email protected]>
6;;; Copyright © 2018, 2019, 2020 Tobias Geerinckx-Rice <[email protected]>
7;;; Copyright © 2018 Mark Meyer <[email protected]>
8;;; Copyright © 2018 Ben Woodcroft <[email protected]>
9;;; Copyright © 2018 Fis Trivial <[email protected]>
10;;; Copyright © 2018 Julien Lepiller <[email protected]>
11;;; Copyright © 2018 Björn Höfling <[email protected]>
12;;; Copyright © 2019 Nicolas Goaziou <[email protected]>
13;;; Copyright © 2019, 2020 Guillaume Le Vaillant <[email protected]>
14;;; Copyright © 2019 Brett Gilio <[email protected]>
15;;; Copyright © 2020 Konrad Hinsen <[email protected]>
16;;; Copyright © 2020 Edouard Klein <[email protected]>
17;;; Copyright © 2020-2025 Vinicius Monego <[email protected]>
18;;; Copyright © 2020, 2021, 2022, 2023 Maxim Cournoyer <[email protected]>
19;;; Copyright © 2022-2025 Nicolas Graves <[email protected]>
20;;; Copyright © 2022 Kiran Shila <[email protected]>
21;;; Copyright © 2022 Wiktor Zelazny <[email protected]>
22;;; Copyright © 2023 zamfofex <[email protected]>
23;;; Copyright © 2023 Navid Afkhami <[email protected]>
24;;; Copyright © 2023 Zheng Junjie <[email protected]>
25;;; Copyright © 2023 Troy Figiel <[email protected]>
26;;; Copyright © 2024-2026 Sharlatan Hellseher <[email protected]>
27;;; Copyright © 2024 David Pflug <[email protected]>
28;;; Copyright © 2024 Timothee Mathieu <[email protected]>
29;;; Copyright © 2024 Spencer King <[email protected]>
30;;; Copyright © 2024, 2025 David Elsing <[email protected]>
31;;; Copyright © 2024, 2025 Andy Tai <[email protected]>
32;;; Copyright © 2025 Lapearldot <[email protected]>
33;;; Copyright © 2025, 2026 Cayetano Santos <[email protected]>
34;;; Copyright © 2025 Janneke Nieuwenhuizen <[email protected]>
35;;; Copyright © 2025 Romain Garbage <[email protected]>
36;;; Copyright © 2026 Nguyễn Gia Phong <[email protected]>
37;;; Copyright © 2026 Goran Vukoman <[email protected]>
38;;; Copyright © 2026 bdunahu <[email protected]>
39;;;
40;;; This file is part of GNU Guix.
41;;;
42;;; GNU Guix is free software; you can redistribute it and/or modify it
43;;; under the terms of the GNU General Public License as published by
44;;; the Free Software Foundation; either version 3 of the License, or (at
45;;; your option) any later version.
46;;;
47;;; GNU Guix is distributed in the hope that it will be useful, but
48;;; WITHOUT ANY WARRANTY; without even the implied warranty of
49;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50;;; GNU General Public License for more details.
51;;;
52;;; You should have received a copy of the GNU General Public License
53;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
54
55(define-module (gnu packages machine-learning)
56 #:use-module (gnu packages algebra)
57 #:use-module (gnu packages assembly)
58 #:use-module (gnu packages audio)
59 #:use-module (gnu packages autotools)
60 #:use-module (gnu packages base)
61 #:use-module (gnu packages bash)
62 #:use-module (gnu packages bdw-gc)
63 #:use-module (gnu packages boost)
64 #:use-module (gnu packages build-tools)
65 #:use-module (gnu packages c)
66 #:use-module (gnu packages calendar)
67 #:use-module (gnu packages check)
68 #:use-module (gnu packages cmake)
69 #:use-module (gnu packages compression)
70 #:use-module (gnu packages cpp)
71 #:use-module (gnu packages cran)
72 #:use-module (gnu packages curl)
73 #:use-module (gnu packages databases)
74 #:use-module (gnu packages dejagnu)
75 #:use-module (gnu packages digest)
76 #:use-module (gnu packages dns)
77 #:use-module (gnu packages documentation)
78 #:use-module (gnu packages freedesktop)
79 #:use-module (gnu packages gcc)
80 #:use-module (gnu packages gettext)
81 #:use-module (gnu packages gl)
82 #:use-module (gnu packages glib)
83 #:use-module (gnu packages graphviz)
84 #:use-module (gnu packages gstreamer)
85 #:use-module (gnu packages guile)
86 #:use-module (gnu packages haskell-xyz)
87 #:use-module (gnu packages image)
88 #:use-module (gnu packages image-processing)
89 #:use-module (gnu packages imagemagick)
90 #:use-module (gnu packages jupyter)
91 #:use-module (gnu packages language)
92 #:use-module (gnu packages libedit)
93 #:use-module (gnu packages libevent)
94 #:use-module (gnu packages libffi)
95 #:use-module (gnu packages linux)
96 #:use-module (gnu packages llvm)
97 #:use-module (gnu packages logging)
98 #:use-module (gnu packages maths)
99 #:use-module (gnu packages monitoring)
100 #:use-module (gnu packages mpi)
101 #:use-module (gnu packages nss)
102 #:use-module (gnu packages ocaml)
103 #:use-module (gnu packages onc-rpc)
104 #:use-module (gnu packages oneapi)
105 #:use-module (gnu packages opencl)
106 #:use-module (gnu packages parallel)
107 #:use-module (gnu packages pdf)
108 #:use-module (gnu packages perl)
109 #:use-module (gnu packages pkg-config)
110 #:use-module (gnu packages pretty-print)
111 #:use-module (gnu packages protobuf)
112 #:use-module (gnu packages pulseaudio)
113 #:use-module (gnu packages python)
114 #:use-module (gnu packages python-build)
115 #:use-module (gnu packages python-check)
116 #:use-module (gnu packages python-crypto)
117 #:use-module (gnu packages python-science)
118 #:use-module (gnu packages python-web)
119 #:use-module (gnu packages python-xyz)
120 #:use-module (gnu packages qt)
121 #:use-module (gnu packages rdf)
122 #:use-module (gnu packages regex)
123 #:use-module (gnu packages rocm)
124 #:use-module (gnu packages rpc)
125 #:use-module (gnu packages rust)
126 #:use-module (gnu packages sdl)
127 #:use-module (gnu packages serialization)
128 #:use-module (gnu packages sphinx)
129 #:use-module (gnu packages sqlite)
130 #:use-module (gnu packages ssh)
131 #:use-module (gnu packages statistics)
132 #:use-module (gnu packages swig)
133 #:use-module (gnu packages time)
134 #:use-module (gnu packages tls)
135 #:use-module (gnu packages valgrind)
136 #:use-module (gnu packages version-control)
137 #:use-module (gnu packages video)
138 #:use-module (gnu packages vulkan)
139 #:use-module (gnu packages web)
140 #:use-module (gnu packages xdisorg)
141 #:use-module (gnu packages xml)
142 #:use-module (gnu packages xorg)
143 #:use-module (gnu packages)
144 #:use-module (guix build-system cargo)
145 #:use-module (guix build-system cmake)
146 #:use-module (guix build-system copy)
147 #:use-module (guix build-system gnu)
148 #:use-module (guix build-system ocaml)
149 #:use-module (guix build-system pyproject)
150 #:use-module (guix build-system r)
151 #:use-module (guix build-system trivial)
152 #:use-module (guix download)
153 #:use-module (guix gexp)
154 #:use-module (guix git-download)
155 #:use-module ((guix licenses) #:prefix license:)
156 #:use-module (guix packages)
157 #:use-module (guix svn-download)
158 #:use-module (guix utils)
159 #:use-module (ice-9 match))
160
161(define-public dlpack
162 (package
163 (name "dlpack")
164 (version "1.2")
165 (source
166 (origin
167 (method git-fetch)
168 (uri (git-reference
169 (url "https://github.com/dmlc/dlpack")
170 (commit (string-append "v" version))))
171 (file-name (git-file-name name version))
172 (sha256
173 (base32 "1zm28s4das0isa5rrh5a1c6iv1k1mcjqgnihbva74s78d52a7hpn"))))
174 (build-system cmake-build-system)
175 (arguments (list #:tests? #f)) ;No tests.
176 (home-page "https://dmlc.github.io/dlpack/latest/")
177 (synopsis "In memory tensor structure")
178 (description
179 "DLPack is an in-memory tensor structure for sharing tensors among
180frameworks.")
181 (license license:asl2.0)))
182
183(define-public fasttext
184 (package
185 (name "fasttext")
186 (version "0.9.2")
187 (source
188 (origin
189 (method git-fetch)
190 (uri (git-reference
191 (url "https://github.com/facebookresearch/fastText")
192 (commit (string-append "v" version))))
193 (file-name (git-file-name name version))
194 (sha256
195 (base32 "07cz2ghfq6amcljaxpdr5chbd64ph513y8zqmibfx2xwfp74xkhn"))))
196 (build-system cmake-build-system)
197 ;; Tests require downloading of test data.
198 (arguments
199 (list
200 #:tests? #false
201 #:phases
202 #~(modify-phases %standard-phases
203 (add-after 'unpack 'gcc-14-fix
204 (lambda _
205 (substitute* "src/args.cc"
206 (("#include <unordered_map>" all)
207 (string-append all "\n#include <cstdint>"))))))))
208 (home-page "https://github.com/facebookresearch/fastText")
209 (synopsis "Library for fast text representation and classification")
210 (description "fastText is a library for efficient learning of word
211representations and sentence classification.")
212 (license license:expat)))
213
214(define-public ggml
215 (package
216 (name "ggml")
217 (version "0.25.2") ;sync with llama.cpp
218 (source
219 (origin
220 (method git-fetch)
221 (uri (git-reference
222 (url "https://github.com/ggml-org/ggml")
223 (commit (string-append "v" version))))
224 (file-name (git-file-name name version))
225 (sha256
226 (base32 "0ww5wk2d6ldy2l5fxh4nr259mnwdpypp316h383as46cbvywyh60"))))
227 (build-system cmake-build-system)
228 (arguments
229 (list
230 #:configure-flags
231 #~(list #$(string-append "-DGGML_BUILD_COMMIT=" version)
232 "-DBUILD_SHARED_LIBS_DEFAULT=ON"
233 "-DGGML_BACKEND_DL=ON"
234 (string-append "-DGGML_BACKEND_DIR="
235 #$output "/lib/backends")
236 "-DGGML_VULKAN=ON"
237 "-DGGML_BUILD_TESTS=ON"
238 "-DGGML_OPENCL=ON"
239 ;; Defaults to ON upstream; ggml-opencl.cpp's own
240 ;; ggml_opencl_is_device_supported() unconditionally
241 ;; rejects every non-Adreno (non-Qualcomm) device when
242 ;; this is compiled in, regardless of how capable the
243 ;; device actually is.
244 "-DGGML_OPENCL_USE_ADRENO_KERNELS=OFF"
245 "-DGGML_NATIVE_DEFAULT=OFF" ;no '-march=native'
246 "-DGGML_BLAS_DEFAULT=ON"
247 "-DGGML_BLAS_VENDOR_DEFAULT=OpenBLAS")))
248 (inputs
249 (list glslang
250 openblas
251 openblas-ilp64
252 opencl-icd-loader
253 shaderc
254 spirv-headers
255 spirv-tools
256 vulkan-headers
257 vulkan-loader))
258 (native-inputs
259 (list opencl-headers pkg-config python-minimal-wrapper))
260 (properties '((tunable? . #true)))
261 (home-page "https://github.com/ggml-org/ggml")
262 (synopsis "Tensor library for machine learning")
263 (description "@code{ggml} is a @acronym{ML, Machine Learning} library
264written in C and C++ with a focus on transformer inference, similar to ML
265libraries such as PyTorch and TensorFlow.")
266 (license license:expat)))
267
268(define-public ggml-for-whisper
269 (package
270 (inherit ggml)
271 (name "ggml-for-whisper")
272 (version "0.15.1") ;sync whisper.cpp
273 (source
274 (origin
275 (method git-fetch)
276 (uri (git-reference
277 (url "https://github.com/ggml-org/ggml")
278 (commit (string-append "v" version))))
279 (file-name (git-file-name name version))
280 (sha256
281 (base32 "06bw4dbnzmy9wz3k6g4a2vf7yjn7xpqzam4ra6mxv3lkvhz0fhsg"))))))
282
283(define-public git-ai
284 (package
285 (name "git-ai")
286 (version "1.1.18")
287 (source (origin
288 (method git-fetch)
289 (uri (git-reference
290 (url "https://github.com/git-ai-project/git-ai")
291 (commit (string-append "v" version))))
292 (file-name (git-file-name name version))
293 (sha256
294 (base32 "0yf864shgi5b35s0f6frds0lf9jwwn8qw4pxiniplhnxadrbpx2f"))))
295 (build-system cargo-build-system)
296 (arguments
297 (list #:install-source? #f
298 #:cargo-test-flags
299 ''("--"
300 ;;This test requires network access.
301 "--skip=test_load_ai_touched_files_for_specific_commits"
302 ;;This test fails in the build environment.
303 "--skip=exit_status_was_interrupted_on_sigint")
304 #:phases
305 #~(modify-phases %standard-phases
306 (add-after 'unpack 'patch-/bin/sh
307 (lambda _
308 (substitute* (list "tests/integration/continue_session.rs"
309 "tests/integration/diff.rs"
310 "tests/integration/stats.rs"
311 "tests/integration/status_ignore.rs"
312 "tests/integration/git_ai_hooks.rs"
313 "tests/integration/hook_forwarding.rs"
314 "tests/integration/hook_modes.rs"
315 "tests/integration/rebase.rs")
316 (("#!/bin/sh") (string-append "#!" (which "sh"))))))
317 (add-after 'unpack 'set-home
318 (lambda _
319 (setenv "HOME" (getenv "TMPDIR"))))
320 (add-before 'check 'setup-git-path
321 (lambda* (#:key inputs #:allow-other-keys)
322 (let ((git (assoc-ref inputs "git-minimal"))
323 (home (getenv "HOME")))
324 (mkdir-p (string-append home "/.git-ai"))
325 (let ((port (open-file
326 (string-append home "/.git-ai/config.json")
327 "a")))
328 (format port "{\"git_path\": \"~a/bin/git\"}" git)
329 (close port))
330
331 (substitute* "src/config.rs"
332 (("\"/usr/bin/git\"")
333 (string-append "\"" git "/bin/git\""))))))
334 (add-before 'check 'git-init
335 (lambda _
336 ;;The tests expect a git repo with at least one commit.
337 (invoke "git" "init")
338 (invoke "git" "config" "--global" "user.email" "[email protected]")
339 (invoke "git" "config" "--global" "user.name" "User Name")
340 (invoke "git" "add" ".")
341 (invoke "git" "commit" "-m" "Commit all."))))))
342 (native-inputs (list
343 git-minimal/pinned ;for tests
344 pkg-config))
345 (inputs
346 (cons*
347 libgit2 libssh2 openssl sqlite zlib (cargo-inputs 'git-ai)))
348 (home-page "https://usegitai.com/")
349 (synopsis "Git extension for tracking LLM-generated code")
350 (description "@code{git-ai} is an extension for git that tracks which
351lines of code were created by an LLM along with metadata about how and why.")
352 (license license:asl2.0)))
353
354(define-public python-apricot-select
355 (package
356 (name "python-apricot-select")
357 ;; 0.6.1 was released in 2021
358 (properties '((commit . "962f597a57fcb880a3b19befa7a3eebccc6b5228")
359 (revision . "0")))
360 (version (git-version "0.6.1"
361 (assoc-ref properties 'revision)
362 (assoc-ref properties 'commit)))
363 (source
364 (origin
365 (method git-fetch)
366 (uri (git-reference
367 (url "https://github.com/jmschrei/apricot")
368 (commit (assoc-ref properties 'commit))))
369 (file-name (git-file-name name version))
370 (sha256
371 (base32 "16hj76nzdr4pbx7wy5f3237f9c1d0yizmz1skix0rwlvjpj3rc9x"))))
372 (build-system pyproject-build-system)
373 (arguments
374 ;; See: <https://github.com/jmschrei/apricot/issues/19>.
375 (list #:tests? #f)) ;tests are very compue havy
376 (native-inputs
377 (list python-pytest
378 python-pytest-xdist
379 python-setuptools
380 python-scikit-learn))
381 (propagated-inputs
382 (list python-numba
383 python-numpy
384 python-scipy
385 python-tqdm))
386 (home-page "https://github.com/jmschrei/apricot")
387 (synopsis "Submodular selection of representative sets for ML models")
388 (description
389 "@code{apricot} implements submodular optimization for the purpose of
390summarizing massive data sets into minimally redundant subsets that are still
391representative of the original data. These subsets are useful for both
392visualizing the modalities in the data and for training accurate machine
393learning models with just a fraction of the examples and compute.")
394 (license license:expat)))
395
396(define-public python-autograd-gamma
397 (package
398 (name "python-autograd-gamma")
399 (version "0.5.0")
400 (source
401 (origin
402 (method git-fetch)
403 (uri (git-reference
404 (url "https://github.com/CamDavidsonPilon/autograd-gamma")
405 ;; The 5.0.0 version is not tagged, but can only be this commit.
406 (commit "5876e0320865c592ed4a370c6a6ef282cf163480")))
407 (file-name (git-file-name name version))
408 (sha256
409 (base32 "0hpjnpw7bsy1xja4pnxx5fvv7xly72lp3hdazhr9zbmn6s7vcs19"))))
410 (build-system pyproject-build-system)
411 (native-inputs
412 (list python-pytest
413 python-setuptools))
414 (propagated-inputs
415 (list python-autograd
416 python-scipy))
417 (home-page "https://github.com/CamDavidsonPilon/autograd-gamma")
418 (synopsis
419 "Autograd-compatible approximations to the gamma family of functions")
420 (description
421 "This package provides Autograd-compatible approximations to the gamma
422family of functions.")
423 (license license:expat)))
424
425(define-public python-burr
426 (package
427 (name "python-burr")
428 (version "0.42.0")
429 (source
430 (origin
431 (method git-fetch)
432 (uri (git-reference
433 (url "https://github.com/apache/burr/")
434 (commit (string-append "burr-" version))))
435 (file-name (git-file-name name version))
436 (sha256
437 (base32 "0a2sf72qy9jkamg6r7d37mv7ayp698h031md7arfyq7v8q9q121n"))))
438 (build-system pyproject-build-system)
439 (arguments
440 (list
441 #:phases
442 '(modify-phases %standard-phases
443 ;; Avoid "async def functions are not natively supported." with 70+
444 ;; test failures. This hack triggers a bunch of warnings, because
445 ;; now also synchronous tests are marked with @pytest.mark.asyncio,
446 ;; but at least the tests run successfully.
447 (add-after 'unpack 'patch-tests
448 (lambda _
449 (substitute* "tests/common/test_async_utils.py"
450 (("from typing.*" m)
451 (string-append m "\
452import asyncio
453import pytest
454pytestmark = pytest.mark.asyncio\n")))
455 (substitute* '("tests/visibility/test_tracing.py"
456 "tests/core/test_parallelism.py"
457 "tests/core/test_action.py"
458 "tests/core/test_application.py"
459 "tests/test_end_to_end.py")
460 (("^import asyncio.*" m)
461 (string-append m "\
462import pytest
463pytestmark = pytest.mark.asyncio\n"))))))
464 ;; There are integration tests and examples comparing Burr to and
465 ;; interfacing with alternatives, such as the overly complex langchain.
466 ;; We should not add them here just to run these tests.
467 #:test-flags
468 #~(list "--ignore-glob=tests/integration**"
469 "--ignore-glob=examples/**"
470 "--ignore-glob=burr/examples/**"
471 "--ignore=tests/core/test_graphviz_display.py"
472 "--ignore=tests/core/test_persistence.py")))
473 (native-inputs
474 (list python-flit-core
475 python-anyio
476 python-pytest
477 python-pytest-asyncio
478 python-setuptools))
479 ;; Burr has very few hard dependencies. Including these optional packages
480 ;; makes it more useful, though.
481 (propagated-inputs
482 (list python-pydantic ;optional
483 python-pydantic-settings ;optional
484 python-loguru
485 python-requests))
486 (home-page "https://burr.apache.org/")
487 (synopsis "Build applications that make decisions")
488 (description
489 "Apache Burr makes it easy to develop applications that make
490decisions (chatbots, agents, simulations, etc...) from simple Python building
491blocks. Apache Burr works well for any application that uses LLMs, and can
492integrate with any of your favorite frameworks. Burr includes a UI that can
493track/monitor/trace your system in real time, along with pluggable
494persisters (e.g. for memory) to save and load application state.")
495 (license license:asl2.0)))
496
497(define-public python-faster-whisper
498 (package
499 (name "python-faster-whisper")
500 (version "1.2.0")
501 (source
502 (origin
503 (method git-fetch)
504 (uri (git-reference
505 (url "https://github.com/SYSTRAN/faster-whisper")
506 (commit (string-append "v" version))))
507 (file-name (git-file-name name version))
508 (sha256
509 (base32 "0wmc9aszpnbr60l5v97np0rc3zsz4pldjald7kmnr668rhpakzcj"))))
510 (build-system pyproject-build-system)
511 ;; XXX: Currently tests requires model download, which we'd rather avoid
512 ;; in Guix unless we're sure about the FOSS weights. To test in source :
513 ;; guix shell -D python-faster-whisper -- pytest
514 (arguments (list #:tests? #f))
515 (propagated-inputs (list (list onnxruntime "python")
516 python-av
517 python-ctranslate2
518 python-huggingface-hub
519 python-tokenizers
520 python-tqdm))
521 (native-inputs (list python-numpy
522 python-pytest
523 python-setuptools))
524 (home-page "https://github.com/SYSTRAN/faster-whisper")
525 (synopsis "Whisper transcription reimplementation")
526 (description
527 "This package provides a reimplementation of OpenAI's Whisper model using
528CTranslate2, which is a inference engine for transformer models.")
529 (license license:expat)))
530
531(define-public python-fasttext
532 (package
533 (inherit fasttext)
534 (name "python-fasttext")
535 (build-system pyproject-build-system)
536 (propagated-inputs (list python-numpy python-scipy))
537 (inputs (list fasttext))
538 (native-inputs (list pybind11-2 python-setuptools python-wheel))))
539
540(define-public python-funsor
541 (package
542 (name "python-funsor")
543 (version "0.4.7")
544 (source
545 (origin
546 (method git-fetch)
547 (uri (git-reference
548 (url "https://github.com/pyro-ppl/funsor")
549 (commit version)))
550 (file-name (git-file-name name version))
551 (sha256
552 (base32 "1ragxy19qfaczn3wfpamg0giqyiscxvm366r3md255lfafzwj96i"))))
553 (build-system pyproject-build-system)
554 (arguments
555 (list
556 ;; tests: 7665 passed, 3949 skipped, 71 xfailed, 2 xpassed, 8 warnings
557 #:test-flags
558 #~(list "--numprocesses" (number->string (min 8 (parallel-job-count)))
559 ;; XXX: The project has no updates since 2023 and probably not
560 ;; compatible with current Python science stack (NumPy, SciPy,
561 ;; Pandas...).
562 ;;
563 ;; See open issues:
564 ;; <https://github.com/pyro-ppl/funsor/issues/609>
565 ;; <https://github.com/pyro-ppl/funsor/pull/610>
566 ;;
567 ;; TypeError: argument of type 'property' is not iterable
568 "--ignore=test/examples/test_sensor_fusion.py"
569 "--ignore=test/torch/test_provenance.py"
570 ;; The most of the tests fail with error: ValueError: Cannot
571 ;; convert to Funsor: tensor..
572 #$@(map (lambda (test) (string-append "--deselect=test/"
573 test))
574 (list "pyro/test_convert.py::test_dist_to_funsor_bernoulli"
575 "pyro/test_convert.py::test_dist_to_funsor_categorical"
576 "pyro/test_convert.py::test_dist_to_funsor_independent"
577 "pyro/test_convert.py::test_dist_to_funsor_masked"
578 "pyro/test_convert.py::test_dist_to_funsor_mvn"
579 "pyro/test_convert.py::test_dist_to_funsor_normal"
580 "pyro/test_convert.py::test_funsor_to_cat_and_mvn"
581 "pyro/test_convert.py::test_funsor_to_mvn"
582 "pyro/test_convert.py::test_matrix_and_mvn_to_funsor"
583 "pyro/test_convert.py::test_matrix_and_mvn_to_funsor_diag"
584 "pyro/test_convert.py::test_mvn_to_funsor"
585 "pyro/test_convert.py::test_tensor_funsor_tensor"
586 "pyro/test_distribution.py::test_categorical_log_prob"
587 "pyro/test_distribution.py::test_categorical_sample"
588 "pyro/test_hmm.py::test_discrete_categorical_log_prob"
589 "pyro/test_hmm.py::test_discrete_diag_normal_log_prob"
590 "pyro/test_hmm.py::test_discrete_mvn_log_prob"
591 "pyro/test_hmm.py::test_discrete_normal_log_prob"
592 "pyro/test_hmm.py::test_gaussian_hmm_log_prob"
593 "pyro/test_hmm.py::test_gaussian_hmm_log_prob_null_dynamics"
594 "pyro/test_hmm.py::test_gaussian_mrf_log_prob"
595 "pyro/test_hmm.py::test_switching_linear_hmm_log_prob"
596 "pyro/test_hmm.py::test_switching_linear_hmm_log_prob_alternating"
597 "pyro/test_hmm.py::test_switching_linear_hmm_shape"
598 "pyroapi/test_pyroapi.py::test_generate_data"
599 "pyroapi/test_pyroapi.py::test_generate_data_plate"
600 "pyroapi/test_pyroapi.py::test_local_param_ok"
601 "pyroapi/test_pyroapi.py::test_mean_field_ok"
602 "pyroapi/test_pyroapi.py::test_nested_plate_plate_ok"
603 "pyroapi/test_pyroapi.py::test_nonempty_model_empty_guide_ok"
604 "pyroapi/test_pyroapi.py::test_optimizer"
605 "pyroapi/test_pyroapi.py::test_plate_ok"
606 "test_tensor.py::test_function_of_numeric_array")))))
607 (native-inputs
608 (list python-pandas
609 python-pillow
610 python-pyro-api
611 python-pytest
612 python-pytest-xdist
613 python-requests
614 python-scipy
615 python-setuptools
616 python-torchvision))
617 (propagated-inputs
618 (list python-makefun
619 python-multipledispatch
620 python-numpy
621 python-opt-einsum
622 python-typing-extensions
623 ;; [optional]
624 ;; python-jax
625 ;; python-jaxlib
626 ;; python-numpyro
627 python-pyro-ppl
628 python-pytorch))
629 (home-page "https://github.com/pyro-ppl/funsor")
630 (synopsis "Tensor-like library for functions and distributions")
631 (description
632 "This package provides a tensor-like library for functions and
633distributions.")
634 (license license:asl2.0)))
635
636(define-public fann
637 ;; The last release is 14 years old.
638 (let ((commit "1783cbf6239a597c4d29f694e227e22b8d4f4bf6")
639 (revision "2"))
640 (package
641 (name "fann")
642 (version (git-version "2.2.0" revision commit))
643 (source
644 (origin
645 (method git-fetch)
646 (uri (git-reference
647 (url "https://github.com/libfann/fann")
648 (commit commit)))
649 (modules '((guix build utils)))
650 (snippet #~(delete-file-recursively "lib/googletest"))
651 (file-name (git-file-name name version))
652 (sha256
653 (base32
654 "0jlcxl0czlr3982mak3935mb08i2f368f0jsxca91ppgfd596ldr"))))
655 (build-system cmake-build-system)
656 (arguments
657 (list
658 #:phases
659 #~(modify-phases %standard-phases
660 (add-after 'unpack 'remove-googletest
661 (lambda _
662 (substitute* "CMakeLists.txt"
663 (("ADD_SUBDIRECTORY\\( lib/googletest \\)")
664 ""))))
665 (replace 'check
666 (lambda* (#:key tests? #:allow-other-keys)
667 (when tests?
668 (with-directory-excursion "tests"
669 (invoke "./fann_tests"))))))))
670 (native-inputs (list googletest-1.13))
671 (home-page "https://leenissen.dk/")
672 (synopsis "Fast Artificial Neural Network")
673 (description
674 "FANN is a neural network library, which implements multilayer
675artificial neural networks in C with support for both fully connected and
676sparsely connected networks.")
677 (license license:lgpl2.1))))
678
679(define-public libsvm
680 (package
681 (name "libsvm")
682 (version "337")
683 (source
684 (origin
685 (method git-fetch)
686 (uri (git-reference
687 (url "https://github.com/cjlin1/libsvm/")
688 (commit (string-append "v" version))))
689 (file-name (git-file-name name version))
690 (sha256
691 (base32 "0rd4balgr62jisml6q682klkcxn8f8mjc5rc69rl2bzvdbrk3xia"))))
692 (build-system gnu-build-system)
693 (arguments
694 (list
695 #:tests? #f ;no "check" target
696 #:phases
697 #~(modify-phases %standard-phases
698 (delete 'configure)
699 (add-after 'build 'build-lib
700 (lambda _
701 (invoke "make" "lib")))
702 (replace 'install
703 ;no "install" target
704 (lambda _
705 (for-each (lambda (file)
706 (install-file file
707 (string-append #$output "/bin")))
708 '("svm-train" "svm-predict" "svm-scale"))
709 (install-file "libsvm.so.4"
710 (string-append #$output "/lib"))
711 (symlink (string-append #$output "/lib/libsvm.so.4")
712 (string-append #$output "/lib/libsvm.so"))
713 (install-file "svm.h"
714 (string-append #$output "/include/"
715 #$name)))))))
716 (native-inputs (list python-minimal-wrapper))
717 (home-page "https://www.csie.ntu.edu.tw/~cjlin/libsvm/")
718 (synopsis "Library for Support Vector Machines")
719 (description
720 "LIBSVM is a machine learning library for support vector
721classification, (C-SVC, nu-SVC), regression (epsilon-SVR, nu-SVR) and
722distribution estimation (one-class SVM). It supports multi-class
723classification.")
724 (license license:bsd-3)))
725
726(define-public python-gpy
727 (package
728 (name "python-gpy")
729 (version "1.14.2")
730 (source
731 (origin
732 (method git-fetch)
733 (uri (git-reference
734 (url "https://github.com/SheffieldML/GPy")
735 (commit (string-append "v" version))))
736 (file-name (git-file-name name version))
737 (sha256
738 (base32 "1l0yxidhsf9s87fcc7v1l38dywq9ps6nr1d84r1nmblp9dgmibr2"))))
739 (build-system pyproject-build-system)
740 (arguments
741 (list
742 #:phases
743 #~(modify-phases %standard-phases
744 (add-after 'unpack 'compatibility
745 (lambda _
746 ;; This file uses Python 2 statements
747 (delete-file "GPy/testing/mpi_test__.py"))))))
748 (native-inputs
749 (list python-cython
750 python-pods
751 python-pytest
752 python-setuptools))
753 (propagated-inputs
754 (list python-numpy
755 python-paramz
756 python-scipy
757 python-six ;hard dependency
758 ;; [optional]
759 python-matplotlib
760 python-plotly))
761 (home-page "https://sheffieldml.github.io/GPy/")
762 (synopsis "The Gaussian Process Toolbox")
763 (description
764 "@command{GPy} is a Gaussian Process (GP) framework written in Python,
765from the Sheffield machine learning group. GPy implements a range of machine
766learning algorithms based on GPs.")
767 (license license:bsd-3)))
768
769(define-public python-libsvm
770 (package
771 (inherit libsvm)
772 (name "python-libsvm")
773 (build-system pyproject-build-system)
774 (arguments
775 (list
776 #:tests? #f ;no "check" target
777 #:phases
778 #~(modify-phases %standard-phases
779 (add-before 'build 'chdir
780 (lambda _
781 (chdir "python"))))))
782 (native-inputs (list python-setuptools))
783 (propagated-inputs (list libsvm python-scipy))
784 (synopsis "Python bindings of libSVM")))
785
786(define-public python-mcfit
787 ;; PyPI variant fails during compile-bytecode phase: "IndentationError:
788 ;; expected an indented block after function definition on line 10
789 ;; (mkfit.py, line 15)".
790 ;; GitHub provides no release tags, use the latest commit from the master
791 ;; branch.
792 ;; See: <https://github.com/eelregit/mcfit/issues/5>.
793 (let ((commit "be3a5cf9c474e16875126adcd35ba785fb781ebb")
794 (revision "0"))
795 (package
796 (name "python-mcfit")
797 (version (git-version "0.0.22" revision commit))
798 (source
799 (origin
800 (method git-fetch)
801 (uri (git-reference
802 (url "https://github.com/eelregit/mcfit")
803 (commit commit)))
804 (sha256
805 (base32 "120ybwhrqpn9a9q96m6l8pw8a7cdz705vzqn3s87wnffa8nslbsi"))))
806 (build-system pyproject-build-system)
807 (native-inputs
808 (list python-pytest
809 python-setuptools
810 python-wheel))
811 (propagated-inputs
812 (list python-mpmath
813 python-numpy
814 python-scipy))
815 (home-page "https://github.com/eelregit/mcfit")
816 (synopsis "Multiplicatively convolutional fast integral transforms")
817 (description
818 "This package provides multiplicatively convolutional fast integral
819transforms.")
820 (license license:gpl3+))))
821
822(define-public python-minisbd
823 (package
824 (name "python-minisbd")
825 (version "0.9.5")
826 (source
827 (origin
828 (method git-fetch)
829 (uri (git-reference
830 (url "https://github.com/LibreTranslate/MiniSBD")
831 (commit (string-append "v" version))))
832 (file-name (git-file-name name version))
833 (sha256
834 (base32 "1dfflfx39vq1fijrzmfq43hva2ackbx7pj6ixpxbq48p1v9r715a"))))
835 (build-system pyproject-build-system)
836 (arguments (list #:tests? #f)) ;no tests
837 (native-inputs
838 (list python-hatchling))
839 (propagated-inputs
840 (list python-filelock
841 python-numpy
842 (list onnxruntime "python")))
843 (home-page "https://github.com/LibreTranslate/MiniSBD")
844 (synopsis "Sentence boundary detection Python library")
845 (description
846 "This package provides a Python library for fast sentence boundary
847detection. It uses 8bit quantized ONNX models for inference, thus making it
848fast and lightweight.")
849 (license license:agpl3+)))
850
851(define-public python-ml-collections
852 (package
853 (name "python-ml-collections")
854 (version "1.1.0")
855 (source
856 (origin
857 (method git-fetch)
858 (uri (git-reference
859 (url "https://github.com/google/ml_collections")
860 (commit (string-append "v" version))))
861 (sha256
862 (base32 "1lv7vs84v4zwyrqg2zdlkrx3x6w08j9lyz74m8vk55ysl4399pqv"))))
863 (build-system pyproject-build-system)
864 (arguments
865 (list
866 ;; tests: 373 passed, 1 skipped, 81 warnings
867 #:test-flags
868 #~(list "--ignore=docs/"
869 "--ignore=ml_collections/config_dict/examples/examples_test.py")))
870 (native-inputs
871 (list python-flit-core
872 python-pytest))
873 (propagated-inputs
874 (list python-absl-py
875 python-pyyaml))
876 (home-page "https://github.com/google/ml_collections")
877 (synopsis "Python collections designed for Machine Learning usecases")
878 (description
879 "ML Collections is a library of Python collections designed for Machine
880Learning usecases.")
881 (license license:asl2.0)))
882
883(define-public python-ml-dtypes
884 (package
885 (name "python-ml-dtypes")
886 (version "0.5.4")
887 (source
888 (origin
889 (method git-fetch)
890 (uri (git-reference
891 (url "https://github.com/jax-ml/ml_dtypes")
892 (commit (string-append "v" version))))
893 (file-name (git-file-name name version))
894 (sha256
895 (base32 "0q6y0m1jh0a2hj0x887gp361zbrsfz93csr8hm3pkamg354plczc"))
896 (modules '((guix build utils)))
897 (snippet
898 ;; Do not use bundled eigen.
899 '(delete-file-recursively "third_party/eigen"))))
900 (build-system pyproject-build-system)
901 (arguments
902 (list
903 ;; tests: 2087 passed, 17 skipped, 2 deselected, 2720 subtests passed
904 #:test-flags
905 ;; Arrays are not equal
906 #~(list (string-append "--deselect=ml_dtypes/tests/"
907 "custom_float_test.py::CustomFloatNumPyTest"
908 "::testArange_float8_e4m3b11fnuz")
909 (string-append "--deselect=ml_dtypes/tests/custom_float_test.py"
910 "::CustomFloatNumPyTest"
911 "::testArange_float8_e4m3b11fnuz_multi_threaded"))
912 #:phases
913 #~(modify-phases %standard-phases
914 (add-after 'unpack 'use-eigen-package
915 (lambda* (#:key inputs #:allow-other-keys)
916 (substitute* "setup.py"
917 (("third_party/eigen")
918 (search-input-directory inputs "include/eigen3")))))
919 (add-after 'install 'symlink-lib
920 (lambda* (#:key inputs outputs #:allow-other-keys)
921 (for-each
922 (lambda (file)
923 (symlink file
924 (string-append #$output "/lib/ml_dtypes.so")))
925 (find-files (site-packages inputs outputs) "\\.so$")))))))
926 (inputs (list eigen-for-python-ml-dtypes))
927 (propagated-inputs (list python-numpy))
928 (native-inputs (list pybind11
929 python-absl-py
930 python-pytest
931 python-setuptools))
932 (home-page "https://github.com/jax-ml/ml_dtypes")
933 (synopsis "NumPy dtype extensions used in machine learning")
934 (description
935 "This package is a stand-alone implementation of several
936NumPy @code{dtype} extensions used in machine learning libraries, including:
937
938@itemize
939@item @code{bfloat16}: an alternative to the standard @code{float16} format
940@item @code{float8_*}: several experimental 8-bit floating point
941 representations including:
942 @itemize
943 @item @code{float8_e4m3b11fnuz}
944 @item @code{float8_e4m3fn}
945 @item @code{float8_e4m3fnuz}
946 @item @code{float8_e5m2}
947 @item @code{float8_e5m2fnuz}
948 @end itemize
949@item @code{int4} and @code{uint4}: low precision integer types.
950@end itemize
951")
952 (license license:asl2.0)))
953
954(define-public llama-cpp
955 ;; llama.cpp itself now tags real semantic-version releases (unlike the
956 ;; old "b<N>" raw-build-number scheme this package used to track), but
957 ;; those releases carry no binary assets of their own -- only a
958 ;; "nightly-tag.txt" pointing at the "b<N>"-tagged nightly build they
959 ;; correspond to, which is where the prebuilt web UI tarball (below)
960 ;; actually lives.
961 (let ((ui-build "11146")) ;from that tag's nightly-tag.txt
962 (package
963 (name "llama-cpp")
964 (version "0.5.0")
965 (source
966 (origin
967 (method git-fetch)
968 (uri (git-reference
969 (url "https://github.com/ggml-org/llama.cpp")
970 (commit (string-append "v" version))))
971 (file-name (git-file-name name version))
972 (sha256
973 (base32 "0q13scf0ygxrj4zjwcdcpi1j2ncxzqzcbmfcg068vw4c9avrbm1j"))))
974 (build-system cmake-build-system)
975 (arguments
976 (list
977 ;; ctest includes a fast-growing set of network-dependent tests
978 ;; (test-download-model and everything that depends on its
979 ;; FIXTURES_REQUIRED, several test-recurrent-state-rollback-*
980 ;; variants, test-jinja-py, ...); the previous approach of
981 ;; patching each one out by name (llama-cpp-disable-tests.patch)
982 ;; already stopped applying cleanly after upstream added more of
983 ;; them, so just skip ctest entirely instead of re-patching it
984 ;; again every version bump.
985 #:tests? #f
986 #:configure-flags
987 #~(list "-DBUILD_SHARED_LIBS=ON"
988 "-DLLAMA_USE_SYSTEM_GGML=ON")
989 #:phases
990 #~(modify-phases %standard-phases
991 ;; See :
992 ;; llama.cpp/issues/23105#issuecomment-4531264818
993 (add-before 'build 'get-ui
994 (lambda _
995 (with-directory-excursion "tools/ui"
996 (copy-file #$(this-package-input "ui.tar.gz") "ui.tar.gz")
997 (invoke "tar" "xvf" "ui.tar.gz")
998 (rename-file #$(string-append "llama-b" ui-build) "dist"))))
999 (add-after 'install 'remove-tests
1000 (lambda _
1001 (for-each delete-file
1002 (find-files (string-append #$output "/bin")
1003 "^test-")))))))
1004 (inputs
1005 (list ggml openssl
1006 (origin
1007 (method url-fetch)
1008 (uri
1009 (format #f "~a/releases/download/b~a/llama-b~a-ui.tar.gz"
1010 "https://github.com/ggml-org/llama.cpp"
1011 ui-build ui-build))
1012 (file-name "ui.tar.gz")
1013 (sha256
1014 (base32 "1wm69rrlhr505q1ww0vs01y9y8lai8pj3lnx8yq80y873lxyfaw3")))))
1015 (properties '((tunable? . #true))) ;use AVX512, FMA, etc. when available
1016 (home-page "https://github.com/ggml-org/llama.cpp")
1017 (synopsis "Port of Facebook's LLaMA model in C/C++")
1018 (description "This package provides a port to Facebook's LLaMA collection
1019of foundation language models. It requires models parameters to be downloaded
1020independently to be able to run a LLaMA model.")
1021 (license license:expat))))
1022
1023(define-public llama-cpp-scripts
1024 (package
1025 (inherit llama-cpp)
1026 (name "llama-cpp-scripts")
1027 (version "0.0.0") ;from pyproject.toml
1028 (build-system pyproject-build-system)
1029 (arguments
1030 (list
1031 #:test-flags
1032 #~(list "--ignore=scripts/snapdragon"
1033 "--ignore=tools/server/tests")))
1034 (inputs '())
1035 (propagated-inputs
1036 (list python-numpy
1037 python-pytorch
1038 python-protobuf
1039 python-sentencepiece
1040 python-transformers
1041 python-gguf))
1042 (native-inputs (list python-poetry-core python-pytest))
1043 (properties '())
1044 (synopsis "Scripts that ship with @code{llama.cpp}")
1045 (description "This package includes the Python scripts included in
1046@code{llama.cpp}. These scripts are necessary for format conversion, shader
1047generation, etc.")
1048 (license license:expat)))
1049
1050(define-public whisper-cpp
1051 (package
1052 (name "whisper-cpp")
1053 (version "1.9.1") ;keep in sync with ggml-for-whisper
1054 (source (origin
1055 (method git-fetch)
1056 (uri (git-reference
1057 (url "https://github.com/ggml-org/whisper.cpp")
1058 (commit (string-append "v" version))))
1059 (file-name (git-file-name name version))
1060 (sha256
1061 (base32
1062 "1mpmmqm83qy39a1zqphy059x2crzwll2j34ypgwwghy2ji6nc2xm"))))
1063 (build-system cmake-build-system)
1064 (arguments
1065 (list
1066 #:configure-flags
1067 #~(list "-DBUILD_SHARED_LIBS=ON"
1068 "-DWHISPER_SDL2=TRUE"
1069 "-DWHISPER_COMMON_FFMPEG=TRUE"
1070 "-DWHISPER_USE_SYSTEM_GGML=ON")
1071 #:phases
1072 #~(modify-phases %standard-phases
1073 #$@(if (target-32bit?)
1074 '((add-after 'unpack 'skip-failing-tests
1075 (lambda _
1076 ;; 32-bit system
1077 ;; large model does not fit in RAM in 32-bit system,
1078 ;; disable large model test
1079 (substitute* "tests/CMakeLists.txt"
1080 (("LABELS \"large\"")
1081 "DISABLED true")))))
1082 '())
1083 (add-after 'unpack 'fix-parakeet-test
1084 (lambda _
1085 ;; Unlike whisper-cli, test-parakeet does not load the
1086 ;; dynamically loadable ggml backends, so it aborts with
1087 ;; "GGML_ASSERT(device) failed" since our ggml is built
1088 ;; with -DGGML_BACKEND_DL=ON.
1089 (substitute* "tests/test-parakeet.cpp"
1090 (("#include \"parakeet\\.h\"")
1091 "#include \"parakeet.h\"\n#include \"ggml-backend.h\"")
1092 (("int main\\(\\) \\{")
1093 "int main() {\n ggml_backend_load_all();"))))
1094 (add-after 'unpack 'skip-failing-vad-tests
1095 (lambda _
1096 (substitute* "tests/CMakeLists.txt"
1097 ;; error: failed to read audio data as wav (Unknown error)
1098 (("\\$\\{VAD_TEST\\} PROPERTIES LABELS \"unit\"")
1099 "${VAD_TEST} PROPERTIES DISABLED true")
1100 ;; error: failed to read audio data as wav (Unknown error)
1101 (("\\$\\{VAD_TEST\\} PROPERTIES LABELS \"base;en\"")
1102 "${VAD_TEST} PROPERTIES DISABLED true")))))))
1103 (native-inputs
1104 (list git-minimal/pinned pkg-config))
1105 (inputs
1106 (list ffmpeg ggml-for-whisper sdl2))
1107 (synopsis "OpenAI's Whisper model in C/C++")
1108 (description
1109 "This package is a high-performance inference of OpenAI's
1110Whisper automatic speech recognition (ASR) model, implemented in plain C/C++
1111without dependencies, with
1112@itemize
1113@item AVX intrinsics support for x86 architectures
1114@item VSX intrinsics support for POWER architectures
1115@item Mixed F16 / F32 precision
1116@item 4-bit and 5-bit integer quantization support
1117@item Zero memory allocations at runtime
1118@item Support for CPU-only inference
1119@item Efficient GPU support for NVIDIA
1120@item OpenVINO Support
1121@item C-style API
1122@end itemize")
1123 (properties '((tunable? . #true))) ;use AVX512, FMA, etc. when available
1124 (home-page "https://github.com/ggml-org/whisper.cpp/")
1125 (license license:expat)))
1126
1127(define-public mcl
1128 (package
1129 (name "mcl")
1130 (version "14.137")
1131 (source (origin
1132 (method url-fetch)
1133 (uri (string-append
1134 "http://micans.org/mcl/src/mcl-"
1135 (string-replace-substring version "." "-")
1136 ".tar.gz"))
1137 (sha256
1138 (base32
1139 "15xlax3z31lsn62vlg94hkm75nm40q4679amnfg13jm8m2bnhy5m"))))
1140 (build-system gnu-build-system)
1141 (arguments
1142 (list
1143 #:configure-flags
1144 #~(list "--enable-blast"
1145 (string-append "CFLAGS=-fcommon -g -O2"
1146 " -Wno-error=implicit-function-declaration"))))
1147 (inputs
1148 (list perl))
1149 (home-page "https://micans.org/mcl/")
1150 (synopsis "Clustering algorithm for graphs")
1151 (description
1152 "The MCL algorithm is short for the @dfn{Markov Cluster Algorithm}, a
1153fast and scalable unsupervised cluster algorithm for graphs (also known as
1154networks) based on simulation of (stochastic) flow in graphs.")
1155 ;; In the LICENCE file and web page it says "The software is licensed
1156 ;; under the GNU General Public License, version 3.", but in several of
1157 ;; the source code files it suggests GPL3 or later.
1158 ;; http://listserver.ebi.ac.uk/pipermail/mcl-users/2016/000376.html
1159 (license license:gpl3)))
1160
1161(define-public ocaml-mcl
1162 (package
1163 (name "ocaml-mcl")
1164 (version "12-068oasis4")
1165 (source
1166 (origin
1167 (method git-fetch)
1168 (uri (git-reference
1169 (url "https://github.com/fhcrc/mcl")
1170 (commit version)))
1171 (file-name (git-file-name name version))
1172 (sha256
1173 (base32
1174 "0009dc3h2jp3qg5val452wngpqnbfyhbcxylghq0mrjqxx0jdq5p"))))
1175 (build-system ocaml-build-system)
1176 (arguments
1177 `(#:phases
1178 (modify-phases %standard-phases
1179 (add-before 'configure 'patch-paths
1180 (lambda _
1181 (substitute* "setup.ml"
1182 (("LDFLAGS=-fPIC")
1183 (string-append "LDFLAGS=-fPIC\"; \"SHELL=" (which "sh")))
1184 (("-std=c89") "-std=gnu99 -fcommon")
1185
1186 ;; This is a mutable string, which is no longer supported. Use
1187 ;; a byte buffer instead.
1188 (("String.make \\(String.length s\\)")
1189 "Bytes.make (String.length s)")
1190
1191 ;; These two belong together.
1192 (("OASISString.replace_chars")
1193 "Bytes.to_string (OASISString.replace_chars")
1194 ((" s;")
1195 " s);"))
1196 (substitute* "myocamlbuild.ml"
1197 (("std=c89") "std=gnu99 -fcommon"))
1198 ;; Since we build with a more recent OCaml, we have to use C99 or
1199 ;; later. This causes problems with the old C code.
1200 (substitute* "src/impala/matrix.c"
1201 (("restrict") "restrict_"))
1202 #t)))))
1203 (native-inputs
1204 (list ocamlbuild))
1205 (home-page "https://github.com/fhcrc/mcl")
1206 (synopsis "OCaml wrappers around MCL")
1207 (description
1208 "This package provides OCaml bindings for the MCL graph clustering
1209algorithm.")
1210 (license license:gpl3)))
1211
1212(define-public openmm
1213 (package
1214 (name "openmm")
1215 (version "8.5.2")
1216 (source
1217 (origin
1218 (method git-fetch)
1219 (uri (git-reference
1220 (url "https://github.com/openmm/openmm")
1221 (commit version)))
1222 (file-name (git-file-name name version))
1223 (sha256
1224 (base32
1225 "0y62jg9jl4hrwgcpak6gm7pyvr509msx72a5yp2bqlqir2fa0qzn"))))
1226 (build-system cmake-build-system)
1227 (arguments
1228 (list
1229 #:configure-flags
1230 '(list "-DOPENMM_BUILD_SHARED_LIB=TRUE"
1231 "-DOPENMM_BUILD_REFERENCE_TESTS=FALSE" ;takes too long on ci
1232 "-DOPENMM_BUILD_C_AND_FORTRAN_WRAPPERS=TRUE"
1233 "-DOPENMM_BUILD_PYTHON_WRAPPERS=TRUE"
1234 "-DOPENMM_BUILD_CUDA_LIB=FALSE")
1235 #:phases
1236 #~(modify-phases %standard-phases
1237 (add-after 'unpack 'patch-wrappers-python-install
1238 (lambda _
1239 (substitute* "wrappers/python/CMakeLists.txt"
1240 (("install --root=\\\\\\$ENV\\{DESTDIR\\}/")
1241 (string-append "install --prefix=" #$output
1242 " --root=/ --single-version-externally-managed")))))
1243 (add-after 'unpack 'remove-shaky-tests
1244 (lambda _
1245 ;; These tests may unpredictably fail in CI, even passing
1246 ;; locally.
1247 (for-each delete-file
1248 (append '("./serialization/tests/TestSerializeIntegrator.cpp")
1249 (find-files "./platforms"
1250 (string-append "Test.*"
1251 "(BrownianIntegrat|"
1252 "LangevinIntegrator)"
1253 "\\.cpp$"))))))
1254 (add-after 'install 'install-python
1255 (lambda _
1256 (invoke "make" "PythonInstall"))))))
1257 (inputs
1258 (list python-wrapper))
1259 (propagated-inputs
1260 (list python-numpy))
1261 (native-inputs
1262 (list doxygen
1263 gfortran
1264 opencl-headers
1265 python-cython
1266 python-setuptools
1267 swig-4.4))
1268 (home-page "https://github.com/openmm/openmm/")
1269 (synopsis "Toolkit for molecular simulation")
1270 (description
1271 "OpenMM is a toolkit for molecular simulation. It can be used either as
1272a stand-alone application for running simulations, or as a library you call
1273from your own code.")
1274 ;; All licenses are listed in <docs-source/licenses/Licenses.txt>.
1275 (license (list license:cc-by3.0 ;PdbxReader
1276 license:expat ;API, Reference Platform, CPU Platform, VkFFT
1277 license:gpl3 ;Hilbert Curve
1278 license:lgpl3)))) ;CUDA and OpenCL Platforms
1279
1280(define-public r-rcppml/devel
1281 (let ((commit "2beac6580174f8f3ef4ac6fdb2ca2b65705d265a")
1282 (revision "3"))
1283 (package
1284 (name "r-rcppml-devel")
1285 (version (git-version "0.5.6" revision commit))
1286 (source (origin
1287 (method git-fetch)
1288 (uri (git-reference
1289 (url "https://github.com/zdebruine/RcppML")
1290 (commit commit)))
1291 (file-name (git-file-name name version))
1292 (sha256
1293 (base32
1294 "0nv4w2a31bhccblnp5jqylpf9dbbwv07mpkxma40gp8r12k6sv0r"))))
1295 (properties `((upstream-name . "RcppML")))
1296 (build-system r-build-system)
1297 ;; Reported here: https://github.com/zdebruine/RcppML/issues/71
1298 (arguments (list #:tests? #false))
1299 (propagated-inputs (list r-matrix r-rcpp))
1300 (native-inputs (list r-knitr r-testthat))
1301 (home-page "https://github.com/zdebruine/RcppML")
1302 (synopsis "Rcpp machine learning Library")
1303 (description
1304 "This package provides fast machine learning algorithms including
1305matrix factorization and divisive clustering for large sparse and dense
1306matrices.")
1307 (license license:gpl3+))))
1308
1309(define-public openfst
1310 (package
1311 (name "openfst")
1312 (version "1.8.4")
1313 (source (origin
1314 (method url-fetch)
1315 (uri (string-append "https://www.openfst.org/twiki/pub/FST/"
1316 "FstDownload/openfst-" version ".tar.gz"))
1317 (sha256
1318 (base32
1319 "05l057mx1cmbm2jm99mrg75qgz4ca5r78n002mkpxl4j7mpvpsx8"))))
1320 (build-system gnu-build-system)
1321 (arguments '(#:configure-flags '("--enable-ngram-fsts")))
1322 (home-page "https://www.openfst.org")
1323 (synopsis "Library for weighted finite-state transducers")
1324 (description "OpenFst is a library for constructing, combining,
1325optimizing, and searching weighted finite-state transducers (FSTs).")
1326 (license license:asl2.0)))
1327
1328(define openfst-for-vosk
1329 (package
1330 (inherit openfst)
1331 (version "1.8.0")
1332 (source
1333 (origin
1334 (method url-fetch)
1335 (uri (string-append "http://www.openfst.org/twiki/pub/FST/"
1336 "FstDownload/openfst-" version ".tar.gz"))
1337 (sha256
1338 (base32 "0h2lfhhihg63b804hrcljnkggijbjmp84i5g8q735wb09y9z2c4p"))
1339 (patches
1340 (search-patches "openfst-for-vosk-fix-unique-ptr.patch"))))
1341 (arguments
1342 '(#:configure-flags
1343 '("--enable-shared" "--enable-far" "--enable-ngram-fsts"
1344 "--enable-lookahead-fsts" "--with-pic" "--disable-bin")))))
1345
1346(define-public sentencepiece
1347 (package
1348 (name "sentencepiece")
1349 (version "0.2.1")
1350 (source
1351 (origin
1352 (method git-fetch)
1353 (uri
1354 (git-reference
1355 (url "https://github.com/google/sentencepiece/")
1356 (commit (string-append "v" version))))
1357 (file-name (git-file-name name version))
1358 (sha256
1359 (base32 "1yzsaam3kk9fqzxfc3nm2pskwq1bdgkrijmcmzmg5x0338rn0hmb"))))
1360 (build-system cmake-build-system)
1361 (arguments (list #:tests? #f)) ;no tests
1362 (native-inputs (list gperftools))
1363 (home-page "https://github.com/google/sentencepiece")
1364 (synopsis "Unsupervised tokenizer for Neural Network-based text generation")
1365 (description
1366 "SentencePiece is an unsupervised text tokenizer and detokenizer mainly
1367for Neural Network-based text generation systems where the vocabulary size is
1368predetermined prior to the neural model training. SentencePiece implements
1369subword units---e.g., byte-pair-encoding (BPE) and unigram language
1370model---with the extension of direct training from raw sentences.
1371SentencePiece allows us to make a purely end-to-end system that does not
1372depend on language-specific pre- or post-processing.")
1373 (license license:asl2.0)))
1374
1375(define-public stable-diffusion-cpp
1376 (package
1377 (name "stable-diffusion-cpp")
1378 (version "827-97d2990")
1379 (source
1380 (origin
1381 (method git-fetch)
1382 (uri (git-reference
1383 (url "https://github.com/leejet/stable-diffusion.cpp")
1384 (commit (string-append "master-" version))
1385 ;; For libwebm 1.0.0, libwepb 1.6.0, and custom fork of ggml.
1386 (recursive? #t)))
1387 (file-name (git-file-name name version))
1388 (sha256
1389 (base32 "1p9b8jvqsxd0dn8ccn0zhxs9nwqx3l20qbp9ybg2dirpja4i0xfm"))))
1390 (build-system cmake-build-system)
1391 (arguments
1392 (list
1393 #:tests? #f ;no tests
1394 ;; see docs/build.md
1395 #:configure-flags
1396 #~(list "-DSD_BUILD_SHARED_LIBS=ON")
1397 #:phases
1398 #~(modify-phases %standard-phases
1399 (add-before 'configure 'set-CXXFLAGS
1400 (lambda _
1401 (setenv "CXXFLAGS" "-DGGML_MAX_NAME=128"))))))
1402 (properties '((tunable? . #true))) ;use AVX512, FMA, etc. when available
1403 (home-page "https://github.com/leejet/stable-diffusion.cpp")
1404 (synopsis "Diffusion model inference in pure C/C++")
1405 (description
1406 "This package provides a Plain C/C++ implementation based
1407on ggml, working in the same way as llama.cpp. It supports diffusion models
1408such as SD, Flux, Wan, Qwen and Image,Z-Image.")
1409 (license license:expat)))
1410
1411(define-public python-hopcroftkarp
1412 ;; This commit fixes a broken import, but has not been released to PyPI.
1413 (let ((commit "2846e1dd3265d95d2bddb0cf4190b830cbb4efe6")
1414 (revision "1"))
1415 (package
1416 (name "python-hopcroftkarp")
1417 (version (git-version "1.2.5" revision commit))
1418 (source
1419 (origin
1420 (method git-fetch)
1421 (uri (git-reference
1422 (url "https://github.com/sofiatolaosebikan/hopcroftkarp")
1423 (commit commit)))
1424 (file-name (git-file-name name version))
1425 (sha256
1426 (base32 "018ilrp41fcclmb5lsml3aijwbmhbq3m7wy65hr1fryj0avic8fr"))))
1427 (build-system pyproject-build-system)
1428 (arguments (list #:test-backend #~'unittest))
1429 (native-inputs (list python-setuptools python-wheel))
1430 (home-page "https://github.com/sofiatolaosebikan/hopcroftkarp")
1431 (synopsis "Implementation of the Hopcroft-Karp algorithm")
1432 (description
1433 "This package implements the Hopcroft-Karp algorithm, producing a maximum
1434cardinality matching from a bipartite graph.")
1435 (license license:gpl3))))
1436
1437(define-public python-paramz
1438 (package
1439 (name "python-paramz")
1440 (version "0.10.0")
1441 (source
1442 (origin
1443 (method git-fetch)
1444 (uri (git-reference
1445 (url "https://github.com/sods/paramz")
1446 (commit (string-append "v" version))))
1447 (file-name (git-file-name name version))
1448 (sha256
1449 (base32 "0h7m7fzb88cx4f8qq2p34z3jv3f48b46pc11is6592zlmrdp67lf"))))
1450 (build-system pyproject-build-system)
1451 (arguments
1452 (list
1453 ;; tests: 114 passed, 4 skipped, 14 warnings
1454 #:test-flags
1455 ;; Compute instance test which times out.
1456 #~(list (string-append "--deselect=paramz/tests/model_tests.py"
1457 "::TestModel::test_optimize_restarts_parallel"))))
1458 (native-inputs
1459 (list python-pytest
1460 python-setuptools))
1461 (propagated-inputs
1462 (list python-decorator
1463 python-numpy
1464 python-scipy
1465 python-six)) ;hard dependency
1466 (home-page "https://github.com/sods/paramz")
1467 (synopsis "The Parameterization Framework")
1468 (description
1469 "@command{paramz} is a lightweight parameterization framework
1470for parameterized model creation and handling. Its features include:
1471
1472@itemize
1473 @item Easy model creation with parameters.
1474 @item Fast optimized access of parameters for optimization routines.
1475 @item Memory efficient storage of parameters (only one copy in memory).
1476 @item Renaming of parameters.
1477 @item Intuitive printing of models and parameters.
1478 @item Gradient saving directly inside parameters.
1479 @item Gradient checking of parameters.
1480 @item Optimization of parameters.
1481 @item Jupyter notebook integration.
1482 @item Efficient storage of models, for reloading.
1483 @item Efficient caching.
1484@end itemize")
1485 (license license:bsd-3)))
1486
1487(define-public python-persim
1488 (package
1489 (name "python-persim")
1490 (version "0.3.8")
1491 (source
1492 (origin
1493 (method url-fetch)
1494 (uri (pypi-uri "persim" version))
1495 (sha256
1496 (base32 "03d4kgakpgj54c3pl9dkqrkbmj6w13gmczkds5jagf3n85c1hgg1"))))
1497 (build-system pyproject-build-system)
1498 (native-inputs
1499 (list python-pytest python-setuptools))
1500 (propagated-inputs
1501 (list python-deprecated
1502 python-hopcroftkarp
1503 python-joblib
1504 python-matplotlib
1505 python-numpy
1506 python-scikit-learn
1507 python-scipy))
1508 (home-page "https://persim.scikit-tda.org")
1509 (synopsis "Tools for analyzing persistence diagrams in Python")
1510 (description
1511 "This package includes a variety of tools used to analyze persistence diagrams.
1512It currently houses implementations of
1513@itemize
1514@item Persistence images
1515@item Persistence landscapes
1516@item Bottleneck distance
1517@item Modified Gromov–Hausdorff distance
1518@item Sliced Wasserstein kernel
1519@item Heat kernel
1520@item Diagram plotting
1521@end itemize
1522")
1523 (license license:expat))) ; MIT License
1524
1525(define-public python-pomegranate
1526 (package
1527 (name "python-pomegranate")
1528 (version "1.1.0")
1529 (source
1530 (origin
1531 (method git-fetch)
1532 (uri (git-reference
1533 (url "https://github.com/jmschrei/pomegranate")
1534 (commit (string-append "v" version))))
1535 (file-name (git-file-name name version))
1536 (sha256
1537 (base32 "0arx5wik4ywna7k7g5y3ggwz98fl1hgap0278pph3c77ap8afqd7"))))
1538 (build-system pyproject-build-system)
1539 (arguments
1540 (list
1541 ;; tests: 830 passed, 19 deselected, 529 warnings
1542 #:test-flags
1543 #~(list #$@(map (lambda (test) (string-append "--deselect="
1544 "tests/distributions/"
1545 test))
1546 ;; _pickle.UnpicklingError: Weights only load failed.
1547 (list "test_bernoulli.py::test_serialization"
1548 "test_categorical.py::test_serialization"
1549 "test_exponential.py::test_serialization"
1550 "test_gamma.py::test_serialization"
1551 "test_independent_component.py::test_serialization"
1552 "test_normal_diagonal.py::test_serialization"
1553 "test_normal_full.py::test_serialization"
1554 "test_poisson.py::test_serialization"
1555 "test_student_t.py::test_serialization"
1556 "test_uniform.py::test_serialization"
1557 ;; Arrays are not almost equal to 3 decimals
1558 "test_categorical.py::test_sample"
1559 "test_independent_component.py::test_sample"
1560 "test_joint_categorical.py::test_sample"
1561 "test_joint_categorical.py::test_sample"))
1562 #$@(map (lambda (test) (string-append "--deselect="
1563 "tests/"
1564 test))
1565 ;; _pickle.UnpicklingError: Weights only load failed.
1566 (list "test_bayes_classifier.py::test_serialization"
1567 "test_gmm.py::test_serialization"
1568 "test_kmeans.py::test_serialization"
1569 ;; Arrays are not almost equal to 3 decimals
1570 "test_bayesian_network.py::test_sample"
1571 "test_gmm.py::test_sample"
1572 "test_markov_chain.py::test_sample"
1573 "test_markov_chain.py::test_sample")))))
1574 (native-inputs
1575 (list python-cython
1576 python-pytest
1577 python-setuptools))
1578 (propagated-inputs
1579 (list python-apricot-select
1580 python-networkx
1581 python-numpy
1582 python-scikit-learn
1583 python-scipy
1584 python-pytorch))
1585 (home-page "https://pypi.python.org/pypi/pomegranate/")
1586 (synopsis "Graphical models library for Python")
1587 (description
1588 "Pomegranate is a graphical models library for Python, implemented in
1589Cython for speed.")
1590 (license license:expat)))
1591
1592(define-public python-pot
1593 (package
1594 (name "python-pot")
1595 (version "0.9.7.post1")
1596 (source
1597 (origin
1598 (method git-fetch)
1599 (uri (git-reference
1600 (url "https://github.com/PythonOT/POT")
1601 (commit version)))
1602 (file-name (git-file-name name version))
1603 (sha256
1604 (base32 "1pcsvxsmilz3xwa8lm5cgllbjjrx9q92nxm2vmb8jlwhh56wan0g"))))
1605 (build-system pyproject-build-system)
1606 ;; tests: 1885 passed, 60 skipped, 6 xfailed, 9288 warnings
1607 (arguments
1608 (list
1609 #:phases
1610 #~(modify-phases %standard-phases
1611 (add-after 'unpack 'use-system-eigen
1612 (lambda* (#:key inputs #:allow-other-keys)
1613 (substitute* "setup.py"
1614 (("os\\.path\\.join\\(ROOT, \"deps/eigen\"\\)")
1615 (format #f "~s"
1616 (search-input-directory inputs
1617 "include/eigen3")))))))))
1618 (native-inputs
1619 (list python-cython
1620 python-pytest
1621 python-setuptools))
1622 (inputs
1623 (list eigen))
1624 (propagated-inputs
1625 (list python-numpy
1626 python-scipy
1627 ;; [optional]
1628 python-autograd
1629 python-cvxopt
1630 ;; python-jax
1631 ;; python-jaxlib
1632 python-matplotlib
1633 python-pymanopt
1634 python-pytorch
1635 python-pytorch-geometric
1636 python-scikit-learn))
1637 (home-page "https://github.com/PythonOT/POT")
1638 (synopsis "Python Optimal Transport Library")
1639 (description
1640 "This Python library provides several solvers for optimization problems
1641related to Optimal Transport for signal, image processing and machine
1642learning.")
1643 (license license:expat)))
1644
1645(define-public python-pymanopt
1646 (package
1647 (name "python-pymanopt")
1648 (version "2.2.1")
1649 (source
1650 (origin
1651 (method url-fetch)
1652 (uri (pypi-uri "pymanopt" version))
1653 (sha256
1654 (base32 "1nm1yz5hbj1valqq23r8c1g9rhfdndfswlqv6xrnvc3f8fd95167"))))
1655 (build-system pyproject-build-system)
1656 (arguments
1657 (list
1658 ;; Tests require jax and tensorflow, which are optional.
1659 #:tests? #false
1660 #:phases
1661 '(modify-phases %standard-phases
1662 ;; This is probably a bad idea. We don't have scipy 1.13 just yet.
1663 (add-after 'unpack 'relax-requirements
1664 (lambda _
1665 (substitute* "pyproject.toml"
1666 ((",!=1.12\\.\\*") "")))))))
1667 (propagated-inputs (list python-numpy python-scipy))
1668 (native-inputs (list python-autograd
1669 python-matplotlib
1670 python-pytest
1671 python-setuptools
1672 python-setuptools-scm
1673 python-wheel))
1674 (home-page "https://pymanopt.org/")
1675 (synopsis "Toolbox for optimization on Riemannian manifolds")
1676 (description
1677 "This package is a toolbox for optimization on Riemannian manifolds with
1678support for automatic differentiation.")
1679 (license license:bsd-3)))
1680
1681(define-public python-ripser
1682 (package
1683 (name "python-ripser")
1684 (version "0.6.14")
1685 (source
1686 (origin
1687 (method git-fetch)
1688 (uri (git-reference
1689 (url "https://github.com/scikit-tda/ripser.py")
1690 (commit (string-append "v" version))))
1691 (file-name (git-file-name name version))
1692 (sha256
1693 (base32
1694 "00na7dpvpc5vwjwgh9ndqrqlswgrzgqf1s7rxfv1vy5wn63fz3m7"))))
1695 (build-system pyproject-build-system)
1696 (propagated-inputs (list python-numpy python-persim python-scikit-learn
1697 python-scipy))
1698 (native-inputs
1699 (list python-cython
1700 python-pytest
1701 python-setuptools))
1702 (home-page "https://ripser.scikit-tda.org")
1703 (synopsis "Persistent homology library for Python")
1704 (description
1705 "This package implements a variety of persistent homology algorithms. It
1706provides an interface for
1707@itemize
1708@item computing persistence cohomology of sparse and dense data sets
1709@item visualizing persistence diagrams
1710@item computing lowerstar filtrations on images
1711@item computing representative cochains
1712@end itemize
1713")
1714 (license license:expat))) ; MIT License
1715
1716(define-public python-sacrebleu
1717 (package
1718 (name "python-sacrebleu")
1719 (version "2.6.0")
1720 (source (origin
1721 (method git-fetch)
1722 (uri (git-reference
1723 (url "https://github.com/mjpost/sacrebleu")
1724 (commit (string-append "v" version))))
1725 (file-name (git-file-name name version))
1726 (sha256
1727 (base32
1728 "0d1s5f4cv668cjpz7zjxl0mjn7jhl6b0y9mx3cf78frzszglvya7"))))
1729 (build-system pyproject-build-system)
1730 (arguments
1731 (list
1732 #:test-flags
1733 ;; These all need internet access.
1734 '(list "-k" "not test_api_get_source \
1735and not test_api_get_reference \
1736and not test_maybe_download \
1737and not test_process_to_text \
1738and not test_get_files_and_fieldnames \
1739and not test_source_and_references \
1740and not test_wmt22_references")
1741 #:phases
1742 '(modify-phases %standard-phases
1743 ;; Needed for tests.
1744 (add-before 'check 'set-HOME
1745 (lambda _ (setenv "HOME" "/tmp"))))))
1746 (propagated-inputs (list python-colorama
1747 python-lxml
1748 python-numpy
1749 python-portalocker
1750 python-regex
1751 python-tabulate))
1752 (native-inputs (list python-pytest python-setuptools python-setuptools-scm))
1753 (home-page "https://github.com/mjpost/sacrebleu")
1754 (synopsis
1755 "Compute shareable, comparable, and reproducible BLEU, chrF, and TER scores")
1756 (description
1757 "This is a package for hassle-free computation of shareable, comparable,
1758and reproducible BLEU, chrF, and TER scores for natural language processing.")
1759 (license license:asl2.0)))
1760
1761(define-public python-safetensors
1762 (package
1763 (name "python-safetensors")
1764 (version "0.4.3")
1765 (source
1766 (origin
1767 (method url-fetch)
1768 (uri (pypi-uri "safetensors" version))
1769 (sha256
1770 (base32 "1hhiwy67jarm70l0k26fs1cjhzkgzrh79q14bklj2yp0qi8gr19g"))
1771 (modules '((guix build utils)
1772 (ice-9 ftw)))
1773 (snippet
1774 #~(begin ;Only keep bindings.
1775 (for-each
1776 (lambda (file)
1777 (unless (member file '("." ".." "bindings" "PKG-INFO"))
1778 (delete-file-recursively file)))
1779 (scandir "."))
1780 (for-each
1781 (lambda (file)
1782 (unless (member file '("." ".."))
1783 (rename-file (string-append "bindings/python/" file)
1784 file)))
1785 (scandir "bindings/python"))
1786 (substitute* "Cargo.toml"
1787 (("^path = .*") ""))))))
1788 (build-system cargo-build-system)
1789 (arguments
1790 (list
1791 #:install-source? #f
1792 #:phases
1793 #~(modify-phases %standard-phases
1794 (add-before 'check 'install-rust-library
1795 (lambda _
1796 (copy-file "target/release/libsafetensors_rust.so"
1797 "py_src/safetensors/_safetensors_rust.so")))
1798 (replace 'check
1799 (lambda* (#:key tests? #:allow-other-keys)
1800 (when tests?
1801 (setenv "PYTHONPATH" (string-append (getcwd) "/py_src"))
1802 (invoke "python3"
1803 "-m" "pytest"
1804 "-n" "auto"
1805 "--dist=loadfile"
1806 "-s" "-v" "./tests/"
1807 ;; Missing jax and tensorflow dependency
1808 "--ignore=./tests/test_flax_comparison.py"
1809 "--ignore=./tests/test_tf_comparison.py"))))
1810 (add-after 'install 'install-python
1811 (lambda _
1812 (let* ((pversion #$(version-major+minor
1813 (package-version python)))
1814 (lib (string-append #$output "/lib/python" pversion
1815 "/site-packages/"))
1816 (info (string-append lib "safetensors-"
1817 #$(package-version this-package)
1818 ".dist-info")))
1819 (mkdir-p info)
1820 (copy-file "PKG-INFO" (string-append info "/METADATA"))
1821 (copy-recursively
1822 "py_src/safetensors"
1823 (string-append lib "safetensors"))))))))
1824 (inputs
1825 (cargo-inputs 'python-safetensors))
1826 (native-inputs
1827 (list python-h5py
1828 python-minimal
1829 python-numpy
1830 python-pytest
1831 python-pytest-xdist
1832 python-pytorch))
1833 (home-page "https://huggingface.co/docs/safetensors")
1834 (synopsis "Simple and safe way to store and distribute tensors")
1835 (description
1836 "This package provides a fast (zero-copy) and safe (dedicated) format for
1837storing tensors safely.")
1838 (license license:asl2.0)))
1839
1840(define-public python-sentencepiece
1841 (package
1842 (inherit sentencepiece)
1843 (name "python-sentencepiece")
1844 (build-system pyproject-build-system)
1845 (arguments
1846 (list
1847 #:phases
1848 #~(modify-phases %standard-phases
1849 (add-after 'unpack 'chdir
1850 (lambda _
1851 (chdir "python"))))))
1852 (native-inputs
1853 (list pkg-config protobuf python-pytest python-setuptools))
1854 (propagated-inputs (list sentencepiece))
1855 (synopsis "SentencePiece python wrapper")
1856 (description "This package provides a Python wrapper for the SentencePiece
1857unsupervised text tokenizer.")))
1858
1859(define-public python-sentence-transformers
1860 (package
1861 (name "python-sentence-transformers")
1862 (version "5.5.0")
1863 (source
1864 (origin
1865 (method git-fetch)
1866 (uri (git-reference
1867 (url "https://github.com/UKPLab/sentence-transformers/")
1868 (commit (string-append "v" version))))
1869 (file-name (git-file-name name version))
1870 (sha256
1871 (base32
1872 "0x6b6gvsasdmm40gr5ld5gwxggpb2j285jv4scvws1bp2s193k9i"))))
1873 (build-system pyproject-build-system)
1874 (arguments
1875 (list #:tests? #f)) ;network access is required
1876 (propagated-inputs (list python-huggingface-hub
1877 python-numpy
1878 python-pillow
1879 python-pytorch
1880 python-typing-extensions
1881 python-scikit-learn
1882 python-scipy
1883 python-tqdm
1884 python-transformers))
1885 (native-inputs (list python-setuptools))
1886 (home-page "https://www.SBERT.net")
1887 (synopsis "Multilingual text embeddings")
1888 (description "This framework provides an easy method to compute dense
1889vector representations for sentences, paragraphs, and images. The models are
1890based on transformer networks like BERT / RoBERTa / XLM-RoBERTa and achieve
1891state-of-the-art performance in various tasks. Text is embedded in vector
1892space such that similar text are closer and can efficiently be found using
1893cosine similarity.
1894
1895This package provides easy access to pretrained models for more than 100
1896languages, fine-tuned for various use-cases.
1897
1898Further, this framework allows an easy fine-tuning of custom embeddings
1899models, to achieve maximal performance on your specific task.")
1900 (license license:asl2.0)))
1901
1902(define-public python-spacy-legacy
1903 (package
1904 (name "python-spacy-legacy")
1905 (version "3.0.12")
1906 (source (origin
1907 (method url-fetch)
1908 (uri (pypi-uri "spacy-legacy" version))
1909 (sha256
1910 (base32
1911 "0x57aw1qgjrzgapsv1cwymqlck2anqm1bisvryhpq7bfkc66wzdk"))))
1912 (build-system pyproject-build-system)
1913 ;; This package depends on spacy, which depends on this package.
1914 (arguments (list #:tests? #false))
1915 (native-inputs (list python-pytest python-setuptools python-wheel))
1916 (home-page "https://spacy.io")
1917 (synopsis "Legacy registered functions for spaCy backwards compatibility")
1918 (description
1919 "This package contains legacy registered functions for spaCy backwards
1920compatibility.")
1921 (license license:expat)))
1922
1923(define-public python-spacy-loggers
1924 (package
1925 (name "python-spacy-loggers")
1926 (version "1.0.4")
1927 (source (origin
1928 (method url-fetch)
1929 (uri (pypi-uri "spacy-loggers" version))
1930 (sha256
1931 (base32
1932 "0a5zjfxd0mci7pwda24ihg55whalpmjby4bvpgar2013f6zq7yg6"))))
1933 (build-system pyproject-build-system)
1934 ;; This package depends on spacy, which depends on this package.
1935 (arguments (list #:tests? #false))
1936 (native-inputs (list python-pytest python-setuptools python-wheel))
1937 (home-page "https://github.com/explosion/spacy-loggers")
1938 (synopsis "Logging utilities for SpaCy")
1939 (description "This package provides logging utilities for the SpaCy
1940natural language processing framework.")
1941 (license license:expat)))
1942
1943(define-public python-spacy
1944 (package
1945 (name "python-spacy")
1946 (version "3.8.14")
1947 (source
1948 (origin
1949 (method git-fetch)
1950 (uri (git-reference
1951 (url "https://github.com/explosion/spaCy")
1952 (commit (string-append "release-v" version))))
1953 (file-name (git-file-name name version))
1954 (sha256
1955 (base32 "0inb1x7gmf1j7kcr35v472hia4lkn1qr234snqkz27rqglzhvmy3"))))
1956 (build-system pyproject-build-system)
1957 (arguments
1958 (list
1959 ;; tests: 3605 passed, 1232 skipped, 6 deselected, 24 xfailed, 7
1960 ;; xpassed, 5 subtests passed
1961 #:test-flags
1962 #~(list #$@(map (lambda (test)
1963 (string-append "--deselect=tests/" test))
1964 (list
1965 ;; Fail to compare setup.cfg and requirements.txt
1966 ;; versions.
1967 "package/test_requirements.py::test_build_dependencies"
1968 ;; Result
1969 ;; DeprecationWarning('datetime.datetime.utcfromtimestamp()
1970 ;; is deprecated and scheduled for removal in a future
1971 ;; version. Use timezone-aware objects to represent
1972 ;; datetimes in UTC:
1973 ;; datetime.datetime.fromtimestamp(timestamp,
1974 ;; datetime.UTC).'
1975 "test_cli_app.py::test_project_assets"
1976 "test_cli_app.py::test_project_push_pull"
1977 ;; AssertionError: Registry 'loggers' missing entries.
1978 "test_registry_population.py::test_registry_entries"
1979 ;; Tests require network access.
1980 "test_cli.py::test_download_compatibility"
1981 "test_cli.py::test_validate_compatibility_table")))
1982 #:phases
1983 #~(modify-phases %standard-phases
1984 (add-before 'check 'remove-local-spacy
1985 (lambda _
1986 (copy-recursively "spacy/tests" "tests")
1987 ;; This would otherwise interfere with finding the installed
1988 ;; spacy when running tests.
1989 (delete-file-recursively "spacy"))))))
1990 (propagated-inputs (list python-catalogue
1991 python-cymem
1992 python-jinja2
1993 python-murmurhash
1994 python-numpy
1995 python-preshed
1996 python-pydantic
1997 python-requests
1998 python-spacy-legacy
1999 python-spacy-loggers
2000 python-srsly
2001 python-thinc
2002 python-tqdm
2003 python-typer
2004 python-wasabi
2005 python-weasel))
2006 (native-inputs
2007 (list python-cython
2008 python-pytest
2009 python-mock
2010 python-setuptools))
2011 (home-page "https://spacy.io")
2012 (synopsis "Natural Language Processing (NLP) in Python")
2013 (description
2014 "SpaCy is a library for advanced Natural Language Processing in Python
2015and Cython. It comes with pretrained pipelines and currently supports
2016tokenization and training for 70+ languages. It features state-of-the-art
2017speed and neural network models for tagging, parsing, named entity
2018recognition, text classification and more, multi-task learning with pretrained
2019transformers like BERT, as well as a production-ready training system and easy
2020model packaging, deployment and workflow management.")
2021 (license license:expat)))
2022
2023(define-public python-stanza
2024 (package
2025 (name "python-stanza")
2026 (version "1.10.1")
2027 (source
2028 (origin
2029 (method git-fetch)
2030 (uri (git-reference
2031 (url "https://github.com/stanfordnlp/stanza")
2032 (commit (string-append "v" version))))
2033 (sha256
2034 (base32 "0zcpzmbv0aafircl12m3x5999hxpg2hzm1xxv97pz09y4v589snj"))))
2035 (build-system pyproject-build-system)
2036 (arguments
2037 (list
2038 #:phases
2039 #~(modify-phases %standard-phases
2040 (add-before 'check 'set-up-check
2041 (lambda _
2042 ;; Cherry pick from stanza/tests/setup.py,
2043 ;; which downloads many datasets
2044 (mkdir-p "stanza_test/out")
2045 (copy-file "stanza/tests/data/example_french.json"
2046 "stanza_test/out/example_french.json"))))
2047 ;; tests: 288 passed, 361 deselected, 1 warning
2048 #:test-flags
2049 #~(list
2050 "-k"
2051 (string-join
2052 '("not CoreNLP" "EnglishPipeline" "FrenchPipeline"
2053 "SentimentPipeline" "TestTrainer"
2054 "amt_annotator" "arabic_pos" "bert"
2055 "charlm" "conllu" "convert_units"
2056 "data_objects" "defaultdict_config"
2057 "depparse" "dictionary" "download"
2058 "ensemble" "example" "finetune" "install"
2059 "langid" "lemmatizer" "long_paragraph" "long_tokens"
2060 "model" "morphology" "multilingual" "mwt"
2061 "pipeline_" "pretrain" "process_doc"
2062 "read_snippets" "register" "reload"
2063 "requirements" "resources" "retag"
2064 "score" "semgrex" "serialized" "server_" "ssurgeon"
2065 "tagger" "test_core" "test_one_sentence" "test_tokenizer"
2066 "text_processing" "tokenize_files" "tokensregex"
2067 "train_pipeline" "training" "tsurgeon")
2068 " and not ") ;exclude tests requiring datasets
2069 "stanza/tests")))
2070 (native-inputs (list python-pytest
2071 python-setuptools
2072 python-transformers))
2073 (propagated-inputs (list python-emoji
2074 python-networkx
2075 python-numpy
2076 python-protobuf
2077 python-pytorch
2078 python-requests
2079 python-tqdm))
2080 (home-page "https://stanfordnlp.github.io/stanza/")
2081 (synopsis "Stanford NLP Python library for many human languages")
2082 (description
2083 "Stanza is a collection of accurate and efficient tools
2084for the linguistic analysis of many human languages. Starting from raw text,
2085Stanza divides it into sentences and words, and then can recognize
2086parts of speech and entities, do syntactic analysis, and more.")
2087 (license license:asl2.0)))
2088
2089(define-public onnx
2090 (package
2091 (name "onnx")
2092 (version "1.17.0")
2093 (source (origin
2094 (method git-fetch)
2095 (uri (git-reference
2096 (url "https://github.com/onnx/onnx")
2097 (commit (string-append "v" version))))
2098 (sha256
2099 (base32
2100 "1i6bh4z2xzz1maykr0xmrwfybm6i3g38vnx7hsls8hr58rdr30zn"))
2101 (file-name (git-file-name name version))
2102 (patches (search-patches
2103 "onnx-shared-libraries.patch"
2104 "onnx-skip-model-downloads.patch"))
2105 (modules '((guix build utils)))
2106 (snippet '(delete-file-recursively "third_party"))))
2107 (build-system pyproject-build-system)
2108 (arguments
2109 (list
2110 ;; python-nbval depends transitively on Rust.
2111 #:tests?
2112 (->bool (member (or (%current-target-system)
2113 (%current-system))
2114 (package-transitive-supported-systems python-nbval)))
2115 ;; tests: 4610 passed, 3044 skipped, 7 deselected, 13 warnings, 98
2116 ;; subtests passed
2117 #:test-flags
2118 ;; XXX: Onnx is on old version and might need to be updated, see:
2119 ;; <https://codeberg.org/guix/guix/issues/9443>.
2120 #~(list #$@(map (lambda (ls) (string-append "--deselect=onnx/"
2121 (string-join ls "::")))
2122 '(("test/test_backend_reference.py"
2123 "OnnxBackendNodeModelTest"
2124 "test_affine_grid_2d_align_corners_expanded_cpu")
2125 ("test/test_backend_reference.py"
2126 "OnnxBackendNodeModelTest"
2127 "test_affine_grid_2d_expanded_cpu")
2128 ("test/test_backend_reference.py"
2129 "OnnxBackendNodeModelTest"
2130 "test_affine_grid_3d_align_corners_expanded_cpu")
2131 ("test/test_backend_reference.py"
2132 "OnnxBackendNodeModelTest"
2133 "test_affine_grid_3d_expanded_cpu")
2134 ("test/tools_test.py" "TestToolsFunctions"
2135 "test_replace_range")
2136 ("test/tools_test.py"
2137 "TestToolsFunctions" "test_replace_range_function")
2138 ("test/tools_test.py"
2139 "TestToolsFunctions" "test_replace_range_graph"))))
2140 #:phases
2141 #~(modify-phases %standard-phases
2142 (add-before 'build 'pass-cmake-arguments
2143 (lambda* (#:key outputs tests? #:allow-other-keys)
2144 ;; For derived package use
2145 (substitute* "CMakeLists.txt"
2146 (("set\\(ONNX_ROOT.*") "")
2147 (("\\$\\{ROOT_DIR\\}(/tools.*)" _ rest)
2148 (string-append "${PROJECT_SOURCE_DIR}" rest)))
2149 ;; Pass options to the CMake-based build process.
2150 (define out
2151 (assoc-ref outputs "out"))
2152
2153 (define args
2154 ;; Copy arguments from 'cmake-build-system', plus ask
2155 ;; for shared libraries.
2156 (list "-DCMAKE_BUILD_TYPE=RelWithDebInfo"
2157 (string-append "-DCMAKE_INSTALL_PREFIX=" out)
2158 "-DCMAKE_INSTALL_LIBDIR=lib"
2159 "-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE"
2160 (string-append "-DCMAKE_INSTALL_RPATH=" out
2161 "/lib")
2162 "-DCMAKE_VERBOSE_MAKEFILE=ON"
2163 (string-append "-DONNX_BUILD_TESTS="
2164 (if tests? "ON" "OFF"))
2165 "-DBUILD_SHARED_LIBS=ON"
2166 "-DONNX_USE_PROTOBUF_SHARED_LIBS=ON"
2167 (string-append
2168 "-DONNX_ROOT=" #$(package-source this-package))))
2169
2170 ;; This environment variable is honored by 'setup.py',
2171 ;; which passes it down to 'cmake'.
2172 (setenv "CMAKE_ARGS" (string-join args))
2173
2174 ;; This one is honored by 'setup.py' and passed to 'make -j'.
2175 (setenv "MAX_JOBS"
2176 (number->string (parallel-job-count)))))
2177 (add-before 'check 'make-test-directory-writable
2178 (lambda _
2179 ;; Make things writable for tests.
2180 (setenv "HOME" (getcwd))
2181 (for-each make-file-writable
2182 (find-files "onnx/examples" "."
2183 #:directories? #t))))
2184 (add-after 'install 'install-from-cmake
2185 (lambda _
2186 ;; Run "make install" in the build tree 'setup.py'
2187 ;; created for CMake so that libonnx.so,
2188 ;; libonnx_proto.so, etc. are installed.
2189 (invoke "make" "install"
2190 "-C" ".setuptools-cmake-build"))))))
2191 (native-inputs
2192 (append
2193 (list cmake-minimal
2194 googletest
2195 pybind11-2
2196 python-fb-re2
2197 python-parameterized
2198 python-pytest
2199 python-setuptools
2200 python-wheel)
2201 (filter
2202 (lambda (pkg)
2203 (member (or (%current-target-system)
2204 (%current-system))
2205 (package-transitive-supported-systems pkg)))
2206 (list python-nbval))))
2207 (inputs
2208 (list protobuf))
2209 (propagated-inputs
2210 (list python-numpy python-protobuf python-six python-tabulate
2211 python-typing-extensions))
2212 (home-page "https://onnx.ai/")
2213 (synopsis "Open Neural Network Exchange")
2214 (description
2215 "@acronym{ONNX, Open Neural Network Exchange} is a format for AI models,
2216both deep learning and traditional @acronym{ML, machine learning}. It defines
2217an extensible computation graph model, as well as definitions of built-in
2218operators and standard data types.")
2219 (license license:expat)))
2220
2221(define-public onnx-for-onnxruntime
2222 (package
2223 (inherit onnx)
2224 (name "onnx-for-onnxruntime")
2225 (source
2226 (origin
2227 (inherit (package-source onnx))
2228 (patches (append (search-patches "onnx-1.17.0-for-onnxruntime.patch")
2229 (origin-patches (package-source onnx))))))
2230 ;; Use cmake-build-system instead of pyproject-build-system so that
2231 ;; only the C++ static library is built and installed. The Python
2232 ;; onnx package (with schemas registered) is provided by regular
2233 ;; onnx; this variant has ONNX_DISABLE_STATIC_REGISTRATION=ON which
2234 ;; would break onnx.shape_inference if its Python files ended up on
2235 ;; PYTHONPATH.
2236 (build-system cmake-build-system)
2237 (arguments
2238 (list
2239 #:tests? #f ; tests fail without schema registration
2240 #:configure-flags
2241 #~(list "-DBUILD_SHARED_LIBS=OFF"
2242 "-DONNX_USE_PROTOBUF_SHARED_LIBS=OFF"
2243 ;; Disable ONNX's schema registration so onnxruntime
2244 ;; handles it. See
2245 ;; <https://onnxruntime.ai/docs/build/dependencies.html>.
2246 "-DONNX_DISABLE_STATIC_REGISTRATION=ON"
2247 "-DONNX_BUILD_TESTS=OFF"
2248 "-DONNX_BUILD_BENCHMARKS=OFF"
2249 "-DONNX_ML=ON"
2250 "-DONNX_USE_LITE_PROTO=OFF"
2251 "-DBUILD_ONNX_PYTHON=OFF")))
2252 (inputs (list protobuf-static-for-onnxruntime))
2253 (native-inputs (list python-minimal-wrapper pybind11))
2254 (propagated-inputs '())
2255 (description
2256 "This variant of the ONNX package is built as a static C++ library
2257with schema registration disabled, for linking into onnxruntime. It
2258should not be used standalone.")))
2259
2260(define-public onnx-optimizer
2261 (package
2262 (name "onnx-optimizer")
2263 ;; Note: 0.3.x is *more* recent than 1.5.0.
2264 (version "0.3.19")
2265 (home-page "https://github.com/onnx/optimizer")
2266 (source (origin
2267 (method git-fetch)
2268 (uri (git-reference
2269 (url home-page)
2270 (commit (string-append "v" version))))
2271 (sha256
2272 (base32
2273 "1mx3hsl42na6fr05nh2x3j9kxm56cpfmwk6lwl2cfq9zs3gv929w"))
2274 (file-name (git-file-name name version))
2275 (patches (search-patches "onnx-optimizer-system-library.patch"))
2276 (modules '((guix build utils)))
2277 (snippet '(delete-file-recursively "third_party"))))
2278 (build-system pyproject-build-system)
2279 (arguments
2280 ;; reuse build system tweaks
2281 (substitute-keyword-arguments (package-arguments onnx)
2282 ((#:phases phases)
2283 #~(modify-phases #$phases
2284 (add-after 'pass-cmake-arguments
2285 'pass-onnx-optimizer-cmake-arguments
2286 (lambda _
2287 (setenv
2288 "CMAKE_ARGS"
2289 (string-append
2290 (getenv "CMAKE_ARGS")
2291 " -DONNX_OPT_USE_SYSTEM_PROTOBUF=ON"
2292 " -DCMAKE_CXX_FLAGS=\"-DONNX_ML=1 -DONNX_NAMESPACE=onnx\""))))
2293 (replace 'check
2294 (lambda* (#:key tests? #:allow-other-keys)
2295 (if tests?
2296 (invoke "pytest" "-vv" "-k"
2297 ;; These tests fail with upstream ONNX:
2298 ;; https://github.com/onnx/optimizer/issues/138
2299 (string-append
2300 "not test_fuse_matmul"
2301 " and not test_fuse_consecutive"
2302 " and not test_fuse_transpose")))))))))
2303 (native-inputs
2304 (append
2305 (list cmake-minimal
2306 python-pytest
2307 python-setuptools)
2308 (filter
2309 (lambda (pkg)
2310 (member (or (%current-target-system)
2311 (%current-system))
2312 (package-transitive-supported-systems pkg)))
2313 (list python-nbval))))
2314 (inputs
2315 ;; Must use the same protobuf as onnx to avoid loading two protobuf
2316 ;; libraries causing duplicate schema registration.
2317 (list onnx protobuf pybind11-2))
2318 (propagated-inputs
2319 (list python-numpy))
2320 (synopsis "Library to optimize ONNX models")
2321 (description
2322 "This package provides a C++ and Python library for performing arbitrary
2323optimizations on ONNX models, as well as a growing list of prepackaged
2324optimization passes.
2325
2326Not all possible optimizations can be directly implemented on ONNX graphs---
2327some will need additional backend-specific information---but many can, and the
2328aim is to provide all such passes along with ONNX so that they can be re-used
2329with a single function call.")
2330 (license license:expat)))
2331
2332(define-public onnxruntime
2333 (package
2334 (name "onnxruntime")
2335 (version "1.22.0")
2336 (source
2337 (origin
2338 (method git-fetch)
2339 (uri (git-reference
2340 (url "https://github.com/microsoft/onnxruntime")
2341 (commit (string-append "v" version))))
2342 (file-name (git-file-name name version))
2343 (sha256
2344 (base32 "0z2s79l4wdilssw9lmj319ypyyqi2y0dx0fpwr2yhq8bax3ci50n"))
2345 (patches
2346 (search-patches
2347 ;; SplitToSequence operator was missing bool type support, despite
2348 ;; the ONNX spec allowing it in models. Fixed upstream in 1.23+,
2349 ;; but we cannot upgrade because ROCm support was removed in 1.23.
2350 ;; <https://github.com/microsoft/onnxruntime/pull/24929>
2351 "onnxruntime-1.22.0-splittosequence-bool.patch"))))
2352 (build-system cmake-build-system)
2353 (arguments
2354 (list
2355 #:modules '((guix build cmake-build-system)
2356 (guix build utils)
2357 ((guix build pyproject-build-system) #:prefix py:))
2358 #:imported-modules (append %cmake-build-system-modules
2359 %pyproject-build-system-modules)
2360 #:configure-flags
2361 #~(list "-Donnxruntime_BUILD_UNIT_TESTS=OFF"
2362 "-Donnxruntime_BUILD_SHARED_LIB=ON"
2363 "-Donnxruntime_ENABLE_LTO=ON"
2364 "-Donnxruntime_ENABLE_PYTHON=ON"
2365 "-Donnxruntime_USE_FULL_PROTOBUF=ON"
2366 ;; Link static protobuf, matching upstream's vcpkg approach.
2367 ;; This keeps the protobuf descriptor pool inside
2368 ;; onnxruntime_pybind11_state.so separate from the shared
2369 ;; libprotobuf.so used by the regular onnx Python package.
2370 "-DProtobuf_USE_STATIC_LIBS=ON"
2371 ;; XXX: Fixes build with gcc@14.
2372 "-DCMAKE_CXX_FLAGS=-Wl,-z,noexecstack")
2373 #:phases
2374 #~(modify-phases %standard-phases
2375 (add-after 'unpack 'chdir
2376 (lambda _
2377 (chdir "cmake")))
2378 (add-after 'unpack 'relax-dependencies
2379 (lambda _
2380 (with-output-to-file "cmake/external/eigen.cmake"
2381 (lambda _
2382 (display "find_package(Eigen3 REQUIRED)\n")))
2383 (substitute* "cmake/external/abseil-cpp.cmake"
2384 (("20240722")
2385 (car (string-split #$(package-version
2386 (this-package-input "abseil-cpp"))
2387 #\.))))))
2388 (add-after 'unpack 'fix-numpy
2389 ;; Prevent TypeError: only 0-dimensional arrays can be converted
2390 ;; to Python scalars.
2391 ;; Fixed upstream in 71d2cd0173c863ee67b3a6803aea248c563d5427.
2392 (lambda _
2393 (substitute*
2394 "onnxruntime/python/tools/transformers/fusion_attention.py"
2395 (("float\\(mul_val)") "mul_val.item()"))))
2396 (add-after 'install 'build-python
2397 (lambda _
2398 (invoke "python3" "../setup.py" "bdist_wheel")))
2399 (add-after 'build-python 'install-python
2400 (lambda* (#:key inputs #:allow-other-keys)
2401 ((assoc-ref py:%standard-phases 'install)
2402 #:inputs inputs
2403 #:outputs `(("out" . ,#$output:python)))))
2404 (add-after 'install-python 'add-install-to-pythonpath
2405 (lambda* (#:key inputs #:allow-other-keys)
2406 ((assoc-ref py:%standard-phases 'add-install-to-pythonpath)
2407 #:inputs inputs
2408 #:outputs `(("out" . ,#$output:python)))))
2409 (delete 'check)
2410 (add-after 'add-install-to-pythonpath 'check
2411 (lambda* (#:key tests? #:allow-other-keys)
2412 (with-directory-excursion "../onnxruntime/test/python"
2413 ((assoc-ref py:%standard-phases 'check)
2414 #:tests? tests?
2415 #:test-flags
2416 `(;; XXX: NotImplementedError
2417 "--ignore-glob=quantization/*"
2418 ;; XXX: These tests require transformer models or have
2419 ;; import issues.
2420 "--ignore=transformers/test_generation.py"
2421 "--ignore=transformers/test_gpt2_benchmark.py"
2422 "--ignore=transformers/test_gpt2_to_onnx.py"
2423 "--ignore=transformers/test_optimizer_huggingface_bert.py"
2424 "--ignore=transformers/test_parity_huggingface_gpt_attention.py"
2425 "--ignore=transformers/test_shape_infer_helper.py"
2426 ;; XXX: onnxscript ModuleNotFound
2427 "--ignore=transformers/test_gelu_fusions.py"
2428 "--ignore=transformers/test_gemma3_vision.py"
2429 ;; XXX: PyTorch 2.9 ONNX exporter requires python-onnxscript.
2430 ;; Skip exporter-dependent tests until packaged/enabled.
2431 "--ignore=test_pytorch_export_contrib_ops.py"
2432 "--ignore=transformers/test_parity_gelu.py"
2433 "--ignore=transformers/test_parity_layernorm.py"
2434 "--ignore=transformers/test_phi_vision.py"
2435 ;; XXX: Other failing tests.
2436 "-k" ,(string-append
2437 "not test_gelu_is_fused_by_default"
2438 " and not test_inverse"))))))
2439 (add-after 'check 'python-sanity-check
2440 (lambda* (#:key tests? inputs #:allow-other-keys)
2441 ((assoc-ref py:%standard-phases 'sanity-check)
2442 #:inputs `(("sanity-check.py" . ,#$(default-sanity-check.py))
2443 ,@inputs)
2444 #:outputs `(("out" . ,#$output:python))))))))
2445 (outputs (list "out" "python"))
2446 (inputs
2447 (list abseil-cpp-20250127
2448 boost
2449 cpuinfo
2450 dlpack
2451 c++-gsl
2452 date
2453 eigen-for-onnxruntime
2454 flatbuffers-23.5
2455 googletest
2456 nlohmann-json
2457 onnx-for-onnxruntime
2458 protobuf-static-for-onnxruntime
2459 pybind11-2
2460 re2-next
2461 safeint
2462 zlib))
2463 (native-inputs
2464 (list pkg-config
2465 python-einops
2466 python-wrapper
2467 python-numpy
2468 python-parameterized
2469 python-psutil
2470 python-pytest
2471 python-pytorch
2472 python-sentencepiece
2473 python-setuptools))
2474 (propagated-inputs
2475 (list python-coloredlogs
2476 python-flatbuffers
2477 python-protobuf
2478 python-sympy))
2479 (home-page "https://github.com/microsoft/onnxruntime")
2480 (synopsis "Cross-platform, high performance scoring engine for ML models")
2481 (description
2482 "ONNX Runtime is a performance-focused complete scoring engine
2483for Open Neural Network Exchange (ONNX) models, with an open
2484extensible architecture to continually address the latest developments
2485in AI and Deep Learning. ONNX Runtime stays up to date with the ONNX
2486standard with complete implementation of all ONNX operators, and
2487supports all ONNX releases (1.2+) with both future and backwards
2488compatibility.")
2489 (license license:expat)))
2490
2491(define-public gemmlowp
2492 (let ((commit "16e8662c34917be0065110bfcd9cc27d30f52fdf")
2493 (version "0.1")
2494 (revision "2"))
2495 (package
2496 (name "gemmlowp")
2497 (version (git-version version revision commit))
2498 (source
2499 (origin
2500 (method git-fetch)
2501 (uri (git-reference
2502 (url "https://github.com/google/gemmlowp")
2503 (commit commit)))
2504 (file-name (git-file-name name version))
2505 (sha256
2506 (base32 "02xmrv921al94nihiqrvi8inlq6qc07j0zll3f9qi8322r31x83v"))))
2507 (arguments
2508 (list
2509 #:configure-flags
2510 #~(list #$@(match (%current-system)
2511 ((or "x86_64-linux" "i686-linux")
2512 '("-DCMAKE_CXX_FLAGS=-msse2"))
2513 (_ '()))
2514 "-DBUILD_SHARED_LIBS=ON")
2515 #:phases
2516 #~(modify-phases %standard-phases
2517 ;; This directory contains the CMakeLists.txt.
2518 (add-after 'unpack 'chdir
2519 (lambda _
2520 (chdir "contrib")))
2521 ;; There is no install target
2522 (replace 'install
2523 (lambda _
2524 (let ((lib (string-append #$output "/lib/")))
2525 (install-file "../build/libeight_bit_int_gemm.so" lib)
2526 (for-each
2527 (lambda (dir)
2528 (let ((target (string-append #$output
2529 "/include/gemmlowp/" dir)))
2530 (for-each (lambda (h)
2531 (install-file h target))
2532 (find-files (string-append "../" dir)
2533 "\\.h$"))))
2534 '("meta" "profiling" "public" "fixedpoint"
2535 "eight_bit_int_gemm" "internal"))))))))
2536 (build-system cmake-build-system)
2537 (home-page "https://github.com/google/gemmlowp")
2538 (synopsis "Small self-contained low-precision GEMM library")
2539 (description
2540 "This is a small self-contained low-precision @dfn{general matrix
2541multiplication} (GEMM) library. It is not a full linear algebra library.
2542Low-precision means that the input and output matrix entries are integers on
2543at most 8 bits. To avoid overflow, results are internally accumulated on more
2544than 8 bits, and at the end only some significant 8 bits are kept.")
2545 (license license:asl2.0))))
2546
2547(define-public dlib
2548 (package
2549 (name "dlib")
2550 (version "20.0")
2551 (source
2552 (origin
2553 (method git-fetch)
2554 (uri (git-reference
2555 (url "https://github.com/davisking/dlib.git")
2556 (commit (string-append "v" version))))
2557 (file-name (git-file-name name version))
2558 (sha256
2559 (base32 "1k6jwbb7n842snd2znv0ix8zwa4a35y324jb7mpkj0vn9arzndam"))
2560 (modules '((guix build utils)))
2561 (snippet
2562 '(begin
2563 (delete-file-recursively "dlib/external")))))
2564 (build-system cmake-build-system)
2565 (arguments
2566 (list
2567 #:configure-flags #~(list "-DBUILD_SHARED_LIBS=ON")
2568 #:phases
2569 #~(modify-phases %standard-phases
2570 (add-after 'unpack 'disable-asserts
2571 (lambda _
2572 ;; config.h recommends explicitly enabling or disabling asserts
2573 ;; when building as a shared library. By default neither is set.
2574 (substitute* "dlib/config.h"
2575 (("^//#define DLIB_DISABLE_ASSERTS") "#define DLIB_DISABLE_ASSERTS"))))
2576 (add-after 'disable-asserts 'disable-failing-tests
2577 (lambda _
2578 ;; One test times out on MIPS, so we need to disable it.
2579 ;; Others are flaky on some platforms.
2580 (let* ((system #$(or (%current-target-system)
2581 (%current-system)))
2582 (disabled-tests (cond
2583 ((string-prefix? "mips64" system)
2584 '("object_detector" ; timeout
2585 "data_io"))
2586 ((string-prefix? "armhf" system)
2587 '("learning_to_track"))
2588 ((string-prefix? "i686" system)
2589 '("optimization"))
2590 (else '()))))
2591 (for-each
2592 (lambda (test)
2593 (substitute* "dlib/test/makefile"
2594 (((string-append "SRC \\+= " test "\\.cpp")) "")))
2595 disabled-tests))))
2596 (add-before 'configure 'fix-test-build-error-with-gcc-14.3
2597 (lambda _
2598 (substitute* "dlib/test/CMakeLists.txt"
2599 ;; Some flags are activated specifically for GCC 14.0 but they
2600 ;; are needed for current GCC version (14.3.0). Let's assume
2601 ;; they are needed for the 14.x branch.
2602 (("14\\.0\\.1")
2603 "14.99")
2604 ;; Tests use deprecated functions from ffmpeg.
2605 (("-Werror\\)")
2606 "-Werror -Wno-error=deprecated-declarations)"))))
2607 (replace 'check
2608 (lambda _
2609 ;; XXX: This causes a rebuild--however, trying to run the tests
2610 ;; without rebuilding causes a lot of errors.
2611 ;; Also, the official way is to rebuild.
2612 (mkdir "../source/dlib/test/build")
2613 (with-directory-excursion "../source/dlib/test/build"
2614 (invoke "cmake" "-DBUILD_SHARED_LIBS=ON" "..")
2615 (invoke "cmake" "--build" "." "--config" "Release")
2616 (invoke "./dtest" "--runall")))))))
2617 (native-inputs
2618 (list pkg-config))
2619 (inputs
2620 (list ffmpeg
2621 giflib
2622 libjpeg-turbo
2623 libjxl
2624 libpng
2625 libwebp
2626 libx11
2627 openblas
2628 pybind11-2
2629 zlib))
2630 (synopsis
2631 "Toolkit for making machine learning and data analysis applications in
2632C++")
2633 (description
2634 "Dlib is a modern C++ toolkit containing machine learning algorithms and
2635tools. It is used in both industry and academia in a wide range of domains
2636including robotics, embedded devices, mobile phones, and large high
2637performance computing environments.")
2638 (home-page "http://dlib.net")
2639 (license license:boost1.0)))
2640
2641(define-public python-scikit-learn
2642 (package
2643 (name "python-scikit-learn")
2644 (version "1.9.0")
2645 (source
2646 (origin
2647 (method git-fetch)
2648 (uri (git-reference
2649 (url "https://github.com/scikit-learn/scikit-learn")
2650 (commit version)))
2651 (file-name (git-file-name name version))
2652 (sha256
2653 (base32 "0ay9zqlv1gimi6smxxjf29rvq3d923hdp34x731gd57rvbf22h3p"))))
2654 (build-system pyproject-build-system)
2655 (arguments
2656 (list
2657 ;; tests: 35838 passed, 11167 skipped, 226 xfailed, 119 xpassed, 5155 warnings
2658 #:test-flags
2659 #~(list "--numprocesses" (number->string (min 8 (parallel-job-count)))
2660 "-m" "not network"
2661 "--pyargs" "sklearn")
2662 #:phases
2663 #~(modify-phases %standard-phases
2664 (add-after 'unpack 'patch-pyproject
2665 (lambda _
2666 (substitute* "pyproject.toml"
2667 ;; FIXME: This line contains regexps and breaks toml parser.
2668 (("notice-rgx.*") ""))))
2669 (add-before 'build 'configure
2670 (lambda _
2671 (setenv "SKLEARN_BUILD_PARALLEL"
2672 (number->string (parallel-job-count)))))
2673 (add-before 'check 'pre-check
2674 (lambda _
2675 ;; Restrict OpenBLAS threads to prevent segfaults while
2676 ;; testing!
2677 (setenv "OPENBLAS_NUM_THREADS" "1")
2678 ;; Some tests require write access to $HOME.
2679 (setenv "HOME" "/tmp")
2680 (delete-file-recursively "sklearn"))))))
2681 (inputs
2682 (list openblas))
2683 (native-inputs
2684 (list gfortran
2685 python-meson
2686 python-pandas
2687 python-pytest
2688 python-pytest-xdist))
2689 (propagated-inputs
2690 (list python-joblib
2691 python-narwhals-minimal ;to reduce closure size
2692 python-numpy
2693 python-scipy
2694 python-threadpoolctl))
2695 (home-page "https://scikit-learn.org/")
2696 (synopsis "Machine Learning in Python")
2697 (description
2698 "Scikit-learn provides simple and efficient tools for data mining and
2699data analysis.")
2700 (license license:bsd-3)))
2701
2702(define-public python-mord
2703 (package
2704 (name "python-mord")
2705 (version "0.7")
2706 (source
2707 (origin
2708 (method url-fetch)
2709 (uri (pypi-uri "mord" version))
2710 (sha256
2711 (base32 "1cvv9b9w69v0inq0zgcw0vmkiq3zn9q9r6clkynpzjik9rrh405n"))))
2712 (build-system pyproject-build-system)
2713 ;; v0.7 does not provide any test cases
2714 ;; v0.6 relies on deprecated scikit-learn functionality
2715 (arguments `(#:tests? #f))
2716 (inputs (list python-numpy python-scipy python-scikit-learn))
2717 (native-inputs (list python-setuptools python-wheel))
2718 (home-page "https://pypi.org/project/mord/")
2719 (synopsis "Ordinal regression models for scikit-learn")
2720 (description
2721 "This package provides a collection of ordinal regression models for
2722machine learning in Python. They are intended to be used with scikit-learn
2723and are compatible with its API.")
2724 (license license:bsd-3)))
2725
2726(define-public python-thinc
2727 (package
2728 (name "python-thinc")
2729 (version "8.3.13")
2730 (source
2731 (origin
2732 (method git-fetch)
2733 (uri (git-reference
2734 (url "https://github.com/explosion/thinc")
2735 ;; XXX: It may be "release-v" as well.
2736 (commit (string-append "v" version))))
2737 (file-name (git-file-name name version))
2738 (sha256
2739 (base32 "04h9lbcaf4xizmcyq10lgr1gsxlgb8w4zcbf9vnzp37bn344cvig"))))
2740 (build-system pyproject-build-system)
2741 (arguments
2742 (list
2743 ;; tests: 1215 passed, 113 skipped, 1657 warnings
2744 #:phases
2745 #~(modify-phases %standard-phases
2746 (add-before 'check 'remove-local-thinc
2747 (lambda _
2748 (copy-recursively "thinc/tests" "tests")
2749 ;; This would otherwise interfere with finding the installed
2750 ;; thinc when running tests.
2751 (delete-file-recursively "thinc"))))))
2752 (propagated-inputs
2753 (list python-blis
2754 python-catalogue
2755 python-confection
2756 python-cymem
2757 python-murmurhash
2758 python-numpy
2759 python-packaging
2760 python-preshed
2761 python-pydantic
2762 python-srsly
2763 python-wasabi))
2764 (native-inputs
2765 (list python-coverage
2766 python-cython
2767 python-mock
2768 python-pytest
2769 python-setuptools))
2770 (home-page "https://github.com/explosion/thinc")
2771 (synopsis "Functional take on deep learning")
2772 (description
2773 "This package provides a functional take on deep learning, compatible
2774with your favorite libraries.")
2775 (license license:expat)))
2776
2777(define-public python-threadpoolctl
2778 (package
2779 (name "python-threadpoolctl")
2780 (version "3.6.0")
2781 (source
2782 (origin
2783 (method git-fetch)
2784 (uri (git-reference
2785 (url "https://github.com/joblib/threadpoolctl")
2786 (commit version)))
2787 (file-name (git-file-name name version))
2788 (sha256
2789 (base32
2790 "1n5gkcw619d9qgnnk46v2v77safj0z8hngb8i75dawq7lan89068"))))
2791 (build-system pyproject-build-system)
2792 (native-inputs
2793 (list python-flit-core python-pytest))
2794 (home-page "https://github.com/joblib/threadpoolctl")
2795 (synopsis "Python helpers for common threading libraries")
2796 (description "Thread-pool Controls provides Python helpers to limit the
2797number of threads used in the threadpool-backed of common native libraries used
2798for scientific computing and data science (e.g. BLAS and OpenMP).")
2799 (license license:bsd-3)))
2800
2801(define-public python-hdbscan
2802 (package
2803 (name "python-hdbscan")
2804 (version "0.8.41")
2805 (source
2806 (origin
2807 (method url-fetch)
2808 (uri (pypi-uri "hdbscan" version))
2809 (sha256
2810 (base32 "0ggzkm153cmgdq88jpdsvcmsipdicri24b957wbz47xjbcz847p4"))))
2811 (build-system pyproject-build-system)
2812 (arguments
2813 (list
2814 #:test-flags
2815 ;; XXX: Test files which fail during test collection.
2816 #~(list "--ignore=hdbscan/tests/test_branches.py"
2817 "--ignore=hdbscan/tests/test_hdbscan.py"
2818 "--ignore=hdbscan/tests/test_rsl.py")
2819 #:phases
2820 #~(modify-phases %standard-phases
2821 (add-before 'check 'pre-check
2822 (lambda _
2823 (delete-file "hdbscan/tests/__init__.py")))
2824 (add-before 'check 'build-extensions
2825 (lambda _
2826 (invoke "python" "setup.py" "build_ext" "--inplace"))))))
2827 (native-inputs
2828 (list python-cython
2829 python-numpy
2830 python-pytest
2831 python-setuptools))
2832 (propagated-inputs
2833 (list python-joblib
2834 python-numpy
2835 python-scikit-learn
2836 python-scipy))
2837 (home-page "https://github.com/scikit-learn-contrib/hdbscan")
2838 (synopsis "High performance implementation of HDBSCAN clustering")
2839 (description "HDBSCAN - Hierarchical Density-Based Spatial Clustering of
2840Applications with Noise. Performs DBSCAN over varying epsilon values and
2841integrates the result to find a clustering that gives the best stability over
2842epsilon. This allows HDBSCAN to find clusters of varying densities (unlike
2843DBSCAN), and be more robust to parameter selection. HDBSCAN is ideal for
2844exploratory data analysis; it's a fast and robust algorithm that you can trust
2845to return meaningful clusters (if there are any).")
2846 (license license:bsd-3)))
2847
2848(define-public python-pynndescent
2849 (package
2850 (name "python-pynndescent")
2851 (version "0.6.0")
2852 (source
2853 (origin
2854 (method url-fetch)
2855 (uri (pypi-uri "pynndescent" version))
2856 (sha256
2857 (base32 "1x94mjdf62f2yqql50qn0qjh4bkhwdvx7xx9aph421s0bgxy1zbz"))))
2858 (build-system pyproject-build-system)
2859 (arguments
2860 (list
2861 #:test-flags
2862 ;; Error from ScikitLearn: The 'metric' parameter of pairwise_distances
2863 ;; must be a str among <...>. Fixed in upcomming release of pynndescent.
2864 #~(list (string-append "--deselect=pynndescent/tests/test_distances.py"
2865 "::test_binary_check[sokalmichener]")
2866 (string-append "--deselect=ynndescent/tests/test_distances.py"
2867 "::test_sparse_binary_check[sokalmichener]")
2868 (string-append "--deselect=pynndescent/tests/test_distances.py"
2869 "::test_sparse_binary_check[sokalmichener]"))))
2870 (native-inputs (list python-pytest python-setuptools))
2871 (propagated-inputs (list python-joblib
2872 python-llvmlite
2873 python-numba
2874 python-scikit-learn
2875 python-scipy))
2876 (home-page "https://github.com/lmcinnes/pynndescent")
2877 (synopsis "Nearest neighbor descent for approximate nearest neighbors")
2878 (description
2879 "PyNNDescent provides a Python implementation of Nearest Neighbor Descent
2880for k-neighbor-graph construction and approximate nearest neighbor search.")
2881 (license license:bsd-2)))
2882
2883(define-public python-opentsne
2884 (package
2885 (name "python-opentsne")
2886 (version "1.0.2")
2887 (source
2888 (origin
2889 (method git-fetch) ;no tests in PyPI release
2890 (uri (git-reference
2891 (url "https://github.com/pavlin-policar/openTSNE")
2892 (commit (string-append "v" version))))
2893 (file-name (git-file-name name version))
2894 (sha256
2895 (base32 "1jn15h8b53z6ah47y51y8y4m0mk20xr6l2kd27ffr0hxswbifmkv"))))
2896 (build-system pyproject-build-system)
2897 (arguments
2898 (list
2899 #:phases
2900 #~(modify-phases %standard-phases
2901 ;; Benchmarks require the 'macosko2015' data files.
2902 (add-after 'unpack 'delete-benchmark
2903 (lambda _
2904 (delete-file-recursively "benchmarks")))
2905 (add-before 'check 'preparations
2906 (lambda _
2907 ;; Numba needs a writable dir to cache functions.
2908 (setenv "NUMBA_CACHE_DIR" "/tmp")
2909 ;; Rebuild extensions to run tests.
2910 (invoke "python" "setup.py" "build_ext" "--inplace"))))))
2911 (native-inputs (list python-cython python-pytest python-setuptools
2912 python-wheel))
2913 (inputs (list fftw))
2914 (propagated-inputs (list python-numpy python-pynndescent
2915 python-scikit-learn python-scipy))
2916 (home-page "https://github.com/pavlin-policar/openTSNE")
2917 (synopsis "Extensible, parallel implementations of t-SNE")
2918 (description
2919 "This is a modular Python implementation of t-Distributed Stochastic
2920Neighbor Embedding (t-SNE), a popular dimensionality-reduction algorithm for
2921visualizing high-dimensional data sets.")
2922 (license license:bsd-3)))
2923
2924;; XXX: Potentially it is an abandonware, no releases or any updates since
2925;; 2021, consider to remove when become incompatible with propagated inputs.
2926(define-public python-scikit-rebate
2927 (package
2928 (name "python-scikit-rebate")
2929 (version "0.62")
2930 (source
2931 (origin
2932 (method url-fetch)
2933 (uri (pypi-uri "skrebate" version))
2934 (sha256
2935 (base32 "0n55ghvnv7rxqa5agq6a4892ad0ghha165b0g4ghwr9gqm6ss3dj"))))
2936 (build-system pyproject-build-system)
2937 ;; There are no tests on PyPI, tests in git repo require an old release of
2938 ;; python-scikit-learn
2939 (arguments '(#:tests? #f))
2940 (native-inputs
2941 (list python-setuptools))
2942 (propagated-inputs
2943 (list python-numpy python-scipy python-scikit-learn python-joblib))
2944 (home-page "https://epistasislab.github.io/scikit-rebate/")
2945 (synopsis "Relief-based feature selection algorithms for Python")
2946 (description "Scikit-rebate is a scikit-learn-compatible Python
2947implementation of ReBATE, a suite of Relief-based feature selection algorithms
2948for Machine Learning. These algorithms excel at identifying features that are
2949predictive of the outcome in supervised learning problems, and are especially
2950good at identifying feature interactions that are normally overlooked by
2951standard feature selection algorithms.")
2952 (license license:expat)))
2953
2954(define-public python-cleanlab
2955 (package
2956 (name "python-cleanlab")
2957 (version "2.9.0")
2958 (source (origin
2959 (method git-fetch)
2960 (uri (git-reference
2961 (url "https://github.com/cleanlab/cleanlab")
2962 (commit (string-append "v" version))))
2963 (file-name (git-file-name name version))
2964 (sha256
2965 (base32
2966 "1fks57i3a297fcm1k4bs48x9cc7rs0jp4ij92r42pd1n0x60jznh"))))
2967 (build-system pyproject-build-system)
2968 (arguments
2969 (list
2970 ;; tests: 616 passed, 3 deselected, 99 warnings
2971 #:test-flags
2972 ;; This test fails because the newer version of scikit learn returns one
2973 ;; more classification result than expected. This should be harmless.
2974 #~(list "-k" "not test_aux_inputs"
2975 ;; Requires Tensorflow
2976 "--ignore=tests/test_frameworks.py"
2977 ;; These need datasets, which needs jax, so it could only live in
2978 ;; the guix-science channel.
2979 "--ignore-glob=tests/datalab/**"
2980 ;; Tries to download datasets from the internet at runtime.
2981 "--ignore=tests/test_dataset.py"
2982 ;; Test requiring not packaged dataset.
2983 "--ignore=tests/spurious_correlation/test_correlation_visualizer.py"
2984 "--ignore=tests/spurious_correlation/test_spurious_correlation.py"
2985 ;; AssertionError: assert 'Annotators [1] did not label any
2986 ;; examples.' in 'labels_multiannotator cannot have columns with
2987 ;; all NaN, each annotator must annotator at least one example.
2988 "--deselect=tests/test_multiannotator.py::test_label_quality_scores_multiannotator"
2989 ;; These tests were not updated to the last numpy update.
2990 ;; Try enabling them on the next update.
2991 (string-append "--deselect=tests/test_object_detection.py::"
2992 "test_return_issues_ranked_by_scores")
2993 (string-append "--deselect=tests/test_object_detection.py::"
2994 "test_bad_input_find_label_issues_internal"))
2995 #:phases
2996 #~(modify-phases %standard-phases
2997 (add-after 'unpack 'remove-datasets
2998 (lambda _
2999 (delete-file "tests/datalab/conftest.py"))))))
3000 (propagated-inputs
3001 (list python-numpy
3002 python-pandas
3003 python-scikit-learn
3004 python-termcolor
3005 python-tqdm))
3006 (native-inputs
3007 (list ;; python-dataset ; https://github.com/huggingface/datasets
3008 python-matplotlib
3009 python-pytest
3010 python-pytorch
3011 python-setuptools
3012 python-torchvision
3013 python-typing-extensions))
3014 (home-page "https://cleanlab.ai")
3015 (synopsis "Automatically find and fix dataset issues")
3016 (description
3017 "cleanlab automatically finds and fixes errors in any ML dataset. This
3018data-centric AI package facilitates machine learning with messy, real-world
3019data by providing clean labels during training.")
3020 (license license:agpl3+)))
3021
3022(define-public python-cma
3023 (package
3024 (name "python-cma")
3025 (version "4.4.4")
3026 (source (origin
3027 (method url-fetch)
3028 (uri (pypi-uri "cma" version))
3029 (sha256
3030 (base32
3031 "0w41k8dk8g1ngx797dzag5xcwws77sfnfriim874rq6wnmadcav3"))))
3032 (build-system pyproject-build-system)
3033 (arguments
3034 (list #:test-backend #~'custom
3035 #:test-flags #~'("src/cma/test.py")))
3036 (native-inputs (list python-pytest python-setuptools))
3037 (propagated-inputs (list python-numpy))
3038 (home-page "https://github.com/CMA-ES/pycma")
3039 (synopsis "Python implementation of CMA-ES")
3040 (description "This package provides a Python implementation of the
3041@acronym{CMA-ES, Covariance Matrix Adaptation Evolution Strategy} algorithm
3042and a few related numerical optimization tools.")
3043 (license license:bsd-3)))
3044
3045(define-public python-cmaes
3046 (package
3047 (name "python-cmaes")
3048 (version "0.13.0")
3049 (source
3050 (origin
3051 (method git-fetch) ;no tests in PyPI
3052 (uri (git-reference
3053 (url "https://github.com/CyberAgentAILab/cmaes")
3054 (commit (string-append "v" version))))
3055 (sha256
3056 (base32 "1fqy7829isg3j00849ifya4ncf9qpm0b3jhw47ibjn4jv0kn4zmh"))
3057 (file-name (git-file-name name version))))
3058 (build-system pyproject-build-system)
3059 (native-inputs (list python-pytest python-setuptools))
3060 (propagated-inputs (list python-numpy))
3061 (home-page "https://github.com/CyberAgentAILab/cmaes")
3062 (synopsis "CMA-ES implementation for Python")
3063 (description "This package provides provides an implementation of the
3064Covariance Matrix Adaptation Evolution Strategy (CMA-ES) for Python.")
3065 (license license:expat)))
3066
3067(define-public python-autograd
3068 (package
3069 (name "python-autograd")
3070 (version "1.8.0")
3071 (source
3072 (origin
3073 (method git-fetch)
3074 (uri (git-reference
3075 (url "https://github.com/HIPS/autograd")
3076 (commit (string-append "v" version))))
3077 (sha256
3078 (base32 "054pkhzz0h9p1jzva8774wb9dj7rvax4rcpr8ava971kbimdr2lk"))
3079 (file-name (git-file-name name version))))
3080 (build-system pyproject-build-system)
3081 (native-inputs
3082 (list python-hatchling
3083 python-pytest
3084 python-pytest-cov ; This package has a custom way of running tests.
3085 python-pytest-xdist))
3086 (propagated-inputs
3087 (list python-future
3088 python-numpy))
3089 (home-page "https://github.com/HIPS/autograd")
3090 (synopsis "Efficiently computes derivatives of NumPy code")
3091 (description
3092 "Autograd can automatically differentiate native Python and NumPy code.
3093It can handle a large subset of Python's features, including loops, ifs,
3094recursion and closures, and it can even take derivatives of derivatives of
3095derivatives. It supports reverse-mode differentiation
3096(a.k.a. backpropagation), which means it can efficiently take gradients of
3097scalar-valued functions with respect to array-valued arguments, as well as
3098forward-mode differentiation, and the two can be composed arbitrarily. The
3099main intended application of Autograd is gradient-based optimization.")
3100 (license license:expat)))
3101
3102(define-public python-torchdiffeq
3103 ;; There are neither releases nor tags.
3104 (let ((commit "657943acefa826ef04c025ebeb1ff5e9d60dc268")
3105 (revision "1"))
3106 (package
3107 (name "python-torchdiffeq")
3108 (version (git-version "0.2.5" revision commit))
3109 (source
3110 (origin
3111 (method git-fetch)
3112 (uri (git-reference
3113 (url "https://github.com/rtqichen/torchdiffeq")
3114 (commit commit)))
3115 (file-name (git-file-name name version))
3116 (sha256
3117 (base32 "15ccm7m0k3jjvx0sxz4s453pb0sxlbg5569dqlvj6ql74jl356x0"))))
3118 (build-system pyproject-build-system)
3119 (arguments
3120 (list
3121 #:test-flags
3122 #~(list
3123 ;; This starts failing with [email protected], it looks like a regression
3124 ;; in the fortran to C rewrite of LSODA.
3125 "-k" "not test_min_max_step"
3126 "tests/run_all.py")))
3127 (propagated-inputs (list python-numpy python-scipy python-pytorch))
3128 (native-inputs (list python-pytest python-setuptools))
3129 (home-page "https://github.com/rtqichen/torchdiffeq")
3130 (synopsis "ODE solvers and adjoint sensitivity analysis in PyTorch")
3131 (description
3132 "This tool provides ordinary differential equation solvers implemented
3133in PyTorch. Backpropagation through ODE solutions is supported using the
3134adjoint method for constant memory cost.")
3135 (license license:expat))))
3136
3137(define-public lightgbm
3138 (package
3139 (name "lightgbm")
3140 (version "2.0.12")
3141 (source
3142 (origin
3143 (method git-fetch)
3144 (uri (git-reference
3145 (url "https://github.com/Microsoft/LightGBM")
3146 (commit (string-append "v" version))))
3147 (sha256
3148 (base32 "0jlvyn7k81dzrh9ij3zw576wbgiwmmr26rzpdxjn1dbpc3njpvzi"))
3149 (file-name (git-file-name name version))))
3150 (build-system cmake-build-system)
3151 (arguments
3152 (list
3153 #:configure-flags
3154 #~(list "-DUSE_MPI=ON")
3155 #:phases
3156 #~(modify-phases %standard-phases
3157 (replace 'check
3158 (lambda* (#:key tests? #:allow-other-keys)
3159 (when tests?
3160 (with-directory-excursion "../source"
3161 (invoke "pytest" "tests/c_api_test/test_.py"))))))))
3162 (native-inputs (list python python-pytest))
3163 (inputs (list openmpi))
3164 (propagated-inputs (list python-numpy python-scipy))
3165 (home-page "https://github.com/Microsoft/LightGBM")
3166 (synopsis "Gradient boosting framework based on decision tree algorithms")
3167 (description
3168 "LightGBM is a gradient boosting framework that uses tree based learning
3169algorithms. It is designed to be distributed and efficient with the following
3170advantages:
3171
3172@itemize
3173@item Faster training speed and higher efficiency
3174@item Lower memory usage
3175@item Better accuracy
3176@item Parallel and GPU learning supported (not enabled in this package)
3177@item Capable of handling large-scale data
3178@end itemize
3179")
3180 (license license:expat)))
3181
3182(define-public python-lightgbm
3183 (package/inherit lightgbm
3184 (name "python-lightgbm")
3185 (build-system pyproject-build-system)
3186 (arguments
3187 (list
3188 ;; XXX: Enable when lightgbm is updated.
3189 #:tests? #f
3190 #:phases
3191 #~(modify-phases %standard-phases
3192 (add-after 'unpack 'chdir
3193 (lambda _
3194 (chdir "python-package"))))))
3195 (native-inputs
3196 (list cmake-minimal
3197 python-pytest
3198 python-setuptools))
3199 (propagated-inputs
3200 (list python-numpy
3201 python-scipy
3202 python-scikit-learn))
3203 (synopsis "LightGBM Python Package")))
3204
3205(define-public vowpal-wabbit
3206 ;; Language bindings not included.
3207 (package
3208 (name "vowpal-wabbit")
3209 (version "8.5.0")
3210 (source (origin
3211 (method git-fetch)
3212 (uri (git-reference
3213 (url "https://github.com/JohnLangford/vowpal_wabbit")
3214 (commit version)))
3215 (sha256
3216 (base32
3217 "04bwzk6ifgnz3fmzid8b7avxf9n5pnx9xcjm61nkjng1vv0bpj8x"))
3218 (file-name (git-file-name name version))))
3219 (build-system gnu-build-system)
3220 (arguments
3221 (list
3222 #:configure-flags
3223 #~(list (string-append "--with-boost=" #$(this-package-input "boost")))
3224 #:phases
3225 #~(modify-phases %standard-phases
3226 (add-after 'unpack 'make-files-writable
3227 (lambda _
3228 (for-each make-file-writable (find-files "." ".*"))))
3229 (add-after 'install 'install-more-headers
3230 (lambda _
3231 (for-each
3232 (lambda (file)
3233 (install-file
3234 file (string-append #$output "/include/vowpalwabbit")))
3235 (find-files "vowpalwabbit" "\\.h$")))))))
3236 (inputs
3237 (list boost zlib))
3238 (home-page "https://vowpalwabbit.org")
3239 (synopsis "Fast machine learning library for online learning")
3240 (description "Vowpal Wabbit is a machine learning system with techniques
3241such as online, hashing, allreduce, reductions, learning2search, active, and
3242interactive learning.")
3243 (license license:bsd-3)))
3244
3245(define-public python-hyperopt
3246 (package
3247 (name "python-hyperopt")
3248 (version "0.3.0")
3249 (source
3250 (origin
3251 (method git-fetch)
3252 (uri (git-reference
3253 (url "https://github.com/hyperopt/hyperopt")
3254 (commit (string-append "v" version))))
3255 (file-name (git-file-name name version))
3256 (sha256
3257 (base32 "09qy7v01dy2kk9wpd50ras5m9qzysg6h23lm3yl5ylr8hk7hi8wj"))))
3258 (build-system pyproject-build-system)
3259 (arguments
3260 (list
3261 ;; tests: 225 passed, 2 skipped, 1 deselected, 2 warnings
3262 #:test-flags
3263 #~(list "-m" "not slow"
3264 "--ignore=hyperopt/tests/integration/"
3265 ;; XXX: Segfaulted test.
3266 (string-append "--deselect=hyperopt/tests/unit/"
3267 "test_atpe_basic.py::test_run_basic_search"))))
3268 (native-inputs
3269 (list python-hatchling
3270 python-hatch-vcs
3271 python-pytest))
3272 (propagated-inputs
3273 (list python-cloudpickle
3274 python-networkx
3275 python-numpy
3276 python-scipy
3277 python-tqdm
3278 ;; [optional]
3279 python-lightgbm
3280 python-py4j
3281 python-pymongo
3282 ;; python-pyspark ;not packaged yet in Guix
3283 python-scikit-learn))
3284 (home-page "https://hyperopt.github.io/hyperopt/")
3285 (synopsis "Library for hyperparameter optimization")
3286 (description "Hyperopt is a Python library for serial and parallel
3287optimization over awkward search spaces, which may include real-valued,
3288discrete, and conditional dimensions.")
3289 (license license:bsd-3)))
3290
3291(define-public python-deepxde
3292 (package
3293 (name "python-deepxde")
3294 (version "1.15.0")
3295 (source (origin
3296 (method url-fetch)
3297 (uri (pypi-uri "deepxde" version))
3298 (sha256
3299 (base32
3300 "1m21hkcj386p0bwf19cr6r2kkv0c054yv1ipsl1rqav13g88l3ic"))))
3301 (build-system pyproject-build-system)
3302 (arguments
3303 (list #:tests? #f ; there are no tests
3304 #:phases #~(modify-phases %standard-phases
3305 (add-before 'sanity-check 'writable-home
3306 ;; sanity-check writes ~/.deepxde/config.json to set
3307 ;; the default backend.
3308 (lambda _
3309 (setenv "HOME" "/tmp"))))))
3310 ;; DeepXDE supported backends are TensorFlow (v1 and v2), PyTorch, JAX and
3311 ;; PaddlePaddle. We test with PyTorch because we have it up to date.
3312 (native-inputs (list python-pytorch python-setuptools
3313 python-setuptools-scm))
3314 (propagated-inputs (list python-matplotlib python-numpy
3315 python-scikit-learn python-scikit-optimize
3316 python-scipy))
3317 (home-page "https://deepxde.readthedocs.io/en/latest/")
3318 (synopsis "Library for scientific machine learning")
3319 (description "DeepXDE is a library for scientific machine learning and
3320physics-informed learning. It includes implementations for the PINN
3321(physics-informed neural networks), DeepONet (deep operator network) and
3322MFNN (multifidelity neural network) algorithms.")
3323 (license license:lgpl2.1+)))
3324
3325(define-public python-jaxtyping
3326 (package
3327 (name "python-jaxtyping")
3328 (version "0.3.3")
3329 (source (origin
3330 (method url-fetch)
3331 (uri (pypi-uri "jaxtyping" version))
3332 (sha256
3333 (base32
3334 "11pajw47mj0px787m6f7vwfsi6ajawm9h7fszm3rpbd2dg8wy0w0"))))
3335 (build-system pyproject-build-system)
3336 ;; Tests require JAX, but JAX can't be packaged because it uses the Bazel
3337 ;; build system.
3338 (arguments (list #:tests? #f))
3339 (native-inputs (list python-hatchling))
3340 (propagated-inputs (list python-numpy python-typeguard
3341 python-typing-extensions python-wadler-lindig))
3342 (home-page "https://github.com/google/jaxtyping")
3343 (synopsis
3344 "Type annotations and runtime checking for JAX arrays and others")
3345 (description "@code{jaxtyping} provides type annotations and runtime
3346checking for shape and dtype of JAX arrays, PyTorch, NumPy, TensorFlow, and
3347PyTrees.")
3348 (license license:expat)))
3349
3350;; There have been no proper releases yet.
3351(define-public kaldi
3352 (let ((commit "01aadd7c19372e3eacadec88caabd86162f33d69")
3353 (revision "2"))
3354 (package
3355 (name "kaldi")
3356 (version (git-version "0" revision commit))
3357 (source (origin
3358 (method git-fetch)
3359 (uri (git-reference
3360 (url "https://github.com/kaldi-asr/kaldi")
3361 (commit commit)))
3362 (file-name (git-file-name name version))
3363 (sha256
3364 (base32
3365 "08l31g256wl81fsrm1dvi0d2rq2vk5zq7ihbbiw7hp51iwg2miif"))
3366 (patches
3367 (search-patches "kaldi-openblas-0.3.29-compatibility.patch"
3368 "kaldi-ignore-failing-test.patch"))))
3369 (build-system gnu-build-system)
3370 (arguments
3371 (list
3372 #:test-target "test"
3373 #:configure-flags
3374 (let ((fst (this-package-input "openfst")))
3375 #~(list "--use-cuda=no"
3376 "--shared"
3377 (string-append "--openblas-root="
3378 #$(this-package-input "openblas"))
3379 (string-append "--fst-root=" #$fst)
3380 (string-append "--fst-version=" #$(package-version fst))))
3381 #:phases
3382 #~(modify-phases %standard-phases
3383 (add-after 'unpack 'chdir
3384 (lambda _ (chdir "src")))
3385 (replace 'configure
3386 (lambda* (#:key build system inputs configure-flags
3387 #:allow-other-keys)
3388 (when (not (or (string-prefix? "x86_64" system)
3389 (string-prefix? "i686" system)))
3390 (substitute* "makefiles/linux_openblas.mk"
3391 (("-msse -msse2") "")))
3392 (substitute* "makefiles/default_rules.mk"
3393 (("/bin/bash") (which "bash")))
3394 (substitute* "Makefile"
3395 (("ext_depend: check_portaudio")
3396 "ext_depend:"))
3397 (substitute* '("online/Makefile"
3398 "onlinebin/Makefile"
3399 "gst-plugin/Makefile")
3400 (("../../tools/portaudio/install")
3401 (assoc-ref inputs "portaudio")))
3402 (substitute* "matrix/Makefile" ;temporary test bypass
3403 (("matrix-lib-test sparse-matrix-test") ""))
3404
3405 ;; This `configure' script doesn't support variables passed as
3406 ;; arguments, nor does it support "prefix".
3407 (substitute* "configure"
3408 (("check_for_slow_expf;") "")
3409 ;; This affects the RPATH and also serves as the installation
3410 ;; directory.
3411 (("KALDILIBDIR=`pwd`/lib")
3412 (string-append "KALDILIBDIR=" #$output "/lib")))
3413 (mkdir-p #$output) ; must exist
3414 (setenv "CONFIG_SHELL" (which "bash"))
3415 (apply invoke "./configure" configure-flags)))
3416 (add-after 'build 'build-ext-and-gstreamer-plugin
3417 (lambda _
3418 (invoke "make" "-C" "online" "depend")
3419 (invoke "make" "-C" "online")
3420 (invoke "make" "-C" "onlinebin" "depend")
3421 (invoke "make" "-C" "onlinebin")
3422 (invoke "make" "-C" "gst-plugin" "depend")
3423 (invoke "make" "-C" "gst-plugin")))
3424 ;; TODO: also install the executables.
3425 (replace 'install
3426 (lambda _
3427 (let* ((inc (string-append #$output "/include"))
3428 (lib (string-append #$output "/lib")))
3429 (mkdir-p lib)
3430 ;; The build phase installed symlinks to the actual
3431 ;; libraries. Install the actual targets.
3432 (for-each (lambda (file)
3433 (let ((target (readlink file)))
3434 (delete-file file)
3435 (install-file target lib)))
3436 (find-files lib "\\.so"))
3437 ;; Install headers
3438 (for-each (lambda (file)
3439 (let ((target-dir (string-append inc "/" (dirname file))))
3440 (install-file file target-dir)))
3441 (find-files "." "\\.h"))
3442 (install-file "gst-plugin/libgstonlinegmmdecodefaster.so"
3443 (string-append lib "/gstreamer-1.0"))))))))
3444 (inputs
3445 (list alsa-lib
3446 `(,gfortran "lib")
3447 glib
3448 gstreamer
3449 jack-1
3450 openblas
3451 openfst
3452 portaudio
3453 python))
3454 (native-inputs
3455 (list `(,glib "bin") ; glib-genmarshal
3456 grep
3457 sed
3458 pkg-config
3459 which))
3460 (home-page "https://kaldi-asr.org/")
3461 (synopsis "Speech recognition toolkit")
3462 (description "Kaldi is an extensible toolkit for speech recognition
3463written in C++.")
3464 (license license:asl2.0))))
3465
3466(define kaldi-for-vosk
3467 ;; Commit of branch "vosk"
3468 (let* ((commit "bc5baf14231660bd50b7d05788865b4ac6c34481")
3469 (revision "1")
3470 (openfst openfst-for-vosk))
3471 (package
3472 (inherit kaldi)
3473 (name "kaldi")
3474 (version (git-version "0" revision commit))
3475 (source
3476 (origin
3477 (method git-fetch)
3478 (uri (git-reference
3479 (url "https://github.com/alphacep/kaldi")
3480 (commit commit)))
3481 (file-name (git-file-name name version))
3482 (sha256
3483 (base32 "1y3d6918srr7cn5r72v5wvbdwz9p9j2bjw1x78sfis2r2k60lllw"))
3484 (patches
3485 (search-patches "kaldi-openblas-0.3.29-compatibility.patch"))))
3486 (inputs
3487 (list alsa-lib
3488 glib
3489 gstreamer
3490 jack-2
3491 openblas
3492 openfst
3493 portaudio
3494 python))
3495 (arguments
3496 (list
3497 #:test-target "test"
3498 #:make-flags '(list "online2" "lm" "rnnlm")
3499 #:phases
3500 #~(modify-phases %standard-phases
3501 (add-after 'unpack 'chdir
3502 (lambda _ (chdir "src")))
3503 (replace 'configure
3504 (lambda _
3505 (let ((portaudio #$(this-package-input "portaudio"))
3506 (openfst #$(this-package-input "openfst"))
3507 (openblas #$(this-package-input "openblas")))
3508 #$@(if (target-x86?)
3509 '()
3510 #~((substitute* "makefiles/linux_openblas.mk"
3511 (("-msse -msse2") ""))))
3512 (substitute* "makefiles/default_rules.mk"
3513 (("/bin/bash") (which "bash")))
3514 (substitute* "Makefile"
3515 (("ext_depend: check_portaudio")
3516 "ext_depend:"))
3517 (substitute* '("online/Makefile"
3518 "onlinebin/Makefile"
3519 "gst-plugin/Makefile")
3520 (("../../tools/portaudio/install")
3521 portaudio))
3522 (substitute* "matrix/Makefile" ;temporary test bypass
3523 (("matrix-lib-test sparse-matrix-test") ""))
3524 (substitute* "cudamatrix/Makefile"
3525 ((" cu-array-test") ""))
3526
3527 ;; This `configure' script doesn't support variables passed as
3528 ;; arguments, nor does it support "prefix".
3529 (substitute* "configure"
3530 (("check_for_slow_expf;") "")
3531 ;; This affects the RPATH and also serves as the installation
3532 ;; directory.
3533 (("KALDILIBDIR=`pwd`/lib")
3534 (string-append "KALDILIBDIR=" #$output "/lib"))
3535 (("OPENBLASROOT=\\\"\\$\\(rel2abs ..\\/tools\\/OpenBLAS\\/install\\)\\\"")
3536 (string-append "OPENBLASROOT=\"" openblas "\""))
3537 (("-L\\$OPENBLASLIBDIR -l:libopenblas.a -l:libblas.a -l:liblapack.a -l:libf2c.a")
3538 (string-append "-L$OPENBLASLIBDIR -lopenblas "
3539 "-L" openblas "/lib -lopenblas")))
3540 (mkdir-p #$output) ; must exist
3541 (setenv "CONFIG_SHELL" (which "bash"))
3542 (setenv "OPENFST_VER" #$(package-version openfst))
3543 (invoke "./configure"
3544 "--use-cuda=no"
3545 "--mathlib=OPENBLAS_CLAPACK"
3546 "--shared"
3547 (string-append "--fst-root=" openfst)))))
3548 (add-after 'configure 'optimize-build
3549 (lambda _ (substitute* "kaldi.mk" ((" -O1") " -O3"))))
3550 (replace 'install
3551 (lambda _
3552 (let ((inc (string-append #$output "/include"))
3553 (lib (string-append #$output "/lib")))
3554 ;; The build phase installed symlinks to the actual
3555 ;; libraries. Install the actual targets.
3556 (for-each (lambda (file)
3557 (let ((target (readlink file)))
3558 (delete-file file)
3559 (install-file target lib)))
3560 (find-files lib "\\.so"))
3561 ;; Install headers
3562 (for-each (lambda (file)
3563 (let ((target-dir (string-append inc "/" (dirname file))))
3564 (install-file file target-dir)))
3565 (find-files "." "\\.h")))))))))))
3566
3567(define-public gst-kaldi-nnet2-online
3568 (let ((commit "7888ae562a65bd7e406783ce2c33535bc66a30ef")
3569 (revision "3"))
3570 (package
3571 (name "gst-kaldi-nnet2-online")
3572 (version (git-version "0" revision commit))
3573 (source (origin
3574 (method git-fetch)
3575 (uri (git-reference
3576 (url "https://github.com/alumae/gst-kaldi-nnet2-online")
3577 (commit commit)))
3578 (file-name (git-file-name name version))
3579 (sha256
3580 (base32
3581 "0xp59a6lmx1y24i8bkmxcm27lhm5x5m6y41670yjzhamcbnx8jcr"))))
3582 (build-system gnu-build-system)
3583 (arguments
3584 (list
3585 #:tests? #f ; there are none
3586 #:make-flags
3587 (let ((kaldi (this-package-input "kaldi"))
3588 (bash (this-package-native-input "bash")))
3589 #~(list (string-append "SHELL=" #$bash "/bin/bash")
3590 (string-append "KALDI_ROOT=" #$(package-source kaldi))
3591 (string-append "KALDILIBDIR=" #$kaldi "/lib")
3592 "KALDI_FLAVOR=dynamic"))
3593 #:phases
3594 #~(modify-phases %standard-phases
3595 (add-after 'unpack 'chdir
3596 (lambda _ (chdir "src")))
3597 (replace 'configure
3598 (lambda* (#:key inputs #:allow-other-keys)
3599 (let ((fst-version #$(package-version
3600 (this-package-input "openfst"))))
3601 (setenv "CXXFLAGS"
3602 (string-append
3603 "-fPIC -DOPENFST_VER="
3604 (string-join (string-split fst-version #\.) "0")))
3605 (setenv "CPLUS_INCLUDE_PATH"
3606 (string-join
3607 (append (map (lambda (dir)
3608 (search-input-directory inputs dir))
3609 '("/include/glib-2.0"
3610 "/lib/glib-2.0/include"
3611 "/include/gstreamer-1.0"))
3612 (list (getenv "CPLUS_INCLUDE_PATH")))
3613 ":")))
3614 (substitute* "Makefile"
3615 (("include \\$\\(KALDI_ROOT\\)/src/kaldi.mk") "")
3616 (("\\$\\(error Cannot find") "#"))))
3617 (add-before 'build 'build-depend
3618 (lambda* (#:key make-flags #:allow-other-keys)
3619 (apply invoke "make" "depend" make-flags)))
3620 (replace 'install
3621 (lambda _
3622 (install-file
3623 "libgstkaldinnet2onlinedecoder.so"
3624 (string-append #$output "/lib/gstreamer-1.0")))))))
3625 (inputs
3626 (list glib gstreamer jansson openfst kaldi))
3627 (native-inputs
3628 (list bash `(,glib "bin") pkg-config))
3629 (home-page "https://kaldi-asr.org/")
3630 (synopsis "Gstreamer plugin for decoding speech")
3631 (description "This package provides a GStreamer plugin that wraps
3632Kaldi's @code{SingleUtteranceNnet2Decoder}. It requires iVector-adapted DNN
3633acoustic models. The iVectors are adapted to the current audio stream
3634automatically.")
3635 (license license:asl2.0))))
3636
3637(define-public kaldi-gstreamer-server
3638 ;; This is the tip of the py3 branch
3639 (let ((commit "f79e204d751a5964918001822e4520fa2acfd246")
3640 (revision "3"))
3641 (package
3642 (name "kaldi-gstreamer-server")
3643 (version (git-version "0" revision commit))
3644 (source (origin
3645 (method git-fetch)
3646 (uri (git-reference
3647 (url "https://github.com/alumae/kaldi-gstreamer-server")
3648 (commit commit)))
3649 (file-name (git-file-name name version))
3650 (sha256
3651 (base32
3652 "1iijq8jmgdxr7961inal1ggs496ymxradm51m4sqx8vl983x14y8"))
3653 ;; XXX: Tests are broken beyond repair and are mingled in the
3654 ;; source directory. Remove them to avoid installing them.
3655 ;; See https://github.com/nicolas-graves/kaldi-gstreamer-server
3656 ;; for a fork that tries to repair them, to no avail.
3657 (snippet #~(for-each delete-file
3658 '("kaldigstserver/test-buffer.py"
3659 "kaldigstserver/decoder_test.py"
3660 "kaldigstserver/decoder2_test.py")))))
3661 (build-system gnu-build-system)
3662 (arguments
3663 `(#:tests? #f
3664 #:modules ((guix build utils)
3665 (guix build gnu-build-system)
3666 (srfi srfi-26))
3667 #:phases
3668 (modify-phases %standard-phases
3669 (delete 'configure)
3670 (replace 'build
3671 (lambda _
3672 ;; Migrate to Glib.MainLoop.
3673 (substitute* (find-files "kaldigstserver" "\\.py")
3674 (("GObject\\.threads_init\\(\\)") "")
3675 (("GObject") "GLib"))
3676 ;; Disable hash randomization to ensure the generated .pycs
3677 ;; are reproducible.
3678 (setenv "PYTHONHASHSEED" "0")
3679 (with-directory-excursion "kaldigstserver"
3680 ;; See https://github.com/alumae/kaldi-gstreamer-server/issues/232
3681 (substitute* "master_server.py"
3682 (("\\.replace\\('\\\\.*") ")"))
3683
3684 (for-each (lambda (file)
3685 (apply invoke
3686 `("python"
3687 "-m" "compileall"
3688 "-f" ; force rebuild
3689 ,file)))
3690 (find-files "." "\\.py$")))))
3691 (replace 'install
3692 (lambda* (#:key inputs outputs #:allow-other-keys)
3693 (let* ((out (assoc-ref outputs "out"))
3694 (bin (string-append out "/bin"))
3695 (share (string-append out "/share/kaldi-gstreamer-server/")))
3696 ;; Install Python files
3697 (with-directory-excursion "kaldigstserver"
3698 (for-each (cut install-file <> share)
3699 (find-files "." ".*")))
3700
3701 ;; Install sample configuration files
3702 (for-each (cut install-file <> share)
3703 (find-files "." "\\.yaml"))
3704
3705 ;; Install executables
3706 (mkdir-p bin)
3707 (let* ((server (string-append bin "/kaldi-gst-server"))
3708 (client (string-append bin "/kaldi-gst-client"))
3709 (worker (string-append bin "/kaldi-gst-worker"))
3710 (wrap (lambda (wrapper what)
3711 (with-output-to-file wrapper
3712 (lambda _
3713 (format #t "#!~a
3714export GUIX_PYTHONPATH=~a
3715export GI_TYPELIB_PATH=~a:${GI_TYPELIB_PATH}
3716export GST_PLUGIN_SYSTEM_PATH=~a:${GST_PLUGIN_SYSTEM_PATH}
3717exec ~a ~a~a \"$@\"~%"
3718 (which "bash")
3719 (getenv "GUIX_PYTHONPATH")
3720 (getenv "GI_TYPELIB_PATH")
3721 (getenv "GST_PLUGIN_SYSTEM_PATH")
3722 (which "python") share what)))
3723 (chmod wrapper #o555))))
3724 (for-each wrap
3725 (list server client worker)
3726 (list "master_server.py"
3727 "client.py"
3728 "worker.py")))))))))
3729 (inputs
3730 (list gstreamer
3731 gst-kaldi-nnet2-online
3732 gst-plugins-base
3733 gst-plugins-good
3734 kaldi
3735 python-wrapper
3736 python-pygobject
3737 python-pyyaml
3738 python-tornado))
3739 (home-page "https://github.com/alumae/kaldi-gstreamer-server")
3740 (synopsis "Real-time full-duplex speech recognition server")
3741 (description "This is a real-time full-duplex speech recognition server,
3742based on the Kaldi toolkit and the GStreamer framework and implemented in
3743Python.")
3744 (license license:bsd-2))))
3745
3746(define-public tensorflow-lite
3747 (package
3748 (name "tensorflow-lite")
3749 (version "2.16.2")
3750 (source
3751 (origin
3752 (method git-fetch)
3753 (uri (git-reference
3754 (url "https://github.com/tensorflow/tensorflow")
3755 (commit (string-append "v" version))))
3756 (file-name (git-file-name name version))
3757 (sha256
3758 (base32
3759 "082qqv7987qb559skkh8199v8knigylbxgxvz49v4m3467sd4468"))))
3760 (build-system cmake-build-system)
3761 (outputs (list "out" "python"))
3762 (arguments
3763 (list
3764 #:build-type "Release"
3765 #:imported-modules (append %cmake-build-system-modules
3766 %pyproject-build-system-modules)
3767 #:modules '((ice-9 match)
3768 (srfi srfi-26)
3769 (guix build utils)
3770 (guix build cmake-build-system)
3771 ((guix build pyproject-build-system) #:prefix py:))
3772 #:configure-flags
3773 #~(list
3774 ;; Access some OpenCL functions in mesa-headers
3775 "-DCMAKE_C_FLAGS=-DCL_ENABLE_BETA_EXTENSIONS=1"
3776 "-DCMAKE_CXX_FLAGS=-DCL_ENABLE_BETA_EXTENSIONS=1"
3777 ;; "-DTFLITE_KERNEL_TEST=ON" ; TODO: build tests
3778 ;; so cmake can be used to find this from other packages
3779 "-DTFLITE_ENABLE_INSTALL=ON"
3780
3781 ;; Use Guix's own packages as dependencies.
3782 "-DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON"
3783
3784 "-DTFLITE_ENABLE_GPU=ON"
3785 "-DTFLITE_ENABLE_RUY=ON"
3786 "-DTFLITE_ENABLE_XNNPACK=ON"
3787
3788 "-DSYSTEM_PTHREADPOOL=ON"
3789 ;; TODO: turn on Farmhash
3790 ;;"-DSYSTEM_FARMHASH=ON"
3791 (string-append "-Dabsl_DIR=" #$(this-package-input "abseil-cpp")
3792 "/lib/cmake/absl")
3793 (string-append "-DEigen3_DIR=" #$(this-package-input "eigen")
3794 "/share/eigen3/cmake")
3795 (string-append "-DFlatBuffers_DIR="
3796 #$(this-package-input "flatbuffers")
3797 "/lib/cmake/flatbuffers")
3798 (string-append "-DNEON_2_SSE_DIR=" #$(this-package-input "neon2sse")
3799 "/lib/cmake/NEON_2_SSE")
3800 (string-append "-Dcpuinfo_DIR=" #$(this-package-input "cpuinfo")
3801 "/share/cpuinfo")
3802 (string-append "-Druy_DIR=" #$(this-package-input "ruy")
3803 "/lib/cmake/ruy")
3804 (string-append "-DML_DTYPES_LIBRARY_DIRS="
3805 #$(this-package-input "python-ml-dtypes") "/lib")
3806
3807 ;; Don't fetch the sources. We have these already
3808 "-Dml_dtypes_POPULATED=ON"
3809 "-Dgemmlowp_POPULATED=TRUE"
3810 "-Degl_headers_POPULATED=TRUE"
3811 "-Dfp16_headers_POPULATED=TRUE"
3812 "-Dopencl_headers_POPULATED=TRUE"
3813 "-Dopengl_headers_POPULATED=TRUE"
3814 "-Dvulkan_headers_POPULATED=TRUE"
3815 "-Dgoogletest_POPULATED=TRUE"
3816 "-Dgoogle_benchmark_POPULATED=TRUE"
3817 "-Dnsync_POPULATED=TRUE"
3818 "-Dre2_POPULATED=TRUE"
3819 "-Dxnnpack_POPULATED=TRUE"
3820
3821 "-DFFT2D_SOURCE_DIR=/tmp/fft2d"
3822 "-DFARMHASH_SOURCE_DIR=/tmp/farmhash"
3823 (string-append "-Dgemmlowp_ROOT=" #$(this-package-input "gemmlowp")))
3824 #:phases
3825 #~(modify-phases %standard-phases
3826 (add-after 'unpack 'chdir
3827 (lambda _
3828 (chdir "tensorflow/lite")))
3829 (add-after 'chdir 'unbundle-gemmlowp
3830 (lambda _
3831 (call-with-output-file "tools/cmake/modules/gemmlowp.cmake"
3832 (lambda (port)
3833 (display "\
3834add_library(gemmlowp INTERFACE IMPORTED)
3835include_directories(\"${gemmlowp_ROOT}/include/gemmlowp\")" port)))
3836 (call-with-output-file "tools/cmake/modules/ml_dtypes.cmake"
3837 (lambda (port)
3838 (display "\
3839add_library(ml_dtypes INTERFACE IMPORTED)
3840find_library(ML_DTYPES_LIBRARIES
3841 NAMES ml_dtypes.so
3842 PATHS \"${ML_DTYPES_LIBRARY_DIRS}\"
3843 NO_DEFAULT_PATH)" port)))))
3844 (add-after 'chdir 'copy-sources
3845 (lambda _
3846 ;; Don't fetch source code; we already have everything we need.
3847 (substitute* '("tools/cmake/modules/fft2d.cmake"
3848 "tools/cmake/modules/farmhash.cmake"
3849 "tools/cmake/modules/gemmlowp.cmake")
3850 (("^ *OverridableFetchContent_Populate.*") ""))
3851
3852 (mkdir-p "/tmp/farmhash")
3853 (with-directory-excursion "/tmp/farmhash"
3854 (copy-recursively #$(this-package-native-input "farmhash-src") ".")
3855 (for-each make-file-writable (find-files ".")))
3856
3857 (mkdir-p "/tmp/fft2d")
3858 (with-directory-excursion "/tmp/fft2d"
3859 (copy-recursively #$(this-package-native-input "fft2d-src") ".")
3860 (for-each make-file-writable (find-files ".")))))
3861 (add-after 'copy-sources 'opencl-fix
3862 (lambda _
3863 (substitute* "delegates/gpu/cl/opencl_wrapper.h"
3864 (("cl_ndrange_kernel_command_properties_khr")
3865 "cl_command_properties_khr"))))
3866 (add-after 'opencl-fix 'absl-fix
3867 (lambda _
3868 (substitute* '("delegates/gpu/cl/cl_operation.h"
3869 "delegates/gpu/common/task/qcom_thin_filter_desc.cc"
3870 "delegates/gpu/common/tasks/special/thin_pointwise_fuser.cc")
3871 (("#include <vector>")
3872 "#include <vector>\n\n#include \"absl/strings/str_cat.h\"\n"))))
3873 (add-after 'opencl-fix 'stdint-fix
3874 (lambda _
3875 (substitute* "kernels/internal/spectrogram.cc"
3876 (("#include <math.h>")
3877 "#include <math.h>\n#include <cstdint>\n"))))
3878 (add-after 'stdint-fix 'gemmlowp-fix
3879 (lambda _
3880 (substitute* "kernels/internal/common.h"
3881 (("#include \"fixedpoint/fixedpoint\\.h\"")
3882 "#include <fixedpoint/fixedpoint.h>"))))
3883 (add-after 'gemmlowp-fix 'xnn-delegate-fix
3884 ;; undefined function, remove call to it
3885 (lambda _
3886 (substitute* "delegates/xnnpack/xnnpack_delegate.cc"
3887 (("xnn_experiment_enable_adaptive_avx_optimization\\(\\);")
3888 ""))))
3889 (add-after 'build 'build-shared-library
3890 (lambda* (#:key configure-flags #:allow-other-keys)
3891 (mkdir-p "c")
3892 (with-directory-excursion "c"
3893 (apply invoke "cmake" (append configure-flags (list "../../lite/c")))
3894 (invoke "cmake" "--build" "." "-j" (number->string
3895 (parallel-job-count))))))
3896 (add-after 'build-shared-library 'build-benchmark-model
3897 (lambda _
3898 (invoke "cmake" "--build" "." "--target" "benchmark_model"
3899 "-j" (number->string (parallel-job-count)))))
3900 (add-after 'build-benchmark-model 'build-python
3901 (lambda* (#:key configure-flags #:allow-other-keys)
3902 (let ((script (string-append "../lite/tools/pip_package/"
3903 "build_pip_package_with_cmake.sh")))
3904 (substitute* script
3905 (("\"\\$\\{TENSORFLOW_LITE_DIR\\}\"" all)
3906 (string-append "${ADDITIONAL_CMAKE_FLAGS} " all))
3907 (("-D(CMAKE_C[X]*_FLAGS)=\"\\$\\{BUILD_FLAGS\\}" all flag)
3908 (string-append all " ${ADDITIONAL_" flag "}")))
3909 (setenv "BUILD_NUM_JOBS" (number->string (parallel-job-count)))
3910 (let* ((config (map (cut string-split <> #\=) configure-flags))
3911 (c-flags (assoc-ref config "-DCMAKE_C_FLAGS"))
3912 (config (alist-delete "-DCMAKE_C_FLAGS" config))
3913 (cxx-flags (assoc-ref config "-DCMAKE_CXX_FLAGS"))
3914 (config (alist-delete "-DCMAKE_CXX_FLAGS" config)))
3915 (setenv "ADDITIONAL_CMAKE_C_FLAGS"
3916 (string-join c-flags "="))
3917 (setenv "ADDITIONAL_CMAKE_CXX_FLAGS"
3918 (string-join cxx-flags "="))
3919 (setenv "ADDITIONAL_CMAKE_FLAGS"
3920 (string-join (map (cut string-join <> "=") config)
3921 " ")))
3922 (invoke "sh" script))))
3923 (add-after 'install 'install-extra
3924 (lambda _
3925 (install-file "../build/c/libtensorflowlite_c.so"
3926 (string-append #$output "/lib"))
3927 (install-file "../build/tools/benchmark/benchmark_model"
3928 (string-append #$output "/bin"))))
3929 (add-after 'install-extra 'install-python
3930 (lambda* (#:key inputs outputs #:allow-other-keys)
3931 (with-directory-excursion
3932 "../lite/tools/pip_package/gen/tflite_pip/python3"
3933 ((assoc-ref py:%standard-phases 'install)
3934 #:inputs inputs
3935 #:outputs `(("out" . ,#$output:python))))))
3936 (replace 'check
3937 (lambda* (#:key tests? #:allow-other-keys)
3938 (when tests?
3939 (invoke "ctest" "-L" "plain"))))
3940 (add-after 'install-python 'add-install-to-pythonpath
3941 (lambda* (#:key inputs #:allow-other-keys)
3942 ((assoc-ref py:%standard-phases 'add-install-to-pythonpath)
3943 #:inputs inputs
3944 #:outputs `(("out" . ,#$output:python)))))
3945 (add-after 'add-install-to-pythonpath 'python-sanity-check
3946 (lambda* (#:key tests? inputs #:allow-other-keys)
3947 ((assoc-ref py:%standard-phases 'sanity-check)
3948 #:inputs `(("sanity-check.py" . ,#$(default-sanity-check.py))
3949 ,@inputs)
3950 #:outputs `(("out" . ,#$output:python))))))))
3951 (inputs
3952 (list abseil-cpp
3953 cpuinfo
3954 eigen
3955 fp16
3956 flatbuffers-23.5
3957 gemmlowp
3958 mesa-headers
3959 neon2sse
3960 nsync
3961 opencl-icd-loader
3962 pthreadpool
3963 python ;for its /lib
3964 python-ml-dtypes
3965 ruy
3966 re2
3967 xnnpack
3968 vulkan-headers
3969 zlib))
3970 (propagated-inputs
3971 (list python-numpy))
3972 (native-inputs
3973 (list pkg-config
3974 googletest
3975 pybind11-2
3976 python-setuptools
3977 python-wrapper ;for its /bin
3978 swig-4.0
3979 (origin
3980 (method git-fetch)
3981 (uri (git-reference
3982 (url "https://github.com/google/farmhash")
3983 (commit "816a4ae622e964763ca0862d9dbd19324a1eaf45")))
3984 (file-name "farmhash-src")
3985 (sha256
3986 (base32
3987 "1mqxsljq476n1hb8ilkrpb39yz3ip2hnc7rhzszz4sri8ma7qzp6")))
3988 (origin
3989 (method git-fetch)
3990 (uri (git-reference
3991 (url "https://github.com/petewarden/OouraFFT")
3992 (commit "v1.0")))
3993 (file-name "fft2d-src")
3994 (sha256
3995 (base32
3996 "1gla8m477din9k7jnbkzzbvc0wzw2rn97skxwf0k0mwcdf6vlhcs")))))
3997 (home-page "https://www.tensorflow.org")
3998 (synopsis "Machine learning framework")
3999 (description
4000 "TensorFlow is a flexible platform for building and training machine
4001learning models. This package provides the \"lite\" variant for mobile
4002devices.")
4003 (license license:asl2.0)))
4004
4005(define-public python-tflite-runtime
4006 (package
4007 (inherit tensorflow-lite)
4008 (name "python-tflite-runtime")
4009 (source #f)
4010 (build-system trivial-build-system)
4011 (outputs (list "out"))
4012 (arguments
4013 (list
4014 #:builder
4015 #~(begin
4016 (mkdir #$output)
4017 (symlink (string-append #$tensorflow-lite:python "/lib")
4018 (string-append #$output "/lib")))))
4019 (native-inputs '())))
4020
4021(define-public tflite-micro
4022 (let ((commit "a94423c6b6ee1f30c82d60952d70f749296a5581")
4023 (version "0")
4024 (revision "0"))
4025 (package
4026 (name "tflite-micro")
4027 (version (git-version version revision commit))
4028 (source
4029 (origin
4030 (method git-fetch)
4031 (uri (git-reference
4032 (url "https://github.com/tensorflow/tflite-micro")
4033 (commit commit)))
4034 (file-name (git-file-name name version))
4035 (sha256
4036 (base32 "0q1l4chj4p7vwclcysjmzl017l08kpqh498wpghq1cph641mdp5n"))
4037 (patches (search-patches "tflite-micro_disable_download.patch"))))
4038 (build-system gnu-build-system)
4039 (arguments
4040 (list
4041 #:tests? #f ;there are no tests
4042 #:phases
4043 #~(modify-phases %standard-phases
4044 (add-after 'unpack 'patch-makefile
4045 (lambda _
4046 (let ((makefile "tensorflow/lite/micro/tools/make/Makefile"))
4047 (substitute* makefile
4048 (("BASE_GENDIR := gen")
4049 "BASE_GENDIR := $(BUILD_DIR)")))))
4050 (delete 'configure)
4051
4052 (replace 'build
4053 (lambda _
4054 (let ((makefile "tensorflow/lite/micro/tools/make/Makefile"))
4055 (mkdir-p "../build")
4056 (invoke "make"
4057 "-j"
4058 (number->string (parallel-job-count))
4059 "-f"
4060 makefile
4061 (string-append "BASE_GENDIR=" "../build")
4062 (string-append "PRE_INCLUDES=-I"
4063 #$(this-package-input "gemmlowp")
4064 "/include/gemmlowp"
4065 " -I"
4066 #$(this-package-input
4067 "kissfft-for-tflite-micro")
4068 "/include/kissfft"
4069 " -I"
4070 #$(package-source
4071 kissfft-for-tflite-micro))))))
4072 (replace 'install
4073 (lambda _
4074 (for-each (lambda (f)
4075 (install-file f
4076 (string-append #$output "/lib")))
4077 (find-files "../build" "\\.a$"))
4078 (for-each (lambda (f)
4079 (install-file f
4080 (string-append #$output
4081 "/include/lite/micro")))
4082 (find-files "tensorflow/lite/micro" "\\.h$"))
4083 (for-each (lambda (f)
4084 (install-file f
4085 (string-append #$output
4086 "/include/lite/micro")))
4087 (find-files "signal/micro/kernels" "\\.h$"))
4088 (for-each (lambda (f)
4089 (install-file f
4090 (string-append #$output
4091 "/include/lite/micro")))
4092 (find-files "signal/src" "\\.h$")))))))
4093 (inputs (list flatbuffers-23.5 gemmlowp kissfft-for-tflite-micro ruy))
4094 (native-inputs (list python python-pillow python-numpy))
4095 (home-page "https://ai.google.dev/edge/litert/microcontrollers/overview")
4096 (synopsis
4097 "Infrastructure to enable deployment of ML models to embedded targets ")
4098 (description
4099 "TensorFlow Lite for Microcontrollers is a port of TensorFlow Lite designed
4100to run machine learning models on DSPs, microcontrollers and other devices with
4101limited memory.")
4102 (license license:asl2.0))))
4103
4104
4105(define-public dmlc-core
4106 (package
4107 (name "dmlc-core")
4108 (version "0.5")
4109 (source
4110 (origin
4111 (method git-fetch)
4112 (uri (git-reference
4113 (url "https://github.com/dmlc/dmlc-core")
4114 (commit (string-append "v" version))))
4115 (file-name (git-file-name name version))
4116 (sha256
4117 (base32 "1x4ad1jhn84fywlk031fmv1kxyiscclmrqn9hhj8gz0mh7z9vcrh"))))
4118 (build-system cmake-build-system)
4119 (arguments
4120 (list
4121 #:configure-flags #~(list "-DGOOGLE_TEST=ON")))
4122 (native-inputs
4123 (list googletest python-wrapper))
4124 (home-page "https://github.com/dmlc/dmlc-core")
4125 (synopsis "Common bricks library for machine learning")
4126 (description
4127 "DMLC-Core is the backbone library to support all DMLC projects,
4128offers the bricks to build efficient and scalable distributed machine
4129learning libraries.")
4130 (license license:asl2.0)))
4131
4132(define-public dmlc-core-next
4133 ;; Apache Tvm needs the latest code from git commits in May 2024 or later.
4134 (let ((commit "13341857549852a9a86b1894b5ba84c6276ab381")
4135 (revision "1"))
4136 (package
4137 (inherit dmlc-core)
4138 (name "dmlc-core")
4139 (version (git-version "0.5" revision commit))
4140 (source
4141 (origin
4142 (method git-fetch)
4143 (uri (git-reference
4144 (url "https://github.com/dmlc/dmlc-core")
4145 (commit commit)))
4146 (file-name (git-file-name name version))
4147 (sha256
4148 (base32 "1hj6h103lal3cm5mnry9lrm3d7aij89rxv46yv6y49vzd5hbnfbd")))))))
4149
4150(define-public xgboost
4151 (package
4152 (name "xgboost")
4153 (version "1.7.6")
4154 (source
4155 (origin
4156 (method git-fetch)
4157 (uri (git-reference
4158 (url "https://github.com/dmlc/xgboost")
4159 (commit (string-append "v" version))))
4160 (file-name (git-file-name name version))
4161 (patches (search-patches "xgboost-use-system-dmlc-core.patch"))
4162 (sha256
4163 (base32 "16fbm5y3hn6ccflmbdlmn7krrdq7c0az3mxd8j1d23s9ky8niw05"))))
4164 (build-system cmake-build-system)
4165 (arguments
4166 (list #:configure-flags #~(list "-DGOOGLE_TEST=ON")))
4167 (native-inputs
4168 (list googletest
4169 python-wrapper))
4170 (inputs
4171 (list dmlc-core))
4172 (home-page "https://xgboost.ai/")
4173 (synopsis "Gradient boosting (GBDT, GBRT or GBM) library")
4174 (description
4175 "XGBoost is an optimized distributed gradient boosting library designed
4176to be highly efficient, flexible and portable. It implements machine learning
4177algorithms under the Gradient Boosting framework. XGBoost provides a parallel
4178tree boosting (also known as GBDT, GBM) that solve many data science problems
4179in a fast and accurate way.")
4180 (license license:asl2.0)))
4181
4182(define-public python-xgboost
4183 (package
4184 (inherit xgboost)
4185 (name "python-xgboost")
4186 (source (package-source xgboost))
4187 (build-system pyproject-build-system)
4188 (arguments
4189 (list
4190 #:tests? #f ; all tests require network access
4191 #:phases
4192 #~(modify-phases %standard-phases
4193 (add-after 'unpack 'preparations
4194 (lambda _
4195 ;; Move python-package content to parent directory to silence
4196 ;; some warnings about files not being found if we chdir.
4197 (rename-file "python-package/xgboost" "xgboost")
4198 (rename-file "python-package/README.rst" "README.rst")
4199 (rename-file "python-package/setup.cfg" "setup.cfg")
4200 (rename-file "python-package/setup.py" "setup.py")
4201 ;; Skip rebuilding libxgboost.so.
4202 (substitute* "setup.py"
4203 (("ext_modules=\\[CMakeExtension\\('libxgboost'\\)\\],") "")
4204 (("'install_lib': InstallLib,") ""))
4205 ;; Remove bad dataset. This has been removed in scipy.
4206 (substitute* "tests/python/testing.py"
4207 (("TestDataset\\('boston', get_boston, 'reg:squarederror', 'rmse'\\),")
4208 "")
4209 (("datasets.load_boston")
4210 "datasets.load_digits"))))
4211 (add-after 'install 'install-version-and-libxgboost
4212 (lambda* (#:key inputs #:allow-other-keys)
4213 (let* ((pylib (string-append #$output "/lib/python"
4214 #$(version-major+minor
4215 (package-version python))
4216 "/site-packages"))
4217 (xgbdir (string-append pylib "/xgboost"))
4218 (version-file (string-append xgbdir "/VERSION"))
4219 (libxgboost (string-append (assoc-ref inputs "xgboost")
4220 "/lib/libxgboost.so")))
4221 (with-output-to-file version-file
4222 (lambda ()
4223 (display #$(package-version xgboost))))
4224 (mkdir-p (string-append xgbdir "/lib"))
4225 (symlink libxgboost (string-append xgbdir "/lib"
4226 "/libxgboost.so"))))))))
4227 (native-inputs
4228 (list python-pandas python-pytest python-scikit-learn python-setuptools
4229 python-wheel))
4230 (inputs
4231 (list xgboost))
4232 (propagated-inputs
4233 (list python-numpy python-scipy))
4234 (synopsis "Python interface for the XGBoost library")))
4235
4236(define-public gloo
4237 (let ((version "0.0.0") ; no proper version tag
4238 (commit "54cbae0d3a67fa890b4c3d9ee162b7860315e341")
4239 (revision "4"))
4240 (package
4241 (name "gloo")
4242 (version (git-version version revision commit))
4243 (source
4244 (origin
4245 (method git-fetch)
4246 (uri (git-reference
4247 (url "https://github.com/pytorch/gloo")
4248 (commit commit)))
4249 (file-name (git-file-name name version))
4250 (sha256
4251 (base32
4252 "1zixybyma7zpwdawy1qi2d48g9r65wcjjd4j3j2bhlvjymyw03z2"))))
4253 (build-system cmake-build-system)
4254 (native-inputs
4255 (list googletest))
4256 (inputs
4257 (append (list openssl)
4258 (if (supported-package? rdma-core)
4259 (list rdma-core)
4260 '())))
4261 (arguments
4262 (list #:configure-flags #~'("-DBUILD_SHARED_LIBS=ON"
4263 "-DBUILD_TEST=1"
4264 "-DCMAKE_CXX_STANDARD=17"
4265 #$@(if (this-package-input "rdma-core")
4266 #~("-DUSE_IBVERBS=ON")
4267 #~()))
4268 #:phases
4269 #~(modify-phases %standard-phases
4270 (replace 'check
4271 (lambda* (#:key tests? #:allow-other-keys)
4272 (when tests?
4273 (invoke "make" "gloo_test")))))))
4274 (synopsis "Collective communications library")
4275 (description
4276 "Gloo is a collective communications library. It comes with a
4277number of collective algorithms useful for machine learning applications.
4278These include a barrier, broadcast, and allreduce.")
4279 (home-page "https://github.com/facebookincubator/gloo")
4280 (supported-systems %64bit-supported-systems)
4281 (license license:bsd-3))))
4282
4283(define-public gloo-for-r-torch
4284 (let ((version "0.0.0") ; no proper version tag
4285 (commit "81925d1c674c34f0dc34dd9a0f2151c1b6f701eb")
4286 (revision "2"))
4287 (package
4288 (name "gloo")
4289 (version (git-version version revision commit))
4290 (source
4291 (origin
4292 (method git-fetch)
4293 (uri (git-reference
4294 (url "https://github.com/facebookincubator/gloo")
4295 (commit commit)))
4296 (file-name (git-file-name name version))
4297 (sha256
4298 (base32
4299 "16zs8ndbiv9nppn8bv6lfanzyyssz7g5pawxiqcnafwq3nvxpj9m"))))
4300 (build-system cmake-build-system)
4301 (native-inputs
4302 (list googletest))
4303 (inputs
4304 (append (list openssl-1.1)
4305 (if (supported-package? rdma-core)
4306 (list rdma-core)
4307 '())))
4308 (arguments
4309 (list #:configure-flags #~'("-DBUILD_SHARED_LIBS=ON"
4310 "-DBUILD_TEST=1"
4311 "-DCMAKE_CXX_STANDARD=17"
4312 #$@(if (this-package-input "rdma-core")
4313 #~("-DUSE_IBVERBS=ON")
4314 #~()))
4315 #:phases
4316 #~(modify-phases %standard-phases
4317 (replace 'check
4318 (lambda* (#:key tests? #:allow-other-keys)
4319 (when tests?
4320 (invoke "make" "gloo_test")))))))
4321 (synopsis "Collective communications library")
4322 (description
4323 "Gloo is a collective communications library. It comes with a
4324number of collective algorithms useful for machine learning applications.
4325These include a barrier, broadcast, and allreduce.")
4326 (home-page "https://github.com/facebookincubator/gloo")
4327 (supported-systems %64bit-supported-systems)
4328 (license license:bsd-3))))
4329
4330(define-public python-tensorly
4331 (package
4332 (name "python-tensorly")
4333 (version "0.9.0")
4334 (source (origin
4335 (method git-fetch)
4336 (uri (git-reference
4337 (url "https://github.com/tensorly/tensorly")
4338 (commit version)))
4339 (file-name (git-file-name name version))
4340 (sha256
4341 (base32
4342 "01xdkhzwq7s18pp6433d4dhyblmlhjs87acagxh73vfsqyknb9h3"))))
4343 (build-system pyproject-build-system)
4344 (arguments
4345 (list
4346 #:test-flags
4347 '(list
4348 ;; These tests fail due to missing example, documentation, or tutorial files.
4349 "--ignore=doc/sphinx_ext/sphinx_gallery/tests/test_gen_rst.py"
4350 ;; XXX There is no "get_marker" method.
4351 "--ignore=doc/sphinx_ext/sphinx_gallery/tests/test_gen_gallery.py"
4352 "-k"
4353 (string-append
4354 ;; tutorials/plot_parse.py is not included
4355 "not test_jupyter_notebook"
4356 ;; nor is examples/plot_quantum.py
4357 " and not test_file_is_generated"))))
4358 (propagated-inputs (list python-jsmin python-numpy python-scipy))
4359 (native-inputs (list python-pytest python-sphinx
4360 python-setuptools python-wheel))
4361 (home-page "https://github.com/tensorly/tensorly")
4362 (synopsis "Tensor learning in Python")
4363 (description
4364 "This is a Python library that aims at making tensor learning simple and
4365accessible. It allows performing tensor decomposition, tensor learning and
4366tensor algebra easily. Its backend system allows seamlessly perform
4367computation with NumPy, PyTorch, JAX, MXNet, TensorFlow or CuPy and run
4368methodxs at scale on CPU or GPU.")
4369 (license license:bsd-3)))
4370
4371(define-public python-umap-learn
4372 (package
4373 (name "python-umap-learn")
4374 (version "0.5.12")
4375 (source
4376 (origin
4377 (method git-fetch)
4378 (uri (git-reference
4379 (url "https://github.com/lmcinnes/umap")
4380 (commit (string-append "release-" version))))
4381 (file-name (git-file-name name version))
4382 (sha256
4383 (base32 "18ahwd94z6ravxvgpw3wyclcyzfpig93197znzgsg2350bgnzr1l"))))
4384 (build-system pyproject-build-system)
4385 (arguments
4386 (list
4387 ;; tests: 253 passed, 65 skipped, 56 warnings
4388 #:phases
4389 #~(modify-phases %standard-phases
4390 ;; Numba needs a writable dir to cache functions.
4391 (add-before 'build 'set-numba-cache-dir
4392 (lambda _
4393 (setenv "NUMBA_CACHE_DIR" "/tmp"))))))
4394 (native-inputs
4395 (list python-pytest
4396 python-setuptools))
4397 (propagated-inputs
4398 (list python-numba
4399 python-numpy
4400 python-pynndescent
4401 python-scikit-learn
4402 python-scipy
4403 python-tqdm))
4404 (home-page "https://github.com/lmcinnes/umap")
4405 (synopsis "Uniform Manifold Approximation and Projection")
4406 (description
4407 "Uniform Manifold Approximation and Projection is a dimension reduction
4408technique that can be used for visualization similarly to t-SNE, but also for
4409general non-linear dimension reduction.")
4410 (license license:bsd-3)))
4411
4412;; Requires AVX2 on x86_64-linux.
4413(define-public nnpack
4414 (let ((version "0.0")
4415 (commit "70a77f485e8b934224f3a79efd8edcd84cd377b8")
4416 (revision "2"))
4417 (package
4418 (name "nnpack")
4419 (version (git-version version revision commit))
4420 (home-page "https://github.com/Maratyszcza/NNPACK")
4421 (source (origin
4422 (method git-fetch)
4423 (uri (git-reference (url home-page) (commit commit)))
4424 (file-name (git-file-name name version))
4425 (sha256
4426 (base32
4427 "0c4pw926279s3rlx7mg4l4vhnfy6dh374n6w7zqhcn0bxpym1hv1"))
4428 (patches (search-patches "nnpack-system-libraries.patch"))))
4429 (build-system cmake-build-system)
4430 ;; XXX: The test suite runs but it's very expensive. On x86_64-linux, it
4431 ;; requires AVX2 instructions.
4432 (arguments '(#:tests? #f))
4433 (synopsis "Acceleration package for neural network computations")
4434 (description
4435 "NNPACK is an acceleration package for neural network computations.
4436NNPACK aims to provide high-performance implementations of convnet layers for
4437multi-core CPUs.
4438
4439NNPACK is not intended to be directly used by machine learning researchers;
4440instead it provides low-level performance primitives leveraged in leading deep
4441learning frameworks, such as PyTorch, Caffe2, MXNet, tiny-dnn, Caffe, Torch,
4442and Darknet.")
4443 (inputs
4444 (list cpuinfo
4445 fp16
4446 fxdiv
4447 psimd
4448 pthreadpool
4449 googletest-1.12))
4450 (native-inputs
4451 `(,python
4452 ,@(if (target-x86-64?) (list python-peachpy) '())
4453 ,python-six))
4454 ;; Supported for Linux.
4455 (supported-systems '("x86_64-linux" "armhf-linux" "aarch64-linux"))
4456 (license license:bsd-2))))
4457
4458(define-public qnnpack
4459 (let ((commit "7d2a4e9931a82adc3814275b6219a03e24e36b4c")
4460 (revision "0"))
4461 (package
4462 (name "qnnpack")
4463 (version (git-version "0" revision commit))
4464 (source
4465 (origin
4466 (method git-fetch)
4467 (uri (git-reference
4468 (url "https://github.com/pytorch/qnnpack")
4469 (commit commit)))
4470 (file-name (git-file-name name version))
4471 (sha256
4472 (base32
4473 "1dgzriiaz9arsrfwhx42y4l74wbzn6xvdmllfb66v4pmvi5gpxc5"))
4474 (modules '((guix build utils)))
4475 (snippet
4476 '(delete-file-recursively "deps"))))
4477 (build-system cmake-build-system)
4478 (arguments
4479 (list
4480 ;; The shared library build fails with linker errors, so we build the
4481 ;; static library with -fPIC as in the bundled PyTorch version.
4482 #:configure-flags
4483 ''("-DQNNPACK_LIBRARY_TYPE=static"
4484 "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
4485 #:phases
4486 #~(modify-phases %standard-phases
4487 (add-after 'unpack 'patch-cmake
4488 (lambda _
4489 (substitute* "CMakeLists.txt"
4490 (("IF.*SOURCE_DIR.*")
4491 "IF(FALSE)\n")
4492 (("IF\\(NOT TARGET.*")
4493 "IF(FALSE)\n")
4494 (("TARGET_LINK_LIBRARIES.*(fxdiv|psimd|fp16)\\).*")
4495 "")
4496 (("(TARGET_LINK_LIBRARIES.*) fp16 (.*)" _ before after)
4497 (string-append before " " after))))))))
4498 (inputs (list clog cpuinfo fp16 fxdiv psimd pthreadpool))
4499 (native-inputs (list googletest-1.12 googlebenchmark))
4500 (home-page "https://github.com/pytorch/qnnpack")
4501 (synopsis "Quantized Neural Network PACKage")
4502 (description "QNNPACK is a library for low-precision neural network
4503inference. It contains the implementation of common neural network operators
4504on quantized 8-bit tensors.")
4505 (supported-systems
4506 '("armhf-linux" "aarch64-linux" "i686-linux" "x86_64-linux"))
4507 (license license:bsd-3))))
4508
4509(define-public xnnpack
4510 ;; There's currently no tag on this repo.
4511 (let ((version "0.0")
4512 (commit "51a0103656eff6fc9bfd39a4597923c4b542c883")
4513 (revision "4"))
4514 (package
4515 (name "xnnpack")
4516 (version (git-version version revision commit))
4517 (home-page "https://github.com/google/XNNPACK") ;fork of QNNPACK
4518 (source
4519 (origin
4520 (method git-fetch)
4521 (uri (git-reference (url home-page) (commit commit)))
4522 (file-name (git-file-name name version))
4523 (sha256
4524 (base32
4525 "0j4smj8yaxw6r14caqn0dgb8j8mnsq34zp8ixxn11zmgbab306ly"))
4526 (modules '((guix build utils)
4527 (ice-9 ftw)
4528 (ice-9 textual-ports)
4529 (srfi srfi-26)))
4530 (snippet
4531 '(begin
4532 (when (directory-exists? "bench/models")
4533 (delete-file-recursively "bench/models"))
4534 ;; Remove autogenerated files, which contain the string
4535 ;; "Auto-generated file"
4536 (for-each
4537 (lambda (dir)
4538 (for-each
4539 (lambda (name)
4540 (let ((path (string-append dir "/" name)))
4541 (when (call-with-input-file path
4542 (lambda (port)
4543 (string-contains
4544 (get-string-all port)
4545 "Auto-generated file")))
4546 (delete-file path))))
4547 (or (scandir dir (negate (cut member <> '("." ".." "simd"))))
4548 '())))
4549 (cons*
4550 "test" "bench" "src/enums" "src/xnnpack" "gen" "cmake/gen"
4551 (filter file-exists?
4552 (map (cut string-append "src/" <> "/gen")
4553 (scandir "src")))))))))
4554 (build-system cmake-build-system)
4555 (arguments
4556 (list
4557 #:build-type "Release" ;; Debugging symbols require a lot of disk space
4558 #:configure-flags
4559 #~(list "-DXNNPACK_USE_SYSTEM_LIBS=YES"
4560 "-DBUILD_SHARED_LIBS=ON"
4561 "-DCMAKE_POSITION_INDEPENDENT_CODE=ON"
4562 "-DXNNPACK_LIBRARY_TYPE=shared"
4563 "-DXNNPACK_BUILD_BENCHMARKS=FALSE"
4564 ;; Tests fail to build with -DXNNPACK_LIBRARY_TYPE=shared:
4565 ;; https://github.com/google/XNNPACK/issues/6285
4566 "-DXNNPACK_BUILD_TESTS=OFF")
4567 #:tests? #f
4568 #:modules '((ice-9 ftw)
4569 (guix build cmake-build-system)
4570 (guix build utils))
4571 #:phases
4572 #~(modify-phases %standard-phases
4573 (add-after 'unpack 'fix-cmake
4574 (lambda _
4575 (substitute* "CMakeLists.txt"
4576 (("TARGET_INCLUDE_DIRECTORIES\\((pthreadpool|cpuinfo).*") "")
4577 (("AMD64") "x86_64"))))
4578 (add-after 'patch-source-shebangs 'generate-files
4579 (lambda _
4580 ;; This script just calls two other scripts.
4581 (delete-file "scripts/generate-tests-and-benchmarks.sh")
4582 ;; The bash scripts run all jobs at once and then wait, so we
4583 ;; convert them to Makefiles.
4584 (for-each
4585 (lambda (name)
4586 (define counter 0) ; For the targets
4587 (define target-deps "")
4588 (when (and (string-prefix? "generate" name)
4589 (string-suffix? ".sh" name))
4590 (let ((file (string-append "scripts/" name)))
4591 (substitute* file
4592 ;; Turn the commands into targets. Avoid comments and
4593 ;; lines starting with - (rest of multilines).
4594 (("\
4595^[[:space:]]*([^ #-].*/.*(\\.sh|\\.py|-o |--output)[^&]*).*$"
4596 _ command)
4597 (begin
4598 (set! counter (+ counter 1))
4599 (string-append "\ntarget" (number->string counter)
4600 ":" target-deps
4601 "\n\t" command)))
4602 ;; Remove trailing '&' characters.
4603 (("&?[[:space:]]*$") "\n")
4604 (("[[:space:]]*wait[[:space:]]*") "")
4605 ;; The commands after this line depend on the
4606 ;; previous commands in the file.
4607 (("JIT requires assembly files to be generated first.*" all)
4608 (begin
4609 (set! target-deps
4610 (string-append
4611 target-deps " target"
4612 (string-join
4613 (map number->string (iota counter 1)) " target")))
4614 all)))
4615 (display (string-append "Running " name "\n"))
4616 (apply invoke "make" "-s" "-f" file "-j"
4617 (number->string (parallel-job-count))
4618 (map
4619 (lambda (i)
4620 (string-append "target" (number->string i)))
4621 (iota counter 1))))))
4622 (scandir "scripts"))
4623 ;; These need to run after the above scripts
4624 (display "Remaining files\n")
4625 (invoke "python3" "tools/update-microkernels.py")
4626 (invoke "python3" "tools/generate-lut-norm-test.py"
4627 "--spec" "test/u8-lut32norm.yaml"
4628 "--output" "test/u8-lut32norm.cc")
4629 ;; Check existence to avoid doubling the phase for r-torch.
4630 (when (file-exists? "test/qd8-f16-qb4w-gemm-minmax.yaml")
4631 (invoke "python3" "tools/generate-gemm-test.py"
4632 "--spec" "test/qd8-f16-qb4w-gemm-minmax.yaml"
4633 "--output-test" "test/qd8-f16-qb4w-gemm-minmax.cc"))
4634 (when (file-exists? "test/qd8-f32-qb4w-gemm-minmax.yaml")
4635 (invoke "python3" "tools/generate-gemm-test.py"
4636 "--spec" "test/qd8-f32-qb4w-gemm-minmax.yaml"
4637 "--output-test" "test/qd8-f32-qb4w-gemm-minmax.cc")))))))
4638 (inputs
4639 (list clog
4640 cpuinfo
4641 pthreadpool
4642 googletest
4643 googlebenchmark
4644 fxdiv
4645 fp16
4646 psimd))
4647 (native-inputs
4648 (list python-pyyaml python-wrapper))
4649 (synopsis "Optimized floating-point neural network inference operators")
4650 (description
4651 "XNNPACK is a highly optimized library of floating-point neural network
4652inference operators for ARM, WebAssembly, and x86 platforms. XNNPACK is not
4653intended for direct use by deep learning practitioners and researchers;
4654instead it provides low-level performance primitives for accelerating
4655high-level machine learning frameworks, such as TensorFlow Lite,
4656TensorFlow.js, PyTorch, and MediaPipe.")
4657 (supported-systems
4658 '("armhf-linux" "aarch64-linux" "riscv64-linux"
4659 "i686-linux" "x86_64-linux"))
4660 (license license:bsd-3))))
4661
4662;; Warning: This package requires AVX2 or AVX-512 instructions.
4663(define-public fbgemm
4664 (package
4665 (name "fbgemm")
4666 (version "1.5.0")
4667 (source (origin
4668 (method git-fetch)
4669 (uri (git-reference
4670 (url "https://github.com/pytorch/fbgemm")
4671 (commit (string-append "v" version))))
4672 (file-name (git-file-name name version))
4673 (sha256
4674 (base32
4675 "0dygcx42iijyhgpj5a8lams1avvc4d0cnvrbgzgxvpf3zx50n01a"))
4676 (patches (search-patches "fbgemm-use-system-libraries.patch"))))
4677 (build-system cmake-build-system)
4678 (arguments
4679 (list
4680 #:configure-flags
4681 ''("-DFBGEMM_LIBRARY_TYPE=shared")
4682 ;; Tests require AVX2 or AVX-512 instructions
4683 #:tests? #f))
4684 (inputs (list cpuinfo))
4685 (propagated-inputs (list asmjit-1.17))
4686 (native-inputs (list pkg-config python googletest))
4687 (home-page "https://github.com/pytorch/fbgemm")
4688 (synopsis "Facebook GEneral Matrix Multiplication")
4689 (description "Low-precision, high-performance matrix-matrix
4690multiplications and convolution library for server-side inference.")
4691 (supported-systems '("x86_64-linux"))
4692 (license license:bsd-3)))
4693
4694(define-public tensorpipe
4695 (let ((commit "bb1473a4b38b18268e8693044afdb8635bc8351b")
4696 (revision "0"))
4697 (package
4698 (name "tensorpipe")
4699 (version (git-version "0" revision commit))
4700 (source (origin
4701 (method git-fetch)
4702 (uri (git-reference
4703 (url "https://github.com/pytorch/tensorpipe")
4704 (commit commit)))
4705 (file-name (git-file-name name version))
4706 (sha256
4707 (base32
4708 "0sbpkd69rzybw2j89sjkf4s0j8vkk96d51bsps28894989a75j6v"))
4709 (modules '((guix build utils)))
4710 (snippet
4711 '(delete-file-recursively "third_party"))))
4712 (build-system cmake-build-system)
4713 (arguments
4714 (list
4715 #:configure-flags
4716 ''("-DBUILD_SHARED_LIBS=ON")
4717 ;; There are no tests
4718 #:tests? #f))
4719 (inputs (list libuv))
4720 (native-inputs (list googletest pkg-config pybind11-2 libnop))
4721 (home-page "https://github.com/pytorch/tensorpipe")
4722 (synopsis "Tensor-aware point-to-point communication primitive for
4723machine learning")
4724 (description "TensorPipe provides a tensor-aware channel to transfer
4725rich objects from one process to another while using the fastest transport for
4726the tensors contained therein.")
4727 (license license:bsd-3))))
4728
4729(define-public tvm
4730 ;; Include a bug fix post 0.19 release.
4731 (let ((commit "d3a2ed68a42f8b51d8ab1533b62e837b9ea74b8e")
4732 (revision "1"))
4733 (package
4734 (name "tvm")
4735 (version (git-version "0.20.dev0" revision commit))
4736 (source
4737 (origin
4738 (method git-fetch)
4739 (uri (git-reference
4740 (url "https://github.com/apache/tvm")
4741 (commit commit)))
4742 (patches (search-patches "tvm_fix_cpptest_build.patch"))
4743 (file-name (git-file-name name version))
4744 (sha256
4745 (base32 "0ng52i0aydljnlrkyg069838c8b311fynhy5976w74smma2m7v72"))))
4746 (build-system cmake-build-system)
4747 (arguments
4748 (list
4749 #:configure-flags
4750 #~(list "-DUSE_OPENCL=ON"
4751 "-DUSE_VULKAN=ON"
4752 "-DUSE_OPENCL_ENABLE_HOST_PTR=ON"
4753 "-DINSTALL_DEV=ON"
4754 "-DUSE_GTEST=ON"
4755 "-DHIDE_PRIVATE_SYMBOLS=ON" ;per upstream build instructions
4756 "-DUSE_LLVM=llvm-config\\ --ignore-libllvm\\ --link-static"
4757 ;; per upstream build instructions
4758 (string-append "-DDLPACK_PATH="
4759 (assoc-ref %build-inputs "dlpack") "/include")
4760 (string-append "-DDMLC_PATH="
4761 (assoc-ref %build-inputs "dmlc-core")
4762 "/include")
4763 (string-append "-DRANG_PATH="
4764 (assoc-ref %build-inputs "rang") "/include"))
4765 #:phases
4766 #~(modify-phases %standard-phases
4767 (replace 'check
4768 (lambda* (#:key source tests? #:allow-other-keys)
4769 (when tests?
4770 (begin
4771 (invoke "make" "-j"
4772 (number->string (parallel-job-count)) "cpptest")
4773 ;; Disable below the actual run of the tests because
4774 ;; several fail due to platform variations (for example,
4775 ;; fp16 tests fail because not supported on CPUs).
4776 ;;
4777 ;; (chdir "..")
4778 ;; (invoke (which "bash")
4779 ;; (string-append source
4780 ;; "/tests/scripts/task_cpp_unittest.sh"))
4781 )))))))
4782 (inputs (list dmlc-core-next
4783 dlpack
4784 libedit
4785 libxml2
4786 llvm-19
4787 opencl-clhpp
4788 opencl-headers-2022
4789 rang
4790 mesa
4791 mesa-opencl
4792 spirv-headers
4793 spirv-tools
4794 vulkan-headers ;TODO; now not building due to missing vta-hw
4795 vulkan-loader
4796 zlib
4797 zstd))
4798 (native-inputs (list bash-minimal
4799 googletest
4800 (module-ref (resolve-interface '(gnu packages debug))
4801 'libbacktrace)
4802 pkg-config
4803 python
4804 python-cython))
4805 (home-page "https://tvm.apache.org/")
4806 (synopsis
4807 "Machine learning compiler framework for CPUs, GPUs and accelerators")
4808 (description
4809 "Apache TVM is a compiler stack for deep learning systems. It is
4810designed to close the gap between the productivity-focused deep learning
4811frameworks, and the performance- and efficiency-focused hardware backends.
4812TVM works with deep learning frameworks to provide end to end compilation to
4813different backends")
4814 (license license:asl2.0))))
4815
4816(define-public usearch
4817 (package
4818 (name "usearch")
4819 (version "2.26.2")
4820 (source
4821 (origin
4822 (method git-fetch)
4823 (uri (git-reference
4824 (url "https://github.com/unum-cloud/usearch")
4825 (commit (string-append "v" version))))
4826 (file-name (git-file-name name version))
4827 (sha256
4828 (base32
4829 "0j8nmqh9q7n15xwlpcs6zd8wr93yl4hn0kbf4v2fcwkkbj6khhzk"))))
4830 (build-system cmake-build-system)
4831 (arguments
4832 (list
4833 #:configure-flags
4834 #~(list "-DUSEARCH_INSTALL=ON"
4835 "-DUSEARCH_BUILD_BENCH_CPP=OFF")))
4836 (inputs (list stringzilla))
4837 (home-page "https://unum.cloud/usearch")
4838 (synopsis "Similarity search engine")
4839 (description "USearch is a free software search and clustering
4840engine. Features include:
4841@itemize
4842@item 10x faster HNSW implementation than FAISS.
4843@item Simple and extensible single C++11 header library.
4844@item SIMD-optimized and user-defined metrics with JIT compilation.
4845@item Hardware-agnostic bf16, e5m2, & i8 - half-precision & quarter-precision support.
4846@item View large indexes from disk without loading into RAM.
4847@item Heterogeneous lookups, renaming/relabeling, and on-the-fly deletions.
4848@item Binary Tanimoto and Sorensen coefficients for Genomics and Chemistry applications.
4849@item Space-efficient point-clouds with uint40_t, accommodating 4B+ size.
4850@item Compatible with OpenMP and custom \"executors\" for fine-grained parallelism.
4851@item Semantic Search and Joins.
4852@item Near-real-time clustering and sub-clustering for Tens or Millions of clusters.
4853@end itemize")
4854 (license license:asl2.0)))
4855
4856(define-public koboldcpp
4857 (package
4858 (name "koboldcpp")
4859 (version "1.122")
4860 (source
4861 (origin
4862 (method git-fetch)
4863 (uri (git-reference
4864 (url "https://github.com/LostRuins/koboldcpp")
4865 (commit (string-append "v" version))))
4866 (file-name (git-file-name name version))
4867 (snippet
4868 #~(begin
4869 (use-modules (guix build utils)
4870 (ice-9 ftw)
4871 (srfi srfi-26))
4872 (delete-file-recursively "lib")
4873 (for-each delete-file (find-files "." "\\.(dll|exe|bat)$"))))
4874 (sha256
4875 (base32 "184336v6n3a3l7gvirm230rkknn93i91710wpr6190sdg5rbmmgl"))))
4876 (build-system gnu-build-system)
4877 (arguments
4878 (list
4879 #:tests? #f ;no tests
4880 #:imported-modules %pyproject-build-system-modules
4881 #:modules '((guix build gnu-build-system)
4882 ((guix build pyproject-build-system) #:prefix python:)
4883 (guix build utils))
4884 #:make-flags
4885 #~(list (string-append "CC=" #$(cc-for-target))
4886 "LLAMA_VULKAN=1"
4887 "LLAMA_PORTABLE=1"
4888 "LLAMA_USE_BUNDLED_GLSLC=0") ;; TODO: add CLBLAS
4889 #:phases
4890 #~(modify-phases %standard-phases
4891 (delete 'configure)
4892 (replace 'install
4893 (lambda _
4894 (for-each
4895 (lambda (f)
4896 (install-file f (string-append #$output "/bin")))
4897 (append (list "koboldcpp.py"
4898 "vulkan-shaders-gen"
4899 "vulkan-shaders-gen-noext")
4900 ;; koboldcpp.py expects .so's
4901 ;; to be in the same directory
4902 (find-files "." "\\.so$")))))
4903 (add-after 'install 'python-wrap
4904 (lambda* (#:key inputs outputs #:allow-other-keys)
4905 ;; Upstream removed the executable flag.
4906 (chmod (search-input-file outputs "bin/koboldcpp.py") #o744)
4907 (wrap-program (search-input-file outputs "bin/koboldcpp.py")
4908 `("GUIX_PYTHONPATH" =
4909 (,(getenv "GUIX_PYTHONPATH")
4910 ,(python:site-packages inputs outputs)))))))))
4911 (inputs
4912 (list bash-minimal
4913 python
4914 python-customtkinter
4915 spirv-headers
4916 spirv-tools
4917 vulkan-headers
4918 vulkan-loader)) ;TODO: add OpenCL
4919 (native-inputs
4920 (list shaderc))
4921 (properties '((tunable? . #t)))
4922 (home-page "https://github.com/lostruins/koboldcpp")
4923 (synopsis "AI text-generation software for GGML and GGUF models")
4924 (description "KoboldCpp is an easy-to-use AI text-generation software for
4925GGML and GGUF models, builds off llama.cpp and adds many additional features:
4926
4927@itemize
4928@item Runs on CPU or GPU, supports full or partial offloaded
4929@item LLM text generation (Supports all GGML and GGUF models, backwards
4930compatibility with ALL past models)
4931@item Image Generation (Stable Diffusion 1.5, SDXL, SD3, Flux)
4932@item Speech-To-Text (Voice Recognition) via Whisper
4933@item Text-To-Speech (Voice Generation) via OuteTTS, Kokoro, Parler and Dia
4934@item Provides many compatible APIs endpoints for many popular webservices
4935(KoboldCppApi OpenAiApi OllamaApi A1111ForgeApi ComfyUiApi
4936WhisperTranscribeApi XttsApi OpenAiSpeechApi)
4937@item Bundled KoboldAI Lite UI with editing tools, save formats, memory,
4938world info, author's note, characters, scenarios
4939@item Includes multiple modes (chat, adventure, instruct, storywriter)
4940and UI Themes (aesthetic roleplay, classic writer, corporate assistant
4941messsenger)
4942@item Supports loading Tavern Character Cards, importing many different
4943data formats from various sites, reading or exporting JSON savefiles
4944and persistent stories
4945@item Many other features including new samplers, regex support
4946websearch, RAG via TextDB, image recognition/vision and more
4947@end itemize
4948
4949All up-to-date GGUF models are supported, and KoboldCpp also includes backward
4950compatibility for older versions/legacy GGML models.")
4951 (license (list license:agpl3 license:expat))))
4952
4953
4954(define-public foxi
4955 (let
4956 ((commit "c278588e34e535f0bb8f00df3880d26928038cad")
4957 (revision "0"))
4958 (package
4959 (name "foxi")
4960 (version (git-version "1.4.1" revision commit))
4961 (source (origin
4962 (method git-fetch)
4963 (uri (git-reference
4964 (url "https://github.com/houseroad/foxi")
4965 (commit commit)))
4966 (file-name (git-file-name name version))
4967 (sha256
4968 (base32
4969 "0q3ssm5hmmvwfwx87mnnajbavzgpahybw6rpn8ysr9r095dwgq5a"))
4970 (patches (search-patches "foxi-fix-build.patch"))))
4971 (build-system cmake-build-system)
4972 (arguments
4973 (list
4974 ;; No tests
4975 #:tests? #f))
4976 (home-page "https://github.com/houseroad/foxi")
4977 (synopsis "ONNXIFI with Facebook Extension")
4978 (description "ONNX Interface for Framework Integration is a cross-platform
4979API for loading and executing ONNX graphs on optimized backends. This package
4980contains facebook extensions and is used by PyTorch.")
4981 (license license:expat))))
4982
4983(define-public ideep-pytorch
4984 (package
4985 (name "ideep-pytorch")
4986 (version "3.7.1")
4987 (source
4988 (origin
4989 (method git-fetch)
4990 (uri (git-reference
4991 (url "https://github.com/intel/ideep")
4992 (commit (string-append "pytorch-rls-v" version))))
4993 (file-name (git-file-name name version))
4994 (sha256
4995 (base32
4996 "06h3q86k9jlb1ia6rc8adzqypab7x9dmy2gc49v80ylqxab6azar"))))
4997 (build-system copy-build-system)
4998 (arguments
4999 (list
5000 #:install-plan
5001 ''(("include" "include"))))
5002 (home-page "https://github.com/intel/ideep")
5003 (synopsis "Ideep headers for internal use by PyTorch")
5004 (description "This library is used internally as header-only library by
5005PyTorch.")
5006 (license license:expat)))
5007
5008(define %python-pytorch-version "2.10.0")
5009
5010(define %python-pytorch-src
5011 (origin
5012 (method git-fetch)
5013 (uri (git-reference
5014 (url "https://github.com/pytorch/pytorch")
5015 (commit (string-append "v" %python-pytorch-version))))
5016 (file-name (git-file-name "python-pytorch" %python-pytorch-version))
5017 (sha256
5018 (base32
5019 "05pw5i1fm1i3grj8ksyrprq3an4a5pzn4ii1jkym00d0nabgbkyx"))
5020 (patches (search-patches "python-pytorch-system-libraries.patch"
5021 "python-pytorch-runpath.patch"
5022 "python-pytorch-without-kineto.patch"
5023 ;; Some autogeneration scripts depend on the
5024 ;; compile PyTorch library. Therefore, we create
5025 ;; dummy versions which are regenerated later.
5026 "python-pytorch-fix-codegen.patch"))
5027 (modules '((guix build utils)))
5028 (snippet
5029 '(begin
5030 ;; Bundled or unused code
5031 (for-each
5032 (lambda (dir)
5033 (when (file-exists? dir)
5034 (delete-file-recursively dir)))
5035 '("android"
5036 "aten/src/ATen/native/cuda/cutlass_extensions"
5037 "aten/src/ATen/native/quantized/cpu/qnnpack"
5038 "caffe2/mobile/contrib/libopencl-stub"
5039 "caffe2/mobile/contrib/libvulkan-stub"
5040 "third_party"))
5041
5042 ;; Autogenerated files
5043 (for-each
5044 delete-file
5045 '("aten/src/ATen/nnapi/nnapi_wrapper.cpp"
5046 "aten/src/ATen/nnapi/nnapi_wrapper.h"
5047 ;; These files contain just lists of floating point values and
5048 ;; might be as well hand-written.
5049 ;; "test/cpp/api/init_baseline.h"
5050 ;; "test/cpp/api/optim_baseline.h"
5051 "test/mobile/test_upgrader_bytecode_table_example.cpp"
5052 "torch/csrc/jit/mobile/upgrader_mobile.cpp"
5053 "torch/csrc/jit/runtime/decomposition_registry_util.cpp"
5054 "torch/csrc/jit/runtime/serialized_shape_function_registry.cpp"
5055 "torch/csrc/jit/tensorexpr/external_functions_codegen.cpp"
5056 "torch/csrc/jit/serialization/mobile_bytecode_generated.h"))
5057 (delete-file-recursively ".github")
5058 (for-each
5059 (lambda (dir)
5060 (for-each
5061 delete-file
5062 (find-files dir "\\.cu$")))
5063 '("aten/src/ATen/native/transformers/cuda/flash_attn"
5064 "aten/src/ATen/native/transformers/cuda/mem_eff_attention"
5065 "aten/src/ATen/native/transformers/hip/flash_attn"))))))
5066
5067(define-public qnnpack-pytorch
5068 (package
5069 (inherit qnnpack)
5070 (name "qnnpack-pytorch")
5071 (version (string-append "pytorch-" %python-pytorch-version))
5072 (source
5073 (origin
5074 (inherit %python-pytorch-src)
5075 (patches '())
5076 (modules '((guix build utils)
5077 (srfi srfi-26)
5078 (ice-9 ftw)))
5079 (snippet
5080 '(begin
5081 (rename-file "aten/src/ATen/native/quantized/cpu/qnnpack"
5082 "../qnnpack")
5083 (let ((outdir (getcwd)))
5084 (chdir "..")
5085 (rename-file outdir "dummy")
5086 (rename-file "qnnpack" outdir)
5087 (chdir outdir)
5088 (delete-file-recursively "deps"))))))
5089 (arguments
5090 (substitute-keyword-arguments arguments
5091 ((#:phases phases #~%standard-phases)
5092 #~(modify-phases %standard-phases
5093 (add-after 'unpack 'patch-cmake
5094 (lambda _
5095 (substitute* "CMakeLists.txt"
5096 (("project\\(.*" orig)
5097 (apply
5098 string-append
5099 orig "\n"
5100 (map (lambda (name)
5101 (string-append
5102 "option(" name " \"\" ON)\n"))
5103 '("USE_SYSTEM_CPUINFO" "USE_SYSTEM_FP16" "USE_SYSTEM_FXDIV"
5104 "USE_SYSTEM_PSIMD" "USE_SYSTEM_PTHREADPOOL"))))
5105 (("if.*SOURCE_DIR.*")
5106 "if(FALSE)\n")
5107 (("if\\(NOT TARGET (clog|gtest|benchmark).*")
5108 "if(FALSE)\n")
5109 (("target_link_libraries.*(fxdiv|psimd|fp16)\\).*")
5110 "")
5111 (("(target_link_libraries.*) fp16 (.*)" _ before after)
5112 (string-append before " " after)))))
5113 (add-after 'unpack 'fix-cstring-include
5114 (lambda _
5115 (substitute* "include/pack_block_sparse.h"
5116 (("#include.*<vector>.*" orig)
5117 (string-append orig "\n#include <cstring>\n")))))
5118 (add-after 'install 'install-missing-headers
5119 (lambda _
5120 (for-each
5121 (lambda (name)
5122 (install-file (string-append "../source/include/" name)
5123 (string-append #$output "/include")))
5124 '("pack_block_sparse.h"
5125 "pytorch_qnnpack.h"
5126 "qnnpack_func.h"))
5127 (copy-recursively
5128 "../source/src/qnnpack"
5129 (string-append #$output "/include/qnnpack"))))))
5130 ;; Some tests occasionally fail on i686 due to floating point rounding.
5131 ((#:tests? _ #t)
5132 (not (string-prefix? "i686" (or (%current-target-system)
5133 (%current-system)))))))))
5134
5135;; Please also update python-torchvision when updating this package.
5136(define-public python-pytorch
5137 (package
5138 (name "python-pytorch")
5139 (version %python-pytorch-version)
5140 (source %python-pytorch-src)
5141 (build-system pyproject-build-system)
5142 (arguments
5143 (list
5144 ;; Even only the core tests take a very long time to run.
5145 #:tests? #f
5146 #:phases
5147 #~(modify-phases %standard-phases
5148 (add-after 'unpack 'patch-build-system
5149 (lambda _
5150 (substitute* "pyproject.toml"
5151 (("setuptools\\.build_meta:__legacy__")
5152 "setuptools.build_meta"))))
5153 (add-after 'unpack 'cmake-patches
5154 (lambda* (#:key inputs outputs #:allow-other-keys)
5155 (substitute* "cmake/Dependencies.cmake"
5156 (("#POCKETFFT_INCLUDE_DIR")
5157 (string-append
5158 #$(this-package-native-input "pocketfft-cpp") "/include"))
5159 (("#FP16_INCLUDE_DIR")
5160 (string-append
5161 #$(this-package-input "fp16") "/include"))
5162 (("#CONCURRENTQUEUE_INCLUDE_DIR")
5163 (search-input-directory inputs "include/concurrentqueue"))
5164 ;; Disable opentelemetry
5165 ((".*(add_library|target_include_directories).*opentelemetry.*")
5166 ""))
5167 (substitute* "torch/CMakeLists.txt"
5168 ((".*opentelemetry.*") ""))
5169 ;; Fix Python install directory
5170 (substitute* "caffe2/CMakeLists.txt"
5171 (("\\$\\{Python_SITELIB\\}")
5172 (site-packages inputs outputs)))
5173 ;; Ensure httplib::httplib is defined when used.
5174 (substitute* "cmake/Caffe2Config.cmake.in"
5175 (("include *\\(.*Caffe2Targets\\.cmake.*\\)" all)
5176 (string-append "find_package(httplib REQUIRED)\n" all)))))
5177 ;; This entry point is broken, because it refers to a module that is
5178 ;; (intentionally) not installed
5179 ;; (https://github.com/pytorch/pytorch/pull/134729), which causes
5180 ;; the 'sanity-check phase to fail.
5181 (add-after 'unpack 'remove-fr-trace-script
5182 (lambda _
5183 (substitute* "setup.py"
5184 (("entry_points\\[\"console_scripts\"\\]\\.append\\(") "("))))
5185 (add-after 'remove-fr-trace-script 'skip-pip-redirect
5186 (lambda _
5187 ;; Keep using setup.py directly instead of invoking pip.
5188 (substitute* "setup.py"
5189 (("if arg == \"install\":")
5190 "if False and arg == \"install\":"))))
5191 (add-before 'build 'use-system-libraries
5192 (lambda _
5193 (for-each
5194 (lambda (file)
5195 ;; Check whether the files exist for the
5196 ;; python-pytorch-for-r-torch package
5197 (when (file-exists? file)
5198 (substitute* file
5199 (("\"miniz\\.h\"") "<miniz/miniz.h>")
5200 (("<miniz\\.h>") "<miniz/miniz.h>"))))
5201 '("caffe2/serialize/crc.cc"
5202 "caffe2/serialize/inline_container.cc"
5203 "torch/csrc/inductor/aoti_package/model_package_loader.cpp"))
5204
5205 ;; Fix missing include for getCvarString/getCvarInt.
5206 (substitute* "torch/csrc/distributed/c10d/GlooDeviceFactory.cpp"
5207 (("#include <c10/util/Exception.h>" all)
5208 (string-append
5209 "#include <torch/csrc/distributed/c10d/Utils.hpp>\n\n"
5210 all)))
5211
5212 ;; Fix moodycamel/concurrentqueue includes for system package
5213 (substitute* '("c10/util/Semaphore.h"
5214 "c10/test/util/Semaphore_test.cpp"
5215 "torch/nativert/executor/ParallelGraphExecutor.cpp")
5216 (("<moodycamel/concurrentqueue\\.h>") "<concurrentqueue.h>")
5217 (("<moodycamel/lightweightsemaphore\\.h>")
5218 "<lightweightsemaphore.h>"))
5219
5220 (substitute* "aten/src/ATen/native/vulkan/api/Allocator.h"
5221 (("<include/vk_mem_alloc.h>")
5222 "<vk_mem_alloc.h>"))
5223 ;; Fix missing <algorithm> header for std::for_each in Vulkan API
5224 (substitute* "aten/src/ATen/native/vulkan/api/QueryPool.cpp"
5225 (("#include <utility>" all)
5226 (string-append all "\n#include <algorithm>")))
5227 ;; For Vulkan
5228 (substitute* "CMakeLists.txt"
5229 (("append_cxx_flag.*-Werror=(return-type|range-loop-construct).*") ""))
5230 (substitute*
5231 (cons*
5232 "torch/csrc/Module.cpp"
5233 (map
5234 (lambda (name)
5235 (string-append
5236 "torch/utils/benchmark/utils/valgrind_wrapper/"
5237 name))
5238 '("compat_bindings.cpp" "timer_callgrind_template.cpp")))
5239 (("<callgrind.h>") "<valgrind/callgrind.h>"))
5240 (setenv "USE_VULKAN" "1")
5241 ;; Tell 'setup.py' to let 'CMakeLists.txt' know that we
5242 ;; want to use "system libraries" instead of the bundled
5243 ;; ones.
5244 (setenv "USE_SYSTEM_LIBS" "1")
5245 ;; For oneDNN
5246 (setenv "USE_MKLDNN" "1")
5247 ;; Only works with CUPTI
5248 (setenv "USE_KINETO" "0")
5249 ;; Prevent CMake error by disabling explicitely
5250 (setenv "USE_ITT" "0")
5251 ;; Disable on unsupported systems
5252 (if #$(not (member
5253 (or (%current-target-system)
5254 (%current-system))
5255 (package-transitive-supported-systems qnnpack)))
5256 (setenv "USE_QNNPACK" "0"))
5257 (substitute* '("requirements.txt" "setup.py")
5258 (("sympy>=1\\.13\\.3")
5259 "sympy>=1.13.1"))
5260 ;; Avoid ModuleNotFoundError while preserving setup.py flow.
5261 (substitute* "setup.py"
5262 (("from build_bundled import create_bundled")
5263 "create_bundled = lambda *args, **kwargs: None"))))
5264 (add-after 'use-system-libraries 'skip-nccl-call
5265 (lambda _
5266 ;; Comment-out `checkout_nccl()` invokation in build_pytorch().
5267 (substitute* "tools/build_pytorch_libs.py"
5268 (("^[[:blank:]]*checkout_nccl\\(\\)" all)
5269 (string-append "# " all "\n pass")))))
5270 ;; PyTorch is still built with AVX2 and AVX-512 support selected at
5271 ;; runtime, but these dependencies require it (nnpack only for
5272 ;; x86_64).
5273 (add-before 'build 'disable-avx-dependencies
5274 (lambda _
5275 (setenv "USE_FBGEMM" "0")
5276 (if #$(not
5277 (member (or (%current-target-system)
5278 (%current-system))
5279 '("armhf-linux" "aarch64-linux")))
5280 (setenv "USE_NNPACK" "0"))))
5281 (add-after 'use-system-libraries 'set-max-jobs
5282 (lambda _
5283 (setenv "MAX_JOBS" (number->string (parallel-job-count)))))
5284 (add-after 'set-max-jobs 'codegen1
5285 (lambda _
5286 (with-directory-excursion "torch/csrc/jit/tensorexpr"
5287 (setenv "PYTHONPATH" "../../../..")
5288 (invoke "python3" "codegen_external.py")
5289 (setenv "PYTHONPATH" #f))
5290
5291 (invoke "python3" "aten/src/ATen/nnapi/codegen.py")
5292
5293 (invoke "bash" "tools/gen_flatbuffers.sh")
5294
5295 ;; Generate dummy files as the generation depends on the compiled
5296 ;; library. They are regenerated later.
5297 (setenv "PYTHONPATH" ".")
5298 (invoke "python3"
5299 "torchgen/operator_versions/gen_mobile_upgraders.py"
5300 "dummy")
5301 (setenv "PYTHONPATH" #f)
5302
5303 (invoke "python3"
5304 "torchgen/shape_functions/gen_jit_shape_functions.py"
5305 "dummy")
5306
5307 (invoke "python3"
5308 "torchgen/decompositions/gen_jit_decompositions.py"
5309 "dummy")))
5310 ;; Properly generate autogenerated files ...
5311 (add-after 'install 'codegen2
5312 (lambda* (#:key inputs outputs #:allow-other-keys)
5313 (add-installed-pythonpath inputs outputs)
5314 (invoke "python3"
5315 "torchgen/operator_versions/gen_mobile_upgraders.py")
5316 (invoke "python3"
5317 "torchgen/shape_functions/gen_jit_shape_functions.py")
5318 (invoke "python3"
5319 "torchgen/decompositions/gen_jit_decompositions.py")))
5320 ;; ... rebuild their dependencies ...
5321 (add-after 'codegen2 'build2
5322 (lambda _
5323 (invoke "python3" "setup.py" "build")))
5324 ;; ... and install again.
5325 (add-after 'build2 'install2
5326 (lambda _
5327 (invoke "python3" "setup.py" "install" (string-append "--prefix=" #$output)
5328 "--no-compile" "--single-version-externally-managed" "--root=/")
5329 (invoke "python" "-m" "compileall"
5330 "--invalidation-mode=unchecked-hash" #$output)))
5331 (replace 'check
5332 (lambda* (#:key tests? #:allow-other-keys)
5333 ;; Run the test suite following the instructions in
5334 ;; 'CONTRIBUTING.md'. Unfortunately this doesn't work, unless
5335 ;; you set PYTHONPATH or GUIX_PYTHONPATH, but this is done in
5336 ;; the codegen2 phase already.
5337 (when tests?
5338 (invoke "python3" "test/run_test.py" "--core"))))
5339 (add-after 'install2 'remove-test-executables
5340 (lambda* (#:key inputs outputs #:allow-other-keys)
5341 ;; Remove test executables, but keep other executables
5342 ;; such as 'torch_shm_manager' and and .so files such as
5343 ;; 'libtorch_global_deps.so'.
5344 (let ((python-site (site-packages inputs outputs)))
5345 (for-each delete-file
5346 (find-files python-site
5347 "(^test_cpp_rpc|_test)$")))))
5348 (add-after 'install2 'remove-caffe2-onnx-scripts
5349 (lambda _
5350 (let ((bin (string-append #$output "/bin")))
5351 ;; Remove 'convert-caffe2-to-onnx' and
5352 ;; 'convert-onnx-to-caffe2': they seem to be
5353 ;; deprecated and they cause a failure of the
5354 ;; 'sanity-check' phase:
5355 ;;
5356 ;; ImportError: cannot import name 'metanet_pb2' from
5357 ;; partially initialized module 'caffe2.proto' (most likely
5358 ;; due to a circular import)
5359 (for-each delete-file
5360 (find-files bin "^convert-.*caffe2"))
5361
5362 (substitute* (find-files #$output "^entry_points\\.txt$")
5363 (("^convert-.*" all)
5364 (string-append "# " all "\n")))))))))
5365 (native-inputs
5366 (list cmake-minimal
5367 doxygen
5368 ideep-pytorch
5369 ninja
5370 nlohmann-json
5371 pocketfft-cpp
5372 python-expecttest
5373 python-pytest-flakefinder
5374 python-pytest-rerunfailures
5375 python-pytest-shard
5376 python-pytest-xdist
5377 python-hypothesis
5378 python-setuptools
5379 python-types-dataclasses
5380 shaderc
5381 valgrind/pinned))
5382 (inputs
5383 (append
5384 (list brotli ; for cpp-httplib
5385 clog
5386 concurrentqueue
5387 cpp-httplib
5388 eigen
5389 flatbuffers
5390 fmt
5391 fp16
5392 fxdiv
5393 gemmlowp
5394 gloo
5395 googletest-1.12
5396 googlebenchmark
5397 libuv
5398 miniz-for-pytorch
5399 onednn
5400 openblas
5401 openmpi
5402 openssl ; for cpp-httplib
5403 pthreadpool
5404 protobuf
5405 pybind11-2
5406 ;; qnnpack
5407 qnnpack-pytorch
5408 rdma-core
5409 sleef
5410 tensorpipe
5411 vulkan-headers
5412 vulkan-loader
5413 vulkan-memory-allocator
5414 xnnpack
5415 zlib ; for cpp-httplib
5416 zstd)
5417 ;; nnpack requires AVX2 for x86_64-linux
5418 (if (equal? (or (%current-target-system)
5419 (%current-system))
5420 '("aarch64-linux"))
5421 (list nnpack)
5422 '())))
5423 (propagated-inputs
5424 (append
5425 (list cpuinfo
5426 onnx ;propagated for its Python modules
5427 onnx-optimizer
5428 python-astunparse
5429 python-click
5430 python-filelock
5431 python-fsspec
5432 python-future
5433 python-jinja2
5434 python-networkx
5435 python-numpy
5436 python-opt-einsum
5437 python-optree
5438 python-packaging
5439 python-psutil
5440 python-pyyaml
5441 python-requests
5442 python-sympy
5443 python-typing-extensions)))
5444 (home-page "https://pytorch.org/")
5445 (synopsis "Python library for tensor computation and deep neural networks")
5446 ;; TODO: Support other 64-bit systems.
5447 (supported-systems '("x86_64-linux" "aarch64-linux"))
5448 (description
5449 "PyTorch is a Python package that provides two high-level features:
5450
5451@itemize
5452@item tensor computation (like NumPy) with strong GPU acceleration;
5453@item deep neural networks (DNNs) built on a tape-based autograd system.
5454@end itemize
5455
5456You can reuse Python packages such as NumPy, SciPy, and Cython to extend
5457PyTorch when needed.
5458
5459Note: currently this package does not provide GPU support.")
5460 (license license:bsd-3)))
5461
5462(define-public python-torchaudio
5463 (package
5464 (name "python-torchaudio")
5465 (version %python-pytorch-version)
5466 (source
5467 (origin
5468 (method git-fetch)
5469 (uri (git-reference
5470 (url "https://github.com/pytorch/audio")
5471 (commit (string-append "v" version))))
5472 (file-name (git-file-name name version))
5473 (sha256
5474 (base32 "1j2h722cvvwa4g4vq8gw9x214ara6qimjmyvdm1x2x2pa4fj6nvg"))))
5475 (build-system pyproject-build-system)
5476 (arguments
5477 (list
5478 #:test-flags
5479 #~(list
5480 ;; XXX: Those packages require additional inputs.
5481 "--ignore=\
5482test/torchaudio_unittest/prototype/hifi_gan/hifi_gan_cpu_test.py"
5483 "--ignore=\
5484test/torchaudio_unittest/prototype/hifi_gan/hifi_gan_gpu_test.py"
5485 "--ignore=test/torchaudio_unittest/kaldi_io_test.py"
5486 "--ignore=test/torchaudio_unittest/test_load_save_torchcodec.py"
5487 "--ignore-glob=test/torchaudio_unittest/backend/dispatcher/ffmpeg"
5488 ;; Dataset tests require torchcodec (used by 'torchaudio.load').
5489 "--ignore-glob=test/torchaudio_unittest/datasets"
5490 ;; XXX: We don't really want to run those tests.
5491 "--ignore-glob=test/torchaudio_unittest/example"
5492 ;; XXX: Integration tests require additional data / models.
5493 "--ignore-glob=test/integration_tests"
5494 ;; XXX: Those tests are very costly.
5495 "--ignore-glob=test/torchaudio_unittest/functional"
5496 "--ignore-glob=test/torchaudio_unittest/models"
5497 "--ignore=test/torchaudio_unittest/models/models_test.py"
5498 "--ignore=test/torchaudio_unittest/transforms/autograd_cpu_test.py"
5499 "-k" (string-append
5500 "not test_torchscript_fails" ; requires BUILD_SOX=1
5501 ;; XXX: Unmatching harmless warning message.
5502 " and not test_unknown_subtype_warning"
5503 ;; Skip TorchScript consistency tests that fail with 2.9.0
5504 " and not test_FrequencyMasking"
5505 " and not test_TimeMasking"
5506 " and not test_deemphasis"
5507 " and not test_rnnt_loss"))
5508 #:phases
5509 #~(modify-phases %standard-phases
5510 (add-before 'build 'configure
5511 (lambda* (#:key inputs outputs #:allow-other-keys)
5512 (setenv "BUILD_SOX" "0")
5513 (setenv "USE_FFMPEG" "0")
5514 (substitute* "tools/setup_helpers/extension.py"
5515 (("^( *)\"-DCMAKE_VERBOSE_MAKEFILE=ON\"," all blank)
5516 (string-append
5517 blank "f\"-DCMAKE_INSTALL_RPATH="
5518 (site-packages inputs
5519 `(("out" .
5520 ,(assoc-ref inputs "python-pytorch"))))
5521 "/torch/lib;"
5522 (site-packages inputs outputs) "/torchaudio/lib\",\n"
5523 blank "\"-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON\",\n"
5524 all))))))))
5525 (native-inputs
5526 (list cmake
5527 ninja
5528 onednn
5529 python-expecttest
5530 python-parameterized
5531 python-pytest
5532 python-scipy
5533 python-setuptools
5534 python-wheel
5535 sox))
5536 (inputs (package-inputs python-pytorch))
5537 (propagated-inputs (list python-soundfile python-pytorch))
5538 (home-page "https://pytorch.org/audio")
5539 (synopsis
5540 "Data manipulation and transformation for audio signal processing")
5541 (description
5542 "This package provides a machine learning library of popular datasets,
5543model architectures, and common transformations to apply @code{python-pytorch}
5544in the audio domain.")
5545 (license license:bsd-2)))
5546
5547;; This package variant includes the dependencies requiring at least AVX2 or
5548;; AVX-512.
5549(define-public python-pytorch-avx
5550 (package/inherit python-pytorch
5551 (name "python-pytorch-avx")
5552 (inputs
5553 (modify-inputs inputs
5554 (append fbgemm nnpack)))
5555 (arguments
5556 (substitute-keyword-arguments arguments
5557 ((#:phases phases)
5558 #~(modify-phases #$phases
5559 (delete 'disable-avx-dependencies)))))
5560 (supported-systems '("x86_64-linux"))))
5561
5562(define %python-pytorch-for-r-torch-version "2.7.1")
5563
5564(define %python-pytorch-for-r-torch-src
5565 (origin
5566 (inherit %python-pytorch-src)
5567 (uri (git-reference
5568 (url "https://github.com/pytorch/pytorch")
5569 (commit (string-append "v" %python-pytorch-for-r-torch-version))))
5570 (file-name (git-file-name "python-pytorch"
5571 %python-pytorch-for-r-torch-version))
5572 (sha256
5573 (base32
5574 "0734kfm66hsqdzgs2s4wj5yagvifijbgb0c5wfmp3qcdrraa9x57"))
5575 (patches (search-patches
5576 "python-pytorch-for-r-torch-system-libraries.patch"
5577 "python-pytorch-runpath.patch"
5578 "python-pytorch-for-r-torch-without-kineto.patch"
5579 ;; Some autogeneration scripts depend on the
5580 ;; compile PyTorch library. Therefore, we create
5581 ;; dummy versions which are regenerated later.
5582 "python-pytorch-for-r-torch-fix-codegen.patch"))))
5583
5584;; Keep in sync with r-torch
5585(define-public python-pytorch-for-r-torch
5586 (package
5587 (inherit python-pytorch)
5588 (name "python-pytorch")
5589 (version %python-pytorch-for-r-torch-version)
5590 (source %python-pytorch-for-r-torch-src)
5591 (build-system pyproject-build-system)
5592 (inputs
5593 (modify-inputs inputs
5594 (replace "gloo" gloo-for-r-torch)))
5595 (arguments
5596 (substitute-keyword-arguments arguments
5597 ((#:phases phases)
5598 #~(modify-phases #$phases
5599 (replace 'use-system-libraries
5600 (lambda _
5601 (for-each
5602 (lambda (file)
5603 ;; Check whether the files exist for the
5604 ;; python-pytorch-for-r-torch package
5605 (when (file-exists? file)
5606 (substitute* file
5607 (("\"miniz\\.h\"") "<miniz/miniz.h>")
5608 (("<miniz\\.h>") "<miniz/miniz.h>"))))
5609 '("caffe2/serialize/crc.cc"
5610 "caffe2/serialize/inline_container.cc"
5611 "torch/csrc/inductor/aoti_package/model_package_loader.cpp"))
5612
5613 (substitute* "aten/src/ATen/native/vulkan/api/Allocator.h"
5614 (("<include/vk_mem_alloc.h>")
5615 "<vk_mem_alloc.h>"))
5616 ;; Fix missing <algorithm> header for std::for_each in Vulkan API
5617 (substitute* "aten/src/ATen/native/vulkan/api/QueryPool.cpp"
5618 (("#include <utility>" all)
5619 (string-append all "\n#include <algorithm>")))
5620 ;; For Vulkan
5621 (substitute* "CMakeLists.txt"
5622 (("append_cxx_flag.*-Werror=(return-type|range-loop-construct).*") ""))
5623 ;; In this variant functorch is installed directly under
5624 ;; site-packages/functorch, so use a direct rpath to
5625 ;; site-packages/torch/lib.
5626 (substitute* "functorch/CMakeLists.txt"
5627 (("set_target_properties\\(\\$\\{PROJECT_NAME\\} PROPERTIES INSTALL_RPATH \"\\$\\{_rpath_portable_origin\\}/\\.\\./torch/lib\"\\)")
5628 "set_target_properties(${PROJECT_NAME} PROPERTIES INSTALL_RPATH \"$ORIGIN/../torch/lib\")"))
5629 (substitute*
5630 (cons*
5631 "torch/csrc/Module.cpp"
5632 (map
5633 (lambda (name)
5634 (string-append
5635 "torch/utils/benchmark/utils/valgrind_wrapper/"
5636 name))
5637 '("compat_bindings.cpp" "timer_callgrind_template.cpp")))
5638 (("<callgrind.h>") "<valgrind/callgrind.h>"))
5639 (setenv "USE_VULKAN" "1")
5640 ;; Tell 'setup.py' to let 'CMakeLists.txt' know that we
5641 ;; want to use "system libraries" instead of the bundled
5642 ;; ones.
5643 (setenv "USE_SYSTEM_LIBS" "1")
5644 ;; For oneDNN
5645 (setenv "USE_MKLDNN" "1")
5646 ;; Only works with CUPTI
5647 (setenv "USE_KINETO" "0")
5648 ;; Prevent CMake error by disabling explicitely
5649 (setenv "USE_ITT" "0")
5650 ;; Disable on unsupported systems
5651 (if #$(not (member
5652 (or (%current-target-system)
5653 (%current-system))
5654 (package-transitive-supported-systems qnnpack)))
5655 (setenv "USE_QNNPACK" "0"))
5656 (substitute* '("requirements.txt" "setup.py")
5657 (("sympy>=1\\.13\\.3")
5658 "sympy>=1.13.1"))
5659 ;; Avoid ModuleNotFoundError while preserving setup.py flow.
5660 (substitute* "setup.py"
5661 (("from build_bundled import create_bundled")
5662 "create_bundled = lambda *args, **kwargs: None"))))
5663 (replace 'skip-nccl-call
5664 (lambda _
5665 ;; Comment-out `checkout_nccl()` invokation in build_pytorch().
5666 (substitute* "tools/build_pytorch_libs.py"
5667 (("^[[:blank:]]*checkout_nccl\\(\\)" all)
5668 (string-append "# " all "\n pass")))))))))))
5669
5670(define-public python-pytorch-geometric
5671 (package
5672 (name "python-pytorch-geometric")
5673 (version "2.7.0")
5674 (source (origin
5675 (method git-fetch)
5676 (uri (git-reference
5677 (url "https://github.com/pyg-team/pytorch_geometric/")
5678 (commit version)))
5679 (file-name (git-file-name name version))
5680 (sha256
5681 (base32
5682 "0w6gpw0wf9w6h317mbqcf3iidx9yqjba34348p44g80ihskb6ly6"))))
5683 (build-system pyproject-build-system)
5684 (arguments
5685 (list
5686 #:test-flags
5687 '(list ;; PyTorch 2.10 raises deprecation warnings during import.
5688 "-W" "ignore::DeprecationWarning"
5689 ;; Hangs with AttributeError: 'NoneType' object has no attribute 'rpc_async'
5690 "--ignore=test/distributed/test_rpc.py"
5691 ;; A message passing jinja template is missing
5692 "--ignore=test/nn/conv/test_message_passing.py"
5693 "--ignore=test/nn/test_sequential.py"
5694 "--ignore=test/nn/models/test_basic_gnn.py"
5695 ;; These all fail with a size mismatch error such as
5696 ;; RuntimeError: shape '[-1, 2, 1, 1]' is invalid for input of size 3
5697 "--ignore=test/explain/algorithm/test_captum_explainer.py"
5698 ;; Requires the nonfree MKL on CPU.
5699 "--ignore=test/nn/models/test_graph_unet.py"
5700 "-k" (string-append
5701 ;; Permissions error
5702 "not test_packaging"
5703 ;; Unknown multiprocessing failure
5704 " and not test_data_share_memory"
5705 ;; This can fail due to accuracy problems
5706 " and not test_gdc"
5707 ;; These refuse to be run on CPU and really want a GPU
5708 " and not test_add_random_walk_pe"
5709 " and not test_asap"
5710 " and not test_two_hop"
5711 ;; Failed when switched to [email protected]
5712 ;; typing module internals
5713 " and not test_type_repr"))
5714 #:phases
5715 '(modify-phases %standard-phases
5716 (add-after 'unpack 'delete-top-level-directories
5717 (lambda _
5718 ;; The presence of these directories confuses the pyproject build
5719 ;; system.
5720 (for-each delete-file-recursively
5721 '("docker" "graphgym")))))))
5722 (propagated-inputs
5723 (list onnx
5724 python-captum
5725 python-graphviz
5726 python-h5py
5727 python-jinja2
5728 python-matplotlib
5729 python-networkx
5730 python-numba
5731 python-numpy
5732 python-opt-einsum
5733 python-pandas
5734 python-protobuf
5735 python-psutil
5736 python-pyparsing
5737 python-pytorch-lightning
5738 python-rdflib
5739 python-requests
5740 python-scikit-image
5741 python-scikit-learn
5742 python-scipy
5743 python-statsmodels
5744 python-sympy
5745 python-tabulate
5746 python-torchmetrics
5747 python-tqdm
5748 python-xxhash))
5749 (native-inputs
5750 (list openssl python-flit-core python-pytest))
5751 (home-page "https://pyg.org")
5752 (synopsis "Graph Neural Network library for PyTorch")
5753 (description
5754 "PyG is a library built upon PyTorch to easily write and train Graph
5755Neural Networks for a wide range of applications related to structured data.")
5756 (license license:expat)))
5757
5758(define-public python-lightning-cloud
5759 (package
5760 (name "python-lightning-cloud")
5761 (version "0.6.0")
5762 (source (origin
5763 (method url-fetch)
5764 (uri (pypi-uri "lightning_cloud" version))
5765 (sha256
5766 (base32
5767 "1g3zwn8r33gkmx529mvyddbrx0wqwf6125qimj4xfchf53g0qkn4"))))
5768 (arguments (list #:tests? #f)) ; no tests in PyPI archive.
5769 (build-system pyproject-build-system)
5770 (propagated-inputs (list python-boto3
5771 python-click
5772 python-fastapi
5773 python-multipart
5774 python-protobuf
5775 python-pyjwt
5776 python-requests
5777 python-rich
5778 python-six
5779 python-urllib3
5780 python-uvicorn
5781 python-websocket-client))
5782 (native-inputs (list python-setuptools))
5783 (home-page "https://lightning.ai")
5784 (synopsis "Lightning Cloud command line client")
5785 (description "This package provides a command line interface for Lightning
5786AI services.")
5787 (license license:asl2.0)))
5788
5789(define-public python-lightning-utilities
5790 (package
5791 (name "python-lightning-utilities")
5792 (version "0.15.3")
5793 (source
5794 (origin
5795 (method git-fetch)
5796 (uri (git-reference
5797 (url "https://github.com/Lightning-AI/utilities")
5798 (commit (string-append "v" version))))
5799 (file-name (git-file-name name version))
5800 (sha256
5801 (base32 "0krdvabdi1lcix5jvjjrrqyh6ibjwabc0g724mpi32gsz6g7ppwg"))))
5802 (build-system pyproject-build-system)
5803 (arguments
5804 (list #:tests? #f)) ;XXX: cycles with python-pytorch-lightning
5805 (native-inputs
5806 (list python-setuptools))
5807 (propagated-inputs
5808 (list python-packaging
5809 python-typing-extensions))
5810 (home-page "https://github.com/Lightning-AI/utilities")
5811 (synopsis "PyTorch Lightning sample project")
5812 (description "This package provides common Python utilities and GitHub
5813Actions for the Lightning suite of libraries.")
5814 (license license:asl2.0)))
5815
5816(define-public python-captum
5817 (package
5818 (name "python-captum")
5819 ;; The latest commit provides compatability with NumPy 2.
5820 (properties '((commit . "4fade3af8dc398c1f96b193c969565aad23aedf5")
5821 (revision . "0")))
5822 (version (git-version "0.8.0"
5823 (assoc-ref properties 'revision)
5824 (assoc-ref properties 'commit)))
5825 (source (origin
5826 (method git-fetch)
5827 (uri (git-reference
5828 (url "https://github.com/pytorch/captum")
5829 (commit (assoc-ref properties 'commit))))
5830 (file-name (git-file-name name version))
5831 (sha256
5832 (base32
5833 "1v1di9kk2xinwwcll5q514fn9r6ivj3zzgg6l5h7dwlsn2vymsnd"))))
5834 (build-system pyproject-build-system)
5835 (arguments
5836 (list
5837 ;; tests: 17 failed, 1368 passed, 75 skipped, 3 deselected, 542 warnings
5838 #:test-flags
5839 #~(list "-k" (string-append
5840 ;; These two tests (out of more than 1000 tests) fail
5841 ;; because of accuracy problems.
5842 "not test_softmax_classification_batch_multi_target"
5843 " and not test_softmax_classification_batch_zero_baseline"
5844 ;; This test fails with PyTorch 2.7.0 due to stricter
5845 ;; torch.load weights_only behavior.
5846 " and not test_exp_sets_with_diffent_lengths")
5847 "tests")))
5848 (native-inputs
5849 (list python-flask
5850 python-pytest
5851 python-flask-compress
5852 python-parameterized
5853 python-scikit-learn
5854 python-setuptools))
5855 (propagated-inputs
5856 (list python-matplotlib
5857 python-numpy
5858 python-pytorch
5859 python-tqdm
5860 ;; [optional]
5861 python-openai))
5862 (home-page "https://captum.ai")
5863 (synopsis "Model interpretability for PyTorch")
5864 (description "Captum is a model interpretability and understanding library
5865for PyTorch. Captum contains general purpose implementations of integrated
5866gradients, saliency maps, smoothgrad, vargrad and others for PyTorch models.
5867It has quick integration for models built with domain-specific libraries such
5868as torchvision, torchtext, and others.")
5869 (license license:bsd-3)))
5870
5871(define-public python-readchar
5872 (package
5873 (name "python-readchar")
5874 (version "4.2.2")
5875 (source
5876 (origin
5877 (method git-fetch)
5878 (uri (git-reference
5879 (url "https://github.com/magmax/python-readchar/")
5880 (commit (string-append "v" version))))
5881 (file-name (git-file-name name version))
5882 (sha256
5883 (base32 "1m5knal63lg1pmhkkkcpvz1vq6k5rpar4yvq1rafc4q47m2cfaaq"))))
5884 (build-system pyproject-build-system)
5885 (native-inputs
5886 (list python-pytest python-setuptools))
5887 (home-page "https://github.com/magmax/python-readchar")
5888 (synopsis "Library to easily read single chars and key strokes")
5889 (description "This package provides a Python library to easily read single
5890characters and key strokes.")
5891 (license license:expat)))
5892
5893(define-public python-inquirer
5894 (package
5895 (name "python-inquirer")
5896 (version "3.4.1")
5897 ;; Pypi has no tests.
5898 (source (origin
5899 (method git-fetch)
5900 (uri (git-reference
5901 (url "https://github.com/magmax/python-inquirer")
5902 (commit (string-append "v" version))))
5903 (file-name (git-file-name name version))
5904 (sha256
5905 (base32
5906 "10ncdjz0z09m9piqxyk3yxqk1rd9icij46a9djqj7rwdj5sfclf5"))))
5907 (build-system pyproject-build-system)
5908 (propagated-inputs
5909 (list python-blessed python-editor python-readchar))
5910 (native-inputs
5911 (list python-poetry-core python-pexpect python-pytest))
5912 (home-page "https://github.com/magmax/python-inquirer")
5913 (synopsis "Collection of common interactive command line user interfaces")
5914 (description
5915 "Inquirer should ease the process of asking end user questions, parsing,
5916validating answers, managing hierarchical prompts and providing error
5917feedback.")
5918 (license license:expat)))
5919
5920(define-public python-pytorch-lightning
5921 (package
5922 (name "python-pytorch-lightning")
5923 (version "2.6.0")
5924 (source (origin
5925 (method git-fetch)
5926 (uri (git-reference
5927 (url "https://github.com/Lightning-AI/pytorch-lightning")
5928 (commit version)))
5929 (file-name (git-file-name name version))
5930 (sha256
5931 (base32
5932 "0fqzjs3k55n2sp1kz8wxf82687d1vq0yydv45qx2vl3kzgvl0qff"))))
5933 (build-system pyproject-build-system)
5934 (arguments
5935 (list
5936 #:test-flags
5937 ;; The tests train a model. They are much too expensive for our
5938 ;; purposes, so we only run the core tests.
5939 '(list "-m" "not cloud and not tpu"
5940 "tests/tests_pytorch/core"
5941 "-k"
5942 (string-append
5943 ;; Some multiprocessing complaint.
5944 "not test_result_reduce_ddp"
5945 ;; FutureWarning is raised.
5946 " and not test_result_collection_restoration"
5947 ;; These need tensorboard
5948 " and not test_property_logger"
5949 " and not test_property_loggers"))
5950 #:phases
5951 '(modify-phases %standard-phases
5952 (add-after 'unpack 'patch-version-detection
5953 (lambda _
5954 ;; We do have pytorch 2.4.0, but the version comparison fails.
5955 (substitute* "src/lightning/fabric/utilities/imports.py"
5956 (("_TORCH_GREATER_EQUAL_2_4 =.*")
5957 "_TORCH_GREATER_EQUAL_2_4 = True\n"))))
5958 (add-after 'patch-version-detection 'fix-leafspec-deprecation
5959 (lambda _
5960 ;; `LeafSpec' is deprecated starting with PyTorch 2.10.
5961 (substitute* "src/lightning/pytorch/utilities/_pytree.py"
5962 (("SUPPORTED_NODES, LeafSpec, PyTree, TreeSpec, _get_node_type, tree_unflatten")
5963 "SUPPORTED_NODES, PyTree, TreeSpec, _get_node_type, tree_unflatten, treespec_leaf")
5964 (("LeafSpec\\(\\)") "treespec_leaf()"))))
5965 (add-before 'build 'pre-build
5966 (lambda _ (setenv "PACKAGE_NAME" "lightning")))
5967 (add-after 'install 'pre-build-pytorch
5968 (lambda _
5969 ;; pyproject-build-system only tolerates unicycles.
5970 (for-each delete-file (find-files "dist" "\\.whl"))
5971 (setenv "PACKAGE_NAME" "pytorch")))
5972 (add-after 'pre-build-pytorch 'build-pytorch
5973 (assoc-ref %standard-phases 'build))
5974 (add-after 'build-pytorch 'install-pytorch
5975 (assoc-ref %standard-phases 'install))
5976 (add-before 'check 'pre-check
5977 (lambda _
5978 ;; We don't have Tensorboard
5979 (substitute* "tests/tests_pytorch/test_cli.py"
5980 ((" TensorBoardLogger\\(\".\"\\)") "")))))))
5981 (propagated-inputs
5982 (list python-arrow
5983 python-beautifulsoup4
5984 python-croniter
5985 python-dateutils
5986 python-deepdiff
5987 python-fastapi
5988 python-fsspec
5989 python-inquirer
5990 python-jsonargparse
5991 python-lightning-cloud
5992 python-lightning-utilities
5993 python-numpy
5994 python-packaging
5995 python-pytorch
5996 python-pyyaml
5997 python-torchmetrics
5998 python-torchvision
5999 python-tqdm
6000 python-traitlets
6001 python-typing-extensions))
6002 (native-inputs
6003 (list python-aiohttp
6004 python-cloudpickle
6005 python-flaky
6006 python-pympler
6007 python-pytest
6008 python-psutil
6009 python-requests-mock
6010 python-scikit-learn
6011 python-setuptools))
6012 (home-page "https://lightning.ai/")
6013 (synopsis "Deep learning framework to train, deploy, and ship AI products")
6014 (description
6015 "PyTorch Lightning is just organized PyTorch; Lightning disentangles
6016PyTorch code to decouple the science from the engineering.")
6017 (license license:asl2.0)))
6018
6019(define-public python-torchmetrics
6020 (package
6021 (name "python-torchmetrics")
6022 (version "1.9.0")
6023 (source (origin
6024 (method git-fetch)
6025 (uri (git-reference
6026 (url "https://github.com/Lightning-AI/torchmetrics")
6027 (commit (string-append "v" version))))
6028 (file-name (git-file-name name version))
6029 (sha256
6030 (base32
6031 "076x59493wym57lrvmlk8xsbfhgs4rlcw4gx3bxlv55ldd0ijllf"))))
6032 (build-system pyproject-build-system)
6033 (arguments
6034 (list
6035 ;; Tests require many additional dependencies
6036 #:tests? #f))
6037 (propagated-inputs
6038 (list python-numpy python-packaging python-pytorch
6039 python-typing-extensions
6040 python-lightning-utilities))
6041 (native-inputs
6042 (list python-cloudpickle
6043 python-fire
6044 python-mir-eval
6045 python-pandas
6046 python-psutil
6047 python-pytest
6048 python-pytest-doctestplus
6049 python-pytest-rerunfailures
6050 python-pytest-timeout
6051 python-requests
6052 python-scikit-image
6053 python-scikit-learn
6054 python-scipy
6055 python-types-protobuf
6056 python-types-setuptools))
6057 (home-page "https://github.com/Lightning-AI/torchmetrics")
6058 (synopsis "Machine learning metrics for PyTorch applications")
6059 (description "TorchMetrics is a collection of 100+ PyTorch metrics
6060implementations and an easy-to-use API to create custom metrics. It offers:
6061
6062@itemize
6063@item A standardized interface to increase reproducibility
6064@item Reduces boilerplate
6065@item Automatic accumulation over batches
6066@item Metrics optimized for distributed-training
6067@item Automatic synchronization between multiple devices
6068@end itemize
6069")
6070 (license license:asl2.0)))
6071
6072;; Keep this in sync with python-pytorch
6073(define-public python-torchvision
6074 (package
6075 (name "python-torchvision")
6076 (version "0.25.0")
6077 (source (origin
6078 (method git-fetch)
6079 (uri (git-reference
6080 (url "https://github.com/pytorch/vision")
6081 (commit (string-append "v" version))
6082 (recursive? #t)))
6083 (file-name (git-file-name name version))
6084 (sha256
6085 (base32
6086 "0bikvjiqgl659vjk1pw7hka95g55h5sgh3lmybwqfkzsqhfljjx2"))
6087 (modules '((guix build utils)))
6088 (snippet
6089 '(begin
6090 (delete-file-recursively "android")
6091 (delete-file-recursively "ios")))))
6092 (build-system pyproject-build-system)
6093 (arguments
6094 (list
6095 ;; The test suite is expensive and there is no easy way to subset it.
6096 #:tests? #f
6097 #:phases
6098 #~(modify-phases %standard-phases
6099 (add-after 'unpack 'setenv
6100 (lambda _
6101 (let ((jpegdir #$(this-package-input "libjpeg-turbo")))
6102 (setenv "TORCHVISION_INCLUDE"
6103 (string-append jpegdir "/include/"))
6104 (setenv "TORCHVISION_LIBRARY"
6105 (string-append jpegdir "/lib/"))))))))
6106 (inputs
6107 (list ffmpeg-6
6108 libpng
6109 libjpeg-turbo))
6110 (propagated-inputs
6111 (list python-numpy
6112 python-typing-extensions
6113 python-requests
6114 python-pillow
6115 python-pytorch))
6116 (native-inputs
6117 (list pybind11-2
6118 python-pytest
6119 python-setuptools
6120 python-wheel
6121 which))
6122 (home-page "https://pytorch.org/vision/stable/index.html")
6123 (synopsis "Datasets, transforms and models specific to computer vision")
6124 (description
6125 "The torchvision package consists of popular datasets, model architectures,
6126and common image transformations for computer vision.")
6127 (license license:bsd-3)))
6128
6129(define-public python-torchfile
6130 ;; Latest release is nine years old.
6131 (let ((commit "fbd434a5b5562c88b91a95e6476e11dbb7735436")
6132 (revision "0"))
6133 (package
6134 (name "python-torchfile")
6135 (version (git-version "0.1.0" revision commit))
6136 (source
6137 (origin
6138 (method git-fetch)
6139 (uri (git-reference
6140 (url "https://github.com/bshillingford/python-torchfile/")
6141 (commit commit)))
6142 (file-name (git-file-name name version))
6143 (sha256
6144 (base32 "1f03ks5n3i3cdh16wx5ysxsxh0ai9vpf0k5pdx759vf31f4niz36"))))
6145 (build-system pyproject-build-system)
6146 (arguments
6147 (list
6148 #:phases
6149 #~(modify-phases %standard-phases
6150 (replace 'check
6151 (lambda* (#:key tests? #:allow-other-keys)
6152 (when tests?
6153 (invoke "python3" "tests.py")))))))
6154 (propagated-inputs
6155 (list python-numpy python-setuptools))
6156 (home-page "https://github.com/bshillingford/python-torchfile")
6157 (synopsis "Torch7 binary serialized file parser")
6158 (description "This package enables you to deserialize Lua
6159torch-serialized objects from Python.")
6160 (license license:bsd-3))))
6161
6162(define-public python-geomloss
6163 (package
6164 (name "python-geomloss")
6165 (version "0.3.1")
6166 (source
6167 (origin
6168 (method git-fetch)
6169 (uri (git-reference
6170 (url "https://github.com/jeanfeydy/geomloss")
6171 (commit (string-append "v" version))))
6172 (file-name (git-file-name name version))
6173 (sha256
6174 (base32 "0sx851d54iagvfmdlpwh4559hms4gr2kabsirbd4ib2m7118p7jb"))))
6175 (build-system pyproject-build-system)
6176 ;; There are no automated tests.
6177 (arguments (list #:tests? #false))
6178 (propagated-inputs (list python-numpy python-pytorch))
6179 (native-inputs (list python-setuptools))
6180 (home-page "https://www.kernel-operations.io/geomloss/")
6181 (synopsis
6182 "Geometric loss functions between point clouds, images and volumes")
6183 (description
6184 "The GeomLoss library provides efficient GPU implementations for:
6185
6186@itemize
6187@item Kernel norms (also known as Maximum Mean Discrepancies).
6188@item Hausdorff divergences, which are positive definite generalizations of
6189the Chamfer-ICP loss and are analogous to log-likelihoods of Gaussian Mixture
6190Models.
6191@item Debiased Sinkhorn divergences, which are affordable yet positive and
6192definite approximations of Optimal Transport (Wasserstein) distances.
6193@end itemize")
6194 (license license:expat)))
6195
6196(define-public python-tokenizers
6197 (package
6198 (name "python-tokenizers")
6199 (version "0.22.2")
6200 (source
6201 (origin
6202 (method git-fetch)
6203 (uri (git-reference
6204 (url "https://github.com/huggingface/tokenizers/")
6205 (commit (string-append "v" version))))
6206 (file-name (git-file-name name version))
6207 (sha256
6208 (base32 "0mcivkmhdpqg872yvp77505apaylml808lbq2i3i5pln2rhgf1jw"))
6209 (modules '((guix build utils)
6210 (ice-9 ftw)))
6211 (snippet
6212 #~(begin ;; Only keeping bindings.
6213 (for-each (lambda (file)
6214 (unless (member file
6215 '("." ".." "bindings" "tokenizers"))
6216 (delete-file-recursively file)))
6217 (scandir "."))
6218 (delete-file-recursively "bindings/node")
6219 (delete-file "bindings/python/Cargo.lock")))))
6220 (build-system pyproject-build-system)
6221 (arguments
6222 (list
6223 #:imported-modules (append %cargo-build-system-modules
6224 %pyproject-build-system-modules)
6225 #:modules '(((guix build cargo-build-system) #:prefix cargo:)
6226 (guix build pyproject-build-system)
6227 (guix build utils))
6228 #:test-flags
6229 #~(list
6230 "--ignore=benches"
6231 ;; This test requires the python-datasets package.
6232 "--ignore=tests/documentation/test_tutorial_train_from_iterators.py"
6233 ;; XXX: Tests below fail because they require a network connection.
6234 ;; "-m" "not network" is respected from version 0.23 onwards
6235 ;; and makes the flags below unecessary.
6236 "-k" (string-join
6237 (list "not TestEncoding"
6238 "TestBPE"
6239 "TestWordLevel"
6240 "TestByteLevelProcessing"
6241 "TestAsyncTokenizer"
6242 "TestUnigram"
6243 "TestPipeline"
6244 "TestCharBPETokenizer"
6245 "TestSerialization"
6246 "TestByteLevelBPE"
6247 "TestBertWordPieceTokenizer"
6248 "TestQuicktour"
6249 "test_encode_formats"
6250 "test_encode_add_special_tokens"
6251 "test_decode_stream_fallback"
6252 "test_decode_skip_special_tokens"
6253 "test_from_pretrained"
6254 "test_from_pretrained_revision"
6255 "test_encode_special_tokens"
6256 "test_instantiate"
6257 "test_splitting")
6258 " and not "))
6259 #:phases
6260 #~(modify-phases %standard-phases
6261 (add-after 'unpack 'prepare-cargo-build-system
6262 (lambda args
6263 (for-each (lambda (phase)
6264 (format #t "Running cargo phase: ~a~%" phase)
6265 (apply (assoc-ref cargo:%standard-phases phase)
6266 #:cargo-target #$(cargo-triplet)
6267 args))
6268 '(prepare-rust-crates
6269 unpack-rust-crates
6270 configure
6271 check-for-pregenerated-files
6272 patch-cargo-checksums))))
6273 (add-after 'prepare-cargo-build-system 'chdir
6274 (lambda _
6275 (chdir "bindings/python"))))))
6276 (native-inputs
6277 (append (list python-httpx
6278 python-huggingface-hub
6279 python-numpy
6280 python-pytest
6281 python-pytest-asyncio
6282 python-pytest-timeout
6283 python-requests
6284 python-tqdm)
6285 (list maturin
6286 nss-certs-for-test
6287 pkg-config
6288 rust
6289 `(,rust "cargo"))
6290 (or (and=> (%current-target-system)
6291 (compose list make-rust-sysroot))
6292 '())))
6293 (inputs
6294 (cons oniguruma (cargo-inputs 'tokenizers-python)))
6295 (home-page "https://huggingface.co/docs/tokenizers")
6296 (synopsis "Implementation of various popular tokenizers")
6297 (description
6298 "This package provides an implementation of today’s most used tokenizers,
6299with a focus on performance and versatility.")
6300 (license license:asl2.0)))
6301
6302(define-public python-transformers
6303 (package
6304 (name "python-transformers")
6305 (version "4.57.6")
6306 (source
6307 (origin
6308 (method url-fetch)
6309 (uri (pypi-uri "transformers" version))
6310 (sha256
6311 (base32 "1lw90svznnmbp48acf33fvr6wbjp5d4ybdr12llhmp79xhk43r2m"))))
6312 (build-system pyproject-build-system)
6313 (arguments
6314 ;; Missing inputs.
6315 (list #:test-flags
6316 '(list "--ignore=tests/test_modeling_tf_common.py"
6317 "--ignore=tests/test_modeling_common.py" ; ImportError
6318 "--ignore=tests/test_processing_common.py" ; ImportError
6319 "--ignore=tests/test_configuration_common.py"
6320 "--ignore=tests/test_pipeline_mixin.py"
6321 "--ignore=tests/test_sequence_feature_extraction_common.py"
6322 "--ignore=tests/test_tokenization_mistral_common.py"
6323 ;; Requires python-accelerate
6324 "--ignore=tests/test_training_args.py"
6325 ;; Requires network access
6326 "--ignore=tests/test_executorch.py")))
6327 ;; The imported package contains ~60 more inputs, but they don't seem
6328 ;; necessary to build a minimal version of the package.
6329 (propagated-inputs
6330 (list python-filelock
6331 python-huggingface-hub
6332 python-numpy
6333 python-packaging
6334 python-pytorch
6335 python-pyyaml
6336 python-regex
6337 python-requests
6338 python-safetensors
6339 python-tokenizers
6340 python-tqdm))
6341 (native-inputs
6342 (list python-parameterized
6343 python-pytest
6344 python-pytest-asyncio
6345 python-setuptools))
6346 (home-page "https://github.com/huggingface/transformers")
6347 (synopsis "Machine Learning for PyTorch and TensorFlow")
6348 (description
6349 "This package provides easy download of thousands of pretrained models to
6350perform tasks on different modalities such as text, vision, and audio.
6351
6352These models can be applied on:
6353@itemize
6354@item Text, for tasks like text classification, information extraction,
6355question answering, summarization, translation, and text generation, in over
6356100 languages.
6357@item Images, for tasks like image classification, object detection, and
6358segmentation.
6359@item Audio, for tasks like speech recognition and audio classification.
6360@end itemize
6361
6362Transformer models can also perform tasks on several modalities combined, such
6363as table question answering, optical character recognition, information
6364extraction from scanned documents, video classification, and visual question
6365answering.
6366
6367This package provides APIs to quickly download and use those pretrained models
6368on a given text, fine-tune them on your own datasets and then share them with
6369the community. At the same time, each Python module defining an architecture
6370is fully standalone and can be modified to enable quick research experiments.
6371
6372Transformers is backed by the three most popular deep learning libraries —
6373Jax, PyTorch and TensorFlow — with a seamless integration between them.")
6374 (license license:asl2.0)))
6375
6376(define-public ctranslate2
6377 (package
6378 (name "ctranslate2")
6379 (version "4.8.0")
6380 (source
6381 (origin
6382 (method git-fetch)
6383 (uri (git-reference
6384 (url "https://github.com/OpenNMT/CTranslate2")
6385 (commit (string-append "v" version))))
6386 (file-name (git-file-name "CTranslate2" version))
6387 (sha256 (base32 "0lpykbp9jvkds2dy3lfyn699d0kvz9kzqzfzg4vh5cgn99d7k4g2"))
6388 (patches (search-patches "ctranslate2-local-build.patch"))))
6389 (build-system cmake-build-system)
6390 (arguments
6391 (list
6392 ;; XXX: mkl and openblas seem incompatible.
6393 #:configure-flags #~(list "-DBUILD_TESTS=ON"
6394 "-DWITH_ACCELERATE=OFF"
6395 "-DWITH_RUY=OFF"
6396 "-DWITH_DNNL=ON"
6397 "-DWITH_CUDA=OFF"
6398 "-DWITH_CUDNN=OFF"
6399 "-DWITH_MKL=OFF"
6400 "-DWITH_OPENBLAS=ON")
6401 #:modules '((guix build cmake-build-system)
6402 ((guix build gnu-build-system) #:prefix gnu:)
6403 (guix build utils))
6404 #:phases
6405 #~(modify-phases %standard-phases
6406 (replace 'check
6407 (lambda* (#:rest args)
6408 (apply (assoc-ref gnu:%standard-phases 'check)
6409 #:test-target "ctranslate2_test" args))))))
6410 (native-inputs (list libomp-13
6411 cxxopts
6412 spdlog
6413 googletest
6414 cpu-features
6415 onednn
6416 openblas))
6417 (home-page "https://opennmt.net/CTranslate2/")
6418 (synopsis "Fast inference engine for Transformer models")
6419 (description "CTranslate2 is a C++ and Python library for efficient
6420inference with Transformer models.
6421
6422The project implements a custom runtime that applies many performance
6423optimization techniques such as weights quantization, layers fusion, batch
6424reordering, etc., to accelerate and reduce the memory usage of Transformer
6425models on CPU and GPU.")
6426 (license license:expat)))
6427
6428(define-public python-ctranslate2
6429 (package/inherit ctranslate2
6430 (name "python-ctranslate2")
6431 (build-system pyproject-build-system)
6432 (arguments
6433 (list
6434 ;; XXX: tests require the eole python project.
6435 #:tests? #f
6436 #:phases
6437 #~(modify-phases %standard-phases
6438 (add-before 'build 'cd-to-build-dir
6439 (lambda _
6440 (chdir "python"))))))
6441 (native-inputs (list ctranslate2
6442 python-setuptools
6443 python-wheel
6444 pybind11
6445 python-pyyaml
6446 python-numpy))))
6447
6448(define-public python-xx-sent-ud-sm
6449 ;; For Argos Translate CLI tool
6450 (hidden-package
6451 (package
6452 (name "python-xx-sent-ud-sm")
6453 (version "3.8.0")
6454 (source
6455 (origin
6456 (method url-fetch)
6457 (uri (string-append "https://github.com/explosion/spacy-models"
6458 "/releases/download/xx_sent_ud_sm-3.8.0"
6459 "/xx_sent_ud_sm-" version ".tar.gz"))
6460 (sha256
6461 (base32 "1pwyl23nvmmkpvq5wgafdqq0mlnq14l2svh9m6gi6w0skv7dd5fq"))))
6462 (build-system pyproject-build-system)
6463 (arguments '(#:tests? #f)) ;no test
6464 (native-inputs (list python-setuptools))
6465 (propagated-inputs (list python-spacy))
6466 (home-page "https://spacy.io/models/xx#xx_sent_ud_sm")
6467 (synopsis "Small multi-language sentence boundary model for spaCy")
6468 (description "@code{xx_sent_ud_sm} is a spaCy model optimized for CPU.
6469It includes a sentence boundary component of a relatively small size.")
6470 (license license:cc-by-sa3.0))))
6471
6472(define-public python-argostranslate
6473 (package
6474 (name "python-argostranslate")
6475 (version "1.10.0")
6476 (source
6477 (origin
6478 (method git-fetch)
6479 (uri (git-reference
6480 (url "https://github.com/argosopentech/argos-translate")
6481 (commit (string-append "v" version))))
6482 (file-name (git-file-name name version))
6483 (sha256
6484 (base32 "18fhqabdyh66ymri9xi9xc3q619f5bd3yb9izwhvwyladx65xcfn"))))
6485 (arguments
6486 (list
6487 #:phases
6488 #~(modify-phases %standard-phases
6489 (add-after 'unpack 'disable-spacy-download
6490 (lambda _
6491 (substitute* "argostranslate/networking.py"
6492 ((".*spacy_download.*") ""))))
6493 (add-before 'build 'set-home-env
6494 (lambda _
6495 (setenv "HOME" "/tmp"))))))
6496 (build-system pyproject-build-system)
6497 (native-inputs (list python-pytest python-setuptools))
6498 (propagated-inputs (list python-ctranslate2
6499 python-packaging
6500 python-sacremoses
6501 python-sentencepiece
6502 python-spacy
6503 python-stanza
6504 python-xx-sent-ud-sm))
6505 (home-page "https://www.argosopentech.com")
6506 (synopsis "Offline translation library and CLI tool")
6507 (description
6508 "Argos Translate uses OpenNMT for translations and can be used
6509as either a Python library, command-line, or GUI application.
6510It supports installing language model packages which are ZIP archives
6511with a @code{.argosmodel} extension. This package provides
6512the Python library and the command-line program.")
6513 (license license:expat)))
6514
6515(define-public argos-translate-gui
6516 ;; The Git repository is not tagged.
6517 (let ((commit "06aafde3faf1709080471c94914382a566f6f775")
6518 (revision "0"))
6519 (package
6520 (name "argos-translate-gui")
6521 (version (git-version "1.6.5" revision commit))
6522 (source
6523 (origin
6524 (method git-fetch)
6525 (uri (git-reference
6526 (url "https://github.com/argosopentech/argos-translate-gui")
6527 (commit commit)))
6528 (file-name (git-file-name name version))
6529 (sha256
6530 (base32 "0g251fgwwbk96f8n11c8gzidqgfkrkwpldxk9zq0kkhm729b9yyw"))))
6531 (build-system pyproject-build-system)
6532 (arguments '(#:tests? #f)) ;no test
6533 (native-inputs (list python-setuptools))
6534 (inputs (list python-argostranslate python-pyqt))
6535 (home-page "https://www.argosopentech.com")
6536 (synopsis "Graphical user interface for Argos Translate")
6537 (description
6538 "Argos Translate uses OpenNMT for translations and can be used
6539as either a Python library, command-line, or GUI application.
6540It supports installing language model packages which are ZIP archives
6541with a @code{.argosmodel} extension. This package provides
6542a Qt interface for Argos Translate.")
6543 (license license:expat))))
6544
6545(define-public python-argos-translate-files
6546 (package
6547 (name "python-argos-translate-files")
6548 (version "1.4.3")
6549 (source
6550 (origin
6551 (method git-fetch)
6552 (uri (git-reference
6553 (url "https://github.com/LibreTranslate/argos-translate-files")
6554 (commit (string-append "v" version))))
6555 (file-name (git-file-name name version))
6556 (sha256
6557 (base32 "1vz5v2gnd5wxwq6cjnhrvhflndl55c7ffy21w05m8sy3ll8iaiij"))))
6558 (build-system pyproject-build-system)
6559 (arguments (list #:phases #~(modify-phases %standard-phases
6560 (add-after 'unpack 'unpin-dependencies
6561 (lambda _
6562 (substitute* "requirements.txt"
6563 (("argos-translate-lt.*")
6564 "argostranslate\n"))))
6565 (add-before 'build 'set-home-env
6566 (lambda _
6567 (setenv "HOME" "/tmp"))))))
6568 (propagated-inputs (list python-argostranslate
6569 python-beautifulsoup4
6570 python-lxml
6571 python-pymupdf
6572 python-pysrt))
6573 (native-inputs (list python-pytest python-setuptools))
6574 (home-page "https://github.com/LibreTranslate/argos-translate-files")
6575 (synopsis "Translate files with Argos Translate")
6576 (description "This package provides a Python library
6577for translating plain- and rich-text documents with Argos Translate.")
6578 (license license:agpl3)))
6579
6580(define-public libretranslate
6581 (package
6582 (name "libretranslate")
6583 (version "1.9.6")
6584 (source
6585 (origin
6586 (method git-fetch)
6587 (uri (git-reference
6588 (url "https://github.com/LibreTranslate/LibreTranslate")
6589 (commit (string-append "v" version))))
6590 (file-name (git-file-name name version))
6591 (sha256 (base32 "0gyhahlyz06nr7h8nb7nrw866z44kw6kaijczk6jk8wn3p1xp200"))
6592 (patches (search-patches "libretranslate-use-flasgger.patch"))))
6593 (build-system pyproject-build-system)
6594 (arguments
6595 (list
6596 #:tests? #f ;all tests depend on Argos models
6597 #:phases
6598 #~(modify-phases %standard-phases
6599 (add-after 'unpack 'unpin-dependencies
6600 (lambda _
6601 (substitute* "pyproject.toml"
6602 ;; Unpin numpy for transitive dependencies.
6603 (("^ \"numpy .+") "")
6604 ;; Unpin dependencies.
6605 (("^( \"[[:alnum:]-]+) ==.+((;.+)?\",)" all left right)
6606 (string-append left right))
6607 (("argos-translate-lt") "argostranslate"))))
6608 (add-before 'build 'set-home-env
6609 (lambda _
6610 (setenv "HOME" "/tmp"))))))
6611 (inputs (list python-apscheduler
6612 python-argos-translate-files
6613 python-argostranslate
6614 python-expiringdict
6615 python-flasgger
6616 python-flask
6617 python-flask-babel
6618 python-flask-limiter
6619 python-itsdangerous
6620 python-langdetect
6621 python-lexilang
6622 python-minisbd
6623 python-numpy
6624 python-packaging
6625 python-polib
6626 python-prometheus-client
6627 python-redis
6628 python-requests
6629 python-waitress
6630 python-werkzeug))
6631 (native-inputs (list python-hatchling))
6632 (home-page "https://docs.libretranslate.com")
6633 (synopsis "Machine translation API and web interface")
6634 (description
6635 "LibreTranslate is a machine translation API and web interface,
6636powered by the Argos Translate library.")
6637 (license license:agpl3)))
6638
6639(define-public python-hmmlearn
6640 (package
6641 (name "python-hmmlearn")
6642 (version "0.3.3")
6643 (source
6644 (origin
6645 (method git-fetch)
6646 (uri (git-reference
6647 (url "https://github.com/hmmlearn/hmmlearn")
6648 (commit version)))
6649 (file-name (git-file-name name version))
6650 (sha256
6651 (base32 "1d1gcw2xb1i7zvkcz2vmrk4c2iqsfy71pgrc0r5p65r51w9p97n1"))))
6652 (build-system pyproject-build-system)
6653 (arguments
6654 (list
6655 #:test-flags
6656 #~(list "--pyargs" "hmmlearn")
6657 #:phases
6658 #~(modify-phases %standard-phases
6659 (add-after 'unpack 'set-core-count
6660 (lambda _
6661 ;; "Could not find the number of physical cores", so we tell it
6662 ;; how many cores to use.
6663 (setenv "LOKY_MAX_CPU_COUNT" "1"))))))
6664 (native-inputs
6665 (list pybind11
6666 python-pytest
6667 python-setuptools
6668 python-setuptools-scm
6669 util-linux)) ;for lscpu
6670 (propagated-inputs
6671 (list python-numpy
6672 python-scikit-learn
6673 python-scipy))
6674 (home-page "https://github.com/hmmlearn/hmmlearn")
6675 (synopsis "Hidden Markov Models with scikit-learn like API")
6676 (description
6677 "Hmmlearn is a set of algorithms for unsupervised learning and inference
6678of Hidden Markov Models.")
6679 (license license:bsd-3)))
6680
6681(define-public llm-proxy
6682 (package
6683 (name "llm-proxy")
6684 (version "0.23.0")
6685 (source
6686 (origin
6687 (method git-fetch)
6688 (uri (git-reference
6689 (url "https://codeberg.org/jbousquie/llm-proxy")
6690 (commit (string-append "v" version))))
6691 (file-name (git-file-name name version))
6692 (sha256
6693 (base32 "125lfhx28fs8s3fzhcqbs87b7crswn9x0br3dnv6qnbybrg0bacd"))))
6694 (build-system cargo-build-system)
6695 (arguments (list #:install-source? #f))
6696 (inputs (cargo-inputs 'llm-proxy))
6697 (home-page "https://jbousquie.codeberg.page/llm-proxy/")
6698 (synopsis "Network proxy for LLM API vendors")
6699 (native-inputs (list nss-certs-for-test))
6700 (description
6701 "This package provides a local HTTP proxy written in Rust. It sits
6702between agentic clients and the Albert API (Etalab).")
6703 (license license:etalab2.0)))
6704
6705;; Keep this in sync with the r-torch package.
6706(define-public liblantern
6707 (package
6708 (name "liblantern")
6709 (version "0.16.3")
6710 (source
6711 (origin
6712 (method git-fetch)
6713 (uri (git-reference
6714 (url "https://github.com/mlverse/torch")
6715 (commit (string-append "v" version))))
6716 (file-name (git-file-name name version))
6717 (sha256
6718 (base32 "13gdrj9aklqgfx10jyylr3jh2ilk8j27fzgv708yv9jn2ckmfdhn"))))
6719 (build-system cmake-build-system)
6720 (arguments
6721 (list
6722 #:tests? #false ;no test target
6723 #:phases
6724 (let ((python-version (version-major+minor (package-version python))))
6725 #~(modify-phases %standard-phases
6726 (add-after 'unpack 'chdir
6727 (lambda _ (chdir "src/lantern")))
6728 (add-after 'chdir 'do-not-download-binaries
6729 (lambda* (#:key inputs #:allow-other-keys)
6730 (substitute* "CMakeLists.txt"
6731 (("find_package\\(Torch.*") "set(TORCH_CXX_FLAGS \"-ltorch\")\n")
6732 (("retrieve_lib\\(.*") ""))
6733 (let ((site-packages (string-append "/lib/python"
6734 #$python-version
6735 "/site-packages")))
6736 (setenv "LIBRARY_PATH"
6737 (string-append
6738 (search-input-directory
6739 inputs (string-append site-packages "/torch/lib"))
6740 ":" (or (getenv "LIBRARY_PATH") "")))
6741 (setenv "CPLUS_INCLUDE_PATH"
6742 (string-append
6743 (search-input-directory
6744 inputs (string-append
6745 site-packages "/torch/include/torch/csrc/api/include/"))
6746 ":"
6747 (search-input-directory
6748 inputs (string-append site-packages "/torch/include/"))
6749 ":"
6750 (or (getenv "CPLUS_INCLUDE_PATH") "")))
6751 (setenv "C_INCLUDE_PATH"
6752 (string-append
6753 (search-input-directory
6754 inputs (string-append site-packages "/torch/include/"))
6755 ":"
6756 (or (getenv "C_INCLUDE_PATH") ""))))))
6757 (replace 'install
6758 (lambda _
6759 (install-file
6760 "../build/liblantern.so"
6761 (string-append #$output "/lib"))
6762 (copy-recursively
6763 "../lantern/include"
6764 (string-append #$output "/include"))))))))
6765 (inputs (list python-pytorch-for-r-torch))
6766 (home-page "https://github.com/mlverse/torch/")
6767 (synopsis "C API to libtorch")
6768 (description
6769 "Lantern provides a C API to the libtorch machine learning library.")
6770 (license license:expat)))
6771
6772(define-public python-lap
6773 (package
6774 (name "python-lap")
6775 (version "0.5.12")
6776 (source (origin
6777 (method url-fetch)
6778 (uri (pypi-uri "lap" version))
6779 (sha256
6780 (base32
6781 "1za4mf5nd7vzwd24sy2mfxrk8mnwq7d8rv6h96yh8v5flx7422sp"))))
6782 (build-system pyproject-build-system)
6783 (arguments
6784 (list
6785 #:test-flags #~(list "-v" #$output)
6786 #:phases
6787 #~(modify-phases %standard-phases
6788 (add-after 'check 'check-cleanup
6789 (lambda* (#:key tests? #:allow-other-keys)
6790 (when tests?
6791 (for-each
6792 delete-file-recursively
6793 (find-files #$output
6794 (lambda (file stat)
6795 (or (member (basename file)
6796 '("tests" ".pytest_cache"))))
6797 #:directories? #t))))))))
6798 (propagated-inputs
6799 (list python-numpy))
6800 (native-inputs
6801 (list python-cython python-pytest python-setuptools python-wheel))
6802 (home-page "https://github.com/gatagat/lap")
6803 (synopsis "Linear Assignment Problem solver (LAPJV/LAPMOD)")
6804 (description "Lap is a linear assignment problem solver using Jonker-Volgenant
6805algorithm for dense (LAPJV) or sparse (LAPMOD) matrices.")
6806 (license license:bsd-2)))
6807
6808(define-public python-visdom
6809 (package
6810 (name "python-visdom")
6811 (version "0.2.4")
6812 (source
6813 (origin
6814 (method url-fetch)
6815 (uri (pypi-uri "visdom" version))
6816 (sha256
6817 (base32 "0x05faxh45bh1zz8afjhzjy49jrqv4dkhaw1ainhajl1r39i3ac4"))))
6818 (build-system pyproject-build-system)
6819 (arguments (list #:tests? #f)) ;tests require launching the server
6820 (native-inputs
6821 (list python-setuptools))
6822 (propagated-inputs
6823 (list python-jsonpatch
6824 python-networkx
6825 python-numpy
6826 python-pillow
6827 python-requests
6828 python-scipy
6829 python-six
6830 python-tornado
6831 python-websocket-client))
6832 (home-page "https://github.com/fossasia/visdom")
6833 (synopsis "Visualizations of live, rich data for Torch and Numpy")
6834 (description
6835 "This package provides a tool for visualizing live, rich data for Torch
6836and Numpy.")
6837 (license license:asl2.0)))
6838
6839(define-public python-pyro-api
6840 (package
6841 (name "python-pyro-api")
6842 (version "0.1.2")
6843 (source
6844 (origin
6845 (method git-fetch)
6846 (uri (git-reference
6847 (url "https://github.com/pyro-ppl/pyro-api")
6848 (commit version)))
6849 (file-name (git-file-name name version))
6850 (sha256
6851 (base32 "17x7niagx43cajqq67dxmssr7q94db6axyg154y7vqdxzp25hf7g"))))
6852 (build-system pyproject-build-system)
6853 (arguments '(#:tests? #false)) ;requires pyro
6854 (native-inputs
6855 (list python-ipython
6856 python-pytest
6857 python-setuptools
6858 python-sphinx
6859 python-sphinx-rtd-theme
6860 python-wheel))
6861 (home-page "https://github.com/pyro-ppl/pyro-api")
6862 (synopsis "Generic API for dispatch to Pyro backends")
6863 (description "This package provides a generic API for dispatch to Pyro backends.")
6864 (license license:asl2.0)))
6865
6866(define-public python-pyro-ppl
6867 (package
6868 (name "python-pyro-ppl")
6869 (version "1.9.1")
6870 ;; The sources on pypi don't include tests.
6871 (source
6872 (origin
6873 (method git-fetch)
6874 (uri (git-reference
6875 (url "https://github.com/pyro-ppl/pyro")
6876 (commit version)))
6877 (file-name (git-file-name name version))
6878 (sha256
6879 (base32 "0q87d0frgzn1ljnpbyxmj582yfn6zy3m960m3ab826h4rpzybxhf"))))
6880 (build-system pyproject-build-system)
6881 (arguments
6882 ;; Tests take too long.
6883 ;; XXX: Maybe select the most important test modules.
6884 (list #:tests? #f))
6885 (propagated-inputs
6886 (list python-numpy
6887 python-opt-einsum
6888 python-pyro-api
6889 python-pytorch
6890 python-tqdm))
6891 (native-inputs (list python-setuptools python-wheel))
6892 (home-page "https://pyro.ai")
6893 (synopsis "Python library for probabilistic modeling and inference")
6894 (description
6895 "This package provides a Python library for probabilistic modeling and
6896inference.")
6897 (license license:asl2.0)))
6898
6899(define-public python-linear-operator
6900 (package
6901 (name "python-linear-operator")
6902 (version "0.6.1")
6903 (source
6904 (origin
6905 (method git-fetch)
6906 (uri (git-reference
6907 (url "https://github.com/cornellius-gp/linear_operator/")
6908 (commit (string-append "v" version))))
6909 (file-name (git-file-name name version))
6910 (sha256
6911 (base32
6912 "1pfk4mdkvm75lyyb7zmq9pxclhica7fkk4cyvkpz8jncgimvh5qs"))))
6913 (build-system pyproject-build-system)
6914 (propagated-inputs (list python-jaxtyping
6915 python-mpmath
6916 python-pytorch
6917 python-scipy))
6918 (native-inputs (list python-pytest
6919 python-setuptools
6920 python-setuptools-scm
6921 python-typeguard))
6922 (home-page "https://github.com/cornellius-gp/linear_operator/")
6923 (synopsis "Linear operator implementation")
6924 (description "LinearOperator is a PyTorch package for abstracting away the
6925linear algebra routines needed for structured matrices (or operators).")
6926 (license license:expat)))
6927
6928(define-public python-gpytorch
6929 (package
6930 (name "python-gpytorch")
6931 (version "1.15.2")
6932 (source (origin
6933 (method url-fetch)
6934 (uri (pypi-uri "gpytorch" version))
6935 (sha256
6936 (base32
6937 "0qakfyw9akxbcvjz2rzn5vmy7ln6lsq5yp5jfbvqa6w57zlja1iq"))))
6938 (build-system pyproject-build-system)
6939 (arguments
6940 (list #:test-flags
6941 #~(list "-k" (string-append
6942 ;; test_deprecated_methods fails with an AssertionError.
6943 "not test_deprecated_methods"
6944 ;; This test is flaky: Expects gradients of 0 exactly,
6945 ;; can get negligible ones (e-10 to e-16).
6946 " and not test_optimization_optimal_error")
6947 ;; Ignore lenghty tests of little relevance.
6948 "--ignore=test/examples/")))
6949 (propagated-inputs (list python-jaxtyping
6950 python-linear-operator
6951 python-mpmath
6952 python-scikit-learn
6953 python-scipy))
6954 (native-inputs (list python-nbval
6955 python-pytest
6956 python-setuptools
6957 python-setuptools-scm))
6958 (home-page "https://gpytorch.ai")
6959 (synopsis "Implementation of Gaussian Processes in PyTorch")
6960 (description
6961 "GPyTorch is a Gaussian process library implemented using PyTorch.")
6962 (license license:expat)))
6963
6964(define-public python-botorch
6965 (package
6966 (name "python-botorch")
6967 (version "0.17.2")
6968 (source (origin
6969 (method git-fetch) ;no tests in PyPI
6970 (uri (git-reference
6971 (url "https://github.com/meta-pytorch/botorch")
6972 (commit (string-append "v" version))))
6973 (file-name (git-file-name name version))
6974 (sha256
6975 (base32
6976 "1flb6fv2m6l8bbmbq9n7lgf1fd45r9xx2rw08qanm1c00dv12s99"))))
6977 (build-system pyproject-build-system)
6978 (arguments
6979 ;; 7 failed, 1502 passed, 1 skipped, 1 deselected, 807 warnings
6980 (list #:test-flags #~(list "-k"
6981 (string-append
6982 "not test_all_cases_covered"
6983 " and not test_input_constructors"
6984 " and not test_gen"
6985 " and not test_mock"
6986 " and not test_evaluation"
6987 ;; SciPy<1.13: gen.py doesn't import
6988 ;; fmin_l_bfgs_b_batched; mock patch fails.
6989 " and not test_emsemble_map_saas"
6990 " and not test_negative_fixed_features")
6991 ;; Requires optional 'pfns' dependency.
6992 "--ignore=test_community/")
6993 #:phases
6994 #~(modify-phases %standard-phases
6995 (add-after 'unpack 'fix-hypervolume-initial-hvs
6996 (lambda _
6997 ;; PyTorch 2.10 rejects passing a torch.Size plus extra args to `view'.
6998 (substitute* "botorch/utils/multi_objective/hypervolume.py"
6999 (("self\\._batch_sample_shape, *\\*obj\\.shape\\[-2:\\]")
7000 "self._batch_sample_shape")))))))
7001 (propagated-inputs (list python-gpytorch
7002 python-linear-operator
7003 python-multipledispatch
7004 python-pyre-extensions
7005 python-pyro-ppl
7006 python-pytorch
7007 python-scipy
7008 python-threadpoolctl
7009 python-typing-extensions))
7010 (native-inputs (list python-pytest
7011 python-setuptools
7012 python-setuptools-scm))
7013 (home-page "https://botorch.org")
7014 (synopsis "Bayesian Optimization in PyTorch")
7015 (description
7016 "BoTorch is a library for Bayesian Optimization built on PyTorch.")
7017 (license license:expat)))
7018
7019(define-public vosk-api
7020 (let* ((openfst openfst-for-vosk)
7021 (kaldi kaldi-for-vosk))
7022 (package
7023 (name "vosk-api")
7024 (version "0.3.50")
7025 (source
7026 (origin
7027 (method git-fetch)
7028 (uri (git-reference
7029 (url "https://github.com/alphacep/vosk-api")
7030 (commit (string-append "v" version))))
7031 (file-name (git-file-name name version))
7032 (sha256
7033 (base32 "0rm7c1n9iv4y9q6a860rqiy2bdawxjhbfd993lms1ly86vwyai8k"))))
7034 (build-system gnu-build-system)
7035 (arguments
7036 (list
7037 #:tests? #f
7038 #:phases
7039 #~(modify-phases %standard-phases
7040 (add-after 'unpack 'chdir
7041 (lambda _ (chdir "src")))
7042 (replace 'configure
7043 (lambda _
7044 (let* ((openfst #$(this-package-input "openfst"))
7045 (openblas #$(this-package-input "openblas"))
7046 (kaldi #$(this-package-input "kaldi")))
7047 (substitute* "./Makefile"
7048 (("USE_SHARED\\?=0")
7049 "USE_SHARED?=1")
7050 (("-DFST_NO_DYNAMIC_LINKING")
7051 "")
7052 (("-lopenblas -llapack -lblas -lf2c")
7053 (string-append
7054 "-L" openblas "/lib " "-lopenblas "))
7055 (("-lfst -lfstngram")
7056 (string-append
7057 "-L" openfst "/lib " "-lfst -lfstngram "))
7058 (("\\$\\(HOME\\)\\/travis\\/kaldi")
7059 (string-append kaldi "/include"))
7060 (("\\$\\(KALDI_ROOT\\)\\/tools\\/openfst")
7061 openfst)
7062 (("\\$\\(KALDI_ROOT\\)\\/tools\\/OpenBLAS\\/install")
7063 openblas)
7064 (("\\$\\(KALDI_ROOT\\)\\/libs")
7065 (string-append kaldi "/lib"))))))
7066 (replace 'install
7067 (lambda _
7068 (let* ((lib (string-append #$output "/lib"))
7069 (src (string-append #$output "/src")))
7070 (mkdir-p lib)
7071 (mkdir-p src)
7072 (install-file "libvosk.so" lib)
7073 (for-each
7074 (lambda (x) (install-file x src))
7075 (find-files "." "\\.h$"))))))))
7076 (inputs (list kaldi openfst openblas))
7077 (home-page "https://alphacephei.com/vosk/")
7078 (synopsis "Speech recognition toolkit based on @code{kaldi}")
7079 (description "This package provides a speech recognition toolkit based
7080on @code{kaldi}. It supports more than 20 languages and dialects - English,
7081Indian English, German, French, Spanish, Portuguese, Chinese, Russian,
7082Turkish, Vietnamese, Italian, Dutch, Catalan, Arabic, Greek, Farsi, Filipino,
7083Ukrainian, Kazakh, Swedish, Japanese, Esperanto, Hindi, Czech, Polish. The
7084program works offline, even on lightweight devices. Portable per-language
7085models are about 50Mb each, and there are much bigger and precise models
7086available.
7087
7088Vosk API provides a streaming API allowing to use it @emph{on-the-fly} and
7089bindings for different programming languages. It allows quick reconfiguration
7090of vocabulary for better accuracy, and supports speaker identification beside
7091simple speech recognition.")
7092 (license license:asl2.0))))
7093
7094(define-public python-vosk
7095 (package
7096 (inherit vosk-api)
7097 (name "python-vosk")
7098 (build-system pyproject-build-system)
7099 (propagated-inputs
7100 (list python-cffi python-requests python-tqdm python-srt python-websockets))
7101 (inputs (list vosk-api))
7102 (native-inputs
7103 (list python-setuptools python-wheel))
7104 (arguments
7105 (list
7106 #:tests? #f ;; TODO There are tests but not run through Makefile.
7107 #:phases
7108 #~(modify-phases %standard-phases
7109 (add-after 'unpack 'config
7110 (lambda _
7111 (chdir "python")
7112 (setenv "VOSK_SOURCE" #$vosk-api)))
7113 (add-before 'build 'from-abi-to-api
7114 (lambda* (#:key inputs #:allow-other-keys)
7115 (substitute* "vosk_builder.py"
7116 (("ffibuilder\\.set_source\\(\"vosk.vosk_cffi\", None\\)")
7117 (string-append
7118 "ffibuilder.set_source(\"vosk.vosk_cffi\", "
7119 "r\"\"\"\n#include<vosk_api.h>\n#include<Python.h>\"\"\",\n\t"
7120 "library_dirs=["
7121 "'" #$vosk-api "/lib'"
7122 "],\n\t"
7123 "libraries=['vosk', 'python"
7124 (python-version
7125 (dirname (dirname (search-input-file inputs "bin/python"))))
7126 "'],\n\t"
7127 "include_dirs=["
7128 "'" #$vosk-api "/src'" "])")))
7129 (substitute* "vosk/__init__.py"
7130 (("_c = open_dll\\(\\)")
7131 "")
7132 (("_ffi")
7133 "ffi")
7134 (("from \\.vosk_cffi import ffi as ffi")
7135 "from .vosk_cffi import ffi, lib")
7136 (("_c\\.")
7137 "lib.")))))))))
7138
7139(define-public nerd-dictation
7140 (let* ((commit "03ce043a6d569a5bb9a715be6a8e45d8ba0930fd")
7141 (revision "2"))
7142 (package
7143 (name "nerd-dictation")
7144 (version (git-version "0" revision commit))
7145 (source
7146 (origin
7147 (method git-fetch)
7148 (uri (git-reference
7149 (url "https://github.com/ideasman42/nerd-dictation")
7150 (commit commit)))
7151 (file-name (git-file-name name version))
7152 (sha256
7153 (base32 "0ksnlpy2jcldxamq7bsbcgxgafcmgxkbjccd4fwmmn0y814kkz9k"))))
7154 (build-system pyproject-build-system)
7155 (arguments
7156 (list
7157 #:test-backend #~'custom
7158 #:test-flags #~(list "../../tests/from_words_to_digits.py")
7159 #:phases
7160 #~(modify-phases %standard-phases
7161 (add-after 'unpack 'chdir
7162 (lambda _
7163 (chdir "package/python"))))))
7164 (native-inputs (list python-setuptools))
7165 (propagated-inputs (list python-vosk))
7166 (home-page "https://github.com/ideasman42/nerd-dictation")
7167 (synopsis "Offline speech-to-text for desktop Linux")
7168 (description
7169 "This package provides simple access speech to text for using in
7170Linux without being tied to a desktop environment, using the @code{vosk-api}.
7171The user configuration lets you manipulate text using Python string
7172operations. It has zero overhead, as this relies on manual activation and
7173there are no background processes. Dictation is accessed manually with
7174@code{nerd-dictation begin} and @code{nerd-dictation end} commands.")
7175 (license license:gpl2+))))
7176
7177(define (nerd-dictation-gexp input-name output-name bash nerd-dictation)
7178 (with-imported-modules '((guix build utils))
7179 #~(begin
7180 (use-modules (guix build utils))
7181
7182 (let* ((exe (string-append #$output "/bin/nerd-dictation"))
7183 (nerd-dictation-exe
7184 #$(file-append nerd-dictation "/bin/nerd-dictation")))
7185 (mkdir-p (dirname exe))
7186 (call-with-output-file exe
7187 (lambda (port)
7188 (format port "#!~a
7189if [ \"$1\" = begin ]
7190 then
7191 exec ~a $@ --input=~a --simulate-input-tool=~a
7192 else
7193 exec ~a $@
7194fi"
7195 #$(file-append bash "/bin/bash")
7196 nerd-dictation-exe
7197 #$input-name
7198 #$output-name
7199 nerd-dictation-exe)))
7200 (chmod exe #o555)))))
7201
7202(define-public nerd-dictation/xdotool
7203 (package
7204 (inherit nerd-dictation)
7205 (name "nerd-dictation-xdotool")
7206 (build-system trivial-build-system)
7207 (arguments
7208 (list #:builder
7209 (nerd-dictation-gexp "PAREC" "XDOTOOL"
7210 (this-package-input "bash-minimal")
7211 (this-package-input "nerd-dictation"))))
7212 (inputs (list bash-minimal nerd-dictation))
7213 (propagated-inputs (list pulseaudio xdotool))))
7214
7215(define-public nerd-dictation/sox-xdotool
7216 (package
7217 (inherit nerd-dictation/xdotool)
7218 (name "nerd-dictation-sox-xdotool")
7219 (arguments
7220 (list #:builder
7221 (nerd-dictation-gexp "SOX" "XDOTOOL"
7222 (this-package-input "bash-minimal")
7223 (this-package-input "nerd-dictation"))))
7224 (propagated-inputs (list sox xdotool))))
7225
7226(define-public nerd-dictation/sox-ydotool
7227 (package
7228 (inherit nerd-dictation/xdotool)
7229 (name "nerd-dictation-sox-ydotool")
7230 (arguments
7231 (list #:builder
7232 (nerd-dictation-gexp "SOX" "YDOTOOL"
7233 (this-package-input "bash-minimal")
7234 (this-package-input "nerd-dictation"))))
7235 (propagated-inputs (list sox ydotool))))
7236
7237(define-public nerd-dictation/sox-wtype
7238 (package
7239 (inherit nerd-dictation/xdotool)
7240 (name "nerd-dictation-sox-wtype")
7241 (arguments
7242 (list #:builder
7243 (nerd-dictation-gexp "SOX" "WTYPE"
7244 (this-package-input "bash-minimal")
7245 (this-package-input "nerd-dictation"))))
7246 (propagated-inputs (list sox wtype))))
7247
7248(define-public python-brian2
7249 (package
7250 (name "python-brian2")
7251 (version "2.10.1")
7252 (source (origin
7253 (method url-fetch)
7254 (uri (pypi-uri "brian2" version))
7255 (sha256
7256 (base32
7257 "0kqvw716q26liifjds807nxz17xbzrqwhvyp34j3d4i115xivln1"))))
7258 (build-system pyproject-build-system)
7259 (arguments
7260 (list
7261 ;; tests: 104 passed, 2 skipped, 16 warnings
7262 #:test-flags
7263 ;; Tests hang during collection with higher number of threads.
7264 #~(list "--numprocesses" (number->string (min 8 (parallel-job-count)))
7265 ;; XXX: The complete test suite is massive, run a simple test
7266 ;; that uses the main simulation elements and force code
7267 ;; generation to use Cython.
7268 "tests/test_synapses.py")
7269 #:phases
7270 #~(modify-phases %standard-phases
7271 (add-after 'unpack 'relax-requirements
7272 (lambda _
7273 (substitute* "pyproject.toml"
7274 ;; 'cython>=0.29.21,<3.1.4',
7275 ((">=0.29.21,<3.1.4") ""))))
7276 (add-before 'check 'pre-check
7277 (lambda _
7278 (setenv "HOME" "/tmp")
7279 (copy-recursively "brian2/tests" "tests")
7280 (delete-file-recursively "brian2"))))))
7281 (native-inputs
7282 (list python-pytest
7283 python-pytest-timeout
7284 python-pytest-xdist
7285 python-setuptools-scm))
7286 (propagated-inputs
7287 (list python-cython
7288 python-jinja2
7289 python-numpy
7290 python-packaging
7291 python-pyparsing
7292 python-setuptools
7293 python-sympy))
7294 (home-page "https://briansimulator.org/")
7295 (synopsis "Clock-driven simulator for spiking neural networks")
7296 (description
7297 "Brian is a simulator for spiking neural networks written in Python. It
7298is therefore designed to be easy to learn and use, highly flexible and
7299easily extensible.")
7300 (license license:cecill)))
7301
7302(define-public python-brian2tools
7303 (package
7304 (name "python-brian2tools")
7305 (version "0.3")
7306 (source (origin
7307 (method url-fetch)
7308 (uri (pypi-uri "brian2tools" version))
7309 (sha256
7310 (base32
7311 "0fn028mfy3qlzjkadd0wr5d7rcplijd5jphln414xifvvsb9jcc2"))))
7312 (build-system pyproject-build-system)
7313 ;; Both pypi tarball and git repo lack test files.
7314 (arguments (list #:tests? #f))
7315 (propagated-inputs (list python-brian2
7316 python-libneuroml
7317 python-markdown-strings
7318 python-matplotlib
7319 python-pylems
7320 python-tables))
7321 (native-inputs (list python-setuptools python-setuptools-scm))
7322 (home-page "https://github.com/brian-team/brian2tools")
7323 (synopsis "Tools for the Brian 2 simulator")
7324 (description "Visualization and NeuroML import/export tools for the
7325Brian 2 simulator.")
7326 (license license:cecill)))
7327
7328(define-public mnn
7329 (package
7330 (name "mnn")
7331 (version "3.5.0")
7332 (source
7333 (origin
7334 (method git-fetch)
7335 (uri (git-reference
7336 (url "https://github.com/alibaba/MNN/")
7337 (commit version)))
7338 (snippet
7339 #~(begin
7340 (use-modules (guix build utils))
7341 ;; Remove failing tests.
7342 (delete-file-recursively "test/expr/ModuleTest.cpp")
7343 (delete-file-recursively "test/op/ConvInt8Test.cpp")
7344 ;; Remove external libraries. Almost all of them are
7345 ;; available in Guix.
7346 (with-directory-excursion "3rd_party"
7347 (for-each delete-file-recursively
7348 '(;;"OpenCLHeaders"; for now does not build if in tree copy removed
7349 ;; "flatbuffers" ; for now does not build if in tree copy removed
7350 "protobuf"
7351 "rapidjson")))))
7352 (file-name (git-file-name name version))
7353 (sha256
7354 (base32 "1jllq0zik55kznnks0kjqkilk362msgbz65qc3az5hvcrz34m8j7"))))
7355 (build-system cmake-build-system)
7356 (native-inputs (list googletest pkg-config python-minimal-wrapper))
7357 (inputs (list ;; flatbuffers ;requires 1.10.2
7358 fp16
7359 glew
7360 glslang
7361 glu
7362 mesa
7363 mesa-headers
7364 mesa-opencl
7365 opencl-headers
7366 opencl-clhpp
7367 opencl-icd-loader
7368 opencv
7369 protobuf
7370 pthreadpool
7371 rapidjson ;requires 1.1.0
7372 shaderc
7373 vulkan-headers
7374 vulkan-loader))
7375 (arguments
7376 (list
7377 #:phases
7378 #~(modify-phases %standard-phases
7379 (replace 'check
7380 (lambda* (#:key tests? #:allow-other-keys)
7381 (when tests?
7382 (invoke "./run_test.out")))))
7383 #:configure-flags
7384 #~(list "-DMNN_USE_SYSTEM_LIB=ON"
7385 "-DMNN_OPENMP=ON"
7386 ;; "-DMNN_OPENGL=ON" ; TO DO
7387 "-DMNN_OPENCL=ON"
7388 "-DMNN_VULKAN=ON"
7389 "-DMNN_SUPPORT_BF16=ON"
7390 "-DMNN_BUILD_TEST=ON"
7391 "-DMNN_BUILD_AUDIO=ON"
7392 "-DMNN_BUILD_OPENCV=ON"
7393 "-DMNN_BUILD_PROTOBUFFER=OFF"
7394 "-DMNN_IMGCODECS=ON"
7395 ;; "-DMNN_AUDIO_TEST=ON"
7396 ;; tests trying to fetch googletest and cannot build
7397 ;; "-DMNN_OPENCV_TEST=ON"
7398 ;; TO DO: remove the fetch in cmake and use system googletest
7399 "-DMNN_OPENCV_BENCH=ON"
7400 "-DMNN_BUILD_QUANTOOLS=ON"
7401 "-DMNN_EVALUATION=ON"
7402 "-DMNN_BUILD_BENCHMARK=ON"
7403 "-DMNN_BUILD_TOOLS=ON"
7404 "-DMNN_BUILD_CONVERTER=ON"
7405 "-DMNN_USE_SSE=ON"
7406 "-DMNN_AVX512=ON"))) ;TO DO: add Pytorch support
7407 (home-page "http://www.mnn.zone/")
7408 (synopsis "Fast, lightweight deep learning framework")
7409 (description
7410 "MNN is a deep learning framework. It supports inference and
7411training of deep learning models for inference and training on-device.")
7412 (license license:asl2.0)))
7413
7414;; This package needs to be in sync with llama-cpp version in use to avoid
7415;; incompatibilities.
7416(define-public python-gguf
7417 (package
7418 (inherit llama-cpp)
7419 (name "python-gguf")
7420 (version "0.19.0") ;from gguf-py/pyproject.toml
7421 (build-system pyproject-build-system)
7422 (arguments
7423 (list
7424 #:phases
7425 #~(modify-phases %standard-phases
7426 (add-after 'unpack 'chdir
7427 (lambda _
7428 (chdir "gguf-py"))))))
7429 (inputs '())
7430 (propagated-inputs (list python-numpy python-pyyaml python-pyside-6
7431 python-sentencepiece python-tqdm))
7432 (native-inputs (list python-poetry-core python-pytest))
7433 (properties '())
7434 (home-page "https://ggml.ai")
7435 (synopsis "Read and write ML models in GGUF for GGML")
7436 (description "A Python library for reading and writing GGUF & GGML format
7437ML models.")
7438 (license license:expat)))
7439
7440(define-public python-gymnasium
7441 (package
7442 (name "python-gymnasium")
7443 (version "0.29.1")
7444 (source
7445 (origin
7446 (method url-fetch)
7447 (uri (pypi-uri "gymnasium" version))
7448 (sha256
7449 (base32 "1cab4wsnlsxn2z90qmymv8ppmsq8yq2amiqwid3r0xfbxx92flqs"))))
7450 (build-system pyproject-build-system)
7451 (arguments
7452 (list
7453 #:phases
7454 #~(modify-phases %standard-phases
7455 (add-after 'unpack 'create-tests-module
7456 (lambda _
7457 (with-output-to-file "tests/__init__.py"
7458 (lambda _ (display ""))))))))
7459 (propagated-inputs (list python-cloudpickle python-farama-notifications
7460 python-numpy python-typing-extensions))
7461 (native-inputs
7462 (list python-pytest python-scipy python-setuptools python-wheel))
7463 (home-page "https://gymnasium.farama.org/")
7464 (synopsis
7465 "Standard API for reinforcement learning and a set of reference environments")
7466 (description
7467 "This package provides a standard API for reinforcement learning and a
7468diverse set of reference environments (formerly Gym).")
7469 (license license:expat)))
7470
7471;; This will build dlib in the process of building python-dlib--and that
7472;; seems to be intended by upstream. Well, at least it probably optimizes
7473;; better that way.
7474(define-public python-dlib
7475 (package
7476 (inherit dlib)
7477 (name "python-dlib")
7478 (build-system pyproject-build-system)
7479 (arguments
7480 (list
7481 #:phases
7482 #~(modify-phases %standard-phases
7483 (add-after 'unpack 'subst
7484 (lambda _
7485 (substitute* "tools/python/CMakeLists.txt"
7486 (("\
7487add_subdirectory[(][.][.]/[.][.]/dlib/external/pybind11 pybind11_build[)]")
7488 "find_package(pybind11 CONFIG)")))))))
7489 (native-inputs
7490 (list cmake-minimal
7491 perl
7492 pkg-config
7493 pybind11-2
7494 python-pytest
7495 python-setuptools))))
7496
7497;; Version 0.16 breaks miopen
7498(define-public frugally-deep
7499 (package
7500 (name "frugally-deep")
7501 (version "0.15.31")
7502 (source (origin
7503 (method git-fetch)
7504 (uri (git-reference
7505 (url "https://github.com/Dobiasd/frugally-deep")
7506 (commit (string-append "v" version))))
7507 (file-name (git-file-name name version))
7508 (sha256
7509 (base32
7510 "0gzkv03kz9p94a9apmds77npvxhmqyahhah4bq5yz3v9pvw6kx10"))))
7511 (build-system cmake-build-system)
7512 ;; Tests require tensorflow
7513 (arguments (list #:tests? #f))
7514 (native-inputs (list eigen functionalplus nlohmann-json))
7515 (home-page "https://github.com/Dobiasd/frugally-deep")
7516 (synopsis "Header-only library for using Keras (TensorFlow) models
7517in C++")
7518 (description "@code{frugally-deep} is a header-only C++ library for
7519inference of Keras machine learning models on a single CPU core.")
7520 (license license:expat)))