Implementation for soft offline distillation using saved top-k teacher logits#3382
Merged
copybara-service[bot] merged 9 commits intomainfrom Mar 20, 2026
Merged
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
entrpn
reviewed
Mar 11, 2026
vlad-karp
requested changes
Mar 12, 2026
Collaborator
vlad-karp
left a comment
There was a problem hiding this comment.
LGTM overall
need a new unit test for this specific path
Collaborator
Author
|
Added unit tests to make sure that in offline mode, only the student model is loaded, while in online mode, both the student and teacher models are loaded. Below are the commands I used to run each of the unit tests: Test offline distillation:
Test online distillation:
|
vlad-karp
approved these changes
Mar 13, 2026
entrpn
approved these changes
Mar 19, 2026
…a_dir to know when to run offfline vs online distillation
…ing the correct models
44c0cf6 to
beb19b9
Compare
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.
Description
This PR introduces an end-to-end offline distillation training pipeline. Previously, the distillation loop executed in an "online" mode, which required both the frozen Teacher model and the learning Student model to be loaded and executed simultaneously during training. This change allows the trainer to load pre-computed, top-K Teacher logits from .array_record files, which allows us to bybass the forward pass for the teacher model during the training loop.
Tests
Tested this code change by running the following command (using Yaml File for Offline Distillation)
python3 src/maxtext/trainers/post_train/distillation/train_distill.py src/maxtext/configs/post_train/distillation.yml steps=100 tokenizer_path="/mnt/ajkv/disks/codebase/maxtext/src/maxtext/assets/tokenizers/tokenizer_llama3.tiktoken"Truncated output showing the successful run: https://paste.googleplex.com/4879271282737152.
Verified that the training happened successfully and finished the distillation run.
Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.