# Native Maia3 transformer fine-tuning

For current results and practical guidance, read the
[research notebook](../research.html). This file keeps reproduction details
and earlier experiments with their corrections.

Maia 3 full transformer training now works in the browser and on CUDA.
The browser uses locally bundled TensorFlow.js WebGPU, not browser Python or
an inference session pretending to train. Both paths update the actual source
transformer and policy weights. Their complete ONNX exports work in the app.

**Correction to historical evidence**. Five of the six accounts in the old full
model study had BOT titles. Nine of the twenty accounts in the old expanded
adapter study had BOT titles. These were mixed account studies, not human only
results. The old full study also used raw pooled features for its frozen
comparator rather than the browser's tanh features. Its 58.13% adapter row does
not describe the exact browser path. Current studies fix both issues and use
training only ratings. Old artifacts remain available with these qualifications.

## Historical artifact checks

These commands verify the existing historical exports. They do not turn the
mixed cohort into a human only result. Use the audited workflow below for new
imitation experiments. Activate a Python environment with the dependencies
listed below before running them.

```powershell
$python = (Get-Command python -ErrorAction Stop).Source
$data = 'temp\doppelmaia-readiness-study\human-dataset.json'
$study = 'temp\doppelmaia-finetune-study'
& $python tools\doppelmaia\experiments\finetune_reference.py $data $study
node tools\doppelmaia\experiments\finetune_browser.mjs $study
& $python tools\doppelmaia\experiments\finetune_review.py $study
& $python tools\doppelmaia\experiments\finetune_test.py
Start-Process "$study\index.html"
```

The tested environment had PyTorch 2.11 CUDA 12.8, ONNX Runtime GPU 1.24.4,
ONNX 1.23.2, NumPy and python-chess. Browser validation uses the repository's
existing Playwright/server helpers. CUDA absence fails explicitly. Output is
resumable per candidate/player; do not reuse an output folder with changed
training settings or data.

The self-contained `index.html` opens offline and includes honest measurements,
not an external dashboard. `finetune-report.json` retains every validation
history, game-bootstrap interval, parameter-gradient check and value-logit drift.
`finetune-followup.json` adds wrong-player controls, rating transfer and label
ambiguity. `browser-parity.json` records actual application-worker inference.
Each player's deployable model is `<player>\maia3-finetuned.onnx`; checkpoints
and test predictions are also retained for verification.

## Verified architecture, not guessed weights

