From e5198386bd10cbfb001e04722f2d64916b4d12da Mon Sep 17 00:00:00 2001 From: Xinyuan Tong <115166877+JustinTong0323@users.noreply.github.com> Date: Mon, 27 Apr 2026 06:33:54 +0100 Subject: [PATCH] Upgrade transformers from 5.5.4 to 5.6.0 (#23525) --- python/pyproject.toml | 2 +- python/pyproject_cpu.toml | 2 +- python/pyproject_npu.toml | 2 +- python/pyproject_other.toml | 2 +- python/pyproject_xpu.toml | 2 +- .../multimodal_gen/runtime/models/encoders/gemma_3.py | 10 ++++++++++ python/sglang/srt/models/llava.py | 3 +++ python/sglang/srt/models/llavavid.py | 3 +++ python/sglang/srt/models/yivl.py | 3 +++ 9 files changed, 24 insertions(+), 5 deletions(-) diff --git a/python/pyproject.toml b/python/pyproject.toml index bfdcd2762..2b81b52b4 100755 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -72,7 +72,7 @@ dependencies = [ "torchvision", "tqdm", "mistral_common>=1.11.0", - "transformers==5.5.4", + "transformers==5.6.0", "uvicorn", "uvloop", "watchfiles", diff --git a/python/pyproject_cpu.toml b/python/pyproject_cpu.toml index 840403cf0..677490ce1 100644 --- a/python/pyproject_cpu.toml +++ b/python/pyproject_cpu.toml @@ -62,7 +62,7 @@ dependencies = [ "torchvision==0.24.0", "tqdm", "mistral_common>=1.11.0", - "transformers==5.5.4", + "transformers==5.6.0", "triton==3.5.0", "uvicorn", "uvloop", diff --git a/python/pyproject_npu.toml b/python/pyproject_npu.toml index 1c5859e84..6b463293b 100644 --- a/python/pyproject_npu.toml +++ b/python/pyproject_npu.toml @@ -59,7 +59,7 @@ dependencies = [ "torchao==0.9.0", "tqdm", "mistral_common>=1.11.0", - "transformers==5.5.4", + "transformers==5.6.0", "uvicorn", "uvloop", "xgrammar==0.1.32", diff --git a/python/pyproject_other.toml b/python/pyproject_other.toml index 93192b644..296b3e41d 100755 --- a/python/pyproject_other.toml +++ b/python/pyproject_other.toml @@ -59,7 +59,7 @@ runtime_common = [ "torchao==0.9.0", "tqdm", "mistral_common>=1.11.0", - "transformers==5.5.4", + "transformers==5.6.0", "uvicorn", "uvloop", "xgrammar==0.1.32", diff --git a/python/pyproject_xpu.toml b/python/pyproject_xpu.toml index 55eee5feb..5f2dfbd01 100644 --- a/python/pyproject_xpu.toml +++ b/python/pyproject_xpu.toml @@ -63,7 +63,7 @@ dependencies = [ "torchao==0.9.0+xpu", "tqdm", "mistral_common>=1.11.0", - "transformers==5.5.4", + "transformers==5.6.0", "uvicorn", "uvloop", # "xgrammar==0.1.24", , xgrammar depends on CUDA PyTorch and Triton only diff --git a/python/sglang/multimodal_gen/runtime/models/encoders/gemma_3.py b/python/sglang/multimodal_gen/runtime/models/encoders/gemma_3.py index 2db60639e..7047af233 100644 --- a/python/sglang/multimodal_gen/runtime/models/encoders/gemma_3.py +++ b/python/sglang/multimodal_gen/runtime/models/encoders/gemma_3.py @@ -931,6 +931,16 @@ class Gemma3TextModel(nn.Module): class Gemma3ForConditionalGeneration(nn.Module): + # transformers 5.6.0 flattened SiglipVisionModel, dropping the + # `vision_model` intermediate wrapper. Our reimpl keeps it, so remap + # HF source keys back into our nested namespace when transferring weights. + param_names_mapping = { + r"^(vision_tower\.)(embeddings|encoder|post_layernorm|head)\.": r"\1vision_model.\2.", + } + reverse_param_names_mapping = { + r"^(vision_tower\.)vision_model\.(embeddings|encoder|post_layernorm|head)\.": r"\1\2.", + } + def __init__( self, config: Gemma3Config, diff --git a/python/sglang/srt/models/llava.py b/python/sglang/srt/models/llava.py index e07ca7418..f07dcaa56 100644 --- a/python/sglang/srt/models/llava.py +++ b/python/sglang/srt/models/llava.py @@ -495,6 +495,9 @@ class LlavaBaseForCausalLM(nn.Module): "model.mm_projector.0": "multi_modal_projector.linear_1", "model.mm_projector.2": "multi_modal_projector.linear_2", "model.vision_tower.vision_tower": "vision_tower", + # transformers 5.6.0 flattened CLIPVisionModel/SiglipVisionModel, + # dropping the `vision_model` intermediate wrapper. + "vision_tower.vision_model.": "vision_tower.", # Update the vision tower weights if we find them in the checkpoint (it may be finetuned). "model.image_newline": "language_model.model.image_newline", } diff --git a/python/sglang/srt/models/llavavid.py b/python/sglang/srt/models/llavavid.py index e5d6aa72b..dc4df698e 100644 --- a/python/sglang/srt/models/llavavid.py +++ b/python/sglang/srt/models/llavavid.py @@ -255,6 +255,9 @@ class LlavaVidForCausalLM(nn.Module): "model.vision_resampler.mm_projector.0": "multi_modal_projector.linear_1", "model.vision_resampler.mm_projector.2": "multi_modal_projector.linear_2", "model.vision_tower.vision_tower": "vision_tower", + # transformers 5.6.0 flattened CLIPVisionModel/SiglipVisionModel, + # dropping the `vision_model` intermediate wrapper. + "vision_tower.vision_model.": "vision_tower.", # Update the vision tower weights if we find them in the checkpoint (it may be finetuned). "model.image_newline": "language_model.model.image_newline", } diff --git a/python/sglang/srt/models/yivl.py b/python/sglang/srt/models/yivl.py index 4c50b0d3c..efd7eb52e 100644 --- a/python/sglang/srt/models/yivl.py +++ b/python/sglang/srt/models/yivl.py @@ -73,6 +73,9 @@ class YiVLForCausalLM(LlavaLlamaForCausalLM): "model.mm_projector.3": "multi_modal_projector.linear_2", "model.mm_projector.4": "multi_modal_projector.ln_2", "model.vision_tower.vision_tower": "vision_tower", # Update the vision tower weights if we find them in the checkpoint (it may be finetuned). + # transformers 5.6.0 flattened CLIPVisionModel/SiglipVisionModel, + # dropping the `vision_model` intermediate wrapper. + "vision_tower.vision_model.": "vision_tower.", } params_dict = dict(self.named_parameters()) weights = list(weights)