all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#63088] [PATCH 0/3] Add Lc0
@ 2023-04-26 13:13 zamfofex
  2023-04-26 13:17 ` [bug#63088] [PATCH 1/3] gnu: Add ISPC. * gnu/packages/c.scm (ispc): New variable zamfofex
                   ` (6 more replies)
  0 siblings, 7 replies; 22+ messages in thread
From: zamfofex @ 2023-04-26 13:13 UTC (permalink / raw)
  To: 63088; +Cc: zamfofex

This patch series adds Lc0 “Leela Chess Zero” (a chess engine), alongside a few other optional dependencies that help improve its runtime performance.

zamfofex (3):
  gnu: Add ISPC. * gnu/packages/c.scm (ispc): New variable.
  gnu: Add oneDNN. * gnu/packages/machine-learning.scm (oneapi-dnnl):
    New variable.
  gnu: Add Lc0. * gnu/packages/games.scm (lc0): New variable.

 gnu/packages/c.scm                | 63 +++++++++++++++++++++++++++++++
 gnu/packages/games.scm            | 60 ++++++++++++++++++++++++++++-
 gnu/packages/machine-learning.scm | 21 +++++++++++
 3 files changed, 143 insertions(+), 1 deletion(-)


base-commit: 380faf265b0c3b231ab8b69597d161be5e704e18
-- 
2.39.2





^ permalink raw reply	[flat|nested] 22+ messages in thread

* [bug#63088] [PATCH 1/3] gnu: Add ISPC. * gnu/packages/c.scm (ispc): New variable.
  2023-04-26 13:13 [bug#63088] [PATCH 0/3] Add Lc0 zamfofex
@ 2023-04-26 13:17 ` zamfofex
  2023-04-26 13:17 ` [bug#63088] [PATCH 2/3] gnu: Add oneDNN. * gnu/packages/machine-learning.scm (oneapi-dnnl): " zamfofex
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 22+ messages in thread
From: zamfofex @ 2023-04-26 13:17 UTC (permalink / raw)
  To: 63088; +Cc: zamfofex

---
 gnu/packages/c.scm | 63 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/gnu/packages/c.scm b/gnu/packages/c.scm
index b2f16613dd..28438f56c8 100644
--- a/gnu/packages/c.scm
+++ b/gnu/packages/c.scm
@@ -17,6 +17,7 @@
 ;;; Copyright © 2022 Artyom V. Poptsov <poptsov.artyom@gmail.com>
 ;;; Copyright © 2022 Ekaitz Zarraga <ekaitz@elenq.tech>
 ;;; Copyright © 2022 ( <paren@disroot.org>
+;;; Copyright © 2023 zamfofex <zamfofex@twdb.moe>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -57,7 +58,9 @@ (define-module (gnu packages c)
   #:use-module (gnu packages guile)
   #:use-module (gnu packages llvm)
   #:use-module (gnu packages lua)
+  #:use-module (gnu packages m4)
   #:use-module (gnu packages multiprecision)
+  #:use-module (gnu packages ncurses)
   #:use-module (gnu packages pcre)
   #:use-module (gnu packages python)
   #:use-module (gnu packages python-xyz)
@@ -1375,3 +1378,63 @@ (define-public utest-h
       (description
        "This package provides a header-only unit testing library for C/C++.")
       (license license:unlicense))))
+
+(define-public ispc
+  (package
+    (name "ispc")
+    (version "1.19.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/ispc/ispc")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "0yhcgyzjlrgs920lm0l6kygj2skanfb6qkxbdgm69r8c2xkzkaa3"))))
+    (inputs (list ncurses))
+    (native-inputs (list bison clang flex m4 python))
+    (build-system cmake-build-system)
+    (supported-systems '("x86_64-linux" "i686-linux" "aarch64-linux" "armhf-linux"))
+    (arguments `(#:tests? #f
+                 #:configure-flags
+                   `(,,(string-append "-DCMAKE_C_COMPILER=" (cc-for-target))
+                     ,,(string-append "-DCMAKE_CXX_COMPILER=" (cxx-for-target))
+                     ,(string-append "-DCLANG_EXECUTABLE="
+                                     (assoc-ref %build-inputs "clang")
+                                     "/bin/clang")
+                     ,(string-append "-DCLANGPP_EXECUTABLE="
+                                     (assoc-ref %build-inputs "clang")
+                                     "/bin/clang++"))
+                 #:phases
+                   (modify-phases %standard-phases
+                     (add-before 'configure 'patch-curses-requirement
+                       (lambda _
+                         (substitute* "CMakeLists.txt"
+                                      (("\\bCURSES_CURSES_LIBRARY\\b")
+                                        "CURSES_LIBRARY"))))
+                     ; Note: This works around the following issue:
+                     ; <https://github.com/ispc/ispc/issues/1865>
+                     ; Because GCC in Guix does not have multilib support.
+                     (add-before 'configure 'patch-target-archs
+                       (lambda _
+                         (substitute* "cmake/GenerateBuiltins.cmake"
+                                      (("\\bforeach \\(bit 32 64\\)")
+                                        ,(if (target-64bit?)
+                                             "foreach (bit 64)"
+                                             "foreach (bit 32)"))
+                                      (("\\bforeach \\(arch .*?\\)")
+                                        ,(if (target-x86?)
+                                             "foreach (arch \"x86\")"
+                                             "foreach (arch \"arm\")"))
+                                      (("\\bforeach \\(os_name \"windows\" .*?\\)")
+                                        "foreach (os_name \"linux\")")))))))
+    (synopsis "Implicit SPMD Program Compiler")
+    (description
+     "ISPC is a compiler for a variant of the C programming language, with
+extensions for single program, multiple data programming.  Under the SPMD
+model, the programmer writes a program that generally appears to be a regular
+serial program, though the execution model is actually that a number of program
+instances execute in parallel on the hardware.")
+    (home-page "https://github.com/ispc/ispc")
+    (license license:bsd-3)))
-- 
2.39.2





