[Misc] Remove code paths for Transformers < 5.16.1 (#59762)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Harry Mellor
2026-10-02 11:17:24 +00:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 8c60714da5
commit 5d20979fc9
18 changed files with 142 additions and 757 deletions
-8
View File
@@ -7,7 +7,6 @@ from collections.abc import Callable, Iterator, Sequence
from contextlib import contextmanager
from dataclasses import asdict
from functools import cache, partial, wraps
from importlib.metadata import version
from pathlib import Path
from typing import Any, Literal, TypeAlias
@@ -15,7 +14,6 @@ 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
from transformers import GenerationConfig, PreTrainedConfig
from transformers.configuration_utils import ALLOWED_LAYER_TYPES
@@ -69,12 +67,6 @@ _DENSE_MODULE_TYPES = {
"pylate.models.Dense.Dense",
}
if Version(version("transformers")) < Version("5.0.0"):
raise ImportError(
"Support for Transformers v4 is deprecated and was removed in vLLM v0.24.0. "
"Please upgrade to Transformers v5: pip install --upgrade transformers"
)
class LazyConfigDict(dict):
def __getitem__(self, key):
+2 -12
View File
@@ -61,10 +61,8 @@ class MistralCommonFeatureExtractor(SequenceFeatureExtractor):
"""HF-compatible duck-typed ``fetch_audio``.
Mirrors :meth:`transformers.SequenceFeatureExtractor.fetch_audio` so
:class:`transformers.ProcessorMixin.prepare_inputs_layout` (added in
transformers 5.10) works on this duck-typed feature extractor. Older
transformers versions never invoke this method, so the addition is a
no-op there.
:class:`transformers.ProcessorMixin.prepare_inputs_layout` works on this
duck-typed feature extractor.
Accepts the same shapes as ``SequenceFeatureExtractor.fetch_audio``:
@@ -77,11 +75,6 @@ class MistralCommonFeatureExtractor(SequenceFeatureExtractor):
``ProcessorMixin.prepare_inputs_layout`` always passes already-decoded
audio (numpy array or torch tensor), so the str / list-of-str branches
exist only to keep the contract identical to the upstream method.
The semantics of ``transformers.audio_utils.is_valid_audio`` differ
between transformers versions (5.9 only accepts ndarray/tensor; 5.10
also accepts ``list[float]``). We detect ``list[float]`` explicitly to
keep behavior identical across versions.
"""
from transformers.audio_utils import is_valid_audio
@@ -89,9 +82,6 @@ class MistralCommonFeatureExtractor(SequenceFeatureExtractor):
if is_valid_audio(audio_url_or_urls):
return audio_url_or_urls
if isinstance(audio_url_or_urls, (list, tuple)):
if audio_url_or_urls and isinstance(audio_url_or_urls[0], float):
# A single audio represented as ``list[float]``.
return audio_url_or_urls
return [
self.fetch_audio(x, sampling_rate=sampling_rate)
for x in audio_url_or_urls