Fix nested vocab_size for DistillationTrainer and GOLDTrainer#5592
Merged
Conversation
5 tasks
3 tasks
Collaborator
|
The changes look good to me! Let's wait for the review from another maintainer before merging |
kashif
approved these changes
Apr 20, 2026
cmpatino
approved these changes
Apr 20, 2026
Contributor
Author
|
Hey @cmpatino, just checking in on this — looks like it has the approvals and wanted to make sure it didn't slip through the cracks. Thanks! |
|
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. |
Collaborator
|
Thank you for the ping @Beichen-Ma! Looks good to me, so I'm merging it. |
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.
Fixes #5585. The root cause was in
DistillationTrainer.__init__callsteacher_model.resize_token_embeddings(self.model.config.vocab_size), which raisesAttributeErroron configs wherevocab_sizeis nested (e.g.Qwen3_5Configexposes it underconfig.text_config).Fix
self.model.config.get_text_config().vocab_size, whichtransformersdefines onPretrainedConfigto return the text sub-config on nested configs and self on flat ones.SimpleNamespacemock didn't implementget_text_config.Tests
Before submitting
AI writing disclosure
We welcome the use of AI tools to help with contributions. For transparency and to help us improve our review process, please indicate the level of AI involvement in this PR.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag members/contributors who may be interested in your PR.
Note
Medium Risk
Touches trainer initialization for
DistillationTrainerandGOLDTrainer; a wrongvocab_sizecould mis-size teacher embeddings or break startup for some model configs, but the change is small and localized.Overview
Fixes teacher embedding resizing for models whose
vocab_sizelives in a nested text config by switching fromself.model.config.vocab_sizetoself.model.config.get_text_config().vocab_sizein bothDistillationTrainerandGOLDTrainer.Updates the GOLD unit test mock config to implement
get_text_config()so the init path continues to validate the resize call.Reviewed by Cursor Bugbot for commit 99bf555. Bugbot is set up for automated code reviews on this repo. Configure here.