transformers - ✅(Solved) Fix Qwen3_5MoeVisionConfig missing deepstack_visual_indexes field — silently dropped by @strict [2 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
huggingface/transformers#45375Fetched 2026-04-12 13:24:03
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
0
Participants
Timeline (top)
cross-referenced ×2labeled ×1mentioned ×1referenced ×1

Error Message

from transformers import AutoConfig

config = AutoConfig.from_pretrained("Qwen/Qwen3.5-35B-A3B-Base", trust_remote_code=True) print(config.vision_config.deepstack_visual_indexes)

AttributeError: 'Qwen3_5MoeVisionConfig' object has no attribute 'deepstack_visual_indexes'

Root Cause

The @strict decorator on Qwen3_5MoeVisionConfig (added in #41250) silently drops the deepstack_visual_indexes field during config loading, because it's not declared as a class attribute. However, every Qwen3.5 MoE model on HuggingFace ships with this field in its config.json.

Fix Action

Fixed

PR fix notes

PR #45379: fix(config): add deepstack_visual_indexes to Qwen3_5MoeVisionConfig

Description (problem / solution / changelog)

Problem

The @strict decorator on Qwen3_5MoeVisionConfig silently drops the deepstack_visual_indexes field during config loading because it is not declared as a class attribute. Every Qwen3.5 MoE model on HuggingFace ships with this field in its config.json (e.g. Qwen/Qwen3.5-35B-A3B-Base).

Root Cause

Qwen3_5MoeVisionConfig inherits from Qwen3_5VisionConfig, which overrides deepstack_visual_indexes with an AttributeError() sentinel (inherited from the parent chain). The generated configuration_qwen3_5_moe.py does not include the field at all, so @strict rejects it when deserializing from config.json.

Fix

Override deepstack_visual_indexes as a properly typed class attribute on Qwen3_5MoeVisionConfig with default (), matching the type annotation used in Qwen3VLVisionConfig. This ensures:

  • The field is accepted when loading model configs
  • config.vision_config.deepstack_visual_indexes returns the value from config.json
  • No silent data loss during deserialization

Verification

from transformers import AutoConfig
config = AutoConfig.from_pretrained("Qwen/Qwen3.5-35B-A3B-Base", trust_remote_code=True)
print(config.vision_config.deepstack_visual_indexes)  # [] — no longer raises AttributeError

Fixes #45375

Changes

  • modular_qwen3_5_moe.py: Add deepstack_visual_indexes field override with docstring
  • configuration_qwen3_5_moe.py: Add deepstack_visual_indexes field with docstring (generated)

Changed files

  • src/transformers/models/qwen3_5_moe/configuration_qwen3_5_moe.py (modified, +3/-0)
  • src/transformers/models/qwen3_5_moe/modular_qwen3_5_moe.py (modified, +6/-1)

PR #45380: fix Qwen3_5MoeVisionConfig deepstack_visual_indexes silently dropped by @strict (Issue: https://github.com/huggingface/transformers/issues/45375)

Description (problem / solution / changelog)

What does this PR do?

<!-- Congratulations! You've made it this far! You're not quite done yet though. Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution. Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change. Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost. --> <!-- Remove if not applicable -->

Fixes #45375 (issue)

Root Cause

In modular_qwen3_5.py, Qwen3_5VisionConfig was marked @strict but also had deepstack_visual_indexes = AttributeError(). That meant the field was effectively undeclared for strict loading, so when a real checkpoint config included "deepstack_visual_indexes": [], Transformers silently dropped it during config construction. Since Qwen3_5MoeVisionConfig inherits that shared Qwen3.5 vision config shape, the bug affected both plain Qwen3.5 and Qwen3.5-MoE configs.

Fix

I restored deepstack_visual_indexes as a real config attribute in modular_qwen3_5.py, with an empty default so Qwen3.5 keeps deepstack disabled by default.

Tests

from transformers import Qwen3_5Config, Qwen3_5MoeConfig

for cls in [Qwen3_5Config, Qwen3_5MoeConfig]:
    config = cls(vision_config={"deepstack_visual_indexes": [1, 2]})
    print(
        cls.__name__,
        type(config.vision_config.deepstack_visual_indexes).__name__,
        config.vision_config.deepstack_visual_indexes,
    )

Output:

Qwen3_5MoeConfig list [1, 2]

Changed files

  • src/transformers/models/qwen3_5/configuration_qwen3_5.py (modified, +4/-0)
  • src/transformers/models/qwen3_5/modular_qwen3_5.py (modified, +3/-1)
  • src/transformers/models/qwen3_5_moe/configuration_qwen3_5_moe.py (modified, +4/-0)

Code Example

{
    "vision_config": {
      "deepstack_visual_indexes": [],
      "depth": 27,
      "hidden_size": 1152,
      ...
    }
  }

---

from transformers import AutoConfig

  config = AutoConfig.from_pretrained("Qwen/Qwen3.5-35B-A3B-Base", trust_remote_code=True)
  print(config.vision_config.deepstack_visual_indexes)
  # AttributeError: 'Qwen3_5MoeVisionConfig' object has no attribute 'deepstack_visual_indexes'

---

@strict
  class Qwen3_5MoeVisionConfig(PreTrainedConfig):
      ...
      num_position_embeddings: int = 2304
      initializer_range: float = 0.02
      deepstack_visual_indexes: list[int] = field(default_factory=list)  # <-- add this
RAW_BUFFERClick to expand / collapse

System Info

Transformers v5.5.0

The @strict decorator on Qwen3_5MoeVisionConfig (added in #41250) silently drops the deepstack_visual_indexes field during config loading, because it's not declared as a class attribute. However, every Qwen3.5 MoE model on HuggingFace ships with this field in its config.json.

For example, Qwen/Qwen3.5-35B-A3B-Base/config.json contains:

  {
    "vision_config": {
      "deepstack_visual_indexes": [],
      "depth": 27,
      "hidden_size": 1152,
      ...
    }
  }

After loading with transformers 5.5.0+, config.vision_config.deepstack_visual_indexes raises AttributeError because @strict rejected the undeclared field.

Who can help?

No response

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

Steps/Code to reproduce bug

  from transformers import AutoConfig

  config = AutoConfig.from_pretrained("Qwen/Qwen3.5-35B-A3B-Base", trust_remote_code=True)
  print(config.vision_config.deepstack_visual_indexes)
  # AttributeError: 'Qwen3_5MoeVisionConfig' object has no attribute 'deepstack_visual_indexes'

Suggested fix

Add the missing field to Qwen3_5MoeVisionConfig in src/transformers/models/qwen3_5_moe/configuration_qwen3_5_moe.py:

  @strict
  class Qwen3_5MoeVisionConfig(PreTrainedConfig):
      ...
      num_position_embeddings: int = 2304
      initializer_range: float = 0.02
      deepstack_visual_indexes: list[int] = field(default_factory=list)  # <-- add this

Expected behavior

Expected behavior

config.vision_config.deepstack_visual_indexes should return the value from the model's config.json

extent analysis

TL;DR

Add the missing deepstack_visual_indexes field to the Qwen3_5MoeVisionConfig class to prevent it from being silently dropped during config loading.

Guidance

  • The issue is caused by the @strict decorator rejecting the undeclared deepstack_visual_indexes field in the Qwen3_5MoeVisionConfig class.
  • To fix this, add the deepstack_visual_indexes field to the Qwen3_5MoeVisionConfig class as suggested in the reproduction steps.
  • Verify the fix by loading the config and accessing the deepstack_visual_indexes attribute without raising an AttributeError.
  • If you are unable to modify the Qwen3_5MoeVisionConfig class, consider using a different version of the Transformers library that includes the fix.

Example

from transformers import AutoConfig

class Qwen3_5MoeVisionConfig(PreTrainedConfig):
    # ...
    deepstack_visual_indexes: list[int] = field(default_factory=list)

config = AutoConfig.from_pretrained("Qwen/Qwen3.5-35B-A3B-Base", trust_remote_code=True)
print(config.vision_config.deepstack_visual_indexes)  # Should not raise AttributeError

Notes

This fix assumes that you have control over the Qwen3_5MoeVisionConfig class and can modify it to include the missing field. If you are using a pre-compiled version of the Transformers library, you may need to wait for an updated version that includes the fix.

Recommendation

Apply the suggested fix by adding the deepstack_visual_indexes field to the Qwen3_5MoeVisionConfig class, as this will allow you to access the field without raising an AttributeError.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Expected behavior

config.vision_config.deepstack_visual_indexes should return the value from the model's config.json

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING