Repository navigation
fix: propagate dtype to text sub-config for composite models in Auto classes - #46460
Closed
Achyuthan-S wants to merge 1 commit into
Closed
Achyuthan-S wants to merge 1 commit into
Achyuthan-S wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR ensures that a composite model config’s dtype is preserved when Auto* classes extract a text-only config (via get_text_config()), and adds a regression test around Qwen3.5 autoclass loading.
Changes:
- Propagate
dtypefrom a parent (composite) config onto the extracted text config inauto_factory. - Add a Qwen3.5 unit test to validate dtype behavior during
AutoModelForCausalLM.from_pretrained(...).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/models/qwen3_5/test_modeling_qwen3_5.py | Adds a regression test intended to verify dtype survives composite-config extraction during AutoModel loading. |
| src/transformers/models/auto/auto_factory.py | Copies dtype from the composite/parent config to the extracted text config in both from_config and from_pretrained. |
Contributor
|
[For maintainers] Suggested jobs to run (before merge) run-slow: auto, qwen3_5 |
Achyuthan-S
force-pushed
the
fix/auto-dtype-composite-models
branch
from
June 6, 2026 08:21
c90daed to
8d30e03
Compare
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 #46459
Problem
dtype passed to AutoModelForCausalLM.from_pretrained is silently ignored for composite (multimodal) checkpoints like Qwen3.5. AutoConfig.from_pretrained absorbs it into the top-level composite config, which is then swapped to the text sub-config via get_text_config() — dropping the user's value. The model falls back to the checkpoint default (bfloat16) with no warning.
Fix
Propagate parent_config.dtype to the extracted text sub-config at both get_text_config() call sites in auto_factory.py, mirroring the existing quantization_config propagation from #45494.
Coordination
Coordinated on issue #46459 before opening this PR. Issue author (@qflen) acknowledged with approval.
Duplicate check
gh pr list --repo huggingface/transformers --state open --search "46459 in:body" returned no results. No overlapping open PRs exist.
Tests run
pytest tests/models/qwen3_5/test_modeling_qwen3_5.py::Qwen3_5ModelTest::test_automodelforcausallm_propagates_dtype
PASSED
AutoModelForCausalLM.from_pretrained("Qwen/Qwen3.5-0.8B", dtype=torch.float32)
Output: torch.float32
AI assistance disclosure
AI assistance (Claude) was used for codebase fix verification. All changed lines were reviewed and understood by personally , and the fix was validated locally end-to-end.
The tests_generate failure is a pre-existing flaky test — Kosmos2_5ModelTest::test_generate_with_cache_matches_no_cache — marked FLAKY by CircleCI. It tests cache consistency in Kosmos2.5 generation and has no relation to this change.
@Cyrilvallez @zucchini-nlp