Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
741f4e04
Unverified
Commit
741f4e04
authored
Mar 11, 2026
by
tianshu-Michael-yu
Committed by
GitHub
Mar 11, 2026
Browse files
fix: align lfm2 thumbnail token counting with HF (#36707)
parent
a5d06dc5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
1 deletion
+19
-1
vllm/model_executor/models/lfm2_vl.py
vllm/model_executor/models/lfm2_vl.py
+19
-1
No files found.
vllm/model_executor/models/lfm2_vl.py
View file @
741f4e04
...
@@ -324,7 +324,25 @@ class Lfm2VLProcessingInfo(BaseProcessingInfo):
...
@@ -324,7 +324,25 @@ class Lfm2VLProcessingInfo(BaseProcessingInfo):
)
)
tile_size
=
mm_kwargs
.
get
(
"tile_size"
,
image_processor
.
tile_size
)
tile_size
=
mm_kwargs
.
get
(
"tile_size"
,
image_processor
.
tile_size
)
num_thumbnail_tokens
=
spatial_shapes
[
-
1
].
prod
()
//
(
downsample_factor
**
2
)
thumbnail_height_patches
=
int
(
spatial_shapes
[
-
1
][
0
].
item
())
thumbnail_width_patches
=
int
(
spatial_shapes
[
-
1
][
1
].
item
())
# HF computes thumbnail tokens as
# ceil(h_patches / downsample_factor) * ceil(w_patches / downsample_factor).
# We assert divisibility here so any processor/model drift is surfaced
# immediately instead of being hidden by floor division.
assert
thumbnail_height_patches
%
downsample_factor
==
0
,
(
"LFM2-VL thumbnail height patch grid must be divisible by "
f
"downsample_factor, got height_patches=
{
thumbnail_height_patches
}
, "
f
"downsample_factor=
{
downsample_factor
}
"
)
assert
thumbnail_width_patches
%
downsample_factor
==
0
,
(
"LFM2-VL thumbnail width patch grid must be divisible by "
f
"downsample_factor, got width_patches=
{
thumbnail_width_patches
}
, "
f
"downsample_factor=
{
downsample_factor
}
"
)
num_thumbnail_tokens
=
math
.
ceil
(
thumbnail_height_patches
/
downsample_factor
)
*
math
.
ceil
(
thumbnail_width_patches
/
downsample_factor
)
num_patches_tile
=
tile_size
//
encoder_patch_size
num_patches_tile
=
tile_size
//
encoder_patch_size
dwn_num_patches_tile
=
math
.
ceil
(
num_patches_tile
/
downsample_factor
)
dwn_num_patches_tile
=
math
.
ceil
(
num_patches_tile
/
downsample_factor
)
num_tiles_tokens
=
dwn_num_patches_tile
*
dwn_num_patches_tile
num_tiles_tokens
=
dwn_num_patches_tile
*
dwn_num_patches_tile
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment