summaryrefslogtreecommitdiff
path: root/src/typhoon_nnue
blob: 7996299851d0b6323fdd8160f1d355522ad15e12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env bash
#
# typhoon_nnue -- thin wrapper that execs ./typhoon with NNUE eval enabled.
#
# Mirrors the NNUE_WEIGHTS/NNUE_PROBE_WEIGHTS/NNUE_LAZY_MARGIN/
# NNUE_SUPERLAZY_MARGIN env-var convention used by eval_tune/test_vs_head.sh
# (see that file's header comment and docs/NNUE.md) so the same weights file
# works whether you're driving a head-to-head match or just want to play
# with the NNUE engine interactively/in --batch mode.
#
# Env vars (all optional):
#   NNUE_WEIGHTS          Path to the main net weights file. Defaults to
#                          eval.nnue, a symlink (next to this script) into
#                          head_reference/nnue/current/weights.nnue -- the
#                          "current best" NNUE generation, promoted only
#                          via head_reference/nnue/promote.sh after a real
#                          self-play match (see that script and
#                          docs/NNUE.md's "Iterating on a net" section).
#                          Override to run an older/other checkpoint, e.g.
#                          one of head_reference/nnue/archive/*.nnue or a
#                          not-yet-promoted candidate straight out of
#                          annotate_pgns/runs/<rundir>/nnue_ckpt/.
#   NNUE_PROBE_WEIGHTS    Path to the probe weights file ("NPRB" format).
#                          Enables the lazy-eval accumulator probe gate.
#                          No default as of 2026-10-17 -- the old default
#                          (annotate_pgns/nnue_probe.bin) was fit against
#                          the PREVIOUS net's accumulator representation;
#                          since nnue_ckpt_matprobe is a from-scratch
#                          retrain, that probe is stale/mismatched for it.
#                          Set this explicitly only once a probe has been
#                          refit against the current NNUE_WEIGHTS net.
#   NNUE_LAZY_MARGIN       Flat cp override for every material bucket's
#                          lazy-probe margin (requires NNUE_PROBE_WEIGHTS).
#   NNUE_SUPERLAZY_MARGIN  Flat cp margin for the even-cheaper material-only
#                          pre-filter (off by default).
#
# The binary path defaults to ./typhoon next to this script; override by
# setting TYPHOON_BIN.
#
# Usage:
#   NNUE_WEIGHTS=/path/to/net.nnue ./typhoon_nnue [engine args...]

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BIN="${TYPHOON_BIN:-${SCRIPT_DIR}/typhoon}"

NNUE_WEIGHTS="${NNUE_WEIGHTS:-${SCRIPT_DIR}/eval.nnue}"
#NNUE_WEIGHTS="/home/scott/typhoon/annotate_pgns/runs/sf_20261020_recal/nnue_weights.nnue"

if [ ! -f "$NNUE_WEIGHTS" ]; then
    echo "typhoon_nnue: NNUE_WEIGHTS file not found: $NNUE_WEIGHTS" >&2
    exit 1
fi

if [ ! -x "$BIN" ]; then
    echo "typhoon_nnue: engine binary not found or not executable: $BIN" >&2
    echo "  (build it first, or set TYPHOON_BIN to an existing binary)" >&2
    exit 1
fi

NNUE_PROBE_WEIGHTS="${NNUE_PROBE_WEIGHTS-}"

ARGS=(--nnueweights "$NNUE_WEIGHTS")

if [ -n "$NNUE_PROBE_WEIGHTS" ] && [ -f "$NNUE_PROBE_WEIGHTS" ]; then
    ARGS+=(--nnueprobeweights "$NNUE_PROBE_WEIGHTS")
    if [ -n "${NNUE_LAZY_MARGIN:-}" ]; then
        ARGS+=(--nnuelazymargin "$NNUE_LAZY_MARGIN")
    fi
fi

if [ -n "${NNUE_SUPERLAZY_MARGIN:-}" ]; then
    ARGS+=(--nnuesuperlazymargin "$NNUE_SUPERLAZY_MARGIN")
fi

exec "$BIN" "${ARGS[@]}" "$@"