projects/guix·blob python-team · refs

223 lines · 8.4 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2023 zamfofex <[email protected]>
3;;; Copyright © 2026 Cayetano Santos <[email protected]>
4;;;
5;;; This file is part of GNU Guix.
6;;;
7;;; GNU Guix is free software; you can redistribute it and/or modify it
8;;; under the terms of the GNU General Public License as published by
9;;; the Free Software Foundation; either version 3 of the License, or (at
10;;; your option) any later version.
11;;;
12;;; GNU Guix is distributed in the hope that it will be useful, but
13;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;;; GNU General Public License for more details.
16;;;
17;;; You should have received a copy of the GNU General Public License
18;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19
20(define-module (gnu packages lc0)
21 #:use-module (guix build utils)
22 #:use-module (guix build-system copy)
23 #:use-module (guix build-system meson)
24 #:use-module (guix build-system trivial)
25 #:use-module (guix download)
26 #:use-module (guix gexp)
27 #:use-module (guix git-download)
28 #:use-module ((guix licenses) #:prefix license:)
29 #:use-module (guix packages)
30 #:use-module (gnu packages)
31 #:use-module (gnu packages algebra)
32 #:use-module (gnu packages c)
33 #:use-module (gnu packages check)
34 #:use-module (gnu packages compression)
35 #:use-module (gnu packages oneapi)
36 #:use-module (gnu packages pkg-config)
37 #:use-module (gnu packages python))
38
39(define-public lc0
40 (package
41 (name "lc0")
42 (version "0.31.2")
43 (source (origin
44 (method git-fetch)
45 (uri (git-reference
46 (url "https://github.com/LeelaChessZero/lc0")
47 (commit (string-append "v" version))
48 ;; Only a few source files are in one Git submodules
49 ;; (rather than there being bundled projects). These
50 ;; files are in a different repository just because they
51 ;; are used across multiple repositories of the Leela
52 ;; Chess Zero project.
53 (recursive? #t)))
54 (file-name (git-file-name name version))
55 (sha256
56 (base32
57 "0hhil95vwx3vval8wz5k8cr3djj2lgy5racahmj9xjaj7h6as1pk"))))
58 (build-system meson-build-system)
59 (arguments
60 (list
61 #:configure-flags
62 #~(list "-Ddnnl=true"
63 (string-append "-Ddnnl_dir="
64 #$(this-package-input "onednn")))
65 #:phases
66 #~(modify-phases %standard-phases
67 (add-after 'unpack 'remove-march-native
68 (lambda _
69 (substitute* "meson.build"
70 (("-march=native") "")))))))
71 (native-search-paths
72 (list (search-path-specification
73 (variable "XDG_DATA_DIRS")
74 (files '("share")))))
75 (inputs (list eigen onednn zlib))
76 (native-inputs (list googletest ispc pkg-config python-minimal-wrapper))
77 (synopsis "Chess engine based on neural networks")
78 (description
79 "Leela Chess Zero is a UCI-compliant chess engine designed to play chess
80using neural networks. This package does not provide a neural network, which
81is necessary to use Leela Chess Zero and should be installed separately.")
82 (home-page "https://lczero.org")
83 (license license:gpl3+)))
84
85(define (make-lc0-net name file-name url hash description)
86 (package
87 (name (string-append "lc0-" name))
88 (version "0")
89 (source (origin
90 (method url-fetch)
91 (uri url)
92 (file-name (string-append "lc0-" file-name))
93 (sha256
94 (base32 hash))))
95 (build-system trivial-build-system)
96 (arguments
97 (list #:builder
98 (with-imported-modules '((guix build utils))
99 #~(let ((share (string-append #$output "/share/lc0/")))
100 (use-modules (guix build utils))
101 (mkdir-p share)
102 (copy-file (assoc-ref %build-inputs "source")
103 (string-append share #$file-name))))))
104 (synopsis "Pre-trained neural network for Leela Chess Zero")
105 (description description)
106 (home-page "https://lczero.org")
107 (license license:gpl3+)))
108
109(define-public (make-lc0-official-net name url-hash hash description)
110 (make-lc0-net
111 name
112 (string-append name ".pb.gz")
113 (string-append "https://storage.lczero.org/files/networks/" url-hash)
114 hash
115 description))
116
117(define-public (make-lc0-contrib-net name file-name hash description)
118 (make-lc0-net name file-name
119 (string-append
120 "https://storage.lczero.org/files/networks-contrib/"
121 file-name)
122 hash description))
123
124(define-public lc0-t2
125 (make-lc0-contrib-net "t2" "t2-768x15x24h-swa-5230000.pb.gz"
126 "126305hby24k5agxiixadp1lcgmv8drm1dkpb4jf5jzq7k4m855w"
127 "T2 is currently one of the best neural networks for Leela Chess Zero,
128superseding the neural network T1."))
129
130(define-public lc0-t1
131 (make-lc0-contrib-net "t1" "t1-768x15x24h-swa-4000000.pb.gz"
132 "0zm9v91gfnm69n4x2fckair24fypjrwiip3j86ylsqncsi1sh5nq"
133 "T1 is currently one of the best neural networks for Leela Chess Zero,
134however, it was superseded by the neural network T2."))
135
136(define-public lc0-t1-512
137 (make-lc0-contrib-net "t1-512" "t1-512x15x8h-distilled-swa-3395000.pb.gz"
138 "1s4pq06qkdpaq0a4z6j5qqnf6h7njpmwh7i0v7qh6bmhwlcibnqz"
139 "This is a smaller version of the T1 neural network, which is currently one
140of the best neural networks for Leela Chess Zero."))
141
142(define-public lc0-t1-256
143 (make-lc0-contrib-net "t1-256" "t1-256x10-distilled-swa-2432500.pb.gz"
144 "01ilar7y2nf3kfkq3x77n4jxlvqdpgddjsham2wz4dmdx35ac9xw"
145 "This is a smaller version of the T1 neural network, which is currently one
146of the best neural networks for Leela Chess Zero."))
147
148(define-public lc0-611246
149 (make-lc0-official-net "611246"
150 "7ca2381cfeac5c280f304e7027ffbea1b7d87474672e5d6fb16d5cd881640e04"
151 "0rapfvjqqrhydhp8a6r3skmjci2dc2yxz912bglv9yd9k00l9rww"
152 "This is an official neural network of a ``main run'' of the Leela Chess
153Zero project that was finished being trained in January of 2022."))
154
155(define-public lc0-791556
156 (make-lc0-official-net "791556"
157 "f404e156ceb2882470fd8c032b8754af0fa0b71168328912eaef14671a256e34"
158 "03b9xl9vkiihdilz5dzcpg6g4inb6n4k5gs911i3gbd8h9sh9ixi"
159 "This is an official neural network of the Leela Chess Zero project that
160was finished being trained in April of 2022."))
161
162(define-public lc0-815383
163 (make-lc0-official-net "815383"
164 "8af6098d6fb76e2bef6ef9ee87e61fadcb99f0b789013a72953a95ad10a9e933"
165 "09gm8lgaick60rn4x9h9w5sxdqivr4ign73viviadw1gj7wsbnsg"
166 "This is an official neural network of a ``main run'' of the Leela Chess
167Zero project. The network was finished being trained in September of 2023."))
168
169(define (make-lc0-maia rating)
170 (package
171 (name (string-append "lc0-maia-" rating))
172 (version "1.0")
173 (source (origin
174 (method git-fetch)
175 (uri (git-reference
176 (url "https://github.com/CSSLab/maia-chess")
177 (commit (string-append "v" version))))
178 (file-name (git-file-name "maia" version))
179 (sha256
180 (base32
181 "0qjkp56pb5vvkr3j1vdsdzligvy7faza917z7vdfmf168pkvrxsr"))))
182 (build-system copy-build-system)
183 (arguments
184 (list
185 #:install-plan
186 #~(list
187 `(,(string-append "model_files/" #$rating
188 "/final_" #$rating "-40.pb.gz")
189 ,(string-append "share/lc0/maia-" #$rating ".pb.gz")))))
190 (synopsis "Human-like neural network for Leela Chess Zero")
191 (description
192 "Maia’s goal is to play the human move, not necessarily the best move.
193As a result, Maia has a more human-like style than previous engines, matching
194moves played by human players in online games over 50% of the time.")
195 (home-page "https://maiachess.com")
196 (license license:gpl3)))
197
198(define-public lc0-maia-1100
199 (make-lc0-maia "1100"))
200
201(define-public lc0-maia-1200
202 (make-lc0-maia "1200"))
203
204(define-public lc0-maia-1300
205 (make-lc0-maia "1300"))
206
207(define-public lc0-maia-1400
208 (make-lc0-maia "1400"))
209
210(define-public lc0-maia-1500
211 (make-lc0-maia "1500"))
212
213(define-public lc0-maia-1600
214 (make-lc0-maia "1600"))
215
216(define-public lc0-maia-1700
217 (make-lc0-maia "1700"))
218
219(define-public lc0-maia-1800
220 (make-lc0-maia "1800"))
221
222(define-public lc0-maia-1900
223 (make-lc0-maia "1900"))