Code Monkey home page Code Monkey logo

sayuri's Introduction


Sayuri Art

Sayuri

Let's ROCK!

Sayuri is a GTP-compliant go engine based on Deep Convolutional Neural Network and Monte Carlo Tree Search. She is strongly inspired by Leela Zero and KataGo. The board data structure, search algorithm and network format are borrowed from Leela Zero in the beginning. Current version follows the KataGo research, the engine supports variable komi and board size now. Some methods you may see my HackMD articles (in chinese).

Requirements

  • Ubuntu, MacOS or Windows
  • GCC, Clang, must support C++14 or higher
  • CMake 3.15 or higher
  • Optional: Eigen or OpenBLAS library
  • Optional: CUDA 10.x - 12.x library
  • Optional: cuDNN 7.x or 8.x library
  • Optional: zlib library

Default Compiling (Ubuntu or MacOS)

$ git clone https://github.com/CGLemon/Sayuri
$ cd Sayuri
$ git submodule update --init --recursive
$ mkdir build && cd build
$ cmake ..
$ make -j

Cmake Option

Accelerate the network forwarding pipe by CPU. OpenBLAS or Eigen are required. OpenBLAS and Eigen are significantly faster than built-in blas. OpenBLAS is recommended on MacOS.

$ cmake .. -DBLAS_BACKEND=OPENBLAS

or

$ cmake .. -DBLAS_BACKEND=EIGEN

Accelerate the network forwarding pipe by GPUs. CUDA is required. It should be as faster as cuDNN backend.

$ cmake .. -DBLAS_BACKEND=CUDA

Accelerate the network forwarding pipe by GPUs. CUDA and cuDNN are both required. This backend is much steady than CUDA-only backend.

$ cmake .. -DBLAS_BACKEND=CUDNN

Compile a bigger board size version. Set it as 0 to disable this option.

$ cmake .. -DBOARD_SIZE=25

Disable the FP16 CUDA code if your CUDA version doesn't support for it.

$ cmake .. -DDISABLE_FP16=1

Compress the training data file. It can save many memory usage in the self-play process.

$ cmake .. -DUSE_ZLIB=1

Windows Version (Experiment)

  1. Download the Visual Studio.

  2. Download the MinGW from here.

  3. Clone the github repo and compile it.

     $ git clone https://github.com/CGLemon/Sayuri
     $ cd Sayuri
     $ git submodule update --init --recursive
     $ cd src
     $ g++ -std=c++14 -ffast-math -I . -lpthread *.cc utils/*.cc summary/*.cc game/*.cc mcts/*.cc neural/*.cc neural/blas/*.cc neural/cuda/*.cc pattern/*.cc selfplay/*.cc -o Sayuri -O3 -DNDEBUG -DWIN32 -I ../third_party/Eigen -DUSE_BLAS -DUSE_EIGEN
    

Weights and Others.

Download the last v0.6 weights here and see the current RL progression here. If you want to use the old network, please use the v0.5 engine.

Engine Arguments

Here are some useful arguments which you may need.

Arguments Type Description
--weights, -w string File with network weights.
--patterns string File with patterns.
--book string File with opening book.
--playouts, -p int The number of maximum playouts.
--const-time int Const time of search in seconds.
--threads, -t int The number of threads used.
--batch-size, -b int The number of batches for a single evaluation.
--gpu, -g int Select a specific GPU device.
--resign-threshold, -r float Resign when winrate is less than x.
--analysis-verbose, -a None Output more search diagnostic verbose.
--quiet, -q None Disable all diagnostic verbose.
--ponder None Thinking on opponent's time.
--friendly-pass None Play pass move if the engine won the game.
--reuse-tree None Will reuse the sub-tree.
--help, -h None Show the more arguments.

Default setting: will select reasonable threads and batch size, 10 seconds per move, all GPU devices

$ ./Sayuri -w <weights file>

Example setting 1: 4 threads, 2 batches and 12800 playouts

$ ./Sayuri -w <weights file> -t 4 -b 2 -p 12800

Example setting 2: quickly and friendly pass game

$ ./Sayuri -w <weights file> -t 1 -b 1 --const-time 1 --friendly-pass

Example setting 3: set 0 playouts, directly policy output

$ ./Sayuri -w <weights file> -t 1 -b 1 -p 0

Example setting 4: use the GPU 0 and GPU 2

$ ./Sayuri -w <weights file> --gpu 0 --gpu 2

Graphical Interface

Sayuri is not complete engine. You need a graphical interface for playing with her. She supports any GTP (version 2) interface application. Sabaki and GoGui are recommended that because Sayuri supports some specific analysis commands.

  • Sabaki analysis mode

sabaki-sample01

  • GoGui analysis commands

gogui-sample01

Analysis Commands

The analysis Commands are useful on the modern GTP interface tool, like Sabaki. It shows the current win-rate, best move and the other informations. The engine supports the following GTP analysis commands.

  • analyze, genmove_analyze [player (optional)] [interval (optional)] ...

    • The behavior is same as lz-analyze, lz-genmove_analyze.
  • lz-analyze, lz-genmove_analyze [player (optional)] [interval (optional)] ...

    • Extension GTP commands of lz-analyze and lz-genmove_analyze. Support the info, move, visits, winrate, prior, lcb, order, pv, scoreLead labels. More detail to see KataGo GTP Extensions.
  • kata-analyze, kata-genmove_analyze [player (optional)] [interval (optional)] ...

    • Subset of kata-analyze and kata-genmove_analyze. Support the info, move, visits, winrate, prior, lcb, order, pv, scoreLead labels. More detail to see KataGo GTP Extensions.
  • Optional Keys

    • All analysis commands support the following keys.
    • interval <int>: Output a line every this many centiseconds.
    • minmoves <int>: There is no effect.
    • maxmoves <int>: Output stats for at most N different legal moves (NOTE: Leela Zero does NOT currently support this field);
    • avoid PLAYER VERTEX,VERTEX,... UNTILDEPTH: Prohibit the search from exploring the specified moves for the specified player, until UNTILDEPTH ply deep in the search.
    • allow PLAYER VERTEX,VERTEX,... UNTILDEPTH: Equivalent to avoid on all vertices EXCEPT for the specified vertices. Can only be specified once, and cannot be specified at the same time as avoid.
    • ownership True: Output the predicted final ownership of every point on the board.
    • movesOwnership True: Output the predicted final ownership of every point on the board for every individual move.

Reinforcement Learning

Please see this section.

Journal

Please see this section.

Features

  • Provide high level player strength on 19x19, depending on hardware.
  • Support Sabaki and GoGui analysis mode.
  • Support handicap game.
  • Support variable komi and board size (from 7x7 to 19x19).
  • Lock-free SMP MCTS.
  • Acceleration by multi-core processor and multi-Nvidia GPU.
  • Predict the current side-to-move winrate and draw-rate.
  • Predict the current side-to-move score lead and death strings.
  • Reuse the sub-tree.
  • Chinese rules with positional superko.
  • Gumbel AlphaZero learning.

Todo

  • Support Windows platform (CUDA version).
  • Support NHWC format.
  • Support distributed computation.

Other Linkings

License

The code is released under the GPLv3, except for threadpool.h, cppattributes.h, Eigen and Fast Float, which have specific licenses mentioned in those files.

Contact

[email protected] (Hung-Tse Lin)

sayuri's People

Contributors

cglemon avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.