Skip to content

fix: propagate dtype to text sub-config for composite models in Auto classes - #46460

Closed
Achyuthan-S wants to merge 1 commit into
huggingface:mainfrom
Achyuthan-S:fix/auto-dtype-composite-models
Closed

Achyuthan-S wants to merge 1 commit into
huggingface:mainfrom
Achyuthan-S:fix/auto-dtype-composite-models

Conversation

@Achyuthan-S

@Achyuthan-S Achyuthan-S commented Jun 6, 2026 •

Copy link
Copy Markdown

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

Copilot AI review requested due to automatic review settings June 6, 2026 07:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 dtype from a parent (composite) config onto the extracted text config in auto_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.

@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: auto, qwen3_5

@Achyuthan-S
Achyuthan-S force-pushed the fix/auto-dtype-composite-models branch from c90daed to 8d30e03 Compare June 6, 2026 08:21
@Achyuthan-S
Achyuthan-S deleted the fix/auto-dtype-composite-models branch July 5, 2026 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dtype is silently ignored when loading composite (multimodal) checkpoints through AutoModelForCausalLM (affects all Qwen3.5 repos)

3 participants