<feed xmlns='http://www.w3.org/2005/Atom'>
<title>typhoon.git/src/nnuefeatures.c, branch master</title>
<subtitle>The typhoon chess playing engine.
</subtitle>
<id>https://git.acknak.org/cgit/typhoon.git/atom?h=master</id>
<link rel='self' href='https://git.acknak.org/cgit/typhoon.git/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.acknak.org/cgit/typhoon.git/'/>
<updated>2026-10-15T22:21:26Z</updated>
<entry>
<title>NNUE accumulator incremental maintenance: MakeMove/UnmakeMove hookup</title>
<updated>2026-10-15T22:21:26Z</updated>
<author>
<name>Scott Gasch</name>
<email>scott@gasch.org</email>
</author>
<published>2026-10-15T22:21:26Z</published>
<link rel='alternate' type='text/html' href='https://git.acknak.org/cgit/typhoon.git/commit/?id=2bf4eb27a473089b9b30726a678fbac27d0f8a69'/>
<id>urn:sha1:2bf4eb27a473089b9b30726a678fbac27d0f8a69</id>
<content type='text'>
Wires the live NNUE accumulator (SEARCHER_THREAD_CONTEXT.sNnueAccum[2],
added in the previous commit) into real incremental maintenance,
hooked directly into the piece-movement primitives rather than
re-deriving move type from MOVE in a separate pass:

- chess.h: shared HalfKAv2_hm feature-index formula/constants
  (NnueFeatureIndex and friends), moved here from nnuefeatures.c so
  the reference dump and the real hot-path code can never drift
  apart. Prototypes for NnueAccumAddFeature/RemoveFeature/Recompute
  and the (still placeholder, zero-initialized) embedding table.
  LiftPiece/PlacePiece/SlidePiece/SlidePawn/SlidePieceWithoutSigs
  signatures gain an NNUE_ACCUMULATOR sNnueAccum[2] parameter.

- nnueaccum.c (new): the embedding table storage and the three
  accumulator operations. Written as straight-line 256-float loops,
  structured for -O3 -ffast-math auto-vectorization on this box's
  AVX2+FMA target; explicit SIMD intrinsics and real weight loading
  are separate, deliberately deferred follow-ups.

- move.c: all 8 Lift/Place/Slide(WithoutSigs) primitives now keep
  sNnueAccum incrementally correct for both perspectives on every
  call -- except when the piece is a king, where each primitive skips
  its own-color perspective entirely (that perspective needs a full
  recompute, not a delta, since every HalfKAv2_hm feature in it is
  own-king-relative; computing an incremental update for it only to
  discard it unread would be wasted work). MakeMove backs up that
  perspective into the current ply's PLY_INFO.sNnueAccumBackup before
  a king moves (castling or a plain step) and overwrites it via
  NnueAccumRecompute once the board reflects the final position;
  UnmakeMove restores it from the same backup slot. DEBUG builds tag
  the backup with the color it belongs to and poison it after
  consumption, release builds carry no overhead for either.

- nnuefeatures.c: now a thin board-walking wrapper around the shared
  chess.h formula instead of its own duplicated copy.

- testmove.c: TestLiftPlaceSlidePiece passes a local (unread) dummy
  accumulator pair -- the only caller of these primitives outside
  move.c, and it never needed NNUE awareness, just a real argument.

Verified via the full precommit_check.sh (all 4 gates, including the
new combined DEBUG=1 TEST=1 self-test, which exercises MakeMove/
UnmakeMove heavily via TestMoveGenerator's perft counts and
TestLegalMoveGenerator) -- confirms nothing crashes and no existing
invariant breaks. Does NOT yet confirm the actual property that
matters (incrementally-maintained accumulator == recompute-from-
scratch) -- no test exercises that yet; next step.

Co-Authored-By: Claude Sonnet 5 &lt;noreply@anthropic.com&gt;
</content>
</entry>
<entry>
<title>Phase A NNUE: feature-indexing spec, annotation/training pipeline, dump nnuefeatures</title>
<updated>2026-10-15T20:11:22Z</updated>
<author>
<name>Scott Gasch</name>
<email>scott@gasch.org</email>
</author>
<published>2026-10-15T20:11:22Z</published>
<link rel='alternate' type='text/html' href='https://git.acknak.org/cgit/typhoon.git/commit/?id=993b6eeb2a9ac7b659c473b6883fa53af1ad3a0b'/>
<id>urn:sha1:993b6eeb2a9ac7b659c473b6883fa53af1ad3a0b</id>
<content type='text'>
Builds out the NNUE Phase A prototype per docs/NNUE.md:

- src/nnuefeatures.c: standalone HalfKAv2_hm feature-index reference
  implementation (new `dump nnuefeatures` command), sourced from
  Stockfish's half_ka_v2_hm.{h,cpp} (sf_16 tag), including the 0x88-&gt;64
  square conversion typhoon's own board representation needs.
- annotate_pgns/: sharded TWIC/self-play annotation harness
  (annotate.py), position extraction, quiet-position filtering (flat
  and game-shaped, plus an upstream --prefilter-quiet option),
  train/holdout game-level stratified split, WDL-sigmoid K fitting,
  the Python HalfKAv2_hm reference encoder (nnue_feature_spec.py) and
  its bit-for-bit cross-checker against the C side
  (cross_check_features.py), and a first PyTorch training pipeline
  (nnue_model.py, nnue_train.py, build_training_tensors.py) -- a
  256x2-32-32-1-ish net trained locally on CPU against ~1.85M quiet
  TWIC positions as a pipeline/framework validation pass.
- Finish an in-progress InitMagic/InitLMRTable/InitEval -&gt;
  InitializeBitboardMagic/InitializeLMRTable/InitializeEval rename:
  chess.h's prototypes hadn't been updated to match the already-renamed
  definitions/call sites, leaving 4 implicit-function-declaration
  warnings.
- tests/arasan.epd: new curated EPD suite.
- docs/: add the project's design docs (previously untracked).

Co-Authored-By: Claude Sonnet 5 &lt;noreply@anthropic.com&gt;
</content>
</entry>
</feed>
