Skip to content

Compress threat indexing, update feature set name to Full Threats v2 - #398

Open
sscg13 wants to merge 4 commits into
official-stockfish:masterfrom
sscg13:compress-indexing
Open

Compress threat indexing, update feature set name to Full Threats v2#398
sscg13 wants to merge 4 commits into
official-stockfish:masterfrom
sscg13:compress-indexing

Conversation

@sscg13

@sscg13 sscg13 commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

This is the corresponding trainer side changes for official-stockfish/Stockfish#6635

@Disservin

Copy link
Copy Markdown
Member

will need a rebase now that shawns pr is in

sscg13 and others added 2 commits February 25, 2026 15:18
Co-authored-by: Viren6 <94880762+Viren6@users.noreply.github.com>
@vondele

vondele commented Feb 27, 2026

Copy link
Copy Markdown
Member

This fails for me..

$ numactl --cpunodebind=0 python -u train.py /workspace/data/vondele/from_kaggle_2/T60T70wIsRightFarseerT60T74T75T76.split_0.binpack /workspace/data/vondele/from_kaggle_2/T60T70wIsRightFarseerT60T74T75T76.split_1.binpack /workspace/data/vondele/from_kaggle_2/T60T70wIsRightFarseerT60T74T75T76.split_2.binpack /workspace/data/vondele/from_kaggle_2/T60T70wIsRightFarseerT60T74T75T76.split_3.binpack /workspace/data/vondele/from_kaggle_2/T60T70wIsRightFarseerT60T74T75T76.split_4.binpack /workspace/data/official-stockfish/master-binpacks/nodes5000pv2_UHO.binpack /workspace/data/official-stockfish/master-binpacks/wrongIsRight_nodes5000pv2.binpack /workspace/data/official-stockfish/master-binpacks/multinet_pv-2_diff-100_nodes-5000.binpack /workspace/data/official-stockfish/master-binpacks/dfrc_n5000.binpack --threads=4 --gpus=0,1,2,3, --num-workers=96 --batch-size=65536 --features=Full_Threatsv2^ --l1=1024 --lr=4.375e-4 --gamma=0.995 --start-lambda=1.0 --end-lambda=0.75 --random-fen-skipping=10 --early-fen-skipping=12 --pc-y1=0.6893201149773951 --pc-y2=2.9285769485515805 --pc-y3=1.4386005301749225 --w1=3.3553547771220007 --w2=0.7006821612968052  --max_epochs=4 --network-save-period=4 --default_root_dir /workspace/scratch/training/runs/run_8
batch_size(global)=65536 | n_devices=4 | batch_size(per_gpu)=16384
Traceback (most recent call last):
  File "/workspace/nnue-pytorch/train.py", line 280, in <module>
    main()
  File "/workspace/nnue-pytorch/train.py", line 154, in main
    feature_cls = M.get_feature_cls(args.features)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspace/nnue-pytorch/model/modules/features/__init__.py", line 28, in get_feature_cls
    raise KeyError(f"Unknown feature '{name}'. Available: {', '.join(_FEATURES)}")
KeyError: "Unknown feature 'Full_Threatsv2^'. Available: HalfKAv2_hm^, Full_Threats^"

A bit unclear why we call this v2, honestly, it is functionally equivalent to the previous version?

@Disservin

Copy link
Copy Markdown
Member

halfkav2 was also identical to halfka except it used less space

@vondele

vondele commented Feb 28, 2026

Copy link
Copy Markdown
Member

Still needs a rebase and

diff --git a/model/modules/__init__.py b/model/modules/__init__.py
index e533443..4e3cec3 100644
--- a/model/modules/__init__.py
+++ b/model/modules/__init__.py
@@ -5,7 +5,7 @@ from .feature_transformer import (
 )
 from .features import (
     HalfKav2Hm,
-    FullThreats,
+    FullThreatsv2,
     get_feature_cls,
     get_available_features,
     add_feature_args,
@@ -18,7 +18,7 @@ __all__ = [
     "DoubleFeatureTransformer",
     "FeatureTransformer",
     "HalfKav2Hm",
-    "FullThreats",
+    "FullThreatsv2",
     "get_feature_cls",
     "get_available_features",
     "add_feature_args",
diff --git a/model/utils/serialize.py b/model/utils/serialize.py
index d4b2989..c128bbe 100644
--- a/model/utils/serialize.py
+++ b/model/utils/serialize.py
@@ -158,7 +158,7 @@ class NNUEWriter:
 
         # Weights stored as [num_features][outputs]
         self.write_tensor(bias.flatten().numpy(), ft_compression)
-        if isinstance(layer, FullThreats):
+        if isinstance(layer, FullThreatsv2):
             threat_weight = weight[: layer.NUM_THREAT_FEATURES].to(torch.int8)
             psq_weight = weight[layer.NUM_THREAT_FEATURES :]
             self.write_tensor(threat_weight.flatten().numpy())
@@ -306,7 +306,7 @@ class NNUEReader:
 
         bias = self.tensor(np.int16, [num_outputs - num_psqt_buckets])
         # weights stored as [num_features][outputs]
-        if isinstance(layer, FullThreats):
+        if isinstance(layer, FullThreatsv2):
             threat_weight = self.tensor(
                 np.int8, [layer.NUM_THREAT_FEATURES, num_outputs - num_psqt_buckets]
             )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants