Unwrap `text_config` in `AutoModelFor*.from_config` (#45770)
* Unwrap text_config in AutoModelFor*.from_config
Mirror the existing from_pretrained text_config unwrap into from_config so
the composite-config -> text-only-model "VLM compatibility" mapping (e.g.
Qwen3.5 / Qwen3.5-MoE) works for meta-init paths too. Without this,
AutoModelForCausalLM.from_config(Qwen3_5MoeConfig(...)) fails with
AttributeError because the text-only model class receives the composite
config. Also propagate quantization_config from the parent so pre-quantized
detection still works, mirroring PR #45494.
Add a parametrized regression test covering both from_pretrained and
from_config in the qwen3_5 and qwen3_5_moe model test files,
and extend the existing gemma3 test_automodelforcausallm to match.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* Revert gemma3 from_config test addition
The unwrap branch in AutoModelFor*.from_config never triggers for gemma3
(its MODEL_FOR_CAUSAL_LM_MAPPING entry routes Gemma3Config to the VLM
class Gemma3ForConditionalGeneration, whose config_class is Gemma3Config
itself, not Gemma3TextConfig). The new from_config parameterization
therefore exercised only the pre-existing path and added no coverage of
the fix.
* Guard quantization_config propagation against None values
`hasattr(parent_config, "quantization_config")` returns True even when
the value is `None` (e.g. a config.json containing
`"quantization_config": null`, or a dequantization step that cleared
the attribute). The previous propagation copied that None onto the
unwrapped text sub-config, and `from_pretrained`'s downstream
`get_hf_quantizer` keys off `hasattr` to set `pre_quantized=True`, then
crashes inside `AutoHfQuantizer.supports_quant_method(None)` on
`None.get(...)`.
Switch to `getattr(parent_config, "quantization_config", None) is not
None` at both call sites so absent and None collapse into the same
"don't propagate" case.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>