Skip to main content
Every distillation algorithm on Whitney shares one mechanism: a single run’s sampler only ever serves its own current weights, so a genuine frozen teacher needs a second Whitney run — synced once, and never trained — answering logprobs on the student’s own generated tokens. There is no external reward; the training signal is purely how much the teacher would have preferred the student’s own choices.

The two-run loop

  1. Create the student session/run as usual (see Quickstart).
  2. Create a second session/run for the teacher — same model for OPSD/SDPO, a different (typically larger) model for OPD.
  3. Sync the teacher’s sampler exactly once with save_weights_for_sampler. Never call optim_step on the teacher run again — it is a frozen reference for the rest of the loop.
  4. Each cycle: sample from the student, then ask the teacher for logprobs on the student’s exact generated tokens (prompt-conditioned differently per algorithm — see each page).
  5. Build the loss from teacher_logprob - student_logprob per completion token, forward_backward and optim_step the student only.
  6. save_state / export_lora / finish / close both sessions.
Fetching one sequence’s teacher logprobs, conditioned on whatever demonstration or feedback prompt your algorithm prepends:
On failure or interruption: cancel both runs, poll each to terminal, then close both sessions. Never mix teacher and student weight versions on the same sampler without explicit versioning. Distillation loops build on the same datum and advantage helpers as every other algorithm — rl_datum() and forward_backward_payload() in particular.