-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Core] Remove legacy input mapper/processor from V0 #15686
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
DarkLight1337
merged 11 commits into
vllm-project:main
from
DarkLight1337:deprecate-input-registry-v0
Apr 28, 2025
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
166b551
[Core] Remove legacy input mapper/processor from V0
DarkLight1337 5e1d1ea
Remove unused code
DarkLight1337 73d0dca
Fix pre-commit
DarkLight1337 0b2b41d
Merge branch 'main' into deprecate-input-registry-v0
DarkLight1337 febf089
Merge branch 'main' into deprecate-input-registry-v0
DarkLight1337 d289671
Fix backward compatibility
DarkLight1337 1bc5f7d
Keep dummy data for now
DarkLight1337 8ffb417
Fix typing
DarkLight1337 bd45937
Fix
DarkLight1337 3f199c1
Update comments
DarkLight1337 3fef0f0
Merge branch 'main' into deprecate-input-registry-v0
DarkLight1337 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,11 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from collections.abc import Iterable | ||
from dataclasses import dataclass | ||
from functools import cached_property | ||
from typing import TYPE_CHECKING, Any, Generic, Literal, Optional, Union, cast | ||
|
||
import torch | ||
from typing_extensions import NotRequired, TypedDict, TypeVar, assert_never | ||
from typing_extensions import NotRequired, TypedDict, TypeVar | ||
|
||
if TYPE_CHECKING: | ||
from vllm.multimodal import (MultiModalDataDict, MultiModalKwargs, | ||
MultiModalPlaceholderDict) | ||
from vllm.multimodal.inputs import MultiModalInputs | ||
from vllm.multimodal.inputs import MultiModalDataDict, MultiModalInputs | ||
|
||
|
||
class TextPrompt(TypedDict): | ||
|
@@ -147,46 +141,11 @@ class TokenInputs(TypedDict): | |
The original prompt text corresponding to the token IDs, if available. | ||
""" | ||
|
||
multi_modal_data: NotRequired["MultiModalDataDict"] | ||
""" | ||
Optional multi-modal data to pass to the model, | ||
if the model supports it. | ||
""" | ||
|
||
Comment on lines
-150
to
-155
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed in this PR, but now that we have a clear set of different branches for input processing, we should probably add some documentation under each input/prompt type to indicate when they will be used. |
||
multi_modal_inputs: NotRequired["MultiModalKwargs"] | ||
""" | ||
Optional multi-modal inputs to pass to the model, | ||
if the model supports it. | ||
""" | ||
|
||
multi_modal_placeholders: NotRequired["MultiModalPlaceholderDict"] | ||
""" | ||
Placeholder ranges for the multi-modal data. | ||
""" | ||
|
||
multi_modal_hashes: NotRequired[list[str]] | ||
""" | ||
The hashes of the multi-modal data. | ||
""" | ||
|
||
mm_processor_kwargs: NotRequired[dict[str, Any]] | ||
""" | ||
Optional multi-modal processor kwargs to be forwarded to the | ||
multimodal input mapper & processor. Note that if multiple modalities | ||
have registered mappers etc for the model being considered, we attempt | ||
to pass the mm_processor_kwargs to each of them. | ||
""" | ||
|
||
|
||
def token_inputs( | ||
prompt_token_ids: list[int], | ||
token_type_ids: Optional[list[int]] = None, | ||
prompt: Optional[str] = None, | ||
multi_modal_data: Optional["MultiModalDataDict"] = None, | ||
multi_modal_inputs: Optional["MultiModalKwargs"] = None, | ||
multi_modal_hashes: Optional[list[str]] = None, | ||
multi_modal_placeholders: Optional["MultiModalPlaceholderDict"] = None, | ||
mm_processor_kwargs: Optional[dict[str, Any]] = None, | ||
) -> TokenInputs: | ||
"""Construct :class:`TokenInputs` from optional values.""" | ||
ywang96 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
inputs = TokenInputs(type="token", prompt_token_ids=prompt_token_ids) | ||
|
@@ -195,16 +154,6 @@ def token_inputs( | |
inputs["prompt"] = prompt | ||
if token_type_ids is not None: | ||
inputs["token_type_ids"] = token_type_ids | ||
if multi_modal_data is not None: | ||
inputs["multi_modal_data"] = multi_modal_data | ||
if multi_modal_inputs is not None: | ||
inputs["multi_modal_inputs"] = multi_modal_inputs | ||
if multi_modal_hashes is not None: | ||
inputs["multi_modal_hashes"] = multi_modal_hashes | ||
if multi_modal_placeholders is not None: | ||
inputs["multi_modal_placeholders"] = multi_modal_placeholders | ||
if mm_processor_kwargs is not None: | ||
inputs["mm_processor_kwargs"] = mm_processor_kwargs | ||
|
||
return inputs | ||
|
||
|
@@ -237,112 +186,6 @@ class EncoderDecoderInputs(TypedDict): | |
:class:`vllm.sequence.Sequence`. | ||
""" | ||
|
||
|
||
@dataclass | ||
class SingletonInputsAdapter: | ||
""" | ||
Unified interface to access the components of :class:`SingletonInputs`. | ||
""" | ||
inputs: SingletonInputs | ||
|
||
@cached_property | ||
def prompt(self) -> Optional[str]: | ||
inputs = self.inputs | ||
|
||
if inputs["type"] == "token" or inputs["type"] == "multimodal": | ||
return inputs.get("prompt") | ||
|
||
assert_never(inputs) # type: ignore[arg-type] | ||
|
||
@cached_property | ||
def prompt_token_ids(self) -> list[int]: | ||
inputs = self.inputs | ||
|
||
if inputs["type"] == "token" or inputs["type"] == "multimodal": | ||
return inputs.get("prompt_token_ids", []) | ||
|
||
assert_never(inputs) # type: ignore[arg-type] | ||
|
||
@cached_property | ||
def token_type_ids(self) -> list[int]: | ||
inputs = self.inputs | ||
|
||
if inputs["type"] == "token" or inputs["type"] == "multimodal": | ||
return inputs.get("token_type_ids", []) | ||
|
||
assert_never(inputs) # type: ignore[arg-type] | ||
|
||
@cached_property | ||
def prompt_embeds(self) -> Optional[torch.Tensor]: | ||
inputs = self.inputs | ||
|
||
if inputs["type"] == "token" or inputs["type"] == "multimodal": | ||
return None | ||
|
||
assert_never(inputs) # type: ignore[arg-type] | ||
|
||
@cached_property | ||
def multi_modal_data(self) -> "MultiModalDataDict": | ||
inputs = self.inputs | ||
|
||
if inputs["type"] == "token": | ||
return inputs.get("multi_modal_data", {}) | ||
|
||
if inputs["type"] == "multimodal": | ||
return inputs.get("mm_kwargs", {}) | ||
|
||
assert_never(inputs) # type: ignore[arg-type] | ||
|
||
@cached_property | ||
def multi_modal_inputs(self) -> Union[dict, "MultiModalKwargs"]: | ||
inputs = self.inputs | ||
|
||
if inputs["type"] == "token": | ||
return inputs.get("multi_modal_inputs", {}) | ||
|
||
if inputs["type"] == "multimodal": | ||
return inputs.get("mm_kwargs", {}) | ||
|
||
assert_never(inputs) # type: ignore[arg-type] | ||
|
||
@cached_property | ||
def multi_modal_hashes(self) -> list[str]: | ||
inputs = self.inputs | ||
|
||
if inputs["type"] == "token": | ||
return inputs.get("multi_modal_hashes", []) | ||
|
||
if inputs["type"] == "multimodal": | ||
# only the case when we use MultiModalInputs | ||
return inputs.get("mm_hashes", []) # type: ignore[return-value] | ||
|
||
assert_never(inputs) # type: ignore[arg-type] | ||
|
||
@cached_property | ||
def multi_modal_placeholders(self) -> "MultiModalPlaceholderDict": | ||
inputs = self.inputs | ||
|
||
if inputs["type"] == "token": | ||
return inputs.get("multi_modal_placeholders", {}) | ||
|
||
if inputs["type"] == "multimodal": | ||
return inputs.get("mm_placeholders", {}) | ||
|
||
assert_never(inputs) # type: ignore[arg-type] | ||
|
||
@cached_property | ||
def mm_processor_kwargs(self) -> dict[str, Any]: | ||
inputs = self.inputs | ||
|
||
if inputs["type"] == "token": | ||
return inputs.get("mm_processor_kwargs", {}) | ||
|
||
if inputs["type"] == "multimodal": | ||
return {} | ||
|
||
assert_never(inputs) # type: ignore[arg-type] | ||
|
||
|
||
ProcessorInputs = Union[DecoderOnlyInputs, EncoderDecoderInputs] | ||
""" | ||
The inputs to :data:`vllm.inputs.InputProcessor`. | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.