Repository navigation
Conversation
ucalyptus
force-pushed
the
sdft-dopd-routing
branch
2 times, most recently
from
October 13, 2026 00:00
e3088a7 to
495c84a
Compare
ucalyptus
marked this pull request as ready for review
October 13, 2026 00:03
4 of 5 tasks
Adds `distillation_mode="dopd"`, following DOPD (Dual On-Policy Distillation, https://huggingface.co/papers/2606.30626). Each completion token routes into one of four regimes by advantage gap and confidence: light top-k reverse KL toward the teacher, weak stop-gradient self-regularization, full-vocabulary JSD toward the teacher, or a light stop-gradient privileged-student consistency nudge. Routing measures the gap between the privileged teacher and the privileged student (the student's no-grad forward on the same privileged context); using the bare-prompt student instead conflates the capability gap with the information gap and inverts regime selection. `teacher_model_kind="live"` is rejected in this mode, because both policies would hold the same weights and the high-gap regimes would be unreachable.
ucalyptus
force-pushed
the
sdft-dopd-routing
branch
from
October 13, 2026 01:08
495c84a to
162fa1f
Compare
ucalyptus
added a commit
to ucalyptus/trl
that referenced
this pull request
Oct 13, 2026
The combined branch: DOPD advantage-gap routing, the distillation plumbing (kl_clip, teacher top-k support, teacher chat-template kwargs with untruncated teacher tokenization, QLoRA, EMA teacher adapter pre-registration, parallelism rejection), and the cross-rank metric averaging fix, with the config validation and tests for each. Split into huggingface#7654 (metric), huggingface#7655 (plumbing), and huggingface#7656 (DOPD) for review. The PEFT + ZeRO-3 guard that this branch also carried was dropped: it rejected a combination that is known to work, and huggingface#6829 owns that fix.
This branch has not been deployed
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.
Split out of #6237.
Adds
distillation_mode="dopd"to SDFTTrainer, following DOPD (Dual On-Policy Distillation, https://huggingface.co/papers/2606.30626). Each completion token routes into one of four regimes, chosen from the advantage gap and each side's confidence:Tokens where the gap is high but neither side is confident fall back to the weakest term, matching the paper's intent that ambiguous tokens get the smallest update.
Routing measures the gap between the privileged teacher and the privileged student, which is the student's own no-grad forward on the same privileged context. Using the bare-prompt student instead mixes the capability gap with the information-asymmetry gap and inverts regime selection; the code comments call this out where it matters.
teacher_model_kind="live"is rejected with this mode. The teacher and the privileged student would hold the same weights on the same input, the gap would collapse to zero, and the two high-gap regimes would be unreachable.use_teacher_server=Trueis rejected for the same reason asfull_logits: the server returns top-k logprobs only, and the routing needs full logits for the confidence and gap terms.Note on
topk_supportcompute_topk_self_distillation_lossgains atopk_supportparameter here, because the DOPD loss mixes a teacher-support regime with two student-support regimes. #7655 adds the same parameter, along with the config field, the teacher-server alignment, and tests for it. If #7655 merges first, I will rebase and this hunk disappears, leaving only the routing code.Tests
CPU, hand-built logits, no model or GPU:
test_dopd_routing.pychecks that each row lands in its expected regime, that the four regime masks are mutually exclusive and exhaustive, that regimes 2 and 4 anchor on the privileged student rather than the bare student (a bare anchor makes the term identically zero, in value and in gradient), and that every regime backprops a nonzero gradient into the student.Note
Medium Risk
Changes the SDFT training loss path and adds a multi-regime objective with new hyperparameters; default
distillation_modestaystopk_logits, but DOPD needs an extra privileged forward per step and rejects some teacher/vLLM setups.Overview
Adds DOPD (Dual On-Policy Distillation) to experimental SDFT via
distillation_mode="dopd", so each completion token gets a different distillation objective instead of one global mode.Routing uses the advantage gap between the privileged teacher and a privileged-student forward (same weights, teacher prompt,
no_grad) plus per-side confidence. Four regimes: light teacher top-k KL, weak self-reg against stop-gradient privileged student, full-vocab JSD, or light student-consistency; ambiguous high-gap tokens fall back to self-reg.Config adds
distillation_dopd_*thresholds/weights;teacher_model_kind="live"anduse_teacher_server=Trueare rejected for DOPD (gap collapse / no full logits).compute_topk_self_distillation_lossgains optionaltopk_support("student"vs"teacher") for mixed DOPD regimes.Tests (
test_dopd_routing.py) cover regime selection, privileged-vs-bare gap, gradients, and config validation. Docs updated insdft_trainer.mdandpaper_index.md.Reviewed by Cursor Bugbot for commit c30e622. Bugbot is set up for automated code reviews on this repo. Configure here.