@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 7fdaaf48ef
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 15, 23:30 UTC

[Bugfix] Fix qwen2.5-vl image processor (#13286)

Isotr0py committed Feb 15, 2025 at 19:00 UTC 7fdaaf48ef2a10c26be7c87103a64a227f245cea
2 files changed +17 -6
vllm/model_executor/models/qwen2_5_vl.py
+8 -5
@@ -33,10 +33,11 @@ import torch.nn as nn
33 import torch.nn.functional as F
34 from einops import rearrange
35 from transformers import BatchFeature
36 -from transformers.models.qwen2_5_vl import (Qwen2_5_VLImageProcessor,
37 - Qwen2_5_VLProcessor)
36 +from transformers.models.qwen2_5_vl import Qwen2_5_VLProcessor
37 from transformers.models.qwen2_5_vl.configuration_qwen2_5_vl import (
38 Qwen2_5_VLConfig, Qwen2_5_VLVisionConfig)
39 +from transformers.models.qwen2_vl import (Qwen2VLImageProcessor,
40 + Qwen2VLImageProcessorFast)
41
42 from vllm.attention import AttentionMetadata
43 from vllm.config import VllmConfig
@@ -693,7 +694,8 @@ class Qwen2_5_VLProcessingInfo(Qwen2VLProcessingInfo):
694 ) -> Qwen2_5_VLProcessor:
695 hf_processor = self.ctx.get_hf_processor(Qwen2_5_VLProcessor)
696 image_processor = hf_processor.image_processor # type: ignore
696 - assert isinstance(image_processor, Qwen2_5_VLImageProcessor)
697 + assert isinstance(image_processor,
698 + (Qwen2VLImageProcessor, Qwen2VLImageProcessorFast))
699
700 if min_pixels:
701 image_processor.min_pixels = min_pixels
@@ -713,14 +715,15 @@ class Qwen2_5_VLProcessingInfo(Qwen2VLProcessingInfo):
715 min_pixels: Optional[int] = None,
716 max_pixels: Optional[int] = None,
717 fps: Optional[float] = 2.0,
716 - ) -> Qwen2_5_VLImageProcessor:
718 + ) -> Union[Qwen2VLImageProcessor, Qwen2VLImageProcessorFast]:
719 hf_processor = self.get_hf_processor(
720 min_pixels=min_pixels,
721 max_pixels=max_pixels,
722 fps=fps,
723 )
724 image_processor = hf_processor.image_processor # type: ignore
723 - assert isinstance(image_processor, Qwen2_5_VLImageProcessor)
725 + assert isinstance(image_processor,
726 + (Qwen2VLImageProcessor, Qwen2VLImageProcessorFast))
727 return image_processor
728
729
vllm/model_executor/models/qwen2_vl.py
+9 -1
@@ -31,7 +31,9 @@ import torch
31 import torch.nn as nn
32 import torch.nn.functional as F
33 from einops import rearrange, repeat
34 +from packaging.version import Version
35 from transformers import BatchFeature
36 +from transformers import __version__ as TRANSFORMERS_VERSION
37 from transformers.models.qwen2_vl import (Qwen2VLImageProcessor,
38 Qwen2VLProcessor)
39 from transformers.models.qwen2_vl.configuration_qwen2_vl import (
@@ -746,7 +748,13 @@ class Qwen2VLProcessingInfo(BaseProcessingInfo):
748 hf_processor = self.get_hf_processor(min_pixels=min_pixels,
749 max_pixels=max_pixels)
750 image_processor = hf_processor.image_processor # type: ignore
749 - assert isinstance(image_processor, Qwen2VLImageProcessor)
751 + if Version(TRANSFORMERS_VERSION) >= Version("4.49"):
752 + from transformers.models.qwen2_vl import Qwen2VLImageProcessorFast
753 + assert isinstance(
754 + image_processor,
755 + (Qwen2VLImageProcessor, Qwen2VLImageProcessorFast))
756 + else:
757 + assert isinstance(image_processor, Qwen2VLImageProcessor)
758 return image_processor
759
760 def get_supported_mm_limits(self) -> Mapping[str, Optional[int]]: