feat(sc): add the teacher top-k forward for distillation on SingleController - #3843
feat(sc): add the teacher top-k forward for distillation on SingleController#3843tianyi-zhang-02 wants to merge 1 commit into
Conversation
e29ded9 to
36323f5
Compare
…troller
Distillation is the last algorithm with a rollout loop that SingleController
cannot run. Its teacher is a Policy, not a separate model class, so the
SingleController side needs no new driver -- only the missing top-k
entrypoint on the two layers every other forward already has:
- TQWorkerMixin.get_topk_logits_presharded: per-rank fetch -> forward ->
write-back. Unlike its siblings it writes back two tensors, and both
carry a third axis ([B, S, k]); the write-back validates only the batch
dimension, so that axis passes through unchanged.
- TQPolicy.get_topk_logits_from_meta: the 1-hop dispatch, reusing
LP_SEED_FIELDS because a teacher forward needs exactly what a logprob
forward needs.
Nothing calls these yet -- wiring the teacher into the train pump is a
follow-up. Splitting it out keeps this piece independently testable.
Signed-off-by: Tianyi Zhang <zhangtianyi975@gmail.com>
Signed-off-by: Tianyi Zhang <123608656+tianyi-zhang-02@users.noreply.github.com>
36323f5 to
7444636
Compare
|
#3768 landed while this was open, so worth saying up front how the two relate — they both put a teacher on SingleController and they are not the same thing. #3768 (MOPD): several teachers, each on its own reserved nodes ( This stack: one frozen teacher, sharing the training GPUs as a second worker group and offloaded between forwards. Its top-k logits feed So: different signal, different resource model, different objective. Both entrypoints now sit next to each other in Rebased onto #3768. One real fix fell out of it: its new validation reads The one thing I would like a steer on: #3768 established |
|
Duplicate flag, found while sweeping the open PRs. @pthombre's #2580 ("feat(distillation): add TransferQueue support for On-Policy Distillation") already adds That PR is much larger (it also adds the write-back dispatcher, payload sizing and transport metrics), has been open since 2026-05-27, last touched 2026-06-26, and is CONFLICTING against I've asked there whether it's being picked back up. If it is, I'll close this — no reason to have two. Flagging it here so a reviewer doesn't find the collision cold. |
What does this PR do?
Adds the teacher top-k forward primitive needed by distillation on SingleController:
TQWorkerMixin.get_topk_logits_preshardedruns the rank-local forward and writes both top-k tensors back to TransferQueue.TQPolicy.get_topk_logits_from_metadispatches that work from the driver.[B, S, k]shape, leader-only write-back, and batch-size validation.This is the first PR in the #3843 → #3846 → #3849 stack. Nothing calls the new entry point until #3846.
Ownership
#2580 already contains the same
get_topk_logits_preshardedentry point and the sameteacher_topk_logits/teacher_topk_indicescolumns as part of a larger TQ distillation implementation. That PR is still open, so ownership is unresolved. I am holding this stack here and will not add more downstream work until the maintainers choose which direction to keep.Validation
744463629719d1e33d49d85ff5f959ac1c4865de.907606048aa8c950027dbc199bff1495035e862cpassed 765 unit/config cases (6 GPU-only skips) and a real 2-GPU teacher/student checkpoint-restore run.This base branch is intentionally not being presented as current-main-ready while #2580 ownership remains unresolved; the two downstream branches are kept tested, but no further stack is being built on it.