[CI] Bump Transformers version to 5.18.0 (#59621)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
Harry Mellor
2026-10-04 00:42:35 +00:00
committed by GitHub
parent 84bcbc6264
commit 9e0b6fcf77
22 changed files with 104 additions and 201 deletions
+22
View File
@@ -147,6 +147,12 @@ _CONFIG_REGISTRY: dict[str, type[PreTrainedConfig]] = LazyConfigDict(
_SPECULATIVE_DECODING_CONFIGS: set[str] = {"eagle", "speculators", "medusa"}
# Checkpoints whose config.json has no model_type, only remote code in auto_map
_ARCHITECTURE_TO_MODEL_TYPE: dict[str, str] = {
"LongcatFlashForCausalLM": "longcat_flash",
"LongcatFlashNgramForCausalLM": "longcat_flash",
}
_PATCH_HF_VALIDATE_ROPE: set[str] = {"sarvam_mla"}
# Model types whose checkpoints carry shared RoPE parameters alongside the
@@ -352,6 +358,8 @@ class HFConfigParser(ConfigParserBase):
if config_dict.get("speculators_config") is not None
else model_type
)
if model_type is None and (architectures := config_dict.get("architectures")):
model_type = _ARCHITECTURE_TO_MODEL_TYPE.get(architectures[0])
# Allow hf_overrides to override model_type before checking _CONFIG_REGISTRY
if (hf_overrides := kwargs.pop("hf_overrides", None)) is not None:
if isinstance(hf_overrides, dict) and "model_type" in hf_overrides:
@@ -374,6 +382,15 @@ class HFConfigParser(ConfigParserBase):
if extra_layer_types := _PATCH_HF_ALLOWED_LAYER_TYPES.get(model_type):
_patch_hf_transformers_allowed_layer_types(extra_layer_types)
if model_type == "vlm":
# HyperCLOVAX remote code registers this alias in a bare
# `try/except` that fails silently since transformers 5.18
from transformers import CONFIG_MAPPING, Qwen2_5_VLVisionConfig
CONFIG_MAPPING.register(
"qwen2_5_vl_visual", Qwen2_5_VLVisionConfig, exist_ok=True
)
rope_parameters = config_dict.get("rope_parameters") or {}
if model_type == "gemma4_text" and "full_attention" in rope_parameters:
from transformers import Gemma4TextConfig
@@ -387,6 +404,11 @@ class HFConfigParser(ConfigParserBase):
}
kwargs.setdefault("name_or_path", str(model))
config = Gemma4TextConfig.from_dict(config_dict, **kwargs)
elif model_type in _ARCHITECTURE_TO_MODEL_TYPE.values():
from transformers import CONFIG_MAPPING
kwargs.setdefault("name_or_path", str(model))
config = CONFIG_MAPPING[model_type].from_dict(config_dict, **kwargs)
elif model_type in _SPECULATIVE_DECODING_CONFIGS:
config_class = _CONFIG_REGISTRY[model_type]
config = config_class.from_pretrained(
@@ -329,7 +329,6 @@ class ModelArchConfigConvertorBase:
"kimi_k2",
"kimi_linear",
"longcat_flash",
"longcat_flash_ngram",
"pangu_ultra_moe",
"pangu_ultra_moe_mtp",
"bailing_hybrid",
@@ -714,6 +713,12 @@ class PanguUltraMoeMTPModelArchConfigConvertor(ModelArchConfigConvertorBase):
return getattr(self.hf_text_config, "num_nextn_predict_layers", 0)
class LongCatFlashModelArchConfigConvertor(ModelArchConfigConvertorBase):
def get_num_hidden_layers(self) -> int:
# `num_hidden_layers` counts attention sublayers, two per decoder layer
return self.hf_text_config.num_layers
class LongCatFlashMTPModelArchConfigConvertor(ModelArchConfigConvertorBase):
def get_num_hidden_layers(self) -> int:
return getattr(self.hf_text_config, "num_nextn_predict_layers", 1)
@@ -825,6 +830,7 @@ MODEL_ARCH_CONFIG_CONVERTORS = {
"gemma4_unified_text": Gemma4ModelArchConfigConvertor,
"glm4_moe_mtp": GLM4MoeMTPModelArchConfigConvertor,
"glm_ocr_mtp": GLM4MoeMTPModelArchConfigConvertor,
"longcat_flash": LongCatFlashModelArchConfigConvertor,
"longcat_flash_mtp": LongCatFlashMTPModelArchConfigConvertor,
"mamba": MambaModelArchConfigConvertor,
"medusa": MedusaModelArchConfigConvertor,