Skip to content

Commit aec9674

Browse files
[Core] Remove legacy input mapper/processor from V0 (#15686)
Signed-off-by: DarkLight1337 <[email protected]>
1 parent 7fcc422 commit aec9674

21 files changed

+144
-1339
lines changed

vllm/core/scheduler.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1596,7 +1596,6 @@ def schedule(
15961596
multi_modal_placeholders=(
15971597
seq_group.multi_modal_placeholders
15981598
if scheduler_outputs.num_prefill_groups > 0 else None),
1599-
mm_processor_kwargs=seq_group.mm_processor_kwargs,
16001599
prompt_adapter_request=seq_group.prompt_adapter_request,
16011600
)
16021601
else:

vllm/engine/async_llm_engine.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,12 +493,11 @@ async def add_request_async(
493493
tokenizer = await self.get_tokenizer_async(lora_request)
494494
self._validate_token_prompt(prompt, tokenizer=tokenizer)
495495

496-
preprocessed_inputs = await self.input_preprocessor.preprocess_async(
496+
processed_inputs = await self.input_preprocessor.preprocess_async(
497497
prompt,
498498
lora_request=lora_request,
499499
prompt_adapter_request=prompt_adapter_request,
500500
)
501-
processed_inputs = self.input_processor(preprocessed_inputs)
502501

503502
if isinstance(params, SamplingParams) and \
504503
params.guided_decoding is not None:

vllm/engine/llm_engine.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
from vllm.entrypoints.openai.logits_processors import (
3030
get_logits_processors as get_openai_logits_processors)
3131
from vllm.executor.executor_base import ExecutorBase
32-
from vllm.inputs import (INPUT_REGISTRY, InputRegistry, ProcessorInputs,
33-
PromptType, SingletonInputs)
32+
from vllm.inputs import ProcessorInputs, PromptType, SingletonInputs
3433
from vllm.inputs.parse import is_token_prompt, split_enc_dec_inputs
3534
from vllm.inputs.preprocess import InputPreprocessor
3635
from vllm.logger import init_logger
@@ -213,7 +212,6 @@ def __init__(
213212
log_stats: bool,
214213
usage_context: UsageContext = UsageContext.ENGINE_CONTEXT,
215214
stat_loggers: Optional[Dict[str, StatLoggerBase]] = None,
216-
input_registry: InputRegistry = INPUT_REGISTRY,
217215
mm_registry: MultiModalRegistry = MULTIMODAL_REGISTRY,
218216
use_cached_outputs: bool = False,
219217
) -> None:
@@ -274,11 +272,7 @@ def get_tokenizer_for_seq(sequence: Sequence) -> AnyTokenizer:
274272
self.tokenizer,
275273
mm_registry)
276274

277-
self.input_registry = input_registry
278-
self.input_processor = input_registry.create_input_processor(
279-
self.model_config)
280-
281-
self.model_executor = executor_class(vllm_config=vllm_config, )
275+
self.model_executor = executor_class(vllm_config=vllm_config)
282276

283277
if self.model_config.runner_type != "pooling":
284278
self._initialize_kv_caches()
@@ -762,12 +756,11 @@ def add_request(
762756
prompt,
763757
tokenizer=self.get_tokenizer(lora_request=lora_request))
764758

765-
preprocessed_inputs = self.input_preprocessor.preprocess(
759+
processed_inputs = self.input_preprocessor.preprocess(
766760
prompt,
767761
lora_request=lora_request,
768762
prompt_adapter_request=prompt_adapter_request,
769763
)
770-
processed_inputs = self.input_processor(preprocessed_inputs)
771764

772765
self._add_processed_request(
773766
request_id=request_id,

vllm/inputs/__init__.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22

33
from .data import (DecoderOnlyInputs, EncoderDecoderInputs,
44
ExplicitEncoderDecoderPrompt, ProcessorInputs, PromptType,
5-
SingletonInputs, SingletonInputsAdapter, SingletonPrompt,
6-
TextPrompt, TokenInputs, TokensPrompt,
7-
build_explicit_enc_dec_prompt, to_enc_dec_tuple_list,
8-
token_inputs, zip_enc_dec_prompts)
5+
SingletonInputs, SingletonPrompt, TextPrompt, TokenInputs,
6+
TokensPrompt, build_explicit_enc_dec_prompt,
7+
to_enc_dec_tuple_list, token_inputs, zip_enc_dec_prompts)
98
from .registry import (DummyData, InputContext, InputProcessingContext,
109
InputRegistry)
1110

@@ -27,7 +26,6 @@
2726
"EncoderDecoderInputs",
2827
"ProcessorInputs",
2928
"SingletonInputs",
30-
"SingletonInputsAdapter",
3129
"build_explicit_enc_dec_prompt",
3230
"to_enc_dec_tuple_list",
3331
"zip_enc_dec_prompts",

vllm/inputs/data.py

Lines changed: 2 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
# SPDX-License-Identifier: Apache-2.0
2-
32
from collections.abc import Iterable
4-
from dataclasses import dataclass
5-
from functools import cached_property
63
from typing import TYPE_CHECKING, Any, Generic, Literal, Optional, Union, cast
74

8-
import torch
9-
from typing_extensions import NotRequired, TypedDict, TypeVar, assert_never
5+
from typing_extensions import NotRequired, TypedDict, TypeVar
106

117
if TYPE_CHECKING:
12-
from vllm.multimodal import (MultiModalDataDict, MultiModalKwargs,
13-
MultiModalPlaceholderDict)
14-
from vllm.multimodal.inputs import MultiModalInputs
8+
from vllm.multimodal.inputs import MultiModalDataDict, MultiModalInputs
159

1610

1711
class TextPrompt(TypedDict):
@@ -147,46 +141,11 @@ class TokenInputs(TypedDict):
147141
The original prompt text corresponding to the token IDs, if available.
148142
"""
149143

150-
multi_modal_data: NotRequired["MultiModalDataDict"]
151-
"""
152-
Optional multi-modal data to pass to the model,
153-
if the model supports it.
154-
"""
155-
156-
multi_modal_inputs: NotRequired["MultiModalKwargs"]
157-
"""
158-
Optional multi-modal inputs to pass to the model,
159-
if the model supports it.
160-
"""
161-
162-
multi_modal_placeholders: NotRequired["MultiModalPlaceholderDict"]
163-
"""
164-
Placeholder ranges for the multi-modal data.
165-
"""
166-
167-
multi_modal_hashes: NotRequired[list[str]]
168-
"""
169-
The hashes of the multi-modal data.
170-
"""
171-
172-
mm_processor_kwargs: NotRequired[dict[str, Any]]
173-
"""
174-
Optional multi-modal processor kwargs to be forwarded to the
175-
multimodal input mapper & processor. Note that if multiple modalities
176-
have registered mappers etc for the model being considered, we attempt
177-
to pass the mm_processor_kwargs to each of them.
178-
"""
179-
180144

181145
def token_inputs(
182146
prompt_token_ids: list[int],
183147
token_type_ids: Optional[list[int]] = None,
184148
prompt: Optional[str] = None,
185-
multi_modal_data: Optional["MultiModalDataDict"] = None,
186-
multi_modal_inputs: Optional["MultiModalKwargs"] = None,
187-
multi_modal_hashes: Optional[list[str]] = None,
188-
multi_modal_placeholders: Optional["MultiModalPlaceholderDict"] = None,
189-
mm_processor_kwargs: Optional[dict[str, Any]] = None,
190149
) -> TokenInputs:
191150
"""Construct :class:`TokenInputs` from optional values."""
192151
inputs = TokenInputs(type="token", prompt_token_ids=prompt_token_ids)
@@ -195,16 +154,6 @@ def token_inputs(
195154
inputs["prompt"] = prompt
196155
if token_type_ids is not None:
197156
inputs["token_type_ids"] = token_type_ids
198-
if multi_modal_data is not None:
199-
inputs["multi_modal_data"] = multi_modal_data
200-
if multi_modal_inputs is not None:
201-
inputs["multi_modal_inputs"] = multi_modal_inputs
202-
if multi_modal_hashes is not None:
203-
inputs["multi_modal_hashes"] = multi_modal_hashes
204-
if multi_modal_placeholders is not None:
205-
inputs["multi_modal_placeholders"] = multi_modal_placeholders
206-
if mm_processor_kwargs is not None:
207-
inputs["mm_processor_kwargs"] = mm_processor_kwargs
208157

209158
return inputs
210159

@@ -237,112 +186,6 @@ class EncoderDecoderInputs(TypedDict):
237186
:class:`vllm.sequence.Sequence`.
238187
"""
239188

240-
241-
@dataclass
242-
class SingletonInputsAdapter:
243-
"""
244-
Unified interface to access the components of :class:`SingletonInputs`.
245-
"""
246-
inputs: SingletonInputs
247-
248-
@cached_property
249-
def prompt(self) -> Optional[str]:
250-
inputs = self.inputs
251-
252-
if inputs["type"] == "token" or inputs["type"] == "multimodal":
253-
return inputs.get("prompt")
254-
255-
assert_never(inputs) # type: ignore[arg-type]
256-
257-
@cached_property
258-
def prompt_token_ids(self) -> list[int]:
259-
inputs = self.inputs
260-
261-
if inputs["type"] == "token" or inputs["type"] == "multimodal":
262-
return inputs.get("prompt_token_ids", [])
263-
264-
assert_never(inputs) # type: ignore[arg-type]
265-
266-
@cached_property
267-
def token_type_ids(self) -> list[int]:
268-
inputs = self.inputs
269-
270-
if inputs["type"] == "token" or inputs["type"] == "multimodal":
271-
return inputs.get("token_type_ids", [])
272-
273-
assert_never(inputs) # type: ignore[arg-type]
274-
275-
@cached_property
276-
def prompt_embeds(self) -> Optional[torch.Tensor]:
277-
inputs = self.inputs
278-
279-
if inputs["type"] == "token" or inputs["type"] == "multimodal":
280-
return None
281-
282-
assert_never(inputs) # type: ignore[arg-type]
283-
284-
@cached_property
285-
def multi_modal_data(self) -> "MultiModalDataDict":
286-
inputs = self.inputs
287-
288-
if inputs["type"] == "token":
289-
return inputs.get("multi_modal_data", {})
290-
291-
if inputs["type"] == "multimodal":
292-
return inputs.get("mm_kwargs", {})
293-
294-
assert_never(inputs) # type: ignore[arg-type]
295-
296-
@cached_property
297-
def multi_modal_inputs(self) -> Union[dict, "MultiModalKwargs"]:
298-
inputs = self.inputs
299-
300-
if inputs["type"] == "token":
301-
return inputs.get("multi_modal_inputs", {})
302-
303-
if inputs["type"] == "multimodal":
304-
return inputs.get("mm_kwargs", {})
305-
306-
assert_never(inputs) # type: ignore[arg-type]
307-
308-
@cached_property
309-
def multi_modal_hashes(self) -> list[str]:
310-
inputs = self.inputs
311-
312-
if inputs["type"] == "token":
313-
return inputs.get("multi_modal_hashes", [])
314-
315-
if inputs["type"] == "multimodal":
316-
# only the case when we use MultiModalInputs
317-
return inputs.get("mm_hashes", []) # type: ignore[return-value]
318-
319-
assert_never(inputs) # type: ignore[arg-type]
320-
321-
@cached_property
322-
def multi_modal_placeholders(self) -> "MultiModalPlaceholderDict":
323-
inputs = self.inputs
324-
325-
if inputs["type"] == "token":
326-
return inputs.get("multi_modal_placeholders", {})
327-
328-
if inputs["type"] == "multimodal":
329-
return inputs.get("mm_placeholders", {})
330-
331-
assert_never(inputs) # type: ignore[arg-type]
332-
333-
@cached_property
334-
def mm_processor_kwargs(self) -> dict[str, Any]:
335-
inputs = self.inputs
336-
337-
if inputs["type"] == "token":
338-
return inputs.get("mm_processor_kwargs", {})
339-
340-
if inputs["type"] == "multimodal":
341-
return {}
342-
343-
assert_never(inputs) # type: ignore[arg-type]
344-
345-
346189
ProcessorInputs = Union[DecoderOnlyInputs, EncoderDecoderInputs]
347190
"""
348191
The inputs to :data:`vllm.inputs.InputProcessor`.

0 commit comments

Comments
 (0)