Repository navigation
Build the SDFT and SDPO teacher with the student's dtype and attention implementation - #7616
Conversation
β¦n implementation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
βΉοΈ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with π while any review is running, comments if it has suggestions, and reacts with π once all reviews finish with no findings. |
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
|
@qgallouedec, #6829 fixes a different branch of this teacher setup. This PR corrects dtype and attention settings when loading a separate teacher. The pure-LoRA EMA branch instead shares the student model and returns before that loading code. #6829 creates the teacher adapter before ZeRO-3 preparation, clones gathered student adapter state, and gathers teacher parameters while writing EMA updates. Those changes are not covered by the separate-teacher loading fix here. The current #6829 head, |
Follow-up to #7597, as suggested in #7597 (review).
SDFT and SDPO build their teacher from the student's path, like the GRPO/DPO reference model. With a student passed as an instance,
model_init_kwargsis empty, so the teacher loads in fp32 with the default attention whatever the student uses. This applies to the"base"and"ema"teachers (the SDFT and SDPO defaults). Same twosetdefaultlines as #7597.Unlike GRPO, both took
args.model_init_kwargsby reference, sosetdefaultwould write the dtype into the user's config. I took GRPO's copy line too.New test in each trainer: a bf16, eager-attention student instance gets a matching teacher. Fails on main (fp32 teacher), passes here.
Note
Low Risk
Narrow initialization fix for separate teacher loading; explicit kwargs still override defaults, with regression tests only.
Overview
When SDFT and SDPO construct a separate teacher (
base/emapaths that reload from the checkpoint), they now copymodel_init_kwargsbefore applying defaults sosetdefaultdoes not mutate the userβs training config.If the student is passed as an already-loaded model (empty
model_init_kwargs), the teacher is loaded with the studentβsdtypeandattn_implementationinstead of defaulting to fp32 and the framework default attention.Adds
test_teacher_model_like_model_instancein both trainer test suites to assert a bf16, eager-attention student gets a matching teacher.Reviewed by Cursor Bugbot for commit 98a3666. Bugbot is set up for automated code reviews on this repo. Configure here.