`finetune_model.py` implements the shipped eight-block, 512-wide, 16-head GAB
transformer directly in differentiable PyTorch. Architecture was cross-checked
against the public [CSSLab implementation](https://github.com/CSSLab/maia3/blob/1e13597c42d4858b7cfd7cfdae01e297263364b2/maia3/models.py).
Initializer consumers, not unstable autogenerated numeric tensor identifiers,
map weights to operations. There is no random replacement network.

The shipped wrapper repeats the present board eight times and supplies fixed
clock features. The contextual path below replaces that input wrapper with
actual causal history. The source FP16-rounded GELU,
attention scaling, RMS epsilon and policy scaling constants must be preserved
even when computing in FP32. Every study runs native/ORT CUDA FP32 parity before
training at Elo 1000, the player's matched rating, and 2200. Maximum policy/value
absolute error must be below 0.0005.

Export replaces the existing initializers in the same standard ONNX graph.
Weights and floating types become FP32, approximately 91 MB rather than the
46 MB FP16 original; this remains below the app's 128 MiB personal-model limit.
Historical 12 channel exports keep the same input/output names and topology.
Contextual exports remove the wrapper's repeat operation and accept 96 channels.
Final parity is checked
again at multiple Elos, then separately in the real application personal-model
worker requesting WebGPU. No custom operator, browser Python, or runtime fallback
is introduced.

## Historical scientific protocol

* The source dataset comes from the local October 2026 rated standard Lichess
  archive: six million scanned games, 20 players selected by activity/rating
  **before** model evaluation. The initial cohort is the first three players,
  broadened to six without changing the protocol after the initial cohort
  improved. This is not a population-wide random sample.
* Use exactly the existing chronological 60/20/20 source-game splits, capped at
  6000 training and 1200 validation/test positions per player. Openings and
  repeated boards remain in the dataset. Every method gets identical samples.
* Compare frozen Maia3, a raw pooled feature SGD adapter at anchoring
  0 and 0.5, last-transformer-block plus policy-head fine-tuning, and all eight
  transformer blocks plus policy/input/Elo/GAB weights. The value head and final
  pooled value normalization are not optimized.
* Native training is FP32 AdamW, learning rates 0.00001 and 0.00003, batch 32,
  weight decay 0.01, gradient clipping 1, seed 42. The objective mixes 75% observed
  recorded move cross-entropy and 25% frozen base-policy distillation. Maximum four
  epochs, patience two. No dropout is added to the shipped inference graph.
* Select checkpoints and learning rates using **training-unseen canonical-board
  validation cross-entropy**, including epoch zero. Adapter checkpoints use the
  same novel validation rows. Sealed tests never choose a configuration.
* The partial model caches only a truly frozen prefix: the shared GAB tensor
  and every initializer used by earlier blocks remain frozen. A regression test
  confirms that cached and recomputed forwards stay identical after an update.
  Full eight-block training does update the shared GAB.
* Report all, train-familiar, train-novel, opening, and **strict novel** test
  boards. Strict novel additionally excludes every validation board. Board keys
  are side-to-move-canonical piece placements, exactly the network's board input;
  castling/en-passant metadata is deliberately not allowed to disguise overlap.
* Controls include uniform-random legal training labels, wrong-player selected
  models, and matched-rating plus/minus 200 transfer. Random-label validation is
  still evaluated against recorded labels, so epoch-zero retention is expected
  and explicitly visible.
* Report both CE and top-1 agreement, with 2000 paired whole-game bootstrap draws.
  Intervals concern games from the sampled players, not unseen players generally.
* Identical network inputs can have conflicting human labels. The follow-up
  reports both native-input and native-input-plus-legal-mask empirical oracle
  agreement/entropy. These are descriptive sample bounds, not population
  guarantees or a claim that human stochasticity can be copied perfectly.

Policy-only training changes the shared trunk and **changes value logits**,
despite frozen value-head weights. The report measures that drift. Agreement
improvements are not evidence of stronger play, calibrated WDL, preserved style
on every position, or near-perfect human reproduction.

## Executed six-player results

The completed run used 4620 source games: 31,754 training, 6975 validation and
6990 sealed test positions. The 5658 **strict novel** test boards exclude both
training and validation piece inputs.

| Method | Strict-novel CE | Strict-novel agreement |
|---|---:|---:|
| Frozen Maia3 | 1.40785 | 57.67% |
| Novel-validation-selected raw pooled adapter | 1.37064 | 58.13% |
| Last-block plus policy fine-tuning | 1.11930 | 62.96% |
| Full eight-block fine-tuning | **1.02437** | **65.82%** |

Full-model agreement improves by 8.15 percentage points versus base (paired
whole-game 95% interval +6.91 to +9.39), and 7.69 points versus the frozen
adapter (+6.46 to +9.00). These are game-level intervals conditional on the
six selected players, not uncertainty over the human population.

All six players selected full eight-block checkpoints (22,409,728 trainable
parameters); source players 1–3 selected learning rate 0.00001, players 4–6
selected 0.00003. Their strict-novel agreement changes were respectively
+5.18, +1.63, +1.76, +22.38, +14.87 and +3.27 points. Individual intervals can
include zero even though pooled intervals do not. Complete CE/top-1 histories
and intervals remain in the JSON report.

Wrong-player controls usually perform worse, but **not universally**: Player02
gets 73.14% agreement from its own selected model and 73.75% from Player01's
model. Thus improved new-board prediction is established for this cohort, but
perfectly player-specific style identification is not. Random-label training
retained the baseline checkpoint. Rating-transfer diagnostics are reported,
not used for selection.

All six exported 91,033,668-byte ONNX models were loaded through the actual app
personal-model API and ran in its real WebGPU worker on an NVIDIA Lovelace
adapter. Across Elo 1000, matched rating, and 2200, the worst native/browser
policy-logit error was **0.00024128**. Five architecture/data/export regression
tests passed, including nonzero first/last-block gradients and frozen-prefix
correctness after an optimizer step.

Value logits are **not preserved**: mean absolute changes range from 0.1334 to
0.6077, with maximum change 3.5123. This experiment has not established improved
playing strength or unchanged WDL calibration.

## Attribution and license

The differentiable architecture is adapted from CSSLab's Maia3 implementation
at commit `1e13597c42d4858b7cfd7cfdae01e297263364b2`. That upstream implementation is
licensed under the **GNU Affero General Public License, version 3**. The adapted
`finetune_model.py` is marked `AGPL-3.0-only`; the unmodified upstream license
text is included as `finetune_LICENSE.txt`. The pinned public source URL is
linked above. Existing model/weight attribution and licensing also continue to
apply; exporting weights does not grant a new or more permissive license.

## Browser training

`../maia3-transformer.js` supplies the complete differentiable architecture
using the bundled source initializers. It trains all 154 policy and shared
transformer tensors, including every attention block. Six value related tensors
stay frozen. `../transformer-training.js` supplies the training workflow.

TensorFlow.js core and WebGPU 4.22.0 are bundled locally with esbuild 0.28.2.
Run `npm --prefix tools\doppelmaia ci` and then
`npm --prefix tools\doppelmaia run build:training` from the repository root.
Keep the generated `.js` runtime, notices and Apache license together.
No training data or model weights are sent to a service.

The browser and CUDA use FP32, source rounded constants, the same LCG batch
ordering, soft targets, AdamW, global clipping and validation checkpoint rule.
Defaults are twelve maximum epochs, rate 0.00001, batch 16 and anchor 0.25.
Advanced settings allow batches from one to 32 and up to 50,000 imported
positions. The browser does not automatically search multiple configurations.
The fast adapter and original Maia methods retain their 10,000 position limit.

The WebGPU runtime disables CPU forwarding and forces packed matrix
multiplication program type three. The automatic SplitK path in this pinned
version gave incorrect transposed GAB products. A measured dot product returned
-0.052438 instead of 2.186038. Keep the packed setting unless fresh forward and
gradient tests prove a replacement correct. Gradient norm reduction uses a
binary tree rather than one AddN with too many WebGPU storage bindings.

GPU loss and uncaptured device errors fail explicitly. Invalid options, missing
novel validation boards and overlapping game IDs fail before loading the large
model. Epoch zero is a valid checkpoint. A model that does not improve the
selection objective is not exported as an improvement.

Checkpoint snapshots read back one weight tensor at a time, keeping independent
CPU copies. Do not parallelize these reads across all 160 tensors, since concurrent
GPU staging buffers increase peak memory during checkpoint selection and export.
Restoration also disposes each temporary tensor before creating the next one.
After training, optimizer buffers are released before restoring the selected
checkpoint. Export reuses that CPU checkpoint instead of reading all restored
GPU weights back a second time.
FP32 export copies the serialized model once and overwrites the existing
initializer byte ranges. Tensor sizes and protobuf framing stay unchanged.
Do not rebuild nested tensor and graph fields with repeated joins, since those
create several additional model-sized buffers during export. Export errors
identify serialization separately from ONNX Runtime verification startup.
This reduces temporary allocation pressure but does not guarantee a run fits
the available GPU or browser memory.

### Numerical evidence

| Comparison | Measured result |
| --- | --- |
| Initial forward policy maximum error | 0.0000935 |
| Initial gradient maximum error | 0.0000625 |
| Four update policy maximum difference | 0.000614 |
| Same learned weights after 96 updates, policy maximum error | 0.0002423 |
| Same learned weights, value maximum error | 0.0000146 |
| Same learned weights, maximum gradient error over all 154 tensors | 0.0001223 |
| Complete six epoch workflow, selected epoch | Four in both implementations |
| Complete workflow, chosen validation CE difference | 0.00000601 |
| Complete workflow, exported validation move agreement difference | Zero |

These are implementation checks, not human imitation scores.
The complete workflow uses 1024 training positions and 256 validation positions,
of which 231 have novel board inputs. Browser training and evaluation took about
76 seconds, eager CUDA about 27 seconds and CUDA graph execution about 11 seconds.
An independent 259 position case verified partial batches under CUDA graphs.

The 96 update stress run at rate 0.00003 did not remain numerically identical.
Independent browser and CUDA weights produced raw logit RMSE 0.585, maximum raw
difference 6.031, mean legal policy KL 0.01298 and 98.46% top move agreement
between implementations. One legal probability differed by 0.624. Keep these
outliers in the report. Matching a chosen checkpoint is not a claim that every
long trajectory matches.

The same learned weights still passed strict forward and all tensor gradient
checks. `transformer_numerics.py` also tests sensitivity to algebraically
equivalent fused and unfused LayerNorm in CUDA alone.
That control finished with raw logit RMSE 0.4882 and mean legal policy KL
0.00820. Top move agreement between the two CUDA paths was 98.46%.
This supports numerical sensitivity as an explanation, not a claim that the
independent implementations always produce the same weights.

The larger account fixture trained 10,241 positions for three epochs, with
512 validation positions and 432 novel validation inputs. Both implementations
selected epoch two. Selected CE differed by 0.00014647 and exported validation
agreement by one of 512 moves. Browser training and evaluation took 326.76
seconds, compared with 75.70 seconds for CUDA graphs.

```powershell
& $python tools\doppelmaia\experiments\transformer_workflow.py temp\doppelmaia-generalization-human-large\human-dataset.json temp\doppelmaia-transformer-human-workflow --player 5 --train 10241 --validation 512 --epochs 3 --cuda-graphs
node tools\doppelmaia\experiments\transformer_workflow.mjs temp\doppelmaia-transformer-human-workflow
& $python tools\doppelmaia\experiments\research_review.py workflow temp\doppelmaia-transformer-human-workflow
```

```powershell
& $python tools\doppelmaia\experiments\transformer_numerics.py temp\doppelmaia-transformer-long-parity
$env:DOPPELMAIA_FULL_TEST = '1'
$env:LC0_TEST_BROWSER = 'C:\Program Files\Google\Chrome\Application\chrome.exe'
node --test --test-concurrency=1 tests\doppelmaia-transformer.test.mjs tests\personalized-maia3-ui.test.mjs
```

The GPU gated browser test includes real UI training, ONNX export, installation,
a legal application bestmove, all four training objectives, baseline fallback,
unavailable GPU errors and narrow screen layouts.

## Audited larger account study

The new source window scans 36 million games from the local archive.
Training uses rows through 24 million. Each account's later games are split
chronologically between validation and an untouched test.
Accounts need at least 100 training games and 80 later games before any new model
scores are seen. Every account with a BOT title in its source records is excluded.
An absent BOT title is not independent proof of a human identity.

Eight accounts remain, with 5720 summed account games, 117,717 training
positions, 17,015 validation positions and 16,940 test positions.
Their training only median ratings range from 1115 to 1741.
Actual UTC ranges, source PGN bytes, file hashes, split ownership and ratings
are independently checked by the study runner.

Four full model settings are fixed before the sealed test is evaluated.

| Candidate | Training limit | Rate | Base anchor |
| --- | --- | --- | --- |
| full-6000 | 6000 | 0.00001 | 0.25 |
| full-all | 24,000 | 0.00001 | 0.25 |
| full-personal | 24,000 | 0.00001 | 0 |
| full-faster | 24,000 | 0.00003 | 0.25 |

All use at most twelve epochs, batch 32, patience two, seed 42, AdamW weight
decay 0.01 and gradient norm limit one. Available account data can be below
the stated cap. Every candidate uses the same validation boards, excluding
all full training inputs even for the 6000 position candidate.

The frozen comparator now uses `tanh` of the actual 512 pooled features.
It is a 6000 position ablation without opening lookup, selected on the common
novel validation set. It is not the entire stock adapter workflow.
Controls include uniform random legal training labels for the first eligible
account and a cyclic other account's selected model.

Training writes all choices to `validation-selections.json` before the separate
evaluation stage. Test labels never select a model. Strict novelty excludes
every board input seen in training or validation. Elo input plus 200 is a
conditioning check, not a measured strength gain.
Intervals cluster whole source games, including shared games across accounts.
They describe this activity selected cohort, not all Lichess players.

### Executed results

| Method on the same 14,022 strictly unseen test moves | Agreement | Cross entropy |
| --- | --- | --- |
| Starting Maia 3 | 54.2719% | 1.414061 |
| Correct tanh adapter ablation | 55.8979% | 1.344612 |
| Full model with 6000 training positions | 58.9645% | 1.254110 |
| Full model with all available training positions | 59.2854% | 1.226136 |
| Validation selected full model | 59.1570% | 1.229112 |
| Selected model at Elo input plus 200 | 58.8718% | 1.246759 |
| Cyclic other account model | 51.8542% | 1.554420 |

These are pooled positions, not equal account means. Both are saved in the JSON.
The selected gain is 4.885 percentage points with a whole source game 95%
interval from 4.252 to 5.531, across 708 test game clusters.
All eight accounts improved recorded move agreement on their strict unseen
subset. Individual selected rates range from 55.77% to 64.99%.
The first account's random label control kept epoch zero.

All test moves improved from 54.56% to 63.13%. Familiar inputs reached 82.63%,
but that is not unseen board generalization. The 80% unseen target was not
reached. Do not select a different setting after seeing the test table.

All eight selected exports ran in the actual app WebGPU worker at Elo 1000,
their matched setting and 2200. Maximum policy error was 0.00031996 and
maximum value error was 0.00005866. Each export is 91,033,668 bytes.
This confirms portable inference, not strength or calibrated value estimates.

### Reproduction

The source collector uses the earlier activity selected cohort before filtering
BOT titles and insufficient activity. To rebuild the exact larger source window
from the retained earlier dataset, run the following command first.

```powershell
& $python tools\doppelmaia\experiments\generalization_data.py temp\lichess-databases\lichess_db_standard_rated_2026-10.pgn.zst temp\doppelmaia-readiness-study\human-dataset.json temp\doppelmaia-generalization-human-large --players 20 --games 36000000 --train-cutoff 24000000 --train-positions 24000 --holdout-positions 3000 --workers 8
```

Add `--reuse-source` to reuse the verified source PGN cache. Archive identity,
the previous dataset, extraction options and cached file hashes must match.

```powershell
$data = 'temp\doppelmaia-generalization-human-large\human-dataset.json'
$study = 'temp\doppelmaia-generalization-study'
& $python tools\doppelmaia\experiments\generalization_study.py $data $study --stage train
& $python tools\doppelmaia\experiments\generalization_study.py $data $study --stage evaluate
& $python tools\doppelmaia\experiments\finetune_reference.py $data $study --generalization
node tools\doppelmaia\experiments\finetune_browser.mjs $study
& $python tools\doppelmaia\experiments\research_review.py generalization $study --dataset $data
& $python tools\doppelmaia\experiments\generalization_test.py --dataset $data --study $study
```

The study saves exact source hashes. Changing any of its eight recorded Python
files while training is running invalidates continuation. Use a new output
directory for a changed protocol. Do not overwrite old experimental results.
The CUDA requirements are pinned in `native-requirements.txt`.
The generated offline review includes `reproduction-source.zip` with the exact
eight executed Python sources, protocol and license. Every source hash is checked
before archiving. This preserves the executed version for later investigation.
An unavailable CUDA device is an error, not an automatic CPU fallback.

Native research JSON is not a browser reusable dataset export. To use the page,
import source PGNs or prepare them through the real import pipeline.
The direct worker verification fixture accepts research game IDs, but the UI
requires the complete reusable schema and hashed game identities.

## Contextual unseen move study

The new full trainer uses eight actual board frames, not eight copies of the
present board. Inputs are `[batch, 64, 96]`. Frames are oldest first, and each
frame is mirrored for its own side to move. Missing earlier frames repeat the
earliest observation. The current frame occupies the last twelve channels.
Both native and browser exports record the same history encoding metadata.
The app reads the input shape and supplies history from its legal UCI continuation.
Old 12 channel models retain their original encoding.

`context_models.py` verifies pinned upstream source and public model hashes.
`context_training.py` supports full, top block and low rank development runs.
Low rank factors are merged into ordinary exported weights. The browser uses
full training rather than adding an adapter path that did not win the pilot.

The development comparison used six settings on Player06, Player13 and Player14.
Across 4989 novel validation moves, full training without base anchoring reached
63.72% agreement and full training with anchor 0.25 reached 63.54%.
Top four blocks and rank 32 or 64 adaptation did not improve that result.
These are earlier development results, not the new held out test.

The pinned 79M model was also fully trained on Player13, using rates 0.000003
and 0.00001. Its selected novel agreement was 59.42% and 59.55%.
The smaller contextual full models reached 59.55% and 59.68% on that same
account. The larger model did not justify a browser migration.
This exploratory comparison used batch 16 rather than the smaller model's
batch 32, so it is not a controlled comparison of model sizes.
`released_context_study.py` vectorizes the promotion head to avoid CPU index
uploads during CUDA graph capture. `released_context_test.py` checks its
forward outputs, every trainable gradient and an actual captured update
against the unmodified pinned source. The failed original capture and its
source snapshot remain in the earlier output directory.

### Fresh data and selection

The local archive was scanned through 72 million games. Global boundaries
are 48 million for training and 60 million for validation.
Test games follow both windows for every account. Six of the eight previously
audited accounts had sufficient later activity. Player06 and Player20 were
excluded for insufficient later games, not model scores. No replacement
accounts were selected.

The resulting data has 159,546 training, 20,487 validation and 26,229 test
positions. All 206,262 examples were replayed against the source PGNs, including
the exact target move, all history frames and the complete legal mask.
The source player must own each target move. Source timestamps, colors and
ratings are compared directly rather than trusting the prepared metadata.
The audit confirms 7097 unique original source games, source account titles,
chronological boundaries and training only conditioning ratings.
Absence of a BOT title is not independent proof of human identity.

Full contextual models and matched repeated board controls use the same
training data, rate 0.00001, batch 32, twelve maximum epochs, patience three,
weight decay 0.01 and gradient clipping one. Each family compares base anchors
0 and 0.25. Minimum novel validation CE selects the checkpoint and setting,
including epoch zero. Test predictions do not choose either one.

The primary test excludes canonical current boards present in that account's
new personal training or validation data, or any of its earlier development splits.
Novelty is within each account, not against other accounts or Maia's pretraining.
This matters because a larger sample budget is not necessarily a superset of
an earlier evenly sampled dataset. Every method receives the same remaining
test rows. Old personalized models are evaluated again on these same boards.
Do not compare the earlier eight account headline with a later six account
headline as though they shared a test set.

Paired intervals resample original source games, including games shared across
accounts. Reports retain pooled and equal account means, raw predictions,
wrong account controls and an Elo input raised by up to 200.
Changing Elo is not evidence of stronger play or preserved habits.

### Measured fresh results

The locked comparison contains 21,687 strictly unseen test moves from 1071
original source games. The old and new models were evaluated on the same rows.

| Method | Move agreement | Cross entropy |
| --- | ---: | ---: |
| Original repeated board base | 53.55% | 1.44700 |
| Base with actual history | 55.98% | 1.35868 |
| Previous personalized checkpoints | 59.01% | 1.24984 |
| New data with repeated board input | 59.09% | 1.22563 |
| New data with causal history | **61.55%** | **1.15170** |
| Same contextual checkpoints at Elo plus 200 | 61.22% | 1.17033 |
| Wrong account contextual checkpoints | 53.23% | 1.49601 |

The paired gain over the previous personalized models is 2.536 points.
The 95% source game interval is 2.051 to 3.000 points.
History improves on the matched data repeated board control by 2.458 points,
with an interval from 1.994 to 2.885. Extra data alone barely helped agreement.
All six accounts improve, but this remains a modest gain rather than an 80%
result. Equal account mean agreement is 61.52%.

| Account | Elo input | Previous agreement | New agreement |
| --- | ---: | ---: | ---: |
| Player07 | 1400 | 57.06% | 60.23% |
| Player11 | 1600 | 58.49% | 62.04% |
| Player13 | 1700 | 55.97% | 57.87% |
| Player14 | 1700 | 66.03% | 68.88% |
| Player16 | 1500 | 56.32% | 58.35% |
| Player19 | 1600 | 59.97% | 61.77% |

The intervals are conditional on these accounts and seed 42. They do not
measure variation across human populations or random training seeds.
Training ownership and metadata audit regressions passed before selection.
The same six exported models passed actual app WebGPU inference at three Elo
inputs and both colors. Maximum raw policy logit error was 0.00019551.
The actual app then processed every one of the 21,687 strict test boards.
Every top move matched native inference using the same weights.
Maximum per position CE difference was 0.00004810.
This checks exported model inference, separately from the independently trained
browser and CUDA workflow described below.

### Reproduction

Use the native environment and pinned dependencies described above. Keep heavy
CUDA processes serial on Windows. Concurrent native processes exhausted commit
capacity on this machine despite having free physical RAM.

The source collector has no Torch import in its parser workers. This avoids
loading CUDA eight times during PGN preparation. Use `--reuse-source` only with
a completed, hash verified source cache. The original collector and its scan
protocol are retained in the data directory.

```powershell
$root = 'temp\doppelmaia-unseen-v4'
$prefix = 'temp\doppelmaia-generalization-human-large'
$data = "$root\data\human-dataset.json"
$training = "$root\training"
$evaluation = "$root\evaluation-v2"
$previous = 'temp\doppelmaia-generalization-study'

& $python tools\doppelmaia\experiments\unseen_data.py temp\lichess-databases\lichess_db_standard_rated_2026-10.pgn.zst $prefix "$root\data" --reuse-source
& $python tools\doppelmaia\experiments\context_test.py
& $python tools\doppelmaia\experiments\context_evaluation_test.py
& $python tools\doppelmaia\experiments\context_study.py $data $training --players Player07 Player11 Player13 Player14 Player16 Player19 --configs full-history full-personal-history full-repeated full-personal-repeated
& $python tools\doppelmaia\experiments\context_evaluation.py $data $training $previous $evaluation --stage audit
& $python tools\doppelmaia\experiments\context_evaluation.py $data $training $previous $evaluation --stage freeze --previous-dataset "$prefix\human-dataset.json"
& $python tools\doppelmaia\experiments\context_evaluation.py $data $training $previous $evaluation --stage evaluate
& $python tools\doppelmaia\experiments\context_app_reference.py $data $evaluation
$env:LC0_TEST_BROWSER = 'C:\Program Files\Google\Chrome\Application\chrome.exe'
node tools\doppelmaia\experiments\finetune_browser.mjs $evaluation
& $python tools\doppelmaia\experiments\research_review.py context $evaluation
```

The native and browser numerical checks use the same tokens, shuffling,
targets, optimizer settings and checkpoint rule.

```powershell
& $python tools\doppelmaia\experiments\transformer_reference.py $data "$root\parity" --history
node tools\doppelmaia\experiments\transformer_parity.mjs "$root\parity"
& $python tools\doppelmaia\experiments\context_workflow.py $data "$root\workflow"
node tools\doppelmaia\experiments\transformer_workflow.mjs "$root\workflow"
$env:DOPPELMAIA_FULL_TEST = '1'
node --test --test-concurrency=1 tests\doppelmaia-history.test.mjs tests\doppelmaia-transformer.test.mjs tests\personalized-maia3-ui.test.mjs
```

The 10,241 position contextual workflow selected epoch one in both implementations.
Selected validation CE differed by 0.00098155 and agreement was identical.
The browser completed 1923 updates. Its exported model was checked against
ONNX Runtime. FP32 optimization is not bit identical, and the larger numerical
differences from the earlier stress study remain documented above.

Each study stores source snapshots and hashes. Use a new directory when
changing data, code or settings. The earlier completed audit is preserved in
`evaluation`, while `evaluation-v2` adds the stricter prior development exclusion.
The raw research dataset is not a browser import format. Use source games in
the page or its correctly prepared reusable export.

## Phase interpretation and practical data budgets

The [readable research notebook](../research.html) is the current human facing
summary. It compares the local Maia, Maia4All and Chessformer papers with the
implemented method, without treating their different headline scores as a
leaderboard. The local Maia4All source matches commit
`741efc342cbda63297f16860ea2fd761cdab2c32`. Its public tree and releases were checked
on 10 November 2026.

`phase_review.py` only describes the locked predictions. It does not retrain
models or turn the already inspected window into fresh confirmation.
Opening means fewer than 24 plies. Sparse boards have at most ten pieces after
the opening, including kings and pawns. All other positions form the middle
group. Forced moves are absent from this dataset.

| Slice | Test moves | Selected agreement |
| --- | ---: | ---: |
| Familiar opening boards | 4446 | 84.17% |
| All opening boards | 10530 | 71.37% |
| Strictly new opening boards | 6008 | 61.92% |
| Strictly new middlegame boards | 14048 | 60.73% |
| Strictly new sparse boards | 1631 | 67.26% |

These slices overlap. A further 76 opening moves belong to validation or earlier
development without appearing in the current training set. They are in the all
opening row but not either strict slice. Do not add the table rows together.
The six training sets represent 621 to 1163 original games per account.
This is a demonstrated sample range, not a universal minimum.

`game_budget_study.py` studies 20, 100, 500 and all available training games.
Subsets are nested with seed 42. Every budget uses the same validation boards,
excluding the entire training pool rather than just its chosen subset.
This avoids letting different novelty definitions make a learning curve look
better. The method uses full history training, batch 32, rate 0.00001,
base anchor 0.25, patience two and up to six epochs. Conditioning Elo is fixed
from the training window. No test predictions are inspected by this script.
Small budgets also receive fewer updates, so this measures practical fixed
settings rather than a pure data effect at equal compute.

All 24 runs completed. Each budget uses the same 17,129 novel validation
positions across the six accounts. The starting model has 55.82% pooled
agreement on those positions.

| Training games per account | Training positions per account | Validation agreement | Validation CE |
| --- | --- | ---: | ---: |
| 20 | 530 to 797 | 58.42% | 1.269 |
| 100 | 2521 to 3584 | 59.58% | 1.231 |
| 500 | 12715 to 17936 | 60.72% | 1.191 |
| 621 to 1163 | 19518 to 38637 | 61.25% | 1.174 |

| Account | Validation games | Validation positions | Base | 20 games | 100 games | 500 games | All games |
| --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
| Player07 | 189 | 3724 | 54.97% | 57.60% | 57.87% | 59.37% | 59.08% |
| Player11 | 28 | 712 | 54.78% | 57.72% | 60.25% | 63.20% | 64.47% |
| Player13 | 102 | 2789 | 51.67% | 55.58% | 57.40% | 58.84% | 59.48% |
| Player14 | 209 | 4446 | 59.74% | 62.53% | 64.15% | 65.09% | 65.81% |
| Player16 | 207 | 4444 | 55.27% | 56.66% | 57.45% | 58.19% | 59.16% |
| Player19 | 51 | 1014 | 56.41% | 59.37% | 60.65% | 60.95% | 60.95% |

Every account improved over its base even with 20 training games. The gains
at that budget ranged from 1.40 to 3.91 percentage points. No run selected
epoch zero. More data was not an automatic win over 500 games. Four accounts
improved, one stayed level and one lost about 0.30 point. The pooled extra
gain was 0.53 point.

The fixed validation sets contain 28 to 209 additional games per account.
Do not interpret 20 training games as 20 total imported games being sufficient.
These development comparisons use validation selected checkpoints and one
sampling seed. They do not replace the fresh test or establish a universal
minimum. Their 24 fits spent about 22 minutes and 34 seconds in native training
and evaluation, excluding preparation and other workflow overhead.

Results and the frozen protocol are in
`temp\doppelmaia-research-20261110\game-budgets`. Each case records its selected
game IDs, complete learning history, best epoch and protocol hash. The study
does not export 24 additional deployable models.

```powershell
$data = 'temp\doppelmaia-unseen-v4\data\human-dataset.json'
$evaluation = 'temp\doppelmaia-unseen-v4\evaluation-v2'
& $python tools\doppelmaia\experiments\phase_review_test.py
& $python tools\doppelmaia\experiments\game_budget_test.py
& $python tools\doppelmaia\experiments\phase_review.py $data $evaluation temp\doppelmaia-research-20261110\phase-review.json
& $python tools\doppelmaia\experiments\game_budget_study.py $data temp\doppelmaia-game-budget-repeat
```

The browser workflow runner records preparation and training separately,
plus wall time from local tool page loading through the verified model download.
That wall measurement excludes PGN import and browser launch. Its initial
10,241 position training run used about 28 seconds for preparation and
211 seconds for training and evaluation. Do not call that an all inclusive
time for any game file or any GPU.

The larger completed run uses 38,637 training and 5,464 validation positions
from Player14. It follows the page defaults with a larger position limit,
including batch 16 and up to six epochs. Both CUDA and the browser made 7,245
updates, selected epoch one and stopped after epoch three.

| Measurement | Browser | CUDA |
| --- | ---: | ---: |
| Preparation | 110.83 seconds | Not timed separately |
| Training and evaluation | 1045.27 seconds | 220.33 seconds |
| Local page load through checked download | 1226.45 seconds | Not measured |
| Selected novel validation CE | 1.00038783 | 1.00014460 |
| Selected novel validation agreement | 65.61% | 65.52% |

The complete browser time is 20 minutes and 26 seconds on an RTX 4070 Ti SUPER
with 16 GB of VRAM and a Ryzen 7 7800X3D. PGN import and browser launch remain
outside that time. The 4,446 novel validation positions are the selection set,
not the fresh test. The browser export passed ONNX validation with maximum
policy logit difference 0.00002480 and maximum value difference 0.00000104.
The numerical checks retained their existing tolerances. Independent training
is not bit identical, and value estimates are still not strength calibrated.

The reports, native and browser exports, protocol and executed browser runner
are in `temp\doppelmaia-research-20261110\browser-budget`.
To repeat in a separate directory, run the native reference before the browser.

```powershell
$study = 'temp\doppelmaia-browser-budget-repeat'
& $python tools\doppelmaia\experiments\context_workflow.py $data $study --player Player14 --train 38637 --validation 5464 --epochs 6
if ($LASTEXITCODE -ne 0) { throw 'CUDA reference failed' }
$env:LC0_TEST_BROWSER = 'C:\Program Files\Google\Chrome\Application\chrome.exe'
node tools\doppelmaia\experiments\transformer_workflow.mjs $study
```

Keep large native and browser jobs serial. A larger run lost its browser while
an additional Chrome test also crashed. Earlier concurrent analysis raised
`MemoryError`. The first failure is retained, not counted as a finished run.
The isolated retry completed. Resource pressure is a likely explanation for
the first failure, not a proven diagnosis. Model capacity, system commit capacity
and available GPU resources all matter.

## Creative development screen

The next screen uses `creative_study.py` and `creative_targets.py`.
It leaves the frozen contextual trainer unchanged. `creative_parity.py`
compared the ordinary recipe with that trainer on 65 training rows and 32
novel validation rows. Two epochs made six CUDA updates, including a short
final batch. Both selected epoch two and the maximum selected parameter
difference was zero.

Seven recipes were fitted on Player07, Player14 and Player16, using the same
10,240 training positions per account. Every recipe sees the same 12,614 novel
validation positions, defined against the complete training pool. The settings
are batch 32, rate 0.00001, six epochs, patience two, seed 42 and base anchor
0.25 unless the recipe explicitly changes it. No test predictions are read.
Three weight averaging variants per account add nine checks without nine
additional fits.

| Recipe | Validation agreement | Validation CE |
| --- | ---: | ---: |
| Ordinary full history training | 60.7183% | 1.18281350 |
| Game balance | 60.9006% | 1.18202550 |
| Peer prior | 60.8530% | 1.18276461 |
| Choice distribution | 60.7737% | 1.18275148 |
| Phase anchor | 60.7579% | 1.18410941 |
| Phase balance | 60.7420% | 1.18370085 |
| Surprise weighting | 60.6231% | 1.18226120 |
| Two checkpoint mean | 60.7420% | 1.18301715 |
| Three checkpoint mean | 60.6548% | 1.18131024 |
| Base shrink | 60.2981% | 1.19630415 |

Game balancing uses inverse square root of the sampled positions per source
game, normalized to mean one. Phase balancing applies the same recipe to the
three phase counts. Surprise weights use the square root of the base move
surprisal clipped between 0.25 and 4, then normalized. The phase anchor is zero
in openings, 0.25 in middlegames and 0.75 on sparse boards.

The choice recipe mixes half the recorded label with half the training only
choice distribution for the same full board state, ignoring move counters.
The peer prior is 75% base plus 25% mean of the other five accounts' full history
weights. The target account never contributes to its own prior. This is not
Maia4All prototype enrichment.

The averaging checks use the two or three trained checkpoints with lowest
validation loss. Epoch zero remains eligible for ordinary checkpoint selection
but is not part of those trained checkpoint means. Base shrink uses 75% selected
weights and 25% original weights. A candidate is exported only when its loss
improves on the selected ordinary checkpoint. All scores are retained.

The completed screen and its original source snapshot are under
`temp\doppelmaia-creative-20261110\screen`. Game balancing improved agreement
slightly on all three accounts. The pooled gain is about 0.18 percentage point,
not a large or independently confirmed improvement. The three checkpoint mean
improves loss more than agreement. These findings do not establish a limit on
what a better method could learn.

The stronger equal game variant was added after the screen. It weights by the
inverse count, so every represented training game has equal total weight.
Its source belongs to a new study directory. Do not resume the old screen
using this changed source.

The followup uses all six accounts and every original training position.
It compares ordinary training, game balancing and equal game weighting with
up to twelve epochs and patience three. Ordinary fits also supply the checkpoint
averages. The new collector fixes archive rows after 72 million through
84 million, checks source identity and chronology, and keeps the same six
accounts without replacing inactive players. Freeze validation choices before
evaluating this later window. The known window must reproduce 13,348 matches
from the original 21,687 strict new positions.

```powershell
& $python -m unittest discover -s tools\doppelmaia\experiments -p 'creative_*test.py'
$env:PYTORCH_ALLOC_CONF = 'garbage_collection_threshold:0.2'
$data = 'temp\doppelmaia-unseen-v4\data\human-dataset.json'
$study = 'temp\doppelmaia-creative-repeat'
& $python tools\doppelmaia\experiments\creative_study.py $data temp\doppelmaia-unseen-v4\training "$study\followup" --players Player07 Player11 Player13 Player14 Player16 Player19 --methods baseline game-balance game-balance-strong --positions 50000 --epochs 12 --patience 3
if ($LASTEXITCODE -ne 0) { throw 'Development training failed' }
& $python tools\doppelmaia\experiments\creative_holdout.py temp\lichess-databases\lichess_db_standard_rated_2026-10.pgn.zst temp\doppelmaia-unseen-v4\data "$study\fresh"
if ($LASTEXITCODE -ne 0) { throw 'Fresh source collection failed' }
$previous = 'temp\doppelmaia-unseen-v4\evaluation-v2\frozen-selections.json'
& $python tools\doppelmaia\experiments\creative_evaluate.py freeze $data $previous "$study\followup" "$study\fresh\holdout.json" "$study\evaluation"
if ($LASTEXITCODE -ne 0) { throw 'Selection freeze failed' }
& $python tools\doppelmaia\experiments\creative_evaluate.py evaluate $data $previous "$study\followup" "$study\fresh\holdout.json" "$study\evaluation"
```

The screen, followup and final comparisons must stay distinct. Later board
novelty excludes all previously examined examples from the same account,
including the old test. It does not claim novelty against other accounts or
Maia pretraining. Intervals group predictions by original source game, not by
individual board. Keep large training, archive analysis and browser work serial.

## Completed full followup and later confirmation

All 18 full data fits and 18 averaging checks completed in
`temp\doppelmaia-creative-20261110\followup-v2`.
These share 17,129 novel validation positions.

| Recipe | Validation agreement | Validation CE |
| --- | ---: | ---: |
| Ordinary full history training | 61.2470% | 1.17407089 |
| Game balance | 61.1536% | 1.17371917 |
| Equal game weighting | 61.0602% | 1.17528740 |
| Two checkpoint mean | 61.0835% | 1.17146219 |
| Three checkpoint mean | 61.2996% | 1.17147475 |
| Base shrink | 60.4705% | 1.19576520 |

Game balancing did not retain its small screen agreement gain. Averaging
slightly improved cross entropy. The previous best models remain eligible
and include the earlier base anchor search, rather than only the 0.25 anchor
used by these new fits.

Frozen validation choices selected the two checkpoint mean for Player07,
the three checkpoint mean for Player16 and Player19, and the previous model
for Player11, Player13 and Player14. No game weighting recipe was selected.
The decisions were saved before either test comparison.

The earlier window exactly reproduced 13,348 correct predictions among
21,687 strict new boards. Its candidate gives 13,336 correct predictions.
This is a descriptive recheck of already examined data.

| Earlier test slice | Positions | Earlier model | Selected candidate |
| --- | ---: | ---: | ---: |
| Familiar opening | 4446 | 84.17% | 84.55% |
| New opening | 6008 | 61.92% | 61.80% |
| New middlegame | 14048 | 60.73% | 60.68% |
| New sparse | 1631 | 67.26% | 67.38% |
| All strict new | 21687 | 61.55% | 61.49% |

The fresh source collection reached exactly 84 million archive games.
Only rows after 72 million enter the later window. All six predefined
accounts supplied eligible games, with 23,853 sampled positions from
1,019 source games in total.

| Later test slice | Positions | Earlier model | Selected candidate |
| --- | ---: | ---: | ---: |
| Familiar opening | 4023 | 82.85% | 83.47% |
| New opening | 5585 | 62.06% | 61.92% |
| New middlegame | 12762 | 60.29% | 60.30% |
| New sparse | 1312 | 69.66% | 69.89% |
| All strict new | 19659 | 61.42% | 61.40% |

The strict new counts are 12,074 correct predictions before and 12,071 after.
The gain is 0.0153 percentage point lower, with a paired source game 95%
interval from 0.1472 lower to 0.1256 higher. CE changes from 1.16780455 to
1.16683976. There is no reliable unseen agreement improvement.
Familiar opening agreement rises by 0.6214 point, with an interval from
0.2463 to 1.0224. Phase intervals are descriptive and not adjusted for
multiple slices. They concern games from these six accounts and one seed.

A further 157 opening positions were seen in earlier nontraining data.
They belong to neither the familiar opening nor strict new opening row.
The three new phase rows partition strict new positions. Do not add familiar
openings to that total.

Do not change the browser defaults on this evidence. The new recipes remain
research implementations. Current full browser training stays unchanged.
The slight familiar opening gain does not justify presenting smoothing as
a solution to the unfamiliar middlegame problem.

The complete records are in `temp\doppelmaia-creative-20261110\evaluation`.
They include immutable selections, both prediction CSVs, paired summaries
and source snapshots. The original source PGNs and row indexes are in
`temp\doppelmaia-creative-20261110\fresh`. An independent audit reproduced
every slice count, source game count and correct prediction total, verified
both CSV hashes and rejected duplicate prediction identities.

The first followup failed while serializing an averaged model. Its exact
cause was not proven. The next run reached an explicit CPU allocation
failure while copying a Player14 checkpoint after ten complete fits.
Both attempts are retained. The successful continuation reclaimed unused
CUDA cache earlier with the process environment setting shown above.
It did not change operating system settings or terminate unrelated processes.

The trainer also clears retained gradients and unused device cache before
export. For Player07 this reduced reserved GPU memory from about 3.83 GB
to 1.24 GB. All three of that account's learning histories, ONNX hashes and
averaging scores matched the precleanup run exactly. The six update baseline
parity check also retained zero parameter difference with the allocator option.
Do not claim the memory change improves imitation or prevents every resource
failure on another machine.

The app comparison reuses the established application worker runner.
It reads the frozen candidate weights and checks every later strict new
prediction, with additional numeric probes at three Elo inputs and both colors.
Run its native preparation before its browser stage.

```powershell
$study = 'temp\doppelmaia-creative-20261110'
& $python tools\doppelmaia\experiments\creative_app_reference.py "$study\fresh\holdout.json" "$study\evaluation"
if ($LASTEXITCODE -ne 0) { throw 'App reference preparation failed' }
$env:LC0_TEST_BROWSER = 'C:\Program Files\Google\Chrome\Application\chrome.exe'
node tools\doppelmaia\experiments\finetune_browser.mjs "$study\evaluation"
```

That completed app check covers all six selected exports and all 19,659
later strict new positions. Every top move matches native inference.
Additional probes use both colors and three Elo inputs per model.
Maximum policy logit error is below 0.00057221, maximum value error is below 0.00004912,
and the largest per account mean CE difference is below 0.000000231.
The existing numerical tolerances were not relaxed. Reports and the executed
reference and browser sources are retained alongside the frozen comparison.
This checks inference of the same CUDA exports, not independent browser
training of the experimental averages.
