-
Notifications
You must be signed in to change notification settings - Fork 447
Soft distillation training support #2901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
9f395a9 to
4d91809
Compare
b1c786c to
de0349d
Compare
richjames0
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
NicoGrande
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
src/MaxText/configs/distillation.yml
Outdated
| tokenizer_path: "meta-llama/Llama-3.1-8B" | ||
| tokenizer_type: "huggingface" | ||
|
|
||
| # dataset_path: "gs://max-datasets-rogue" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove these commented lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| # 1. Setup Mesh | ||
| devices = jax.devices() | ||
| devices_array = maxtext_utils.create_device_mesh(student_config, devices) | ||
| mesh = jax.sharding.Mesh(devices_array, student_config.mesh_axes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is my understanding correct that both models will be collocated on the same Mesh? Will this need to be extended to disaggregated to work for different size student / teacher models for example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it's collocated setup on the same mesh, we can still run different model sizes on the same mesh with possibly different sharding.
disaggregated setup not yet planned / supported, we can extend in the future if needed.
Description
This PR introduces
train_distill.py, a new training script that implements a "Post-Pruning Recovery" distillation workflow by integrating the Tunix library with MaxText.Context & Problem Solved:
This script recovers model quality after structural pruning (e.g., reducing attention heads) by enabling a distillation process where a smaller, trainable Student model mimics the output distribution of a larger, frozen Teacher model on general data.
Key Implementation Details:
pyconfigwithstudent_overridesandteacher_overridesto support different architectures.TunixMaxTextAdapterto expose a standard interface compatible with the TunixDistillationTrainer.Run distillation
Tests
I have tested this script end-to-end on a TPU VM.
Verified that Student and Teacher models load with distinct configurations
Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.