[CI] Bump Transformers version to 5.17.0 (#56108)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Harry Mellor
2026-09-16 06:34:16 -07:00
committed by GitHub
co-authored by mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Claude Opus 5
parent f8b5c11468
commit ec4a3a5370
17 changed files with 148 additions and 171 deletions
+49 -2
View File
@@ -13,6 +13,7 @@ from typing import Any, Literal, TypeAlias
import huggingface_hub
import torch
import transformers.configuration_utils as hf_configuration_utils
from huggingface_hub import constants
from packaging.version import Version
from safetensors.torch import _TYPES as _SAFETENSORS_TO_TORCH_DTYPE
@@ -126,7 +127,6 @@ _CONFIG_REGISTRY: dict[str, type[PretrainedConfig]] = LazyConfigDict(
RefinedWebModel="RWConfig", # For tiiuae/falcon-7b(-instruct)
mlp_speculator="MLPSpeculatorConfig",
medusa="MedusaConfig",
mellum="MellumConfig",
midashenglm="MiDashengLMConfig",
minimax_m3_vl="MiniMaxM3Config",
minimax_m3_mtp="MiniMaxM3MTPConfig",
@@ -151,7 +151,6 @@ _CONFIG_REGISTRY: dict[str, type[PretrainedConfig]] = LazyConfigDict(
qwen3_5_text="Qwen3_5TextConfig",
qwen3_5_moe="Qwen3_5MoeConfig",
qwen3_5_moe_text="Qwen3_5MoeTextConfig",
laguna="LagunaConfig",
lfm2_moe="Lfm2MoeConfig",
**{"unlimited-ocr": "UnlimitedOCRConfig"},
**{"deepseek_v41": "DeepseekV41Config"},
@@ -163,6 +162,12 @@ _SPECULATIVE_DECODING_CONFIGS: set[str] = {"eagle", "speculators", "medusa"}
_PATCH_HF_VALIDATE_ROPE: set[str] = {"sarvam_mla"}
# Model types whose checkpoints store shared RoPE parameters alongside the
# per-layer-type dicts (e.g. Laguna's `original_max_position_embeddings`).
# Since transformers 5.17, `validate_rope` treats every top-level value of such
# a dict as a layer's parameters and raises on the shared ones.
_PATCH_HF_NESTED_ROPE_VALIDATION: set[str] = {"laguna"}
# Model types whose checkpoints declare `layer_types` entries that upstream
# transformers has not added to `ALLOWED_LAYER_TYPES` yet, so its strict config
# validation rejects them (e.g. GLM-5.2 `glm_moe_dsa` use
@@ -236,6 +241,11 @@ def _patch_hf_transformers_validate_rope():
def patched_validate_rope(self, *args, **kwargs):
ignore_keys_param = kwargs.pop("ignore_keys", None)
original_ignore_keys = self.ignore_keys_at_rope_validation
if ignore_keys_param is not None:
logger.warning(
"validate_rope() was called with the legacy 'ignore_keys' "
"argument; use 'ignore_keys_at_rope_validation' instead"
)
self.ignore_keys_at_rope_validation = original_ignore_keys or ignore_keys_param
result = _original_validate_rope(self, *args, **kwargs)
return result
@@ -244,6 +254,40 @@ def _patch_hf_transformers_validate_rope():
PretrainedConfig.validate_rope = patched_validate_rope
def _patch_hf_transformers_nested_rope_validation() -> None:
"""Drop shared entries sitting alongside a nested ``rope_parameters`` dict.
Transformers validates a dict with any layer-type key by iterating all of
its values, so a shared entry next to the per-layer dicts raises an
``AttributeError``. The per-layer dicts already carry their own defaults by
the time validation runs, so the shared entries can be dropped.
"""
if hasattr(PretrainedConfig.validate_rope, "__vllm_nested_rope_patched__"):
return
_original_validate_rope = PretrainedConfig.validate_rope
@wraps(_original_validate_rope)
def patched_validate_rope(self, *args, **kwargs):
rope_parameters = getattr(self, "rope_parameters", None)
if isinstance(rope_parameters, dict):
layer_types = set(rope_parameters) & set(
hf_configuration_utils.ALLOWED_LAYER_TYPES
)
if shared_keys := set(rope_parameters) - layer_types:
for key in shared_keys:
del rope_parameters[key]
logger.warning(
"Dropping %s from rope_parameters; entries shared across "
"layer types are not supported",
sorted(shared_keys),
)
return _original_validate_rope(self, *args, **kwargs)
patched_validate_rope.__vllm_nested_rope_patched__ = True # type: ignore[attr-defined]
PretrainedConfig.validate_rope = patched_validate_rope
def _patch_hf_transformers_allowed_layer_types(
extra_layer_types: tuple[str, ...],
) -> None:
@@ -304,6 +348,9 @@ class HFConfigParser(ConfigParserBase):
if model_type in _PATCH_HF_VALIDATE_ROPE:
_patch_hf_transformers_validate_rope()
if model_type in _PATCH_HF_NESTED_ROPE_VALIDATION:
_patch_hf_transformers_nested_rope_validation()
if extra_layer_types := _PATCH_HF_ALLOWED_LAYER_TYPES.get(model_type):
_patch_hf_transformers_allowed_layer_types(extra_layer_types)