Fix nested vocab_size for DistillationTrainer and GOLDTrainer#5592
Open
Beichen-Ma wants to merge 3 commits intohuggingface:mainfrom
Open
Fix nested vocab_size for DistillationTrainer and GOLDTrainer#5592Beichen-Ma wants to merge 3 commits intohuggingface:mainfrom
Beichen-Ma wants to merge 3 commits intohuggingface:mainfrom
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
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
Low Risk
Single-line logic change in trainer initialization plus a test mock update; low risk aside from potential edge cases if a model config lacks
get_text_config().Overview
Fixes teacher embedding resizing during initialization for
DistillationTrainerandGOLDTrainerby reading vocabulary size viaself.model.config.get_text_config().vocab_sizeinstead ofself.model.config.vocab_size, supporting models with nested text configs.Updates the existing GOLD init unit test mock config to implement
get_text_config()so the new code path is exercised.Reviewed by Cursor Bugbot for commit d1e8543. Bugbot is set up for automated code reviews on this repo. Configure here.