Skip to content

fix(megatron): defer full-vocabulary GKD teacher logits to forward_step - #10276

Open
FOWEPJF255 wants to merge 2 commits into
modelscope:mainfrom
FOWEPJF255:fix/gkd-defer-full-vocab-teacher-logits-10097
Open

FOWEPJF255 wants to merge 2 commits into
modelscope:mainfrom
FOWEPJF255:fix/gkd-defer-full-vocab-teacher-logits-10097

Conversation

@FOWEPJF255

Copy link
Copy Markdown

Summary

  • When gkd_logits_topk is unset, defer local teacher full-vocabulary logits to forward_step so only one [S, V] tensor is alive per micro-batch instead of one per rollout batch during preparation.
  • Extract _compute_teacher_output_local for single-micro-batch teacher forwards; keep top-k teacher outputs eager at batch prep (small tensors).
  • Add regression tests for defer vs eager paths and JIT computation in forward_step.

Fixes #10097

Test plan

  • python -m pytest tests/megatron/test_gkd_teacher_logits_defer.py -q (3 passed locally; skips when megatron-core/transformers are unavailable)
  • Megatron GKD full-vocab training smoke on GPU (maintainer/CI)

Made with Cursor

When gkd_logits_topk is unset, materialize local teacher [S, V] logits
just-in-time per micro-batch instead of retaining one tensor per rollout
batch during preparation. Top-k teacher outputs stay eager. Fixes modelscope#10097.

Co-authored-by: Cursor <cursoragent@cursor.com>
@FOWEPJF255

Copy link
Copy Markdown
Author

CI note: fork PR workflows show action_required (citest / Lint test / citest-npu). This is the upstream approval gate for first-time fork contributors -- not a code failure. Please approve workflow runs when convenient so checks can execute.

Local: pytest tests/megatron/test_gkd_teacher_logits_defer.py -q (3 passed).

Co-authored-by: Cursor <cursoragent@cursor.com>
@FOWEPJF255

Copy link
Copy Markdown
Author

Pushed \dd247d4: fix isort blank line in \ ests/megatron/test_gkd_teacher_logits_defer.py\ (Lint test failed on isort auto-fix). Local isort check + pytest for that file pass. Fork workflows may still show \�ction_required\ until upstream approves.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(gkd): defer full-vocabulary local teacher logits to forward_step

2 participants