Replaces the (768 -> 128)x2 value net with (768 -> 1024)x2 -> 1 SCReLU, same inputs, quantisation and output scale, trained on much more data: the 12 S2 files of huggingface.co/datasets/linrock/bullet-training-data (6.6B positions, already filtered and shuffled; v1 had one month of test80). Training: 170 superbatches of 100M positions (17B positions, about 2.6 passes over S2), AdamW, LR 1e-3 cosine to 2.4e-6, target 0.4 * result + 0.6 * sigmoid(score / 400) as in v1. 1h34m on the RTX 3070 at ~3M positions/s (GPU-bound); final running loss 0.01278 (not comparable to v1's 0.0220, other data). The width was picked for the 2 hour budget: 1024 trains at 3-4M/s, and in the engine a random 1024 net cost only 16% nps against 128, thanks to the SIMD kernels. Trainer (train/value): - --hidden N (default now 1024) and --batches N for speed tests - reads bulletformat straight from .bin.zst (src/zstd_reader.rs), so the 108 GB of S2 never has to be unpacked to 210 GB; training needs ~40 MB/s of compressed input, which the HDD holding it gives easily - also reads raw .bin files (bullet's DirectSequentialDataLoader) Engine: - nnue::HIDDEN = 1024, Makefile EVALFILE = networks/rigby-value-v2.bin - the output layer now sums in blocks of 128 that fit 32 bits and adds them up in 64, so it stays exact for any width (the single 32-bit sum was only provably safe up to 128) Checked: evalfens against the trainer's --check on the final checkpoint: same signs and sizes, within 6 cp on quiet positions and up to 7% on large evaluations (quantisation; e.g. 553 vs 594 cp). Bench deterministic. UCI: uci, isready, ucinewgame, go nodes / movetime / infinite + stop. nps on bench: 4.6M -> 3.5M. Bench: 663779 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
97 lines
2.1 KiB
Makefile
97 lines
2.1 KiB
Makefile
# Rigby - MCTS chess engine
|
|
# OpenBench calls: make EXE=<name> [EVALFILE=<net>] [CXX=<compiler>]
|
|
# POLICYFILE=<net> picks the built-in policy network; POLICYFILE= builds none
|
|
# (move heuristics).
|
|
|
|
SRC_DIR := src
|
|
OBJ_DIR := obj
|
|
|
|
EXE ?= Rigby
|
|
# The value network embedded into the binary
|
|
EVALFILE ?= networks/rigby-value-v2.bin
|
|
# The policy network embedded into the binary; empty means move heuristics
|
|
POLICYFILE ?= networks/rigby-policy-v1.bin
|
|
CXX ?= clang++
|
|
ifeq ($(origin CXX),default)
|
|
CXX := clang++
|
|
endif
|
|
|
|
ifeq ($(OS),Windows_NT)
|
|
EXE_EXT := .exe
|
|
PLATFORM := windows
|
|
else
|
|
EXE_EXT :=
|
|
UNAME_S := $(shell uname -s)
|
|
ARCH := $(shell uname -m)
|
|
ifeq ($(UNAME_S),Darwin)
|
|
PLATFORM := mac
|
|
else
|
|
PLATFORM := unix
|
|
endif
|
|
endif
|
|
|
|
CXXFLAGS := -std=c++20 -O3 -flto -Wall -Wextra -DNDEBUG -Iexternal
|
|
LDFLAGS := -O3 -flto
|
|
|
|
ifeq ($(PLATFORM),windows)
|
|
ARCH_FLAGS := -march=native
|
|
# clang on Windows defaults to MSVC; use the MinGW runtime like Eleanor does.
|
|
ifneq ($(findstring clang,$(CXX)),)
|
|
CXXFLAGS += --target=x86_64-w64-windows-gnu
|
|
LDFLAGS += --target=x86_64-w64-windows-gnu
|
|
endif
|
|
CXXFLAGS += -pthread
|
|
LDFLAGS += -pthread -static
|
|
else ifeq ($(PLATFORM),mac)
|
|
ifeq ($(ARCH),arm64)
|
|
ARCH_FLAGS := -mcpu=apple-m1
|
|
else
|
|
ARCH_FLAGS := -march=native
|
|
endif
|
|
CXXFLAGS += -pthread
|
|
LDFLAGS += -pthread
|
|
else
|
|
ifeq ($(ARCH),aarch64)
|
|
ARCH_FLAGS := -mcpu=native
|
|
else
|
|
ARCH_FLAGS := -march=native
|
|
endif
|
|
CXXFLAGS += -pthread
|
|
LDFLAGS += -pthread -static
|
|
endif
|
|
|
|
CXXFLAGS += -DEVALFILE=\"$(EVALFILE)\"
|
|
ifneq ($(POLICYFILE),)
|
|
CXXFLAGS += -DPOLICYFILE=\"$(POLICYFILE)\"
|
|
endif
|
|
|
|
CXXFLAGS += $(ARCH_FLAGS)
|
|
LDFLAGS += $(ARCH_FLAGS)
|
|
|
|
SRCS := $(wildcard $(SRC_DIR)/*.cpp)
|
|
OBJS := $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(SRCS))
|
|
DEPS := $(OBJS:.o=.d)
|
|
|
|
MAKEFLAGS += -j
|
|
|
|
$(EXE)$(EXE_EXT): $(OBJS)
|
|
$(CXX) $^ -o $@ $(LDFLAGS)
|
|
|
|
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp | $(OBJ_DIR)
|
|
$(CXX) $(CXXFLAGS) -MMD -MP -c -o $@ $<
|
|
|
|
$(OBJ_DIR):
|
|
mkdir $(OBJ_DIR)
|
|
|
|
# Rebuild the network's translation unit when the network changes
|
|
$(OBJ_DIR)/nnue.o: $(EVALFILE)
|
|
ifneq ($(POLICYFILE),)
|
|
$(OBJ_DIR)/policy.o: $(POLICYFILE)
|
|
endif
|
|
|
|
-include $(DEPS)
|
|
|
|
.PHONY: clean
|
|
clean:
|
|
rm -rf $(OBJ_DIR) $(EXE)$(EXE_EXT)
|