Summary
When resuming a training run with DTensorPolicyWorkerV2 (policy.dtensor_cfg._v2: true), the reference policy is set after the resume checkpoint has been loaded into the model.
Lines
|
model_and_optimizer_state = setup_model_and_optimizer( |
|
config=config, |
|
tokenizer=self.tokenizer, |
|
runtime_config=runtime_config, |
|
distributed_context=distributed_context, |
|
checkpoint_manager=self.checkpoint_manager, |
|
is_vlm=self.is_vlm, |
|
init_optimizer=init_optimizer, |
|
weights_path=weights_path, |
|
optimizer_path=optimizer_path, |
|
) |
carry out the setup of the model, loading a checkpoint if
weights_path is provided.
Then, the reference model is set from that model in lines
|
# Initialize reference model if requested |
|
self.reference_model_state_dict = None |
|
if init_reference_model: |
|
self.reference_model_state_dict = setup_reference_model_state(self.model) |
This impacts training runs in GRPO with loss_fn.reference_policy_kl_penalty > 0, as the penalty will be computed w.r.t. the resumed checkpoint rather than the original policy.
Steps to reproduce
- GRPO training run with
policy.dtensor_cfg._v2: true and loss_fn.reference_policy_kl_penalty > 0.
- Train, checkpoint after a small number of steps (e.g. 10), resume from the checkopint
- Plot
train/kl_penalty
Expected behaviour
Reference model is set to original policy, not resumed checkpoint. Plotting train/kl_penalty should result in a continuous curve, like in v0.4.0.
Current behaviour
Plotting train/kl_penalty shows it reset to 0 after every resume.
Additional context
Looks like this is a regression, it could have been introduced with #1709.
Summary
When resuming a training run with DTensorPolicyWorkerV2 (
policy.dtensor_cfg._v2: true), the reference policy is set after the resume checkpoint has been loaded into the model.Lines
RL/nemo_rl/models/policy/workers/dtensor_policy_worker_v2.py
Lines 306 to 316 in 9b331d2
weights_pathis provided.Then, the reference model is set from that model in lines
RL/nemo_rl/models/policy/workers/dtensor_policy_worker_v2.py
Lines 332 to 335 in 9b331d2
This impacts training runs in GRPO with
loss_fn.reference_policy_kl_penalty > 0, as the penalty will be computed w.r.t. the resumed checkpoint rather than the original policy.Steps to reproduce
policy.dtensor_cfg._v2: trueandloss_fn.reference_policy_kl_penalty > 0.train/kl_penaltyExpected behaviour
Reference model is set to original policy, not resumed checkpoint. Plotting
train/kl_penaltyshould result in a continuous curve, like in v0.4.0.Current behaviour
Plotting
train/kl_penaltyshows it reset to 0 after every resume.Additional context
Looks like this is a regression, it could have been introduced with #1709.