AttributeError: 'ColQwen3Config' object has no attribute 'text_config' on load (after separately hitting a mutable-default dataclass bug)

#3
by knowsitall - opened

AttributeError: 'ColQwen3Config' object has no attribute 'text_config' on load

Trying to load this model per the README's Inference Code example fails during config instantiation.

Environment: Python 3.14, transformers 5.9.0 and 5.14.1 (both tested, identical failure), torch 2.13.0, Linux.

Steps to reproduce

from transformers import AutoModel, AutoProcessor
processor = AutoProcessor.from_pretrained(
    "TomoroAI/tomoro-colqwen3-embed-4b", trust_remote_code=True, max_num_visual_tokens=1280
)

Issue 1 (worked around locally)

configuration_colqwen3.py line 35 sets sub_configs: dict[str, Any] = {...} as a bare dict default on a dataclass-decorated PretrainedConfig subclass, which Python's dataclasses module rejects:

ValueError: mutable default <class 'dict'> for field sub_configs is not allowed: use default_factory

Wrapping it in field(default_factory=lambda: {...}) resolves this specific error.

Full traceback for Issue 1 (click to expand)
File ".../configuration_colqwen3.py", line 31, in <module>
    class ColQwen3Config(PretrainedConfig):
    ...<75 lines>...
            return self.text_config
  File ".../transformers/configuration_utils.py", line 316, in __init_subclass__
    cls = dataclass(cls, repr=False, kw_only=True)
  File "/usr/lib/python3.14/dataclasses.py", line 1450, in dataclass
    return wrap(cls)
  File "/usr/lib/python3.14/dataclasses.py", line 917, in _get_field
    raise ValueError(f'mutable default {type(f.default)} for field '
ValueError: mutable default <class 'dict'> for field sub_configs is not allowed: use default_factory

Issue 2 (blocking, no workaround found)

After patching Issue 1, DEFAULT_CONFIG = ColQwen3Config() at module load time fails with:

AttributeError: 'ColQwen3Config' object has no attribute 'text_config'. Did you mean: 'get_text_config'?

This happens inside transformers' validate_token_ids, which calls self.get_text_config(), which returns self.text_config — but nothing in ColQwen3Config.__init__ appears to actually set self.text_config from sub_configs before super().__init__(**kwargs) runs validation.

Reproduced identically on two transformers versions three months apart (5.9.0 and 5.14.1), so it doesn't look version-specific.

Full traceback for Issue 2 (click to expand)
File ".../configuration_colqwen3.py", line 111, in <module>
    DEFAULT_CONFIG = ColQwen3Config()
  File ".../configuration_colqwen3.py", line 74, in __init__
    super().__init__(**kwargs)
  File ".../huggingface_hub/dataclasses.py", line 276, in init_with_validate
    cls.validate(self)
  File ".../huggingface_hub/dataclasses.py", line 251, in validate
    validator(self)
  File ".../transformers/configuration_utils.py", line 458, in validate_token_ids
    text_config = self.get_text_config(decoder=True)
  File ".../configuration_colqwen3.py", line 108, in get_text_config
    return self.text_config
  File ".../transformers/configuration_utils.py", line 434, in __getattribute__
    return super().__getattribute__(key)
AttributeError: 'ColQwen3Config' object has no attribute 'text_config'. Did you mean: 'get_text_config'?

Happy to share the full patch script or more environment details if useful. Is there a known-good transformers pin, or a fix planned for configuration_colqwen3.py's __init__?

Tomoro AI Ltd org

Hi, the latest PR should have fixed the issue with latest transfomer version.

hxssgaa changed discussion status to closed

Sign up or log in to comment