[codex] compact training sample transport payloads#2809
Open
samsja wants to merge 1 commit into
Open
Conversation
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.
Summary
Stacked on #2807. This continues the train-trace memory work by compacting the remaining trainer-bound
TrainingSamplelist payloads at the orchestrator/train transport boundary.What changed
PackedArrayfields toTrainingSamplefor byte-backed token IDs, masks, logprobs, per-token temperatures, teacher logprobs, andmm_token_type_ids.prime_rl.transport.compacthelpers to compact samples before send, read compact lengths without inflation, and inflate only when preparing selected trainer microbatches.batch.samplesimmediately after optional teacher logprobs and immediately beforeTrainingBatchsend.prepare_sampleto read either legacy lists or packed arrays.MultiPackervalidation/token-budget accounting to use compact lengths so buffered samples do not inflate just to schedule packing.Synthetic Size Check
Single synthetic
TrainingSamplewith30ktokens (15kprompt +15kcompletion), scalar completion temperature, no R3 bytes:315,075bytes ->183,882bytes (58.36%of previous)2,643,088bytes ->184,943bytes (7.00%of previous)Validation
uv run pytest tests/unit/orchestrator/test_batch.py tests/unit/train/rl/test_packer_compact.py-> 15 passeduv run pytest tests/unit/orchestrator tests/unit/train/rl/test_packer_compact.py-> 89 passeduv run ruff check src/prime_rl/transport/types.py src/prime_rl/transport/compact.py src/prime_rl/trainer/batch.py src/prime_rl/trainer/rl/packer.py src/prime_rl/orchestrator/orchestrator.py tests/unit/orchestrator/test_batch.py tests/unit/train/rl/test_packer_compact.py-> passeduv run ruff format --check src/prime_rl/transport/types.py src/prime_rl/transport/compact.py src/prime_rl/trainer/batch.py src/prime_rl/trainer/rl/packer.py src/prime_rl/orchestrator/orchestrator.py tests/unit/orchestrator/test_batch.py tests/unit/train/rl/test_packer_compact.py-> passedgit diff --check-> passedNote
Medium Risk
Changes the hot orchestrator→trainer data path for all training samples; behavior is covered by roundtrip and packer tests and legacy list fields remain supported via accessors.
Overview
Shrinks orchestrator→trainer msgpack traffic and in-process memory by replacing large per-sample Python lists with byte-backed
PackedArrayfields onTrainingSample, compacting immediately beforeTrainingBatchsend (after optional teacher logprobs).Adds
prime_rl.transport.compactto pack/unpack token IDs, masks, logprobs, temperatures, teacher logprobs, andmm_token_type_ids, expose lengths without inflating lists, and inflate only inprepare_samplewhen building microbatches.MultiPackervalidation and token budgeting use those length helpers so buffered compact samples are not expanded just for scheduling.Reviewed by Cursor Bugbot for commit b0ea1f9. Bugbot is set up for automated code reviews on this repo. Configure here.