^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [bug#63088] [PATCH 2/3] gnu: Add oneDNN. * gnu/packages/machine-learning.scm (oneapi-dnnl): New variable.
  2023-04-26 13:13 [bug#63088] [PATCH 0/3] Add Lc0 zamfofex
  2023-04-26 13:17 ` [bug#63088] [PATCH 1/3] gnu: Add ISPC. * gnu/packages/c.scm (ispc): New variable zamfofex
@ 2023-04-26 13:17 ` zamfofex
  2023-04-26 13:17 ` [bug#63088] [PATCH 3/3] gnu: Add Lc0. * gnu/packages/games.scm (lc0): " zamfofex
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 22+ messages in thread
From: zamfofex @ 2023-04-26 13:17 UTC (permalink / raw)
  To: 63088; +Cc: zamfofex

---
 gnu/packages/machine-learning.scm | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index 37d4ef78ad..a29bb312e6 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -17,6 +17,7 @@
 ;;; Copyright © 2020 Edouard Klein <edk@beaver-labs.com>
 ;;; Copyright © 2020, 2021, 2022, 2023 Vinicius Monego <monego@posteo.net>
 ;;; Copyright © 2020, 2021, 2022, 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2023 zamfofex <zamfofex@twdb.moe>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -3868,3 +3869,23 @@ (define-public python-brian2tools
 Brian 2 simulator.")
     (license license:cecill)))
 
+(define-public oneapi-dnnl
+  (package
+    (name "oneapi-dnnl")
+    (version "3.1")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/oneapi-src/oneDNN")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "1jgmb5kl0bf4a2zfn94zlb117672r9lvvkkmwl86ihlyr1mpr3d0"))))
+    (build-system cmake-build-system)
+    (home-page "https://github.com/oneapi-src/oneDNN")
+    (synopsis "Deep Neural Network Library")
+    (description
+     "OneAPI Deep Neural Network Library (oneDNN) is a cross-platform
+performance library of basic building blocks for deep learning applications.")
+    (license license:asl2.0)))
-- 
2.39.2





^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [bug#63088] [PATCH 3/3] gnu: Add Lc0. * gnu/packages/games.scm (lc0): New variable.
  2023-04-26 13:13 [bug#63088] [PATCH 0/3] Add Lc0 zamfofex
  2023-04-26 13:17 ` [bug#63088] [PATCH 1/3] gnu: Add ISPC. * gnu/packages/c.scm (ispc): New variable zamfofex
  2023-04-26 13:17 ` [bug#63088] [PATCH 2/3] gnu: Add oneDNN. * gnu/packages/machine-learning.scm (oneapi-dnnl): " zamfofex
@ 2023-04-26 13:17 ` zamfofex
  2023-05-11 14:29   ` [bug#63088] [PATCH 0/3] Add Lc0 宋文武 via Guix-patches via
  2023-07-27 23:34 ` [bug#63088] [PATCH] " zamfofex
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 22+ messages in thread
From: zamfofex @ 2023-04-26 13:17 UTC (permalink / raw)
  To: 63088; +Cc: zamfofex

---
 gnu/packages/games.scm | 60 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 59 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/games.scm b/gnu/packages/games.scm
index 23b6c39c46..9350c9224c 100644
--- a/gnu/packages/games.scm
+++ b/gnu/packages/games.scm
@@ -70,7 +70,7 @@
 ;;; Copyright © 2021 Foo Chuan Wei <chuanwei.foo@hotmail.com>
 ;;; Copyright © 2022, 2023 Yovan Naumovski <yovan@gorski.stream>
 ;;; Copyright © 2022 Roman Riabenko <roman@riabenko.com>
-;;; Copyright © 2022 zamfofex <zamfofex@twdb.moe>
+;;; Copyright © 2022, 2023 zamfofex <zamfofex@twdb.moe>
 ;;; Copyright © 2022 Gabriel Arazas <foo.dogsquared@gmail.com>
 ;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2022 Hendursaga <hendursaga@aol.com>
@@ -114,6 +114,7 @@ (define-module (gnu packages games)
   #:use-module (gnu packages bash)
   #:use-module (gnu packages bison)
   #:use-module (gnu packages boost)
+  #:use-module (gnu packages c)
   #:use-module (gnu packages check)
   #:use-module (gnu packages cmake)
   #:use-module (gnu packages compression)
@@ -166,6 +167,7 @@ (define-module (gnu packages games)
   #:use-module (gnu packages linux)
   #:use-module (gnu packages llvm)
   #:use-module (gnu packages lua)
+  #:use-module (gnu packages machine-learning)
   #:use-module (gnu packages man)
   #:use-module (gnu packages maths)
   #:use-module (gnu packages messaging)
@@ -10395,6 +10397,62 @@ (define-public stockfish
       (home-page "https://stockfishchess.org/")
       (license license:gpl3+))))
 
+(define lc0-neural-network
+  (let ((hash
+         "f404e156ceb2882470fd8c032b8754af0fa0b71168328912eaef14671a256e34"))
+      (origin
+        (method url-fetch)
+        (uri (string-append "https://storage.lczero.org/files/networks/"
+                            hash))
+        (sha256
+         (base32
+          "03b9xl9vkiihdilz5dzcpg6g4inb6n4k5gs911i3gbd8h9sh9ixi"))
+        (file-name "lc0-neural-network"))))
+
+(define-public lc0
+  (package
+    (name "lc0")
+    (version "0.29.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/LeelaChessZero/lc0")
+             (commit (string-append "v" version))
+             (recursive? #t)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "1yn91738wd8zlbvrcw0dszy7hqjpkml0wi5xhh36j4zgid6x8i2m"))))
+    (build-system meson-build-system)
+    (native-search-paths
+       (list (search-path-specification
+              (variable "XDG_DATA_DIRS")
+              (files (list "share")))))
+    (inputs
+     `(("neural-network" ,lc0-neural-network)
+       ("eigen" ,eigen)
+       ("oneapi-dnnl" ,oneapi-dnnl)
+       ("zlib" ,zlib)))
+    (native-inputs
+     (list googletest ispc pkg-config python))
+    (arguments
+     '(#:phases (modify-phases %standard-phases
+                  (add-after 'install 'copy-net
+                    (lambda* (#:key outputs inputs #:allow-other-keys)
+                      (mkdir-p (string-append (assoc-ref outputs "out")
+                                              "/share/lc0"))
+                      (copy-file (assoc-ref inputs "neural-network")
+                                 (string-append (assoc-ref outputs "out")
+                                                "/share/lc0/neural-network")))))
+       #:configure-flags (list "-Ddnnl=true"
+                               (string-append
+                                 "-Ddnnl_dir="
+                                 (assoc-ref %build-inputs "oneapi-dnnl")))))
+    (synopsis "Neural network based chess engine")
+    (description "Lc0 is a chess engine based on neural networks")
+    (home-page "https://lczero.org")
+    (license license:gpl3+)))
+
 (define-public barrage
   (package
     (name "barrage")
-- 
2.39.2





^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [bug#63088] [PATCH 0/3] Add Lc0
  2023-04-26 13:17 ` [bug#63088] [PATCH 3/3] gnu: Add Lc0. * gnu/packages/games.scm (lc0): " zamfofex
@ 2023-05-11 14:29   ` 宋文武 via Guix-patches via
  2023-05-11 21:25     ` zamfofex
  0 siblings, 1 reply; 22+ messages in thread
From: 宋文武 via Guix-patches via @ 2023-05-11 14:29 UTC (permalink / raw)
  To: zamfofex; +Cc: 63088


Hello, I have pushed ispc and oneapi-dnnl, thank you!


zamfofex <zamfofex@twdb.moe> writes:
> +(define lc0-neural-network
> +  (let ((hash
> +         "f404e156ceb2882470fd8c032b8754af0fa0b71168328912eaef14671a256e34"))
> +      (origin
> +        (method url-fetch)
> +        (uri (string-append "https://storage.lczero.org/files/networks/"
> +                            hash))
> +        (sha256
> +         (base32
> +          "03b9xl9vkiihdilz5dzcpg6g4inb6n4k5gs911i3gbd8h9sh9ixi"))
> +        (file-name "lc0-neural-network"))))

Will we able to train a model from source?  And how much will it cost?

As far as I know, guix haven't decided to accept pre-trained models:

https://yhetil.org/guix/xanfHBZT3lYlyrr_OqHHMWkunLeZZlcxzY37_T3TeZo7mfJClD5-OTbkXDH2f3lMTkn94YIFVUj-Z31BP2Wj0W2rISNP6glC2PzXcPdb560=@protonmail.com/




^ permalink raw reply	[flat|nested] 22+ messages in thread

* [bug#63088] [PATCH 0/3] Add Lc0
  2023-05-11 14:29   ` [bug#63088] [PATCH 0/3] Add Lc0 宋文武 via Guix-patches via
@ 2023-05-11 21:25     ` zamfofex
  2023-05-16 12:16       ` Simon Tournier
  0 siblings, 1 reply; 22+ messages in thread
From: zamfofex @ 2023-05-11 21:25 UTC (permalink / raw)
  To: 宋文武; +Cc: 63088

> Will we able to train a model from source?  And how much will it cost?
> 
> As far as I know, guix haven't decided to accept pre-trained models:
> 
> https://yhetil.org/guix/xanfHBZT3lYlyrr_OqHHMWkunLeZZlcxzY37_T3TeZo7mfJClD5-OTbkXDH2f3lMTkn94YIFVUj-Z31BP2Wj0W2rISNP6glC2PzXcPdb560=@protonmail.com/

I don’t think it is feasible. Lc0’s approach is based on self‐play reinforcement‐learning, which in effect means that training starts with no knowledge about chess except for its rules (playing seemingly random moves), and going from there to learn increasingly more about it. So, in practice, this means it would take multiple months or at least several weeks to attain a neural network model that is anywhere close to as effective as the ones provided and pre‐trained. Besides, I believe training requires a (reasonably decent) GPU.

But the network isn’t prohibitively large and its license is not proprietary. I’ll also note that Stockfish (packaged immediately above my Lc0 package) *does* itself include a provided pre‐trained network and no‐one has really complained about it, so I think it should be fine here too.




^ permalink raw reply	[flat|nested] 22+ messages in thread

* [bug#63088] [PATCH 0/3] Add Lc0
  2023-05-11 21:25     ` zamfofex
@ 2023-05-16 12:16       ` Simon Tournier
  0 siblings, 0 replies; 22+ messages in thread
From: Simon Tournier @ 2023-05-16 12:16 UTC (permalink / raw)
  To: zamfofex, 宋文武; +Cc: 63088

Hi,

On Thu, 11 May 2023 at 18:25, zamfofex <zamfofex@twdb.moe> wrote:
>> Will we able to train a model from source?  And how much will it cost?
>> 
>> As far as I know, guix haven't decided to accept pre-trained models:
>> 
>> https://yhetil.org/guix/xanfHBZT3lYlyrr_OqHHMWkunLeZZlcxzY37_T3TeZo7mfJClD5-OTbkXDH2f3lMTkn94YIFVUj-Z31BP2Wj0W2rISNP6glC2PzXcPdb560=@protonmail.com/
>
> I don’t think it is feasible. Lc0’s approach is based on self‐play
> reinforcement‐learning, which in effect means that training starts
> with no knowledge about chess except for its rules (playing seemingly
> random moves), and going from there to learn increasingly more about
> it. So, in practice, this means it would take multiple months or at
> least several weeks to attain a neural network model that is anywhere
> close to as effective as the ones provided and pre‐trained. Besides, I
> believe training requires a (reasonably decent) GPU.

I concur.


> But the network isn’t prohibitively large and its license is not
> proprietary. I’ll also note that Stockfish (packaged immediately above
> my Lc0 package) *does* itself include a provided pre‐trained network
> and no‐one has really complained about it, so I think it should be
> fine here too.

I will try to dedicate some time for reviewing this patch set.


Cheers,
simon





^ permalink raw reply	[flat|nested] 22+ messages in thread

* [bug#63088] [PATCH] Add Lc0.
  2023-04-26 13:13 [bug#63088] [PATCH 0/3] Add Lc0 zamfofex
                   ` (2 preceding siblings ...)
  2023-04-26 13:17 ` [bug#63088] [PATCH 3/3] gnu: Add Lc0. * gnu/packages/games.scm (lc0): " zamfofex
@ 2023-07-27 23:34 ` zamfofex
  2023-07-28  0:24   ` zamfofex
  2023-07-28  4:23   ` Liliana Marie Prikler
  2023-09-07 10:23 ` [bug#63088] [PATCH v2] gnu: " iyzsong--- via Guix-patches via
                   ` (2 subsequent siblings)
  6 siblings, 2 replies; 22+ messages in thread
From: zamfofex @ 2023-07-27 23:34 UTC (permalink / raw)
  To: 63088
  Cc: zamfofex, zimon.toutoune, Liliana Marie Prikler,
	宋文武

Lc0 recently released version 0.30.0, so here is a patch with the updates version (in case the issue regarding the network’s inclusion is ever resolved).

Also, I wanted to say: Is it reasonable to include Lc0 without the networks in? People can still download and use them, they just wouldn’t be included in Guix itself.

Note that, unlike Stockfish, Lc0 does run without the neural networks, so it would be necessary for the user to download or otherwise acquire one by themself in order to use Lc0. The user can choose an appropriate network in their chess GUI program when configuring Lc0 in it.

If this is more desireable, I can submit a patch without the trained neural network, which would allow the user to choose whichever one they might want.

Thanks in advance!

* gnu/packages/games.scm (lc0): New variable.
---
 gnu/packages/games.scm | 58 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/gnu/packages/games.scm b/gnu/packages/games.scm
index cc6bef1114..21aa370701 100644
--- a/gnu/packages/games.scm
+++ b/gnu/packages/games.scm
@@ -118,6 +118,7 @@ (define-module (gnu packages games)
   #:use-module (gnu packages bash)
   #:use-module (gnu packages bison)
   #:use-module (gnu packages boost)
+  #:use-module (gnu packages c)
   #:use-module (gnu packages check)
   #:use-module (gnu packages cmake)
   #:use-module (gnu packages compression)
@@ -171,6 +172,7 @@ (define-module (gnu packages games)
   #:use-module (gnu packages linux)
   #:use-module (gnu packages llvm)
   #:use-module (gnu packages lua)
+  #:use-module (gnu packages machine-learning)
   #:use-module (gnu packages man)
   #:use-module (gnu packages maths)
   #:use-module (gnu packages messaging)
@@ -10285,6 +10287,62 @@ (define-public stockfish
       (home-page "https://stockfishchess.org/")
       (license license:gpl3+))))
 
+(define lc0-neural-network
+  (let ((hash
+         "f404e156ceb2882470fd8c032b8754af0fa0b71168328912eaef14671a256e34"))
+      (origin
+        (method url-fetch)
+        (uri (string-append "https://storage.lczero.org/files/networks/"
+                            hash))
+        (sha256
+         (base32
+          "03b9xl9vkiihdilz5dzcpg6g4inb6n4k5gs911i3gbd8h9sh9ixi"))
+        (file-name "lc0-neural-network"))))
+
+(define-public lc0
+  (package
+    (name "lc0")
+    (version "0.30.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/LeelaChessZero/lc0")
+             (commit (string-append "v" version))
+             (recursive? #t)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "1m7k8m8iz4pxv3h9g2j1dkgryi4k9c1bcg3fx5j7ii4ysif63kj3"))))
+    (build-system meson-build-system)
+    (native-search-paths
+       (list (search-path-specification
+              (variable "XDG_DATA_DIRS")
+              (files (list "share")))))
+    (inputs
+     `(("neural-network" ,lc0-neural-network)
+       ("eigen" ,eigen)
+       ("oneapi-dnnl" ,oneapi-dnnl)
+       ("zlib" ,zlib)))
+    (native-inputs
+     (list googletest ispc pkg-config python))
+    (arguments
+     '(#:phases (modify-phases %standard-phases
+                  (add-after 'install 'copy-net
+                    (lambda* (#:key outputs inputs #:allow-other-keys)
+                      (mkdir-p (string-append (assoc-ref outputs "out")
+                                              "/share/lc0"))
+                      (copy-file (assoc-ref inputs "neural-network")
+                                 (string-append (assoc-ref outputs "out")
+                                                "/share/lc0/neural-network")))))
+       #:configure-flags (list "-Ddnnl=true"
+                               (string-append
+                                 "-Ddnnl_dir="
+                                 (assoc-ref %build-inputs "oneapi-dnnl")))))
+    (synopsis "Neural network based chess engine")
+    (description "Lc0 is a chess engine based on neural networks")
+    (home-page "https://lczero.org")
+    (license license:gpl3+)))
+
 (define-public barrage
   (package
     (name "barrage")

base-commit: c7e45139faa27b60f2c7d0a4bc140f9793d97d47
-- 
2.40.1





^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [bug#63088] [PATCH] Add Lc0.
  2023-07-27 23:34 ` [bug#63088] [PATCH] " zamfofex
@ 2023-07-28  0:24   ` zamfofex
  2023-07-28  4:23   ` Liliana Marie Prikler
  1 sibling, 0 replies; 22+ messages in thread
From: zamfofex @ 2023-07-28  0:24 UTC (permalink / raw)
  To: 63088; +Cc: zimon.toutoune

> Note that, unlike Stockfish, Lc0 does run without the neural networks

Sorry, I meant to say “Lc0 does *not* run without the neural networks”. (“Not” is a fairly important word to have forgotten!)




^ permalink raw reply	[flat|nested] 22+ messages in thread

* [bug#63088] [PATCH] Add Lc0.
  2023-07-27 23:34 ` [bug#63088] [PATCH] " zamfofex
  2023-07-28  0:24   ` zamfofex
@ 2023-07-28  4:23   ` Liliana Marie Prikler
  2023-07-28 18:14     ` zamfofex
  1 sibling, 1 reply; 22+ messages in thread
From: Liliana Marie Prikler @ 2023-07-28  4:23 UTC (permalink / raw)
  To: zamfofex, 63088; +Cc: 宋文武, zimon.toutoune

Am Donnerstag, dem 27.07.2023 um 20:34 -0300 schrieb zamfofex:
> Note that, unlike Stockfish, Lc0 does run without the neural
> networks, so it would be necessary for the user to download or
> otherwise acquire one by themself in order to use Lc0.
This sentence looks semantically incorrect.

> The user can choose an appropriate network in their chess GUI program
> when configuring Lc0 in it.
> 
> If this is more desireable, I can submit a patch without the trained
> neural network, which would allow the user to choose whichever one
> they might want.
Providing a default, if it can be bootstrapped, but allowing the user
to choose would be the best option.

> Thanks in advance!
> 
> * gnu/packages/games.scm (lc0): New variable.
> ---
>  gnu/packages/games.scm | 58
> ++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 58 insertions(+)
> 
> diff --git a/gnu/packages/games.scm b/gnu/packages/games.scm
> index cc6bef1114..21aa370701 100644
> --- a/gnu/packages/games.scm
> +++ b/gnu/packages/games.scm
> @@ -118,6 +118,7 @@ (define-module (gnu packages games)
>    #:use-module (gnu packages bash)
>    #:use-module (gnu packages bison)
>    #:use-module (gnu packages boost)
> +  #:use-module (gnu packages c)
>    #:use-module (gnu packages check)
>    #:use-module (gnu packages cmake)
>    #:use-module (gnu packages compression)
> @@ -171,6 +172,7 @@ (define-module (gnu packages games)
>    #:use-module (gnu packages linux)
>    #:use-module (gnu packages llvm)
>    #:use-module (gnu packages lua)
> +  #:use-module (gnu packages machine-learning)
>    #:use-module (gnu packages man)
>    #:use-module (gnu packages maths)
>    #:use-module (gnu packages messaging)
> @@ -10285,6 +10287,62 @@ (define-public stockfish
>        (home-page "https://stockfishchess.org/")
>        (license license:gpl3+))))
>  
> +(define lc0-neural-network
> +  (let ((hash
> +        
> "f404e156ceb2882470fd8c032b8754af0fa0b71168328912eaef14671a256e34"))
> +      (origin
> +        (method url-fetch)
> +        (uri (string-append
> "https://storage.lczero.org/files/networks/"
> +                            hash))
> +        (sha256
> +         (base32
> +          "03b9xl9vkiihdilz5dzcpg6g4inb6n4k5gs911i3gbd8h9sh9ixi"))
> +        (file-name "lc0-neural-network"))))
> +
> +(define-public lc0
> +  (package
> +    (name "lc0")
> +    (version "0.30.0")
> +    (source
> +     (origin
> +       (method git-fetch)
> +       (uri (git-reference
> +             (url "https://github.com/LeelaChessZero/lc0")
> +             (commit (string-append "v" version))
> +             (recursive? #t)))
> +       (file-name (git-file-name name version))
> +       (sha256
> +        (base32
> "1m7k8m8iz4pxv3h9g2j1dkgryi4k9c1bcg3fx5j7ii4ysif63kj3"))))
> +    (build-system meson-build-system)
> +    (native-search-paths
> +       (list (search-path-specification
> +              (variable "XDG_DATA_DIRS")
> +              (files (list "share")))))
> +    (inputs
> +     `(("neural-network" ,lc0-neural-network)
> +       ("eigen" ,eigen)
> +       ("oneapi-dnnl" ,oneapi-dnnl)
> +       ("zlib" ,zlib)))
> +    (native-inputs
> +     (list googletest ispc pkg-config python))
> +    (arguments
> +     '(#:phases (modify-phases %standard-phases
> +                  (add-after 'install 'copy-net
> +                    (lambda* (#:key outputs inputs #:allow-other-
> keys)
> +                      (mkdir-p (string-append (assoc-ref outputs
> "out")
> +                                              "/share/lc0"))
> +                      (copy-file (assoc-ref inputs "neural-network")
> +                                 (string-append (assoc-ref outputs
> "out")
> +                                                "/share/lc0/neural-
> network")))))
> +       #:configure-flags (list "-Ddnnl=true"
> +                               (string-append
> +                                 "-Ddnnl_dir="
> +                                 (assoc-ref %build-inputs "oneapi-
> dnnl")))))
> +    (synopsis "Neural network based chess engine")
I think the postfix "based", which typically requires a dash is not
easily applied here.  Simply write "Chess engine using neural networks"
or something like that.
> +    (description "Lc0 is a chess engine based on neural networks")
Not a full sentence without period
> +    (home-page "https://lczero.org")
> +    (license license:gpl3+)))
> +
>  (define-public barrage
>    (package
>      (name "barrage")
> 
> base-commit: c7e45139faa27b60f2c7d0a4bc140f9793d97d47

Cheers


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [bug#63088] [PATCH] Add Lc0.
  2023-07-28  4:23   ` Liliana Marie Prikler
@ 2023-07-28 18:14     ` zamfofex
  0 siblings, 0 replies; 22+ messages in thread
From: zamfofex @ 2023-07-28 18:14 UTC (permalink / raw)
  To: Liliana Marie Prikler, 63088; +Cc: 宋文武, zimon.toutoune

> This sentence looks semantically incorrect.

Yes, sorry! I guess you didn’t receive my correction email. (I’m still bad at sending emails properly, it seems.) See: <https://issues.guix.gnu.org/63088#8> I had meant “Lc0 does *not* run without the neural networks”.

> Providing a default, if it can be bootstrapped, but allowing the user to choose would be the best option.

I don’t think a default can be easily bootstrapped. When I first submitted the patch, I talked with some of the Lc0 developers, and they said it might be possible to bootstrap one by using Stockfish in several minutes, but there is no code that does that currrently (it would have to be written and is nontrivial). And it wouldn’t be as effective as the existing networks, because Stockfish’s evaluation provides less information than Lc0’s is able to use.

In any case, that feels entirely redundant, because Stockfish’s NNUE networks were trained on Lc0’s anyway, so it seems to be only adding a layer of complexity for no seemingly good reason.

If this concern can be addressed somehow, I can submit a followup patch. (Either just fixing the wording, or also removing the networks.)




^ permalink raw reply	[flat|nested] 22+ messages in thread

* [bug#63088] [PATCH v2] gnu: Add Lc0.
  2023-04-26 13:13 [bug#63088] [PATCH 0/3] Add Lc0 zamfofex
                   ` (3 preceding siblings ...)
  2023-07-27 23:34 ` [bug#63088] [PATCH] " zamfofex
@ 2023-09-07 10:23 ` iyzsong--- via Guix-patches via
  2023-09-07 17:03   ` Liliana Marie Prikler
  2023-09-12 11:58 ` [bug#63088] [PATCH 1/3] gnu: Add lc0 zamfofex
  2023-09-13  1:49 ` [bug#63088] [PATCH 1/3] gnu: Add lc0 zamfofex
  6 siblings, 1 reply; 22+ messages in thread
From: iyzsong--- via Guix-patches via @ 2023-09-07 10:23 UTC (permalink / raw)
  To: 63088
  Cc: zamfofex, 宋文武, Liliana Marie Prikler,
	宋文武

From: zamfofex <zamfofex@twdb.moe>

* gnu/packages/games.scm (lc0): New variable.

Signed-off-by: 宋文武 <iyzsong@member.fsf.org>
---
 gnu/packages/games.scm | 59 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/gnu/packages/games.scm b/gnu/packages/games.scm
index 760234b031..f82f1dcc52 100644
--- a/gnu/packages/games.scm
+++ b/gnu/packages/games.scm
@@ -118,6 +118,7 @@ (define-module (gnu packages games)
   #:use-module (gnu packages bash)
   #:use-module (gnu packages bison)
   #:use-module (gnu packages boost)
+  #:use-module (gnu packages c)
   #:use-module (gnu packages check)
   #:use-module (gnu packages cmake)
   #:use-module (gnu packages compression)
@@ -171,6 +172,7 @@ (define-module (gnu packages games)
   #:use-module (gnu packages linux)
   #:use-module (gnu packages llvm)
   #:use-module (gnu packages lua)
+  #:use-module (gnu packages machine-learning)
   #:use-module (gnu packages man)
   #:use-module (gnu packages maths)
   #:use-module (gnu packages messaging)
@@ -10409,6 +10411,63 @@ (define-public stockfish
       (home-page "https://stockfishchess.org/")
       (license license:gpl3+))))
 
+(define lc0-neural-network
+  (let ((hash
+         "f404e156ceb2882470fd8c032b8754af0fa0b71168328912eaef14671a256e34"))
+    (origin
+      (method url-fetch)
+      (uri (string-append "https://storage.lczero.org/files/networks/"
+                          hash))
+      (sha256
+       (base32
+        "03b9xl9vkiihdilz5dzcpg6g4inb6n4k5gs911i3gbd8h9sh9ixi"))
+      (file-name "lc0-neural-network"))))
+
+(define-public lc0
+  (package
+    (name "lc0")
+    (version "0.30.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/LeelaChessZero/lc0")
+             (commit (string-append "v" version))
+             (recursive? #t)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "1m7k8m8iz4pxv3h9g2j1dkgryi4k9c1bcg3fx5j7ii4ysif63kj3"))))
+    (build-system meson-build-system)
+    (native-search-paths
+     (list (search-path-specification
+            (variable "XDG_DATA_DIRS")
+            (files '("share")))))
+    (inputs
+     `(("neural-network" ,lc0-neural-network)
+       ("eigen" ,eigen)
+       ("oneapi-dnnl" ,oneapi-dnnl)
+       ("zlib" ,zlib)))
+    (native-inputs
+     (list googletest ispc pkg-config python))
+    (arguments
+     '(#:phases (modify-phases %standard-phases
+                  (add-after 'install 'copy-net
+                    (lambda* (#:key outputs inputs #:allow-other-keys)
+                      (mkdir-p (string-append (assoc-ref outputs "out")
+                                              "/share/lc0"))
+                      (copy-file (assoc-ref inputs "neural-network")
+                                 (string-append (assoc-ref outputs "out")
+                                                "/share/lc0/neural-network")))))
+       #:configure-flags (list "-Ddnnl=true"
+                               (string-append
+                                "-Ddnnl_dir="
+                                (assoc-ref %build-inputs "oneapi-dnnl")))))
+    (synopsis "Chess engine using neural networks")
+    (description "Lc0 is a UCI-compliant chess engine designed to play chess
+via neural network, specifically those of the LeelaChessZero project.")
+    (home-page "https://lczero.org")
+    (license license:gpl3+)))
+
 (define-public barrage
   (package
     (name "barrage")

base-commit: 5ef28595e9dff8b88ec3fcb4d887fbc380c9a8b8
prerequisite-patch-id: 8cee4be3d25dba0dde5c2d0e317f31741c010f50
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [bug#63088] [PATCH v2] gnu: Add Lc0.
  2023-09-07 10:23 ` [bug#63088] [PATCH v2] gnu: " iyzsong--- via Guix-patches via
@ 2023-09-07 17:03   ` Liliana Marie Prikler
  2023-09-11 10:22     ` zamfofex
  0 siblings, 1 reply; 22+ messages in thread
From: Liliana Marie Prikler @ 2023-09-07 17:03 UTC (permalink / raw)
  To: iyzsong, 63088; +Cc: zamfofex, 宋文武

Am Donnerstag, dem 07.09.2023 um 18:23 +0800 schrieb iyzsong@envs.net:
> From: zamfofex <zamfofex@twdb.moe>
> 
> * gnu/packages/games.scm (lc0): New variable.
Missing the entry for lc0-neural-network.
> 
> Signed-off-by: 宋文武 <iyzsong@member.fsf.org>
> ---
>  gnu/packages/games.scm | 59
> ++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 59 insertions(+)
> 
> diff --git a/gnu/packages/games.scm b/gnu/packages/games.scm
> index 760234b031..f82f1dcc52 100644
> --- a/gnu/packages/games.scm
> +++ b/gnu/packages/games.scm
> @@ -118,6 +118,7 @@ (define-module (gnu packages games)
>    #:use-module (gnu packages bash)
>    #:use-module (gnu packages bison)
>    #:use-module (gnu packages boost)
> +  #:use-module (gnu packages c)
>    #:use-module (gnu packages check)
>    #:use-module (gnu packages cmake)
>    #:use-module (gnu packages compression)
> @@ -171,6 +172,7 @@ (define-module (gnu packages games)
>    #:use-module (gnu packages linux)
>    #:use-module (gnu packages llvm)
>    #:use-module (gnu packages lua)
> +  #:use-module (gnu packages machine-learning)
>    #:use-module (gnu packages man)
>    #:use-module (gnu packages maths)
>    #:use-module (gnu packages messaging)
> @@ -10409,6 +10411,63 @@ (define-public stockfish
>        (home-page "https://stockfishchess.org/")
>        (license license:gpl3+))))
>  
> +(define lc0-neural-network
> +  (let ((hash
> +        
> "f404e156ceb2882470fd8c032b8754af0fa0b71168328912eaef14671a256e34"))
> +    (origin
> +      (method url-fetch)
> +      (uri (string-append
> "https://storage.lczero.org/files/networks/"
> +                          hash))
> +      (sha256
> +       (base32
> +        "03b9xl9vkiihdilz5dzcpg6g4inb6n4k5gs911i3gbd8h9sh9ixi"))
> +      (file-name "lc0-neural-network"))))
> +
> +(define-public lc0
> +  (package
> +    (name "lc0")
> +    (version "0.30.0")
> +    (source
> +     (origin
> +       (method git-fetch)
> +       (uri (git-reference
> +             (url "https://github.com/LeelaChessZero/lc0")
> +             (commit (string-append "v" version))
> +             (recursive? #t)))
recursive? #t is meh ._.
Can we work around that?
> +       (file-name (git-file-name name version))
> +       (sha256
> +        (base32
> "1m7k8m8iz4pxv3h9g2j1dkgryi4k9c1bcg3fx5j7ii4ysif63kj3"))))
> +    (build-system meson-build-system)
> +    (native-search-paths
> +     (list (search-path-specification
> +            (variable "XDG_DATA_DIRS")
> +            (files '("share")))))
> +    (inputs
> +     `(("neural-network" ,lc0-neural-network)
> +       ("eigen" ,eigen)
> +       ("oneapi-dnnl" ,oneapi-dnnl)
> +       ("zlib" ,zlib)))
Use new-style inputs.
> +    (native-inputs
> +     (list googletest ispc pkg-config python))
> +    (arguments
> +     '(#:phases (modify-phases %standard-phases
> +                  (add-after 'install 'copy-net
> +                    (lambda* (#:key outputs inputs #:allow-other-
> keys)
> +                      (mkdir-p (string-append (assoc-ref outputs
> "out")
> +                                              "/share/lc0"))
> +                      (copy-file (assoc-ref inputs "neural-network")
> +                                 (string-append (assoc-ref outputs
> "out")
> +                                                "/share/lc0/neural-
> network")))))
Can we use search-input-file or the like here?
> +       #:configure-flags (list "-Ddnnl=true"
> +                               (string-append
> +                                "-Ddnnl_dir="
> +                                (assoc-ref %build-inputs "oneapi-
> dnnl")))))
> +    (synopsis "Chess engine using neural networks")
> +    (description "Lc0 is a UCI-compliant chess engine designed to
> play chess
> +via neural network, specifically those of the LeelaChessZero
> project.")
Is Lc0 = Leela Chess Zero?  What's the connection?
> +    (home-page "https://lczero.org")
> +    (license license:gpl3+)))
Cheers

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [bug#63088] [PATCH v2] gnu: Add Lc0.
  2023-09-07 17:03   ` Liliana Marie Prikler
@ 2023-09-11 10:22     ` zamfofex
  2023-09-11 18:00       ` Liliana Marie Prikler
  0 siblings, 1 reply; 22+ messages in thread
From: zamfofex @ 2023-09-11 10:22 UTC (permalink / raw)
  To: Liliana Marie Prikler, iyzsong, 63088; +Cc: 宋文武

> recursive? #t is meh ._.
> Can we work around that?

Yes, presumably easily, but I don’t think it would be a good idea in this case, because it isn’t used to build bundled software, but rather just for a small project‐specific pair of source files (that are in a separate repo just because they are used by other repos of the project too).

> Can we use search-input-file or the like here?

Probably. Though would it be reasonable to package the network separately instead? Note that Lc0 is able to load various networks, and there is no canonical network, so maybe it would be useful to have it in a different package so that more can be potentially added in the future.

Then people could use them with something like ‘guix shell lc0 lc0-NETWORK_NAME’.

> Is Lc0 = Leela Chess Zero?  What's the connection?

“Lc0”, “Leela Chess Zero”, “LCZero”, and sometimes just “Leela Chess” can be used roughly interchangeably to refer to the project as a whole. Though, occasionally, people will use the term “Lc0” (sometimes capitalised as “lc0”) to refer specifically to the ‘lc0’ executable, which can use the networks from the Leela Chess Zero project, but networks created by other people too, including those of e.g. the Maia project, see <https://github.com/CSSLab/maia-chess> and <https://maiachess.com>

At some point (very early on), the code for the executable was rewritten or otherwise largely refactored, and at the same time renamed from ‘lczero’ to the current ‘lc0’, so sometimes (very rarely nowadays), people will use the term “lc0” (or “Lc0”) to refer specifically to this new executable and code base, contrasting with the former ‘lczero’ executable and its code base.

Honestly, this all feels convoluted to me, so I usually like to use the terms interchangeably, and I don’t think using them differently in the package description is a good choice.

- - - - -

Hopefully this helps clarify things well enough! If there is interest, I can submit another patch with the requested changes and the appropriate path taken regarding the packaging for the networks.




^ permalink raw reply	[flat|nested] 22+ messages in thread

* [bug#63088] [PATCH v2] gnu: Add Lc0.
  2023-09-11 10:22     ` zamfofex
@ 2023-09-11 18:00       ` Liliana Marie Prikler
  0 siblings, 0 replies; 22+ messages in thread
From: Liliana Marie Prikler @ 2023-09-11 18:00 UTC (permalink / raw)
  To: zamfofex, iyzsong, 63088; +Cc: 宋文武

Am Montag, dem 11.09.2023 um 07:22 -0300 schrieb zamfofex:
> > recursive? #t is meh ._.
> > Can we work around that?
> 
> Yes, presumably easily, but I don’t think it would be a good idea in
> this case, because it isn’t used to build bundled software, but
> rather just for a small project‐specific pair of source files (that
> are in a separate repo just because they are used by other repos of
> the project too).
In that case, a comment explaining this in 1-2 lines would probably be
fine.

> > Can we use search-input-file or the like here?
> 
> Probably. Though would it be reasonable to package the network
> separately instead? Note that Lc0 is able to load various networks,
> and there is no canonical network, so maybe it would be useful to
> have it in a different package so that more can be potentially added
> in the future.
> 
> Then people could use them with something like ‘guix shell lc0 lc0-
> NETWORK_NAME’.
Sounds reasonable to me.  Do add a phrase or two about this to the lc0
description though if it doesn't even ship a basic network.

> 
> > Is Lc0 = Leela Chess Zero?  What's the connection?
> 
> “Lc0”, “Leela Chess Zero”, “LCZero”, and sometimes just “Leela Chess”
> can be used roughly interchangeably to refer to the project as a
> whole. Though, occasionally, people will use the term “Lc0”
> (sometimes capitalised as “lc0”) to refer specifically to the ‘lc0’
> executable, which can use the networks from the Leela Chess Zero
> project, but networks created by other people too, including those of
> e.g. the Maia project, see <https://github.com/CSSLab/maia-chess> and
> <https://maiachess.com>
> 
> At some point (very early on), the code for the executable was
> rewritten or otherwise largely refactored, and at the same time
> renamed from ‘lczero’ to the current ‘lc0’, so sometimes (very rarely
> nowadays), people will use the term “lc0” (or “Lc0”) to refer
> specifically to this new executable and code base, contrasting with
> the former ‘lczero’ executable and its code base.
> 
> Honestly, this all feels convoluted to me, so I usually like to use
> the terms interchangeably, and I don’t think using them differently
> in the package description is a good choice.
In that case, for the description we should probably go with "Leela
Chess Zero" or "@acronym{lc0, Leela Chess Zero}"

Cheers




^ permalink raw reply	[flat|nested] 22+ messages in thread

* [bug#63088] [PATCH 1/3] gnu: Add lc0.
  2023-04-26 13:13 [bug#63088] [PATCH 0/3] Add Lc0 zamfofex
                   ` (4 preceding siblings ...)
  2023-09-07 10:23 ` [bug#63088] [PATCH v2] gnu: " iyzsong--- via Guix-patches via
@ 2023-09-12 11:58 ` zamfofex
  2023-09-12 11:58   ` [bug#63088] [PATCH 2/3] gnu: Add neural networks for Leela Chess Zero zamfofex
  2023-09-12 11:58   ` [bug#63088] [PATCH 3/3] gnu: Add neural networks from the Maia Chess project zamfofex
  2023-09-13  1:49 ` [bug#63088] [PATCH 1/3] gnu: Add lc0 zamfofex
  6 siblings, 2 replies; 22+ messages in thread
From: zamfofex @ 2023-09-12 11:58 UTC (permalink / raw)
  To: 63088; +Cc: zamfofex, iyzsong, liliana.prikler, iyzsong

* gnu/packages/lc0.scm: New file.
* gnu/packages/local.mk: Register file.
---
 gnu/local.mk         |  2 ++
 gnu/packages/lc0.scm | 71 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 73 insertions(+)
 create mode 100644 gnu/packages/lc0.scm

diff --git a/gnu/local.mk b/gnu/local.mk
index 4f8637418a..f46a2973ae 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -59,6 +59,7 @@
 # Copyright © 2023 Zheng Junjie <873216071@qq.com>
 # Copyright © 2023 Ivana Drazovic <iv.dra@hotmail.com>
 # Copyright © 2023 Andy Tai <atai@atai.org>
+# Copyright © 2023 zamfofex <zamfofex@twdb.moe>
 #
 # This file is part of GNU Guix.
 #
@@ -375,6 +376,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/packages/kerberos.scm			\
   %D%/packages/kodi.scm				\
   %D%/packages/language.scm			\
+  %D%/packages/lc0.scm				\
   %D%/packages/lean.scm				\
   %D%/packages/lego.scm				\
   %D%/packages/less.scm				\
diff --git a/gnu/packages/lc0.scm b/gnu/packages/lc0.scm
new file mode 100644
index 0000000000..e19436c381
--- /dev/null
+++ b/gnu/packages/lc0.scm
@@ -0,0 +1,71 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2023 zamfofex <zamfofex@twdb.moe>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages lc0)
+  #:use-module (guix build-system meson)
+  #:use-module (guix gexp)
+  #:use-module (guix git-download)
+  #:use-module (guix packages)
+  #:use-module ((guix licenses)
+                #:prefix license:)
+  #:use-module (gnu packages)
+  #:use-module (gnu packages algebra)
+  #:use-module (gnu packages c)
+  #:use-module (gnu packages check)
+  #:use-module (gnu packages compression)
+  #:use-module (gnu packages machine-learning)
+  #:use-module (gnu packages pkg-config)
+  #:use-module (gnu packages python))
+
+(define-public lc0
+  (package
+    (name "lc0")
+    (version "0.30.0")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/LeelaChessZero/lc0")
+                    (commit (string-append "v" version))
+                    ;; Only a few source files are in one Git submodules (rather than
+                    ;; there being bundled projects).  These files are in a different
+                    ;; repository just because they are used across multiple
+                    ;; repositories of the Leela Chess Zero project.
+                    (recursive? #t)))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "1m7k8m8iz4pxv3h9g2j1dkgryi4k9c1bcg3fx5j7ii4ysif63kj3"))))
+    (build-system meson-build-system)
+    (native-search-paths
+     (list (search-path-specification
+            (variable "XDG_DATA_DIRS")
+            (files '("share")))))
+    (inputs (list eigen oneapi-dnnl zlib))
+    (native-inputs (list googletest ispc pkg-config python))
+    (arguments
+     '(#:configure-flags (list "-Ddnnl=true"
+                               (string-append "-Ddnnl_dir="
+                                              (assoc-ref %build-inputs
+                                                         "oneapi-dnnl")))))
+    (synopsis "Chess engine based on neural networks")
+    (description
+     "Leela Chess Zero is a UCI-compliant chess engine designed to play chess
+using neural networks.  This package does not provide a neural network, which
+is necessary to use Leela Chess Zero and should be installed separately.")
+    (home-page "https://lczero.org")
+    (license license:gpl3+)))

base-commit: daeeaa221605726d8853b00261619ba039bd6db7
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [bug#63088] [PATCH 2/3] gnu: Add neural networks for Leela Chess Zero.
  2023-09-12 11:58 ` [bug#63088] [PATCH 1/3] gnu: Add lc0 zamfofex
@ 2023-09-12 11:58   ` zamfofex
  2023-09-12 17:07     ` Liliana Marie Prikler
  2023-09-12 11:58   ` [bug#63088] [PATCH 3/3] gnu: Add neural networks from the Maia Chess project zamfofex
  1 sibling, 1 reply; 22+ messages in thread
From: zamfofex @ 2023-09-12 11:58 UTC (permalink / raw)
  To: 63088; +Cc: zamfofex, iyzsong, liliana.prikler, iyzsong

* gnu/packages/lc0.scm (make-lc0-nn): New procedure.
* gnu/packages/lc0.scm (lc0-t2, lc0-t1, lc0-t1-512, lc0-t1-256)
(lc0-611246, lc0-791556, lc0-815383): New variables.
---
 gnu/packages/lc0.scm | 76 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)

diff --git a/gnu/packages/lc0.scm b/gnu/packages/lc0.scm
index e19436c381..1cda2efd1c 100644
--- a/gnu/packages/lc0.scm
+++ b/gnu/packages/lc0.scm
@@ -17,7 +17,10 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu packages lc0)
+  #:use-module (guix build utils)
   #:use-module (guix build-system meson)
+  #:use-module (guix build-system trivial)
+  #:use-module (guix download)
   #:use-module (guix gexp)
   #:use-module (guix git-download)
   #:use-module (guix packages)
@@ -69,3 +72,76 @@ (define-public lc0
 is necessary to use Leela Chess Zero and should be installed separately.")
     (home-page "https://lczero.org")
     (license license:gpl3+)))
+
+(define (make-lc0-nn name file-name url hash description)
+  (package
+    (name (string-append "lc0-" name))
+    (version "0")
+    (source (origin
+              (method url-fetch)
+              (uri url)
+              (file-name (string-append "lc0-" file-name))
+              (sha256
+               (base32
+                hash))))
+    (build-system trivial-build-system)
+    (arguments
+     (list #:builder (with-imported-modules '((guix build utils))
+                                            #~(let ((share (string-append (assoc-ref
+                                                                           %outputs
+                                                                           "out")
+                                                            "/share/lc0/")))
+                                                (use-modules (guix build utils))
+                                                (mkdir-p share)
+                                                (copy-file (assoc-ref
+                                                            %build-inputs
+                                                            "source")
+                                                           (string-append
+                                                            share
+                                                            #$file-name))))))
+    (synopsis "Pretrained neural network for Leela Chess Zero")
+    (description description)
+    (home-page "https://lczero.org")
+    (license license:gpl3+)))
+
+(define-public lc0-t2
+  (make-lc0-nn "t2" "t2-768.pb.gz"
+   "https://storage.lczero.org/files/networks-contrib/t2-768x15x24h-swa-5230000.pb.gz"
+   "126305hby24k5agxiixadp1lcgmv8drm1dkpb4jf5jzq7k4m855w"
+   "T2 is currently one of the best neural network for Leela Chess Zero, superceeding the neural network T1."))
+
+(define-public lc0-t1
+  (make-lc0-nn "t1" "t1-768.pb.gz"
+   "https://storage.lczero.org/files/networks-contrib/t1-768x15x24h-swa-4000000.pb.gz"
+   "0zm9v91gfnm69n4x2fckair24fypjrwiip3j86ylsqncsi1sh5nq"
+   "T1 is currently one of the best neural network for Leela Chess Zero, however it was superceeded by the neural network T2."))
+
+(define-public lc0-t1-512
+  (make-lc0-nn "t1-512" "t1-512.pb.gz"
+   "https://storage.lczero.org/files/networks-contrib/t1-512x15x8h-distilled-swa-3395000.pb.gz"
+   "1s4pq06qkdpaq0a4z6j5qqnf6h7njpmwh7i0v7qh6bmhwlcibnqz"
+   "This is a smaller version of the T1 neural network, which is currently one of the best neural network for Leela Chess Zero."))
+
+(define-public lc0-t1-256
+  (make-lc0-nn "t1-256" "t1-256.pb.gz"
+   "https://storage.lczero.org/files/networks-contrib/t1-256x10-distilled-swa-2432500.pb.gz"
+   "01ilar7y2nf3kfkq3x77n4jxlvqdpgddjsham2wz4dmdx35ac9xw"
+   "This is a smaller version of the T1 neural network, which is currently one of the best neural network for Leela Chess Zero."))
+
+(define-public lc0-611246
+  (make-lc0-nn "611246" "611246.pb.gz"
+   "https://storage.lczero.org/files/networks/7ca2381cfeac5c280f304e7027ffbea1b7d87474672e5d6fb16d5cd881640e04"
+   "0rapfvjqqrhydhp8a6r3skmjci2dc2yxz912bglv9yd9k00l9rww"
+   "This is an official neural network of a “main run” of the Leela Chess Zero project that was finished being trained in January of 2022."))
+
+(define-public lc0-791556
+  (make-lc0-nn "791556" "791556.pb.gz"
+   "https://storage.lczero.org/files/networks/f404e156ceb2882470fd8c032b8754af0fa0b71168328912eaef14671a256e34"
+   "03b9xl9vkiihdilz5dzcpg6g4inb6n4k5gs911i3gbd8h9sh9ixi"
+   "This is an official neural network of the Leela Chess Zero project that was finished being trained in April of 2022."))
+
+(define-public lc0-815383
+  (make-lc0-nn "815383" "815383.pb.gz"
+   "https://storage.lczero.org/files/networks/8af6098d6fb76e2bef6ef9ee87e61fadcb99f0b789013a72953a95ad10a9e933"
+   "09gm8lgaick60rn4x9h9w5sxdqivr4ign73viviadw1gj7wsbnsg"
+   "This is an official neural network of a “main run” of the Leela Chess Zero project.  The network was finished being trained in September of 2023."))
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [bug#63088] [PATCH 3/3] gnu: Add neural networks from the Maia Chess project.
  2023-09-12 11:58 ` [bug#63088] [PATCH 1/3] gnu: Add lc0 zamfofex
  2023-09-12 11:58   ` [bug#63088] [PATCH 2/3] gnu: Add neural networks for Leela Chess Zero zamfofex
@ 2023-09-12 11:58   ` zamfofex
  1 sibling, 0 replies; 22+ messages in thread
From: zamfofex @ 2023-09-12 11:58 UTC (permalink / raw)
  To: 63088; +Cc: zamfofex, iyzsong, liliana.prikler, iyzsong

* gnu/packages/lc0.scm (make-lc0-maia): New procedure.
* gnu/packages/lc0.scm (lc0-maia-1100, lc0-maia-1200, lc0-maia-1300)
(lc0-maia-1400, lc0-maia-1500, lc0-maia-1600, lc0-maia-1700)
(lc0-maia-1800, lc0-maia-1900): New variables.
---
 gnu/packages/lc0.scm | 55 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/gnu/packages/lc0.scm b/gnu/packages/lc0.scm
index 1cda2efd1c..495d93b110 100644
--- a/gnu/packages/lc0.scm
+++ b/gnu/packages/lc0.scm
@@ -18,6 +18,7 @@
 
 (define-module (gnu packages lc0)
   #:use-module (guix build utils)
+  #:use-module (guix build-system copy)
   #:use-module (guix build-system meson)
   #:use-module (guix build-system trivial)
   #:use-module (guix download)
@@ -145,3 +146,57 @@ (define-public lc0-815383
    "https://storage.lczero.org/files/networks/8af6098d6fb76e2bef6ef9ee87e61fadcb99f0b789013a72953a95ad10a9e933"
    "09gm8lgaick60rn4x9h9w5sxdqivr4ign73viviadw1gj7wsbnsg"
    "This is an official neural network of a “main run” of the Leela Chess Zero project.  The network was finished being trained in September of 2023."))
+
+(define (make-lc0-maia rating)
+  (package
+    (name (string-append "lc0-maia-" rating))
+    (version "1.0")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/CSSLab/maia-chess")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name "maia" version))
+              (sha256
+               (base32
+                "0qjkp56pb5vvkr3j1vdsdzligvy7faza917z7vdfmf168pkvrxsr"))))
+    (build-system copy-build-system)
+    (arguments
+     `(#:install-plan '((,(string-append "model_files/" rating "/final_"
+                                         rating "-40.pb.gz") ,(string-append
+                                                               "share/lc0/maia-"
+                                                               rating ".pb.gz")))))
+    (synopsis "Human-like neural network for Leela Chess Zero")
+    (description
+     "Maia’s goal is to play the human move — not necessarily the best move.
+As a result, Maia has a more human-like style than previous engines, matching
+moves played by human players in online games over 50% of the time.")
+    (home-page "https://maiachess.com")
+    (license license:gpl3)))
+
+(define-public lc0-maia-1100
+  (make-lc0-maia "1100"))
+
+(define-public lc0-maia-1200
+  (make-lc0-maia "1200"))
+
+(define-public lc0-maia-1300
+  (make-lc0-maia "1300"))
+
+(define-public lc0-maia-1400
+  (make-lc0-maia "1400"))
+
+(define-public lc0-maia-1500
+  (make-lc0-maia "1500"))
+
+(define-public lc0-maia-1600
+  (make-lc0-maia "1600"))
+
+(define-public lc0-maia-1700
+  (make-lc0-maia "1700"))
+
+(define-public lc0-maia-1800
+  (make-lc0-maia "1800"))
+
+(define-public lc0-maia-1900
+  (make-lc0-maia "1900"))
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [bug#63088] [PATCH 2/3] gnu: Add neural networks for Leela Chess Zero.
  2023-09-12 11:58   ` [bug#63088] [PATCH 2/3] gnu: Add neural networks for Leela Chess Zero zamfofex
@ 2023-09-12 17:07     ` Liliana Marie Prikler
  0 siblings, 0 replies; 22+ messages in thread
From: Liliana Marie Prikler @ 2023-09-12 17:07 UTC (permalink / raw)
  To: zamfofex, 63088; +Cc: iyzsong, iyzsong

Am Dienstag, dem 12.09.2023 um 08:58 -0300 schrieb zamfofex:
> * gnu/packages/lc0.scm (make-lc0-nn): New procedure.
> * gnu/packages/lc0.scm (lc0-t2, lc0-t1, lc0-t1-512, lc0-t1-256)
> (lc0-611246, lc0-791556, lc0-815383): New variables.
> ---
>  gnu/packages/lc0.scm | 76
> ++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 76 insertions(+)
> 
> diff --git a/gnu/packages/lc0.scm b/gnu/packages/lc0.scm
> index e19436c381..1cda2efd1c 100644
> --- a/gnu/packages/lc0.scm
> +++ b/gnu/packages/lc0.scm
> @@ -17,7 +17,10 @@
>  ;;; along with GNU Guix.  If not, see
> <http://www.gnu.org/licenses/>.
>  
>  (define-module (gnu packages lc0)
> +  #:use-module (guix build utils)
>    #:use-module (guix build-system meson)
> +  #:use-module (guix build-system trivial)
> +  #:use-module (guix download)
>    #:use-module (guix gexp)
>    #:use-module (guix git-download)
>    #:use-module (guix packages)
> @@ -69,3 +72,76 @@ (define-public lc0
>  is necessary to use Leela Chess Zero and should be installed
> separately.")
>      (home-page "https://lczero.org")
>      (license license:gpl3+)))
> +
> +(define (make-lc0-nn name file-name url hash description)
> +  (package
> +    (name (string-append "lc0-" name))
> +    (version "0")
> +    (source (origin
> +              (method url-fetch)
> +              (uri url)
> +              (file-name (string-append "lc0-" file-name))
> +              (sha256
> +               (base32
> +                hash))))
> +    (build-system trivial-build-system)
> +    (arguments
> +     (list #:builder (with-imported-modules '((guix build utils))
> +                                            #~(let ((share (string-
> append (assoc-ref
> +                                                                    
>        %outputs
> +                                                                    
>        "out")
> +                                                           
> "/share/lc0/")))
> +                                                (use-modules (guix
> build utils))
> +                                                (mkdir-p share)
> +                                                (copy-file (assoc-
> ref
> +                                                            %build-
> inputs
> +                                                           
> "source")
> +                                                           (string-
> append
> +                                                            share
> +                                                            #$file-
> name))))))
> +    (synopsis "Pretrained neural network for Leela Chess Zero")
> +    (description description)
> +    (home-page "https://lczero.org")
> +    (license license:gpl3+)))
> +
> +(define-public lc0-t2
> +  (make-lc0-nn "t2" "t2-768.pb.gz"
> +  
> "https://storage.lczero.org/files/networks-contrib/t2-768x15x24h-swa-
> 5230000.pb.gz"
You might want to search for ways to shorten these urls.  E.g. Define a
procedure (lc0-network "short-name")
> +   "126305hby24k5agxiixadp1lcgmv8drm1dkpb4jf5jzq7k4m855w"
> +   "T2 is currently one of the best neural network for Leela Chess
> Zero, superceeding the neural network T1."))
> +
> +(define-public lc0-t1
> +  (make-lc0-nn "t1" "t1-768.pb.gz"
> +  
> "https://storage.lczero.org/files/networks-contrib/t1-768x15x24h-swa-
> 4000000.pb.gz"
> +   "0zm9v91gfnm69n4x2fckair24fypjrwiip3j86ylsqncsi1sh5nq"
> +   "T1 is currently one of the best neural network for Leela Chess
> Zero, however it was superceeded by the neural network T2."))
> +
> +(define-public lc0-t1-512
> +  (make-lc0-nn "t1-512" "t1-512.pb.gz"
> +  
> "https://storage.lczero.org/files/networks-contrib/t1-512x15x8h-disti
> lled-swa-3395000.pb.gz"
> +   "1s4pq06qkdpaq0a4z6j5qqnf6h7njpmwh7i0v7qh6bmhwlcibnqz"
> +   "This is a smaller version of the T1 neural network, which is
> currently one of the best neural network for Leela Chess Zero."))
> +
> +(define-public lc0-t1-256
> +  (make-lc0-nn "t1-256" "t1-256.pb.gz"
> +  
> "https://storage.lczero.org/files/networks-contrib/t1-256x10-distille
> d-swa-2432500.pb.gz"
> +   "01ilar7y2nf3kfkq3x77n4jxlvqdpgddjsham2wz4dmdx35ac9xw"
> +   "This is a smaller version of the T1 neural network, which is
> currently one of the best neural network for Leela Chess Zero."))
> +
> +(define-public lc0-611246
> +  (make-lc0-nn "611246" "611246.pb.gz"
> +  
> "https://storage.lczero.org/files/networks/7ca2381cfeac5c280f304e7027
> ffbea1b7d87474672e5d6fb16d5cd881640e04"
> +   "0rapfvjqqrhydhp8a6r3skmjci2dc2yxz912bglv9yd9k00l9rww"
> +   "This is an official neural network of a “main run” of the Leela
> Chess Zero project that was finished being trained in January of
> 2022."))
> +
> +(define-public lc0-791556
> +  (make-lc0-nn "791556" "791556.pb.gz"
> +  
> "https://storage.lczero.org/files/networks/f404e156ceb2882470fd8c032b
> 8754af0fa0b71168328912eaef14671a256e34"
> +   "03b9xl9vkiihdilz5dzcpg6g4inb6n4k5gs911i3gbd8h9sh9ixi"
> +   "This is an official neural network of the Leela Chess Zero
> project that was finished being trained in April of 2022."))
> +
> +(define-public lc0-815383
> +  (make-lc0-nn "815383" "815383.pb.gz"
> +  
> "https://storage.lczero.org/files/networks/8af6098d6fb76e2bef6ef9ee87
> e61fadcb99f0b789013a72953a95ad10a9e933"
> +   "09gm8lgaick60rn4x9h9w5sxdqivr4ign73viviadw1gj7wsbnsg"
> +   "This is an official neural network of a “main run” of the Leela
> Chess Zero project.  The network was finished being trained in
> September of 2023."))

Cheers

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [bug#63088] [PATCH 1/3] gnu: Add lc0.
  2023-04-26 13:13 [bug#63088] [PATCH 0/3] Add Lc0 zamfofex
                   ` (5 preceding siblings ...)
  2023-09-12 11:58 ` [bug#63088] [PATCH 1/3] gnu: Add lc0 zamfofex
@ 2023-09-13  1:49 ` zamfofex
  2023-09-13  1:49   ` [bug#63088] [PATCH 2/3] gnu: Add neural networks for Leela Chess Zero zamfofex
  2023-09-13  1:49   ` [bug#63088] [PATCH 3/3] gnu: Add neural networks from the Maia Chess project zamfofex
  6 siblings, 2 replies; 22+ messages in thread
From: zamfofex @ 2023-09-13  1:49 UTC (permalink / raw)
  To: 63088; +Cc: zamfofex, liliana.prikler

* gnu/packages/lc0.scm: New file.
* gnu/packages/local.mk: Register file.
---
 gnu/local.mk         |  2 ++
 gnu/packages/lc0.scm | 71 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 73 insertions(+)
 create mode 100644 gnu/packages/lc0.scm

diff --git a/gnu/local.mk b/gnu/local.mk
index 4f8637418a..f46a2973ae 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -59,6 +59,7 @@
 # Copyright © 2023 Zheng Junjie <873216071@qq.com>
 # Copyright © 2023 Ivana Drazovic <iv.dra@hotmail.com>
 # Copyright © 2023 Andy Tai <atai@atai.org>
+# Copyright © 2023 zamfofex <zamfofex@twdb.moe>
 #
 # This file is part of GNU Guix.
 #
@@ -375,6 +376,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/packages/kerberos.scm			\
   %D%/packages/kodi.scm				\
   %D%/packages/language.scm			\
+  %D%/packages/lc0.scm				\
   %D%/packages/lean.scm				\
   %D%/packages/lego.scm				\
   %D%/packages/less.scm				\
diff --git a/gnu/packages/lc0.scm b/gnu/packages/lc0.scm
new file mode 100644
index 0000000000..e19436c381
--- /dev/null
+++ b/gnu/packages/lc0.scm
@@ -0,0 +1,71 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2023 zamfofex <zamfofex@twdb.moe>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages lc0)
+  #:use-module (guix build-system meson)
+  #:use-module (guix gexp)
+  #:use-module (guix git-download)
+  #:use-module (guix packages)
+  #:use-module ((guix licenses)
+                #:prefix license:)
+  #:use-module (gnu packages)
+  #:use-module (gnu packages algebra)
+  #:use-module (gnu packages c)
+  #:use-module (gnu packages check)
+  #:use-module (gnu packages compression)
+  #:use-module (gnu packages machine-learning)
+  #:use-module (gnu packages pkg-config)
+  #:use-module (gnu packages python))
+
+(define-public lc0
+  (package
+    (name "lc0")
+    (version "0.30.0")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/LeelaChessZero/lc0")
+                    (commit (string-append "v" version))
+                    ;; Only a few source files are in one Git submodules (rather than
+                    ;; there being bundled projects).  These files are in a different
+                    ;; repository just because they are used across multiple
+                    ;; repositories of the Leela Chess Zero project.
+                    (recursive? #t)))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "1m7k8m8iz4pxv3h9g2j1dkgryi4k9c1bcg3fx5j7ii4ysif63kj3"))))
+    (build-system meson-build-system)
+    (native-search-paths
+     (list (search-path-specification
+            (variable "XDG_DATA_DIRS")
+            (files '("share")))))
+    (inputs (list eigen oneapi-dnnl zlib))
+    (native-inputs (list googletest ispc pkg-config python))
+    (arguments
+     '(#:configure-flags (list "-Ddnnl=true"
+                               (string-append "-Ddnnl_dir="
+                                              (assoc-ref %build-inputs
+                                                         "oneapi-dnnl")))))
+    (synopsis "Chess engine based on neural networks")
+    (description
+     "Leela Chess Zero is a UCI-compliant chess engine designed to play chess
+using neural networks.  This package does not provide a neural network, which
+is necessary to use Leela Chess Zero and should be installed separately.")
+    (home-page "https://lczero.org")
+    (license license:gpl3+)))

base-commit: daeeaa221605726d8853b00261619ba039bd6db7
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [bug#63088] [PATCH 2/3] gnu: Add neural networks for Leela Chess Zero.
  2023-09-13  1:49 ` [bug#63088] [PATCH 1/3] gnu: Add lc0 zamfofex
@ 2023-09-13  1:49   ` zamfofex
  2023-09-13  1:49   ` [bug#63088] [PATCH 3/3] gnu: Add neural networks from the Maia Chess project zamfofex
  1 sibling, 0 replies; 22+ messages in thread
From: zamfofex @ 2023-09-13  1:49 UTC (permalink / raw)
  To: 63088; +Cc: zamfofex, liliana.prikler

* gnu/packages/lc0.scm (make-lc0-net, make-lc0-official-net)
(make-lc0-contrib-net): New procedures.
* gnu/packages/lc0.scm (lc0-t2, lc0-t1, lc0-t1-512, lc0-t1-256)
(lc0-611246, lc0-791556, lc0-815383): New variables.
---
 gnu/packages/lc0.scm | 84 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 84 insertions(+)

diff --git a/gnu/packages/lc0.scm b/gnu/packages/lc0.scm
index e19436c381..f49d71538e 100644
--- a/gnu/packages/lc0.scm
+++ b/gnu/packages/lc0.scm
@@ -17,7 +17,10 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu packages lc0)
+  #:use-module (guix build utils)
   #:use-module (guix build-system meson)
+  #:use-module (guix build-system trivial)
+  #:use-module (guix download)
   #:use-module (guix gexp)
   #:use-module (guix git-download)
   #:use-module (guix packages)
@@ -69,3 +72,84 @@ (define-public lc0
 is necessary to use Leela Chess Zero and should be installed separately.")
     (home-page "https://lczero.org")
     (license license:gpl3+)))
+
+(define (make-lc0-net name file-name url hash description)
+  (package
+    (name (string-append "lc0-" name))
+    (version "0")
+    (source (origin
+              (method url-fetch)
+              (uri url)
+              (file-name (string-append "lc0-" file-name))
+              (sha256
+               (base32
+                hash))))
+    (build-system trivial-build-system)
+    (arguments
+     (list #:builder (with-imported-modules '((guix build utils))
+                                            #~(let ((share (string-append (assoc-ref
+                                                                           %outputs
+                                                                           "out")
+                                                            "/share/lc0/")))
+                                                (use-modules (guix build utils))
+                                                (mkdir-p share)
+                                                (copy-file (assoc-ref
+                                                            %build-inputs
+                                                            "source")
+                                                           (string-append
+                                                            share
+                                                            #$file-name))))))
+    (synopsis "Pretrained neural network for Leela Chess Zero")
+    (description description)
+    (home-page "https://lczero.org")
+    (license license:gpl3+)))
+
+(define-public (make-lc0-official-net name url-hash hash description)
+  (make-lc0-net name
+                (string-append name ".pb.gz")
+                (string-append "https://storage.lczero.org/files/networks/"
+                               url-hash) hash description))
+
+(define-public (make-lc0-contrib-net name file-name hash description)
+  (make-lc0-net name file-name
+                (string-append
+                 "https://storage.lczero.org/files/networks-contrib/"
+                 file-name) hash description))
+
+(define-public lc0-t2
+  (make-lc0-contrib-net "t2" "t2-768x15x24h-swa-5230000.pb.gz"
+   "126305hby24k5agxiixadp1lcgmv8drm1dkpb4jf5jzq7k4m855w"
+   "T2 is currently one of the best neural networks for Leela Chess Zero, superceeding the neural network T1."))
+
+(define-public lc0-t1
+  (make-lc0-contrib-net "t1" "t1-768x15x24h-swa-4000000.pb.gz"
+   "0zm9v91gfnm69n4x2fckair24fypjrwiip3j86ylsqncsi1sh5nq"
+   "T1 is currently one of the best neural networks for Leela Chess Zero, however, it was superceeded by the neural network T2."))
+
+(define-public lc0-t1-512
+  (make-lc0-contrib-net "t1-512" "t1-512x15x8h-distilled-swa-3395000.pb.gz"
+   "1s4pq06qkdpaq0a4z6j5qqnf6h7njpmwh7i0v7qh6bmhwlcibnqz"
+   "This is a smaller version of the T1 neural network, which is currently one of the best neural networks for Leela Chess Zero."))
+
+(define-public lc0-t1-256
+  (make-lc0-contrib-net "t1-256" "t1-256x10-distilled-swa-2432500.pb.gz"
+   "01ilar7y2nf3kfkq3x77n4jxlvqdpgddjsham2wz4dmdx35ac9xw"
+   "This is a smaller version of the T1 neural network, which is currently one of the best neural networks for Leela Chess Zero."))
+
+(define-public lc0-611246
+  (make-lc0-official-net "611246"
+   "7ca2381cfeac5c280f304e7027ffbea1b7d87474672e5d6fb16d5cd881640e04"
+   "0rapfvjqqrhydhp8a6r3skmjci2dc2yxz912bglv9yd9k00l9rww"
+   "This is an official neural network of a “main run” of the Leela Chess Zero project that was finished being trained in January of 2022."))
+
+(define-public lc0-791556
+  (make-lc0-official-net "791556"
+   "f404e156ceb2882470fd8c032b8754af0fa0b71168328912eaef14671a256e34"
+   "03b9xl9vkiihdilz5dzcpg6g4inb6n4k5gs911i3gbd8h9sh9ixi"
+   "This is an official neural network of the Leela Chess Zero project that was finished being trained in April of 2022."))
+
+(define-public lc0-815383
+  (make-lc0-official-net "815383"
+   "8af6098d6fb76e2bef6ef9ee87e61fadcb99f0b789013a72953a95ad10a9e933"
+   "09gm8lgaick60rn4x9h9w5sxdqivr4ign73viviadw1gj7wsbnsg"
+   "This is an official neural network of a “main run” of the Leela Chess Zero project.  The network was finished being trained in September of 2023."))
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [bug#63088] [PATCH 3/3] gnu: Add neural networks from the Maia Chess project.
  2023-09-13  1:49 ` [bug#63088] [PATCH 1/3] gnu: Add lc0 zamfofex
  2023-09-13  1:49   ` [bug#63088] [PATCH 2/3] gnu: Add neural networks for Leela Chess Zero zamfofex
@ 2023-09-13  1:49   ` zamfofex
  1 sibling, 0 replies; 22+ messages in thread
From: zamfofex @ 2023-09-13  1:49 UTC (permalink / raw)
  To: 63088; +Cc: zamfofex, liliana.prikler

* gnu/packages/lc0.scm (make-lc0-maia): New procedure.
* gnu/packages/lc0.scm (lc0-maia-1100, lc0-maia-1200, lc0-maia-1300)
(lc0-maia-1400, lc0-maia-1500, lc0-maia-1600, lc0-maia-1700)
(lc0-maia-1800, lc0-maia-1900): New variables.
---
 gnu/packages/lc0.scm | 55 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/gnu/packages/lc0.scm b/gnu/packages/lc0.scm
index f49d71538e..abbac73ce7 100644
--- a/gnu/packages/lc0.scm
+++ b/gnu/packages/lc0.scm
@@ -18,6 +18,7 @@
 
 (define-module (gnu packages lc0)
   #:use-module (guix build utils)
+  #:use-module (guix build-system copy)
   #:use-module (guix build-system meson)
   #:use-module (guix build-system trivial)
   #:use-module (guix download)
@@ -153,3 +154,57 @@ (define-public lc0-815383
    "8af6098d6fb76e2bef6ef9ee87e61fadcb99f0b789013a72953a95ad10a9e933"
    "09gm8lgaick60rn4x9h9w5sxdqivr4ign73viviadw1gj7wsbnsg"
    "This is an official neural network of a “main run” of the Leela Chess Zero project.  The network was finished being trained in September of 2023."))
+
+(define (make-lc0-maia rating)
+  (package
+    (name (string-append "lc0-maia-" rating))
+    (version "1.0")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/CSSLab/maia-chess")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name "maia" version))
+              (sha256
+               (base32
+                "0qjkp56pb5vvkr3j1vdsdzligvy7faza917z7vdfmf168pkvrxsr"))))
+    (build-system copy-build-system)
+    (arguments
+     `(#:install-plan '((,(string-append "model_files/" rating "/final_"
+                                         rating "-40.pb.gz") ,(string-append
+                                                               "share/lc0/maia-"
+                                                               rating ".pb.gz")))))
+    (synopsis "Human-like neural network for Leela Chess Zero")
+    (description
+     "Maia’s goal is to play the human move — not necessarily the best move.
+As a result, Maia has a more human-like style than previous engines, matching
+moves played by human players in online games over 50% of the time.")
+    (home-page "https://maiachess.com")
+    (license license:gpl3)))
+
+(define-public lc0-maia-1100
+  (make-lc0-maia "1100"))
+
+(define-public lc0-maia-1200
+  (make-lc0-maia "1200"))
+
+(define-public lc0-maia-1300
+  (make-lc0-maia "1300"))
+
+(define-public lc0-maia-1400
+  (make-lc0-maia "1400"))
+
+(define-public lc0-maia-1500
+  (make-lc0-maia "1500"))
+
+(define-public lc0-maia-1600
+  (make-lc0-maia "1600"))
+
+(define-public lc0-maia-1700
+  (make-lc0-maia "1700"))
+
+(define-public lc0-maia-1800
+  (make-lc0-maia "1800"))
+
+(define-public lc0-maia-1900
+  (make-lc0-maia "1900"))
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2023-09-13  1:51 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-26 13:13 [bug#63088] [PATCH 0/3] Add Lc0 zamfofex
2023-04-26 13:17 ` [bug#63088] [PATCH 1/3] gnu: Add ISPC. * gnu/packages/c.scm (ispc): New variable zamfofex
2023-04-26 13:17 ` [bug#63088] [PATCH 2/3] gnu: Add oneDNN. * gnu/packages/machine-learning.scm (oneapi-dnnl): " zamfofex
2023-04-26 13:17 ` [bug#63088] [PATCH 3/3] gnu: Add Lc0. * gnu/packages/games.scm (lc0): " zamfofex
2023-05-11 14:29   ` [bug#63088] [PATCH 0/3] Add Lc0 宋文武 via Guix-patches via
2023-05-11 21:25     ` zamfofex
2023-05-16 12:16       ` Simon Tournier
2023-07-27 23:34 ` [bug#63088] [PATCH] " zamfofex
2023-07-28  0:24   ` zamfofex
2023-07-28  4:23   ` Liliana Marie Prikler
2023-07-28 18:14     ` zamfofex
2023-09-07 10:23 ` [bug#63088] [PATCH v2] gnu: " iyzsong--- via Guix-patches via
2023-09-07 17:03   ` Liliana Marie Prikler
2023-09-11 10:22     ` zamfofex
2023-09-11 18:00       ` Liliana Marie Prikler
2023-09-12 11:58 ` [bug#63088] [PATCH 1/3] gnu: Add lc0 zamfofex
2023-09-12 11:58   ` [bug#63088] [PATCH 2/3] gnu: Add neural networks for Leela Chess Zero zamfofex
2023-09-12 17:07     ` Liliana Marie Prikler
2023-09-12 11:58   ` [bug#63088] [PATCH 3/3] gnu: Add neural networks from the Maia Chess project zamfofex
2023-09-13  1:49 ` [bug#63088] [PATCH 1/3] gnu: Add lc0 zamfofex
2023-09-13  1:49   ` [bug#63088] [PATCH 2/3] gnu: Add neural networks for Leela Chess Zero zamfofex
2023-09-13  1:49   ` [bug#63088] [PATCH 3/3] gnu: Add neural networks from the Maia Chess project zamfofex

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.