[Misc] Remove unnecessary Transformers version guards (#57556)

Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>

Cyrus Leung committed Sep 18, 2026 at 23:01 UTC dbf4b89cf229fa52869aa36744d2e0ec0c8997ed
11 files changed +15 -146
tests/basic_correctness/test_basic_correctness.py
-11
@@ -11,8 +11,6 @@ from unittest.mock import Mock
11
12 import pytest
13 import torch
14 -from packaging.version import Version
15 -from transformers import __version__ as TRANSFORMERS_VERSION
14
15 import vllm.envs as envs
16 from vllm import LLM
@@ -149,15 +147,6 @@ def test_models(
147 if enable_prompt_embeds:
148 with torch.no_grad():
149 prompt_embeds = hf_model.get_prompt_embeddings(example_prompts)
152 - if model == "hmellor/tiny-random-Gemma2ForCausalLM" and (
153 - Version(TRANSFORMERS_VERSION) < Version("5.3.0.dev0")
154 - ):
155 - # For Gemma 1/2 models with Transformers 5.4.0+, the prompt embeddings
156 - # are normalised in `get_prompt_embeddings`, like Gemma 3.
157 - # For older versions, we need to manually normalise.
158 - embed_scale = hf_model.config.hidden_size**0.5
159 - normalizer = torch.tensor(embed_scale, dtype=prompt_embeds[0].dtype)
160 - prompt_embeds = [p_e * normalizer for p_e in prompt_embeds]
150
151 with VllmRunner(
152 model,
tests/lora/test_qwenvl.py
+5 -15
@@ -3,8 +3,6 @@
3 from dataclasses import dataclass
4
5 import pytest
6 -from packaging.version import Version
7 -from transformers import __version__ as TRANSFORMERS_VERSION
6
7 import vllm
8 from tests.conftest import VllmRunner
@@ -29,20 +27,12 @@ class TestConfig:
27
28 def __post_init__(self):
29 if self.mm_processor_kwargs is None:
32 - # There is a bug in transformers v4 where size is ignored by
33 - # `Qwen2VLProcessor.__call__`
34 - if Version(TRANSFORMERS_VERSION) < Version("5.2.0"):
35 - self.mm_processor_kwargs = {
36 - "min_pixels": 28 * 28,
37 - "max_pixels": 1280 * 28 * 28,
38 - }
39 - else:
40 - self.mm_processor_kwargs = {
41 - "size": {
42 - "shortest_edge": 28 * 28,
43 - "longest_edge": 1280 * 28 * 28,
44 - }
30 + self.mm_processor_kwargs = {
31 + "size": {
32 + "shortest_edge": 28 * 28,
33 + "longest_edge": 1280 * 28 * 28,
34 }
35 + }
36
37
38 class Qwen2VLTester:
tests/models/language/generation/test_common.py
-12
@@ -3,8 +3,6 @@
3
4 import pytest
5 import torch
6 -from packaging.version import Version
7 -from transformers import __version__ as TRANSFORMERS_VERSION
6
7 from vllm.platforms import current_platform
8
@@ -162,16 +160,6 @@ def test_models(
160 if prompt_embeds is not None:
161 embed = hf_model.model.get_input_embeddings()(token_ids)
162
165 - if "gemma" in model.lower() and (
166 - Version(TRANSFORMERS_VERSION) < Version("5.3.0.dev0")
167 - ):
168 - # For Gemma 1/2 models with Transformers 5.4.0+, the prompt
169 - # embeddings are normalised in `get_prompt_embeddings`,
170 - # like Gemma 3. For older versions, we need to manually normalise.
171 - embed_scale = hf_model.config.hidden_size**0.5
172 - normalizer = torch.tensor(embed_scale, dtype=embed.dtype)
173 - embed *= normalizer
174 -
163 # MiniCPM models apply scale_emb to embeddings internally.
164 # vLLM expects pre-scaled embeddings when using inputs_embeds.
165 if model in EMBED_SCALING_MODELS:
tests/models/multimodal/generation/test_common.py
-6
@@ -317,8 +317,6 @@ VLM_TEST_SETTINGS = {
317 img_idx_to_prompt=lambda idx: "",
318 auto_cls=AutoModelForImageTextToText,
319 vllm_output_post_proc=model_utils.blip2_vllm_to_hf_output,
320 - # FIXME: https://github.com/huggingface/transformers/pull/38510
321 - marks=[pytest.mark.skip("Model is broken")],
320 ),
321 "cosmos3": VLMTestInfo(
322 models=["nvidia/Cosmos3-Nano"],
@@ -819,10 +817,6 @@ VLM_TEST_SETTINGS = {
817 patch_hf_runner=model_utils.paddleocr_vl_patch_hf_runner,
818 image_size_factors=[(0.25,)],
819 marks=[
822 - pytest.mark.skipif(
823 - Version(TRANSFORMERS_VERSION) == Version("4.57.3"),
824 - reason="This model is broken in Transformers v4.57.3",
825 - ),
820 pytest.mark.skipif(
821 Version(TRANSFORMERS_VERSION) >= Version("5.0.0"),
822 reason="Model's custom code uses ROPE_INIT_FUNCTIONS"
tests/models/multimodal/generation/vlm_utils/model_utils.py
-10
@@ -308,16 +308,6 @@ def gemma3_patch_hf_runner(hf_model: HfRunner) -> HfRunner:
308
309 hf_model.processor = processor
310
311 - orig_generate = hf_model.model.generate
312 -
313 - def _generate(self, *args, **kwargs):
314 - # FIXME: https://github.com/huggingface/transformers/issues/38333
315 - kwargs["disable_compile"] = True
316 -
317 - return orig_generate(*args, **kwargs)
318 -
319 - hf_model.model.generate = types.MethodType(_generate, hf_model.model)
320 -
311 return hf_model
312
313
tests/models/multimodal/pooling/test_jinavl_reranker.py
-22
@@ -2,8 +2,6 @@
2 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
4 import pytest
5 -import transformers
6 -from packaging import version
5 from transformers import AutoModel
6
7 from vllm.assets.base import VLLM_S3_BUCKET_URL
@@ -246,10 +244,6 @@ def _run_test(
244
245 @pytest.mark.parametrize("model", MODELS)
246 @pytest.mark.parametrize("dtype", ["half"])
249 -@pytest.mark.skipif(
250 - version.parse(transformers.__version__) == version.parse("4.57.5"),
251 - reason="Skipped for transformers==4.57.5, https://github.com/huggingface/transformers/issues/43295",
252 -)
247 def test_model_text_image(
248 hf_runner,
249 vllm_runner,
@@ -269,10 +263,6 @@ def test_model_text_image(
263
264 @pytest.mark.parametrize("model", MODELS)
265 @pytest.mark.parametrize("dtype", ["half"])
272 -@pytest.mark.skipif(
273 - version.parse(transformers.__version__) == version.parse("4.57.5"),
274 - reason="Skipped for transformers==4.57.5, https://github.com/huggingface/transformers/issues/43295",
275 -)
266 def test_model_text_text(
267 hf_runner,
268 vllm_runner,
@@ -292,10 +282,6 @@ def test_model_text_text(
282
283 @pytest.mark.parametrize("model", MODELS)
284 @pytest.mark.parametrize("dtype", ["half"])
295 -@pytest.mark.skipif(
296 - version.parse(transformers.__version__) == version.parse("4.57.5"),
297 - reason="Skipped for transformers==4.57.5, https://github.com/huggingface/transformers/issues/43295",
298 -)
285 def test_model_image_text(
286 hf_runner,
287 vllm_runner,
@@ -315,10 +301,6 @@ def test_model_image_text(
301
302 @pytest.mark.parametrize("model", MODELS)
303 @pytest.mark.parametrize("dtype", ["half"])
318 -@pytest.mark.skipif(
319 - version.parse(transformers.__version__) == version.parse("4.57.5"),
320 - reason="Skipped for transformers==4.57.5, https://github.com/huggingface/transformers/issues/43295",
321 -)
304 def test_model_image_image(
305 hf_runner,
306 vllm_runner,
@@ -338,10 +320,6 @@ def test_model_image_image(
320
321 @pytest.mark.parametrize("model", MODELS)
322 @pytest.mark.parametrize("dtype", ["half"])
341 -@pytest.mark.skipif(
342 - version.parse(transformers.__version__) == version.parse("4.57.5"),
343 - reason="Skipped for transformers==4.57.5, https://github.com/huggingface/transformers/issues/43295",
344 -)
323 def test_model_text_mixed_documents(
324 hf_runner,
325 vllm_runner,
tests/models/multimodal/processing/test_idefics3.py
-6
@@ -3,9 +3,7 @@
3 """Tests for Idefics3's multimodal preprocessing kwargs."""
4
5 import pytest
6 -from packaging.version import Version
6 from transformers import Idefics3Config
8 -from transformers import __version__ as TRANSFORMERS_VERSION
7
8 from vllm.multimodal import MULTIMODAL_REGISTRY
9
@@ -13,10 +11,6 @@ from ....conftest import ImageTestAssets
11 from ...utils import build_model_context
12
13
16 -@pytest.mark.skipif(
17 - Version(TRANSFORMERS_VERSION) < Version("5.2.0"),
18 - reason="See https://github.com/huggingface/transformers/pull/43948",
19 -)
14 @pytest.mark.parametrize("model_id", ["HuggingFaceM4/Idefics3-8B-Llama3"])
15 @pytest.mark.parametrize(
16 ("mm_processor_kwargs", "expected_toks_per_img"),
tests/models/multimodal/processing/test_qwen2_vl.py
-14
@@ -3,9 +3,7 @@
3
4 import pytest
5 import torch
6 -from packaging.version import Version
6 from PIL import Image
8 -from transformers import __version__ as TRANSFORMERS_VERSION
7
8 from vllm.model_executor.models.vision import FusedInputNorm
9 from vllm.multimodal import MULTIMODAL_REGISTRY
@@ -133,12 +131,6 @@ def test_processor_override(
131 kwargs_on_init: bool,
132 ):
133 """Ensure Qwen2VLMultiModalProcessor handles min/max pixels properly."""
136 - if (
137 - Version(TRANSFORMERS_VERSION) < Version("5.2.0")
138 - and "size" in mm_processor_kwargs
139 - ):
140 - pytest.skip("`size` ignored by `Qwen2VLProcessor.__call__`")
141 -
134 ctx = build_model_context(
135 model_id,
136 mm_processor_kwargs=mm_processor_kwargs if kwargs_on_init else None,
@@ -184,12 +176,6 @@ def test_get_image_size_with_most_features(
176 model_id: str,
177 mm_processor_kwargs: dict[str, object],
178 ):
187 - if (
188 - Version(TRANSFORMERS_VERSION) < Version("5.2.0")
189 - and "size" in mm_processor_kwargs
190 - ):
191 - pytest.skip("`size` ignored by `Qwen2VLProcessor.__call__`")
192 -
179 ctx = build_model_context(
180 model_id,
181 mm_processor_kwargs=mm_processor_kwargs,
tests/models/multimodal/processing/test_smolvlm.py
-6
@@ -3,9 +3,7 @@
3 """Tests for smolvlm's multimodal preprocessing kwargs."""
4
5 import pytest
6 -from packaging.version import Version
6 from transformers import SmolVLMConfig
8 -from transformers import __version__ as TRANSFORMERS_VERSION
7
8 from vllm.multimodal import MULTIMODAL_REGISTRY
9
@@ -13,10 +11,6 @@ from ....conftest import ImageTestAssets
11 from ...utils import build_model_context
12
13
16 -@pytest.mark.skipif(
17 - Version(TRANSFORMERS_VERSION) < Version("5.2.0"),
18 - reason="See https://github.com/huggingface/transformers/pull/43948",
19 -)
14 @pytest.mark.parametrize("model_id", ["HuggingFaceTB/SmolVLM2-2.2B-Instruct"])
15 @pytest.mark.parametrize(
16 ("mm_processor_kwargs", "expected_toks_per_img"),
vllm/model_executor/models/glm4_1v.py
+10 -32
@@ -36,9 +36,7 @@ import numpy as np
36 import torch
37 import torch.nn as nn
38 import torch.nn.functional as F
39 -import transformers
39 from einops import rearrange
41 -from packaging.version import Version
40 from transformers import BatchFeature, Glm4vProcessor
41 from transformers.image_processing_base import ImageProcessingMixin
42 from transformers.models.glm4v.configuration_glm4v import (
@@ -132,8 +130,6 @@ logger = init_logger(__name__)
130 # For profile run
131 _MAX_FRAMES_PER_VIDEO = 600
132
135 -TRANSFORMERS_WITH_GA = Version(transformers.__version__) >= Version("5.10.0.dev0")
136 -
133
134 def _to_video_metadata(metadata: Mapping[str, Any]) -> VideoMetadata:
135 return VideoMetadata(
@@ -1389,17 +1385,6 @@ class Glm4vProcessingInfo(BaseProcessingInfo):
1385 timestamps_list = full_second_idxs[::2]
1386 return list(timestamps_list)
1387
1392 - def _get_video_frame_embed_token_id(self, hf_processor: object) -> int:
1393 - attr = (
1394 - "image_token_id"
1395 - if isinstance(hf_processor, Glm4vProcessor) or TRANSFORMERS_WITH_GA
1396 - else "video_token_id"
1397 - )
1398 - token_id = getattr(hf_processor, attr, None)
1399 - if not isinstance(token_id, int):
1400 - raise ValueError(f"Processor has no valid {attr}")
1401 - return token_id
1402 -
1388 def _construct_video_placeholder(
1389 self,
1390 video_array: np.ndarray,
@@ -1437,7 +1422,7 @@ class Glm4vProcessingInfo(BaseProcessingInfo):
1422 num_tokens_per_frame = int(H * W) // merge_length
1423 placeholder = []
1424 placeholder.append(bov_token_id)
1440 - frame_embed_token_id = self._get_video_frame_embed_token_id(hf_processor)
1425 + frame_embed_token_id = hf_processor.image_token_id
1426 for frame_idx in frames_idx_token:
1427 placeholder.append(boi_token_id)
1428 placeholder.extend([frame_embed_token_id] * num_tokens_per_frame)
@@ -1601,10 +1586,7 @@ class Glm4vMultiModalProcessor(BaseMultiModalProcessor[Glm4vProcessingInfo]):
1586
1587 processor = self.info.get_hf_processor(**hf_kwargs)
1588
1604 - use_direct_path = (
1605 - not isinstance(processor, Glm4vProcessor) and TRANSFORMERS_WITH_GA
1606 - )
1607 - if use_direct_path:
1589 + if not isinstance(processor, Glm4vProcessor):
1590 prepared_data, prepared_kwargs = self._get_direct_path_inputs(
1591 hf_data, hf_kwargs
1592 )
@@ -1627,8 +1609,6 @@ class Glm4vMultiModalProcessor(BaseMultiModalProcessor[Glm4vProcessingInfo]):
1609 del hf_data["videos"]
1610 video_grid_thw_lst = []
1611 pixel_values_videos_lst = []
1630 - frame_embed_token_id = self.info._get_video_frame_embed_token_id(processor)
1631 - swap_video_frame_tokens = frame_embed_token_id == processor.image_token_id
1612 for item in videos:
1613 video_array, metadata = item
1614
@@ -1651,10 +1631,10 @@ class Glm4vMultiModalProcessor(BaseMultiModalProcessor[Glm4vProcessingInfo]):
1631 video_mm_kwargs,
1632 )
1633 input_ids = video_outputs.pop("input_ids")
1654 - if swap_video_frame_tokens:
1655 - input_ids[input_ids == processor.image_token_id] = (
1656 - processor.video_token_id
1657 - )
1634 +
1635 + input_ids[input_ids == processor.image_token_id] = (
1636 + processor.video_token_id
1637 + )
1638 video_placeholder = processor.tokenizer.batch_decode(input_ids)[0]
1639 prompt_text = prompt_text.replace(
1640 "<|begin_of_video|><|video|><|end_of_video|>",
@@ -1670,17 +1650,15 @@ class Glm4vMultiModalProcessor(BaseMultiModalProcessor[Glm4vProcessingInfo]):
1650 )
1651 else:
1652 video_outputs = dict()
1673 - swap_video_frame_tokens = False
1653
1654 processed_data = self.info.ctx.call_hf_processor(
1655 self.info.get_hf_processor(**hf_kwargs),
1656 dict(text=prompt_text, **hf_data),
1657 hf_kwargs,
1658 )
1680 - if swap_video_frame_tokens:
1681 - input_ids = processed_data["input_ids"]
1682 - input_ids[input_ids == processor.video_token_id] = processor.image_token_id
1683 - processed_data["input_ids"] = input_ids
1659 + input_ids = processed_data["input_ids"]
1660 + input_ids[input_ids == processor.video_token_id] = processor.image_token_id
1661 + processed_data["input_ids"] = input_ids
1662
1663 processed_data.update(video_outputs)
1664 return self._finalize_hf_mm_data(
@@ -1728,7 +1706,7 @@ class Glm4vMultiModalProcessor(BaseMultiModalProcessor[Glm4vProcessingInfo]):
1706 )
1707 return PromptUpdateDetails.select_token_id(
1708 placeholder,
1731 - embed_token_id=self.info._get_video_frame_embed_token_id(hf_processor),
1709 + embed_token_id=hf_processor.image_token_id,
1710 )
1711
1712 return [
vllm/model_executor/models/qwen3_omni_moe_thinker.py
-12
@@ -1228,18 +1228,6 @@ class Qwen3OmniMoeThinkerMultiModalProcessor(
1228 ) -> HFMultiModalInputs:
1229 hf_inputs = super()._get_hf_mm_inputs(mm_items, hf_kwargs)
1230
1231 - if mm_items.get_count("audio", strict=False):
1232 - # TODO(Isotr0py): Remove this patch after upstream fix PR
1233 - # released and Transformers version update:
1234 - # https://github.com/huggingface/transformers/pull/41473
1235 - hf_inputs = hf_inputs._replace(
1236 - hf_kwargs={
1237 - **hf_inputs.hf_kwargs,
1238 - "audio_kwargs": dict(hf_inputs.hf_kwargs.get("audio_kwargs") or {}),
1239 - "text_kwargs": dict(hf_inputs.hf_kwargs.get("text_kwargs") or {}),
1240 - }
1241 - )
1242 -
1231 audios = hf_inputs.hf_data.get("audio")
1232 if audios:
1233 feature_extractor = self.info.get_feature_extractor()