Skip to content

TypeError in rope validation: set -= list when config loaded from JSON #45068

@Fr0do

Description

@Fr0do

Bug description

_check_received_keys in modeling_rope_utils.py (line 919) performs received_keys -= ignore_keys where received_keys is a set but ignore_keys can be a list after JSON deserialization, causing:

TypeError: unsupported operand type(s) for -=: 'set' and 'list'

Root cause

Model configs like Qwen3.5 define ignore_keys_at_rope_validation = {"mrope_section", "mrope_interleaved"} as a Python set. However, JSON has no set type — when the config is serialized to JSON and loaded back (e.g. via huggingface_hub dataclass validation), sets become lists. The _check_received_keys method doesn't account for this.

Reproduction

# transformers==5.4.0, huggingface_hub>=1.7
from transformers import AutoConfig
# Works fine (loads from Python class):
config = AutoConfig.from_pretrained("Qwen/Qwen3.5-35B-A3B")

# Fails when loaded via huggingface_hub strict dataclass validation
# (e.g. through vLLM which triggers this path):
# StrictDataclassClassValidationError: Class validation error for validator 'validate_rope':
#     TypeError: unsupported operand type(s) for -=: 'set' and 'list'

Triggered by vLLM 0.18.0 serving Qwen/Qwen3.5-35B-A3B.

Affected models

Any model defining ignore_keys_at_rope_validation: Qwen3.5, ErnieVLMoe, GLM4V, Ministral3, etc.

Fix

# src/transformers/modeling_rope_utils.py, line 919
- received_keys -= ignore_keys
+ received_keys -= set(ignore_keys)

set() is a no-op when input is already a set, and correctly handles the list case.

Environment

  • transformers 5.4.0
  • huggingface_hub 1.7.2 / 1.8.0
  • vLLM 0.18.0
  • Python 3.13

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions