Skip to content

[skyrl-train] Add example for on-policy distillation#585

Merged
SumanthRH merged 19 commits intoNovaSky-AI:mainfrom
erictang000:on_policy_distillation
Nov 6, 2025
Merged

[skyrl-train] Add example for on-policy distillation#585
SumanthRH merged 19 commits intoNovaSky-AI:mainfrom
erictang000:on_policy_distillation

Conversation

@erictang000
Copy link
Collaborator

@erictang000 erictang000 commented Oct 27, 2025

Overview

Adds an example of extending the RayPPOTrainer to do on policy distillation by providing a custom apply_reward_kl_penalty function, a pass through advantage estimator, and using the importance_sampling loss function as detailed in the thinky blog.

distilling rl trained qwen3-4b-base (dapo recipe) back into qwen3-4b-base

image

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds an example for on-policy distillation, which is a great addition. The core logic change to support a separate reference model path is correct. I've added a few comments to the new example files:

  • In main_on_policy_distill.py, I've suggested a refactoring for clarity and a change to the loss calculation to improve training stability.
  • In run_on_policy_distill_math.sh, I've pointed out a misleading checkpoint path and a missing newline at the end of the file.
    Overall, the changes look good and the example is very helpful.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Copy link
Member

@tyler-griggs tyler-griggs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a README.md to this examples sub-directory with a brief overview of what is in this example and how to run it

erictang000 and others added 9 commits November 6, 2025 11:28
Added a README for On-Policy Distillation with usage instructions and references.
Added details about On-Policy Distillation and reverse KL loss in the README.
Updated README.md to enhance explanation of On-Policy Distillation and provide quickstart instructions.
@erictang000 erictang000 requested a review from SumanthRH November 6, 2025 20:22
@SumanthRH SumanthRH merged commit d6a866c into NovaSky-AI:main Nov 6, 2025
3 checks passed
li-boxuan pushed a commit to li-boxuan/SkyRL that referenced this pull request Nov 23, 2025
Adds an example of extending the `RayPPOTrainer` to do on policy
distillation by providing a custom `apply_reward_kl_penalty` function, a
pass through advantage estimator, and using the `importance_sampling`
loss function as detailed in the [thinky
blog](https://tinker-docs.thinkingmachines.ai/losses#policy-gradient-importance_sampling).

qwen3-4b-base
<img width="1108" height="580" alt="image"
src="https://github.com/user-attachments/assets/059dd495-3cdf-4df1-bf27-70e010e368e4"
/>

---------

Co-authored-by: Sumanth R Hegde <39546518+SumanthRH@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
dzorlu pushed a commit to fleet-ai/SkyRL that referenced this pull request Feb 4, 2026
# Overview
Adds an example of extending the `RayPPOTrainer` to do on policy
distillation by providing a custom `apply_reward_kl_penalty` function, a
pass through advantage estimator, and using the `importance_sampling`
loss function as detailed in the [thinky
blog](https://tinker-docs.thinkingmachines.ai/losses#policy-gradient-importance_sampling).

### distilling rl trained qwen3-4b-base (dapo recipe) back into
qwen3-4b-base
<img width="1108" height="580" alt="image"
src="https://github.com/user-attachments/assets/059dd495-3cdf-4df1-bf27-70e010e368e4"
/>

---------

Co-authored-by: Sumanth R Hegde <39546518+SumanthRH@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants