Skip to content

Commit 9c49f53

Browse files
committed
chore: cleanups following review
Signed-off-by: Alexandre Milesi <[email protected]>
1 parent 8da6645 commit 9c49f53

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

vllm/multimodal/profiling.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def get_decoder_dummy_data(
256256
multi_modal_placeholders=mm_inputs["mm_placeholders"],
257257
)
258258

259-
def get_mm_max_tokens(
259+
def _get_mm_max_tokens(
260260
self,
261261
seq_len: int,
262262
mm_counts: Optional[Mapping[str, int]] = None,
@@ -292,11 +292,22 @@ def get_mm_max_tokens(
292292
return self._get_mm_num_tokens(mm_inputs,
293293
mm_embeddings_only=mm_embeddings_only)
294294

295-
def get_max_placeholder_tokens(
295+
def get_mm_max_contiguous_tokens(
296296
self,
297297
seq_len: int,
298298
mm_counts: Optional[Mapping[str, int]] = None,
299299
):
300-
return self.get_mm_max_tokens(seq_len,
301-
mm_counts,
302-
mm_embeddings_only=False)
300+
"""
301+
Returns the maximum length of the multimodal (image placeholders+text)
302+
tokens, including any break/text tokens in-between image embeddings.
303+
304+
<im_start> [IMG] [IMG] [IMG] <row_break> [IMG] [IMG] [IMG] <im_end>
305+
Returns 9, even when the number of image embeddings is 6.
306+
307+
This is important to take into account when profiling and
308+
initializing the encoder cache size.
309+
"""
310+
311+
return self._get_mm_max_tokens(seq_len,
312+
mm_counts,
313+
mm_embeddings_only=False)

vllm/multimodal/registry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def get_max_tokens_per_item_by_modality(
129129
seq_len = model_config.max_model_len
130130
mm_limits = self.get_mm_limits_per_prompt(model_config)
131131

132-
return profiler.get_max_placeholder_tokens(
132+
return profiler.get_mm_max_contiguous_tokens(
133133
seq_len,
134134
{
135135
modality: 1

0 commit comments

Comments
 (0)