Repository navigation
[BREAKING, perf] Compact controller state with partition-local rows - #248
Closed
ji-huazhong wants to merge 1 commit into
Closed
ji-huazhong wants to merge 1 commit into
ji-huazhong wants to merge 1 commit into
Conversation
Signed-off-by: ji-huazhong <hzji210@gmail.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem and implementation
The Python controller indexes each partition's production and consumption tensors by global sample index. A partition containing only 4,096 samples starting at index 1,000,000 therefore allocates more than a million rows. Multiple partitions duplicate these unused rows, and partition statistics scan them.
Store those tensors in partition-local rows, reuse cleared slots, and cache sorted global-index/row lookups until partition membership changes. Queries and updates translate global indexes at the boundary. Sampling order, KV keys, global-indexed query results, and SimpleStorage payload routing are preserved. Reserved rows and consumption retained by
clear_consumption=Falsekeep their existing semantics. Explicit global-indexed status views materialize dense tensors when needed.Breaking change: Python checkpoint format
Python controller checkpoints now use format version 2. Convert existing unversioned checkpoints before loading them:
The converter preserves the original directory, copies storage files unchanged, retains reserved rows and historical consumption, and validates the converted checkpoint before publishing the destination. Load the result with
tq.load_checkpointas usual.Rust already stores partition-local rows. Its checkpoint format is unchanged; its Python snapshot adapter now constructs the compact representation. The converter does not convert between controller backends.
Performance
CPU microbenchmarks against
ffde754, with 4,096 samples, 16 fields and two consumer tasks, using one Torch thread and warmed query caches:For 64 partitions of 1,024 samples each, measured state storage falls from 38,338,560 to 7,480,576 bytes (80.5% less), including the new row maps, free lists and cached index tensor data. This measures those structures, not process RSS, and excludes small tensor/cache wrapper overhead. Dense single-partition workloads retain the same state tensor size and add mapping/cache memory. These measurements do not imply the same speedup for end-to-end training.
Validation
critic/score/mean: 0.7144; last-five-step mean: 0.6334. This is a training regression run, not evidence of a quality improvement.