fix: propagate num_labels/id2label to text_config in Qwen3_5Config#44920
Closed
s-zx wants to merge 1 commit intohuggingface:mainfrom
Closed
fix: propagate num_labels/id2label to text_config in Qwen3_5Config#44920s-zx wants to merge 1 commit intohuggingface:mainfrom
s-zx wants to merge 1 commit intohuggingface:mainfrom
Conversation
…t_config When num_labels (or id2label) is passed to AutoConfig.from_pretrained, super().__post_init__(**kwargs) correctly sets self.id2label on the outer config, but the already-initialized text_config retains its default id2label (2 labels). This prevents Qwen3_5ForSequenceClassification from using the correct number of labels. Fix by propagating id2label and label2id from the outer config to text_config after super().__post_init__() runs, when num_labels or id2label was explicitly provided. Fixes huggingface#44625
Contributor
|
[For maintainers] Suggested jobs to run (before merge) run-slow: qwen3_5 |
Member
|
Nope, not what we want as per comment under the issue. Also we'd need a bigger PR to sync all multimodal/nested models |
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.
What does this PR do?
Fixes
num_labelsnot being propagated fromQwen3_5Configto itstext_configwhen loading viaAutoConfig.from_pretrained(model, num_labels=N).Root cause:
Qwen3_5Config.__post_init__initializestext_configwith default label settings, then callssuper().__post_init__(**kwargs)which correctly setsself.id2labelon the outer config. However,text_configalready has the defaultid2label(2 labels) and never gets updated.Fix: After
super().__post_init__(**kwargs)runs, propagateid2labelandlabel2idfrom the outer config totext_configwhennum_labelsorid2labelwas explicitly provided.Before:
After:
Both
modular_qwen3_5.pyand the generatedconfiguration_qwen3_5.pyare updated.Fixes #44625