new feature: On policy distillation#344
Open
sfc-gh-thonguyen wants to merge 7 commits into
Open
Conversation
Collaborator
There was a problem hiding this comment.
This file should probably be with the trainer code. config/ is for base config classes
Comment on lines
+354
to
+377
| def step(self, batch: Dict[str, torch.Tensor]) -> None: | ||
| """Execute a single training step. | ||
|
|
||
| Overrides the base step to handle the unique requirements of | ||
| on-policy distillation (generation + training). | ||
| """ | ||
| self.model.train() | ||
|
|
||
| loss = self.loss(batch) | ||
|
|
||
| self.backward(loss) | ||
|
|
||
| def maybe_item(v): | ||
| return v.item() if torch.is_tensor(v) else v | ||
|
|
||
| self.metrics.record("loss", maybe_item(loss)) | ||
|
|
||
| self.model.step() | ||
|
|
||
| self.checkpoint() | ||
|
|
||
| # Update step counters | ||
| self.global_step = self.model.global_steps | ||
| self.global_step_this_run = self.global_step - self.global_step_at_start_this_run |
Collaborator
There was a problem hiding this comment.
This appears to be an exact copy of the step method in the base trainer class. Why do we redefine it here?
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.
Based on this blog post https://thinkingmachines.ai/blog/on-policy-distillation/ -- figured Arctic Training would be an appropriate place to have this feature.
Training validated with GSM8K dataset on Qwen3-1.7B model using Qwen3-8B teacher.


Lower teacher perplexity means teacher is less surprised by the student's answer. Higher teacher logprob means teacher agrees with the student's answer.
Lower reverse KL means student's answers converge to teacher's.
Student's perplexity initially jumped up, meaning it's learning, and slowly ramped down, meaning it's getting more confident along the training progress.
Full dashboard: https://snowflake.wandb.io/thongnguyen/on-policy-distillation-gsm8k/runs/zuwzrd11?nw=nwuserthongnguyen
Once this PR is in we can make the claim ArcticTraining supports RL :)