OPD: on-policy distillation
On-policy distillation trains a student on its own responses, scored by a frozen teacher.
What it trains #
The student's weights. Each report references one receipt with an empty teacher_context:
{"references": ["<inference receipt>"], "metadata": {"teacher_context": ""}}The teacher scores the student's exact token IDs; the opd loss is the sampled-token reverse KL, once per batch. Scores do not enter it.
When to use it #
When a better model can score the student and you have prompts without answers. For demonstrations, use SDFT.
Requirements #
-
Slime (Train model weights); the example needs eight 80 GB GPUs.
-
A teacher engine (the teacher section: a frozen SGLang model on its own GPUs with the student's tokenizer, and rollout-temperature 1), or a teacher checkpoint (opd-teacher-checkpoint) with the student's architecture, parallel layout and token IDs.
-
Sequences that fit the teacher's context. A scoring failure stops training before the step.
Run the example #
Prepare the models, chat template and dataset as the math example says, then:
export OPD_MODEL_PATH=/work/models/Qwen3-8B-Base-SFT
export OPD_TEACHER_PATH=/work/models/Qwen3-32B
export OPD_RUN_DIR=/work/opd
recipes/opd/examples/math/run.shIt distils Qwen3-32B into a Qwen3-8B-Base student, and writes scores to $OPD_RUN_DIR/results.
Configuration #
-
teacher.model-path and teacher.num-gpus (its tensor parallel size), with opd-teacher: separate.
-
pipeline.sample2job.config.job_samples: Slime's global-batch-size. Sample after the new artifact serves.
-
training.options: the opd-* flags; the recipe README describes opd-advantage-clip.
Results #
55 updates: AIME'24 accuracy goes from 41.0% to 52.1%; the teacher scores 80.2% (results).