Conversation
Extract the slice/prepare/cat stitch so TrainStack and UnifiedModelTrainStack cannot drift as the anchor contract evolves. Each stack still builds its own plan.
chi030303
requested review from
Ideny42,
haonan3,
leviking98z-rgb and
zzhuoxin1508
as code owners
September 20, 2026 08:39
This branch has not been deployed
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
TrainStackandUnifiedModelTrainStackboth froze π_old by slicing planned micros, callingalgorithm.prepare_segment, rejecting a missinganchor_fieldstensor, then concatenating in plan order. That stitch now lives in one helper next to_validate_anchor_contract. Each stack still builds its ownmicro_slices(Planvs_optimizer_step_slices).old_logp_source=rollout, packed concat order, and the single-micro / non-recompute fast paths are unchanged.Related Issue
Closes #439
Test Plan
python -m py_compile unirl/train/stack/base.py unirl/train/unified_model_stack.py— passtests/): multiple micros with non-uniform packed lengths, token-budget planner concat order,num_updates_per_batch>1, missing declared field,old_logp_source=rolloutwhole-shard,TrainStackandUnifiedModelTrainStack— 6/6 passedCompatibility / Risk
No config, checkpoint, data format, or public API changes. Unified missing-field errors now say "a micro produced None" instead of "a micro-slice produced None"; the stack prefix is unchanged.
Reviewer Notes
Proposed on #439 before opening this PR. No overlapping open PR touches this stitch (
#476editseval_trackonly). AI-assisted implementation; I reviewed the diff. Follow-up commitcd2cbc2is ruff-format only (error string on one line).Checklist