Self-distillation with an EMA teacher at scale: ZeRO-3 + PEFT [P]
Self-distillation methods usually rely on an Exponential Moving Average (EMA) teacher to get synced and stable critics. However, this doesn't scale well for large models since holding both teacher and student (trained) on GPU increases latency, ZeRO-3 communication, etc.
We can mitigate this with LoRA finetuning: the backbone is shared and frozen, and we need to maintain two light adapters: one for the student (trained) and one for the teacher (EMA of the student adapter).
Getting this to work cleanly under TRL and ZeRO-3 took some fixes, so I packaged it as a plug-and-play repo.
What it supports
- robust SDFT implementation that runs under ZeRO-3
- ZeRO-3 + LoRA integration with adapter switching for teacher/student passes
- Saving and resuming EMA teacher checkpoint
- working deepspeed configs that fix memory spikes when GPU memory is tight
I tested on Qwen3.5 and ToolAlpaca.
Repo: https://github.com/ifiaposto/sdft_zero3
Feedback / more examples / issues welcome!
Comments
No comments yet. Start the discussion.