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 9, 14:45 UTC
[StepVL] support close img patch (#32923)
Signed-off-by: luotingdan <luotingdan@stepfun.com> Signed-off-by: ltd0924 <32387785+ltd0924@users.noreply.github.com> Co-authored-by: luotingdan <luotingdan@stepfun.com>
ltd0924 committed
Jan 26, 2026 at 12:56 UTC
105d104576cbe86b11d8e37786eeb61b9ad21f33
1 file changed
+10
-5
vllm/model_executor/models/step3_vl.py
+10
-5
@@ -142,8 +142,11 @@ class Step3VisionProcessor:
142
143
144
class ImagePatcher:
145
+ def __init__(self, enable_patch: bool = True) -> None:
146
+ self.enable_patch = enable_patch
147
+
148
def determine_window_size(self, long: int, short: int) -> int:
146
- if long <= 728:
149
+ if long < 728:
150
return short if long / short > 1.5 else 0
151
return min(short, 504) if long / short > 4 else 504
152
@@ -241,7 +244,7 @@ class ImagePatcher:
244
window_size = self.determine_window_size(
245
max(img_height, img_width), min(img_height, img_width)
246
)
244
- if window_size == 0:
247
+ if window_size == 0 or not self.enable_patch:
248
return 0, 0
249
else:
250
img_width, img_height = self.get_image_size_for_crop(
@@ -277,7 +280,7 @@ class ImagePatcher:
280
max(new_img_height, new_img_width), min(new_img_height, new_img_width)
281
)
282
280
- if window_size == 0:
283
+ if window_size == 0 or not self.enable_patch:
284
return img, [], None
285
else:
286
new_img_width, new_img_height = self.get_image_size_for_crop(
@@ -327,7 +330,6 @@ class Step3VLProcessor:
330
331
self.config = config
332
self.tokenizer = tokenizer
330
-
333
self.image_size = 728
334
self.patch_size = 504
335
self.image_preprocessor = Step3VisionProcessor(
@@ -340,7 +342,10 @@ class Step3VLProcessor:
342
self.image_feature_placeholder = self.image_token * self.num_image_feature_size
343
self.patch_feature_placeholder = self.image_token * self.num_patch_feature_size
344
343
- self.patcher = ImagePatcher()
345
+ # Respect vision config switch to enable/disable patch extraction.
346
+ # For video understanding, it's preferable to disable patch.
347
+ enable_patch = getattr(self.config.vision_config, "enable_patch", True)
348
+ self.patcher = ImagePatcher(enable_patch=enable_patch)
349
350
@property
351
def image_token_id(self) -> int: