← All experiments THE RESEARCH RECORD / partition-kv-scoping

Partition-scoped KV cache

Can the CUDA trainer size its KV cache to the largest partition group rather than the whole trie file, so that --partition-depth reduces peak memory enough to train the full d=16 global trie in one super-epoch?

infrastructureconcludedn/an/aeval: none
Opened Updated
THE ANSWER SO FAR

Not answered. Phase 1 only reported the achievable savings: for the largest d=16 per-subtree file with bigram partitions, peak KV would fall from 1295.7 MB to 161.7 MB (8.0x). Phase 2 (scoped allocation, index remap, ancestor mini-forward) was planned but never built. The branch has no commits after 2026-04-22.

d=16 largest per-subtree file (rc=2), whole-file allocation 1295.7 peak KV cache MB (Phase 1 stats) pre-loss-fixpre-race-fix
same file, scoped to largest bigram partition group (projected) 161.7 peak KV cache MB (Phase 1 stats) pre-loss-fixpre-race-fix
TOPICS
RELATED
SUPERSEDED BY
CODE
THE FULL RECORD

Experiment notes

Open directory on GitHub ↗

Partition-scoped KV cache

The CUDA trainer sizes its KV cache for a whole trie file, even when --partition-depth splits the file into groups that train one after another. At d=16 the global trie needs about 9.5 GB of KV and does not fit. This branch planned to size the cache to the largest partition group instead. Each group would get a CPU-side global_to_local index remap and an ancestor mini-forward, with no kernel changes. Only Phase 1 was built: a --partition-kv-scoped flag that prints the achievable savings and does not change behaviour. For the largest d=16 per-subtree file with bigram groups it reported peak KV of 1295.7 MB unscoped vs 161.7 MB scoped (8.0x). Phase 2 (the scoped allocation, remap, mini-forward, a parity test and the d=16 global run) is fully specified in the plan but was never implemented.

Code: branch agpt-partition-kv-scoping, tag exp/partition-kv-scoping. Key files are notes/agpt/partition-kv-scoping-plan.md (the full Phase 2 plan) and src/cuda/agpt_train.cu (Phase 1 stats, commit 48ee729).