Skip to content

Commit b5020c2

Browse files
committed
Rename _find_placeholders
Signed-off-by: DarkLight1337 <[email protected]>
1 parent 95339d6 commit b5020c2

File tree

3 files changed

+26
-16
lines changed

3 files changed

+26
-16
lines changed

vllm/model_executor/models/llava.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,11 @@ def get_replacement_mantis(item_idx: int):
716716
)
717717
orig_repls = self._bind_prompt_replacements(unbound_orig_repls)
718718

719-
mm_placeholders = self._find_placeholders(orig_repls, prompt_ids,
720-
mm_item_counts)
719+
mm_placeholders = self._find_placeholders_by_modality(
720+
orig_repls,
721+
prompt_ids,
722+
mm_item_counts,
723+
)
721724

722725
self._validate_placeholders(mm_placeholders, mm_item_counts)
723726

vllm/model_executor/models/qwen2_audio.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,10 @@ def get_replacement_qwen2_audio(item_idx: int):
185185

186186
def _always_apply_prompt_replacements(self) -> bool:
187187
# HF never applies prompt replacements, so we have to do it ourselves.
188-
# NOTE: `_find_placeholders` may incorrectly think that HF has already
189-
# performed processing for multi-audio input when the input audios are
190-
# short (the corresponding placeholders may take up fewer tokens than
191-
# the number of audio items)
188+
# NOTE: `_find_placeholders_by_modality` may incorrectly think that HF
189+
# has already performed processing for multi-audio input when the input
190+
# audios are short (the corresponding placeholders may take up fewer
191+
# tokens than the number of audio items)
192192
return True
193193

194194
def _get_dummy_mm_inputs(

vllm/multimodal/processing.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ def _get_prompt_replacements(
719719
"""
720720
raise NotImplementedError
721721

722-
def _find_placeholders(
722+
def _find_placeholders_by_modality(
723723
self,
724724
all_prompt_repls: Sequence[_BoundPromptReplacement],
725725
new_token_ids: list[int],
@@ -930,10 +930,11 @@ def _always_apply_prompt_replacements(self) -> bool:
930930
"""
931931
A flag which can be overridden so that
932932
:meth:`_apply_prompt_replacements` is always called even if we
933-
detect that HF has performed processing via :meth:`_find_placeholders`.
933+
detect that HF has performed processing via
934+
:meth:`_find_placeholders_by_modality`.
934935
935-
This is useful in cases where :meth:`_find_placeholders` cannot be
936-
reliably used to detect whether HF has performed processing or not.
936+
This is useful in cases where :meth:`_find_placeholders_by_modality`
937+
cannot be reliably used to detect whether HF has performed processing.
937938
"""
938939
return False
939940

@@ -986,8 +987,11 @@ def _apply_prompt_replacements(
986987
token_ids = _encode(tokenizer, text)
987988
matched_repls = [match.prompt_repl for match in text_matches]
988989

989-
placeholders = self._find_placeholders(matched_repls, token_ids,
990-
mm_item_counts)
990+
placeholders = self._find_placeholders_by_modality(
991+
matched_repls,
992+
token_ids,
993+
mm_item_counts,
994+
)
991995

992996
return token_ids, text, placeholders
993997

@@ -1043,12 +1047,15 @@ def apply(
10431047
)
10441048
prompt_repls = self._bind_prompt_replacements(unbound_prompt_repls)
10451049

1046-
# If HF processor already inserts placeholder tokens,
1047-
# there is no need for us to insert them
10481050
mm_item_counts = mm_items.get_all_counts()
1049-
mm_placeholders = self._find_placeholders(prompt_repls, prompt_ids,
1050-
mm_item_counts)
1051+
mm_placeholders = self._find_placeholders_by_modality(
1052+
prompt_repls,
1053+
prompt_ids,
1054+
mm_item_counts,
1055+
)
10511056

1057+
# If HF processor already inserts placeholder tokens,
1058+
# there is no need for us to insert them
10521059
try:
10531060
self._validate_placeholders(mm_placeholders, mm_item_counts)
10541061
except ValueError:

0 commit comments

Comments
 (0)