refactor(trainer): separate lifecycle and loop programs - #25
Draft
leviking98z-rgb wants to merge 1 commit into
Draft
refactor(trainer): separate lifecycle and loop programs#25leviking98z-rgb wants to merge 1 commit into
leviking98z-rgb wants to merge 1 commit into
Conversation
This was referenced Jul 31, 2026
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
Separates trainer lifecycle and outer-loop policy from model/domain wiring.
LoopSpec/LoopState, an orderedTrainerLifecycle, and three explicit program families:BatchRLProgram,AgenticRLProgram, andSFTProgram.LoopKindselect the program centrally. OnlyBaseTrainerand the intentionally distinctSFTTrainernow definetrain().This is stacked on fork Draft PR #24 (
refactor/execution-plan-capabilities).Related Issue
N/A
Test Plan
pre-commit run --all-files— all hooks passed, including recipe targets, architecture boundaries, and framework contracts.python lint/check_framework_contracts.py—7 rollout engines, 6 weight syncs, 19 model pipelines, 2 train backends, 2 wire types, 4 loop programs, 13 entrypoints conform.python -m compileall -q unirl/trainer unirl/config/execution.py— passed.python - <<'PY'and not committed per repository policy:Compatibility / Risk
save_modedefaults remainfullfor async AR/agentic andautoelsewhere throughDEFAULT_SAVE_MODE.train()completion now consistently shuts down trainer-owned rollout engines and theDevicePool; shutdown is idempotent for the AR signal-handler path.AsyncRolloutSchedulerwith engine-owned async contracts and overlaps the async trainer files. If it lands first, this branch should be rebased by adaptingBatchRLProgram.run_asyncandAgenticRLProgram.run_asyncto itsquiescecontract.Reviewer Notes
BaseTrainertemplate and explicitly leaves PE, unified, SFT, async, and agentic follow-ups. This branch is the broader program-family design rather than a duplicate.TrainerLifecyclegeneralizes that rule across every program family.Checklist