Skip to content

Multimodal (VLM) load crashes with AttributeError on model.config.pad_token_id for transformers-5 composite configs (CR-A03-006) #404

Open

Description

@cemililik

Wave 1 · theme D1-5: Training, merging and export correctness · highest severity High · 1 finding(s) · effort small

Summary

An operator fine-tunes a Gemma-3 or Qwen2.5-VL checkpoint whose config.json has no top-level pad_token_id. The run aborts with AttributeError (exit 2) after the weights are downloaded and loaded.

Primary finding

CR-A03-006 — Multimodal (VLM) load crashes with AttributeError on model.config.pad_token_id for transformers-5 composite configs

severity High · reachability default · intent contract-violation · confidence confirmed · independently confirmed · reproduced end to end

What happens. get_model_and_tokenizer reads model.config.pad_token_id at model.py:595. In transformers 5.x, composite VLM configs do not define a top-level pad_token_id. When config.json does not set the key, attribute access raises AttributeError. This holds for LlavaConfig, Gemma3Config, Qwen2VLConfig, Qwen2_5_VLConfig, PaliGemmaConfig, MllamaConfig, Qwen3VLConfig, Mistral3Config, Gemma3nConfig and LlavaNextConfig on 5.3.0, 5.13.0 and 5.18.0. The tokenizer branch (model.py:399-402) always guarantees a non-None pad_token_id, so the comparison is always evaluated. The multimodal path (F-011) fails after the weights are already loaded. Text-only configs are not affected: all 26 text configs probed expose pad_token_id.

Where.

Evidence.

  • I built a tiny random Llava (Llama text + CLIP vision) with LlavaProcessor locally (mk_vlm.py). Its config.json has no pad_token_id. Running get_model_and_tokenizer with multimodal.enabled gave: File forgelm/model.py, line 595: if pad_token_id is not None and model.config.pad_token_id is None -> AttributeError: 'LlavaConfig' object has no attribute 'pad_token_id' (transformers 5.13.0). vlmcfg.py shows the same AttributeError for the listed config classes on all three K-3 lanes. Idefics3 and Smo…

Recommended fix. Use getattr(model.config, 'pad_token_id', None) and set the pad id on the text sub-config (model.config.get_text_config()) and/or model.generation_config. Add a VLM test that does not use mocks, built on a tiny random composite model.

Acceptance criteria

  • A regression test reproduces the failure scenario and asserts the corrected behaviour.
  • Documentation listed above is corrected in English and in its Turkish mirror in the same PR.
  • Every finding in this issue is resolved or explicitly closed with a reason.

Found by the October 2026 ForgeLM code and documentation review against commit cab2947. Code links point at that commit; line numbers may have moved since. Finding IDs (CR-…, DOC-…, TECH-…) are stable references for this backlog.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: model-dataCode area: model-databugSomething isn't workingseverity: highWrong behaviour or a false claim users rely onsource: review-2026-10Found by the October 2026 code and documentation reviewwave: 1Roadmap wave 1: high severity, small effort

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions