From 04e267fbcb6b1f0cd0e646e965923e4198fd920a Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Mar 2026 23:58:50 +0000 Subject: [PATCH 1/5] Fix softmax masking for illegal moves in inference MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Multiplying logits by a binary 0/1 mask sets illegal move logits to 0, but softmax(0) is not zero — it still contributes probability mass. Use masked_fill with -inf so softmax correctly assigns exactly 0 probability to illegal moves. Fixes the issue raised in PR #9. https://claude.ai/code/session_01ELpknikQ4vWB4q8hWhxoVG --- maia2/inference.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/maia2/inference.py b/maia2/inference.py index f4f2cfa..6fe4e55 100644 --- a/maia2/inference.py +++ b/maia2/inference.py @@ -60,7 +60,7 @@ def get_preds(model, dataloader, all_moves_dict_reversed): legal_moves = legal_moves.to(device) logits_maia, _, logits_value = model(boards, elos_self, elos_oppo) - logits_maia_legal = logits_maia * legal_moves + logits_maia_legal = logits_maia.masked_fill(legal_moves == 0, float('-inf')) probs = logits_maia_legal.softmax(dim=-1).cpu().tolist() logits_value = (logits_value / 2 + 0.5).clamp(0, 1).cpu().tolist() @@ -154,7 +154,7 @@ def inference_each(model, prepared, fen, elo_self, elo_oppo): legal_moves = legal_moves.unsqueeze(dim=0).to(device) logits_maia, _, logits_value = model(board_input, elo_self, elo_oppo) - logits_maia_legal = logits_maia * legal_moves + logits_maia_legal = logits_maia.masked_fill(legal_moves == 0, float('-inf')) probs = logits_maia_legal.softmax(dim=-1).cpu().tolist() logits_value = (logits_value / 2 + 0.5).clamp(0, 1).item() From e51b972a5b2d02ca098a5235b1a8e37c8cbf3320 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 8 Mar 2026 00:22:10 +0000 Subject: [PATCH 2/5] Fix PyYAML package name casing Use canonical PyPI name 'PyYAML' instead of 'pyyaml' in both requirements.txt and pyproject.toml. https://claude.ai/code/session_01ELpknikQ4vWB4q8hWhxoVG --- maia2/requirements.txt | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/maia2/requirements.txt b/maia2/requirements.txt index a94f2cc..265dbdd 100644 --- a/maia2/requirements.txt +++ b/maia2/requirements.txt @@ -3,7 +3,7 @@ einops==0.8.0 gdown==5.2.0 numpy==2.1.3 pandas==2.2.3 -pyyaml==6.0.2 +PyYAML==6.0.2 pyzstd==0.15.9 Requests==2.32.3 torch==2.4.0 diff --git a/pyproject.toml b/pyproject.toml index 0ac599c..2aa810e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,7 @@ dependencies = [ "gdown==5.2.0", "numpy==2.1.3", "pandas==2.2.3", - "pyyaml>=6.0.2", + "PyYAML>=6.0.2", "pyzstd==0.15.9", "requests==2.32.3", "torch==2.4.0", From db7393c3e295ee3ee609396457101f79022263ea Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 8 Mar 2026 00:56:10 +0000 Subject: [PATCH 3/5] Lowercase package names in requirements.txt and pyproject.toml https://claude.ai/code/session_01ELpknikQ4vWB4q8hWhxoVG --- maia2/requirements.txt | 4 ++-- pyproject.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/maia2/requirements.txt b/maia2/requirements.txt index 265dbdd..0fd8809 100644 --- a/maia2/requirements.txt +++ b/maia2/requirements.txt @@ -3,8 +3,8 @@ einops==0.8.0 gdown==5.2.0 numpy==2.1.3 pandas==2.2.3 -PyYAML==6.0.2 +pyyaml==6.0.2 pyzstd==0.15.9 -Requests==2.32.3 +requests==2.32.3 torch==2.4.0 tqdm==4.65.0 \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 2aa810e..0ac599c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,7 @@ dependencies = [ "gdown==5.2.0", "numpy==2.1.3", "pandas==2.2.3", - "PyYAML>=6.0.2", + "pyyaml>=6.0.2", "pyzstd==0.15.9", "requests==2.32.3", "torch==2.4.0", From 124505142ed5d068bfeb2af36bf2e5654b1776da Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 8 Mar 2026 01:00:48 +0000 Subject: [PATCH 4/5] Bump version to 0.9.1 to trigger PyPI release with updated dependencies Fixes #10 https://claude.ai/code/session_01ELpknikQ4vWB4q8hWhxoVG --- maia2/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maia2/__init__.py b/maia2/__init__.py index 784611b..43c24d8 100644 --- a/maia2/__init__.py +++ b/maia2/__init__.py @@ -1,3 +1,3 @@ """An amazing sample package for maia2.""" -__version__ = "0.9" +__version__ = "0.9.1" From a7c864a9b0615d1504b2c63900c661d133bd4af4 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 8 Mar 2026 01:05:21 +0000 Subject: [PATCH 5/5] Filter bot accounts from training data using Lichess BOT title header Lichess PGN files include WhiteTitle/BlackTitle headers set to "BOT" for bot accounts, including Maia itself. Skip any game where either player has the BOT title. Fixes #2 https://claude.ai/code/session_01ELpknikQ4vWB4q8hWhxoVG --- maia2/main.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/maia2/main.py b/maia2/main.py index 32b061d..b84c8f0 100644 --- a/maia2/main.py +++ b/maia2/main.py @@ -84,16 +84,19 @@ def process_per_game(game, white_elo, black_elo, white_win, cfg): def game_filter(game): - + white_elo = game.headers.get("WhiteElo", "?") black_elo = game.headers.get("BlackElo", "?") time_control = game.headers.get("TimeControl", "?") result = game.headers.get("Result", "?") event = game.headers.get("Event", "?") - + if white_elo == "?" or black_elo == "?" or time_control == "?" or result == "?" or event == "?": return + if game.headers.get("WhiteTitle") == "BOT" or game.headers.get("BlackTitle") == "BOT": + return + if 'Rated' not in event: return