Skip to content

Commit b35706d

Browse files
Refine Ovis padding
1 parent a3d8fa9 commit b35706d

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

vllm/model_executor/models/ovis2_5.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,13 +477,19 @@ def find_padding(self, h_orig, w_orig, desired_patches):
477477
if desired_patches % h_orig == 0:
478478
best_pad_h = 0
479479
w_factor = desired_patches // h_orig
480-
best_pad_w = w_factor - w_orig if (w_factor > w_orig
481-
and w_factor % 2 == 0) else 0
480+
best_pad_w = (
481+
w_factor - w_orig if (w_factor > w_orig and w_factor %
482+
self.config.vit_config.hidden_stride
483+
== 0) else 0
484+
)
482485
elif desired_patches % w_orig == 0:
483486
best_pad_w = 0
484487
h_factor = desired_patches // w_orig
485-
best_pad_h = h_factor - h_orig if (h_factor > h_orig
486-
and h_factor % 2 == 0) else 0
488+
best_pad_h = (
489+
h_factor - h_orig if (h_factor > h_orig and h_factor %
490+
self.config.vit_config.hidden_stride
491+
== 0) else 0
492+
)
487493
elif desired_patches % h_orig != 0 and desired_patches % w_orig != 0:
488494
if h_orig > w_orig:
489495
w_factor = self.find_factor(desired_patches, w_orig)

0 commit comments

Comments
 (0)