Repository navigation
fix(dtensor-v2): keep the KL reference anchored to base weights across resumes - #3722
Conversation
…s resumes setup_model_and_optimizer restores weights_path internally, so capturing the reference model from its output re-anchors the KL reference to the resumed step on every resume instead of the original base policy. Each resume then grants a fresh KL drift budget, defeating the anchor over multi-window runs. When a reference model is needed on a resumed run, defer the checkpoint load: build the model from the pristine base weights first, capture the reference from that, then load the checkpoint. (cherry picked from commit f186c3b) Signed-off-by: Yuekai Zhang <[email protected]>
|
/ok to test 79c519e |
yuekaizhang
left a comment
There was a problem hiding this comment.
Self-review via the team-review skill (5 agents: rl-expert, bug-finder, test-agent, design-reviewer, devil's advocate), per the new self-review-before-human-review process.
Summary: the fix itself was verified correct and necessary — deferred load is kwarg-identical to the internal one, setup_reference_model_state copies to pinned CPU memory (no aliasing), ordering matches the v1 worker's existing semantics, and the megatron/value workers are unaffected. Devil's advocate: 2 findings confirmed, 3 downgraded, 0 disputed. Linters (pre-commit on the changed file): pass. All actionable findings are inline below.
Generated by Claude Code
- Log an explicit note when the checkpoint load is deferred for KL reference capture, since setup_model_and_optimizer otherwise prints a misleading 'No weights path provided ... default policy init' line on every KL-anchored resume; also use bool(weights_path) to match the truthiness guard inside setup_model_and_optimizer. - Add mock-based unit tests pinning the deferred-load contract: base weights used for setup, reference captured before load_checkpoint, checkpoint loaded with the original paths, and pass-through/fresh-run negative cases. Signed-off-by: Yuekai Zhang <[email protected]>
|
/ok to test 358a19d |
yuki-97
left a comment
There was a problem hiding this comment.
thanks for adding this, feels this is a feature rather than a fix, left some comments.
…est mocks - Deferred path now delegates to the worker's own load_checkpoint() instead of duplicating the five checkpoint-manager kwargs, matching how the v1 worker loads on resume. - Test mocks construct RuntimeConfig and ModelAndOptimizerState by keyword instead of bare positional tuples, so a field addition or reorder fails here with a named error rather than a silent swap. Signed-off-by: Yuekai Zhang <[email protected]>
|
/ok to test 198064f |
…_base_weights Per review, the deferred checkpoint load is now opt-in: - New optional policy config bool ref_model_from_base_weights (default false). False keeps the existing behavior — on resume the reference is captured from the restored checkpoint weights. True anchors the KL reference to the pristine base (model_name) weights across resumes. - Documented in PolicyConfig, grpo_math_1B exemplar, and the matching reference config for the v1->v2 migration check. - Tests updated: the deferred-load test opts in; a new test pins the default checkpoint-anchored behavior. Signed-off-by: Yuekai Zhang <[email protected]>
|
/ok to test e18d99a |
…oss resume Three runs share one TRAIN_CMD (Qwen3-0.6B, 2 GPUs, 3 GRPO steps): an uninterrupted baseline that checkpoints step_2, a default resume, and a flag-on resume, each resuming from its own copy of step_2. Asserts the deferred-load log line only appears with the flag on, and on step-3 train/kl_penalty: the default resume collapses to the noise floor (reference re-anchored to the checkpoint) while the flag-on resume stays continuous with the baseline (reference still on base weights). Verified locally on 2xH100: baseline 9.4e-2, default resume 3.7e-3, flag-on resume 1.1e-1. Registered in L1 AutoModel. Signed-off-by: Yuekai Zhang <[email protected]>
|
/ok to test 0eaa949 |
|
/ok to test 25bfb18 |
…config flag Per review discussion this is a bug fix, not an opt-in feature: on a resumed run that needs a reference model, the v2 worker now always defers the NeMo RL checkpoint load, captures the KL reference from the pristine base (model_name) weights, then loads the checkpoint — the ordering the v1 worker already had. Removes the ref_model_from_base_weights config knob from PolicyConfig and the exemplar/reference YAMLs, and simplifies the functional test to a baseline-vs-resume KL continuity check (verified locally: baseline 9.9e-2, resume 1.1e-1 at the resume-boundary step). Signed-off-by: Yuekai Zhang <[email protected]>
|
/ok to test 58b7886 |
❌ Submodule Fast-Forward Check FailedCheck based on commit: 58b7886 (PR #3722 from ❌ Submodules that need attention:Gym: ❌ PR branch is BEHIND main branch Please ensure all submodule commits are fast-forwards of the main branch before merging. |
❌ Submodule Fast-Forward Check FailedCheck based on commit: a2bbe61 (PR #3722 from ❌ Submodules that need attention:Gym: ❌ PR branch is BEHIND main branch Please ensure all submodule commits are fast-forwards of the main branch before merging. |
The Gym gitlink was bumped to bb9b26de by accident in 58b7886 (a dirty local submodule checkout swept up by git add -u); this PR does not touch Gym. Restore the pointer to c3bac963 as recorded on main. Signed-off-by: Yuekai Zhang <[email protected]>
|
/ok to test 5faea40 |
What does this PR do?
Cherry-pick of f186c3b from #3643 (which was merged into the
muse-glimmer-supportbranch, notmain) so the fix lands onmain.In
dtensor_policy_worker_v2,setup_model_and_optimizerrestoresweights_pathinternally, so capturing the reference model from its output re-anchors the KL reference to the resumed step on every resume instead of the original base policy. Each resume then grants the policy a fresh KL drift budget, defeating the anchor over multi-window runs.Fix: when a reference model is needed on a resumed run, defer the NeMo RL checkpoint load — build the model from the pristine base weights first, capture the reference from that, then load the checkpoint. This matches the ordering already used by the v1
dtensor_policy_worker(reference captured beforeload_checkpoint).Issues
Regression introduced in the v2 worker refactor; v1 worker is unaffected.