[DO NOT REVIEW][NOT FOR LAND] on-policy distillation example #525
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.
Summary
This PR adds a new online distillation app that demonstrates how a smaller student model (Qwen3-1.7B) can learn from a larger teacher model (Qwen3-32B) via KL divergence on generated completions.
This is an example of online distillation where:
Key Components
Architecture:
StudentGenerator(vLLM): Generates completions from prompts using student modelStudentTrainer: Trains student model to match teacher distributionsTeacherModel(frozen): Provides target logprobs for distillationDatasetActor: Provides prompts (GSM8K)ReplayBuffer: Batches episodes for trainingLoss Function:
Implementation Details
Based on
apps/grpo/main.pywith key differences:RewardActorandComputeAdvantages(not needed for distillation)simple_grpo_losswithdistillation_loss(pure KL divergence)Episodedataclass (removedrewardandadvantagefields)policy→student_generator,ref_model→teacher_modelfor clarityFiles Added
apps/distillation/main.py: Main training loopapps/distillation/qwen3_distillation.yaml: Config for Qwen3-1.7B → Qwen3-32B distillationUsage
Test Plan
py_compilecc @wukaixingxp