Skip to content

DTensorPolicyWorkerV2 sets reference policy from resumed weights on restart #2955

Description

@tommasobonomo

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

  1. GRPO training run with policy.dtensor_cfg._v2: true and loss_fn.reference_policy_kl_penalty > 0.
  2. Train, checkpoint after a small number of steps (e.g. 10), resume from the checkopint
  3. 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.

Image

Current behaviour

Plotting train/kl_penalty shows it reset to 0 after every resume.

Image

Additional context

Looks like this is a regression, it could have been introduced with #1709.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions