-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
[Core] Use individual MM items in P0/P1 cache and model runner #22570
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: DarkLight1337 <[email protected]>
👋 Hi! Thank you for contributing to the vLLM project. 💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels. Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging. To run CI, PR reviewers can either: Add 🚀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request is a significant refactoring of how multimodal inputs are handled, moving from MultiModalKwargs
per request to a list of MultiModalKwargsItem
. This change is aimed at improving the design for caching and processing of multimodal data. The changes are extensive, touching many files in the core engine, workers, and tests. The tests have been updated to reflect the new logic, which is a positive sign. However, I've identified a critical issue in the new MultiModalKwargsItem.__init__
method that can lead to runtime errors with empty inputs. Additionally, there's a potential data loss bug in gpu_model_runner.py
when handling raw multimodal inputs with mixed modalities, which could silently drop data. These issues should be addressed to ensure the correctness of the new implementation.
Signed-off-by: DarkLight1337 <[email protected]>
Signed-off-by: DarkLight1337 <[email protected]>
if len(batch) > 0 and is_list_of(batch, torch.Tensor, check="all"): | ||
if len(batch) == 1: | ||
# An optimization when `batch` contains only one tensor: | ||
# - produce exactly same result as `torch.concat(batch)` | ||
# - will achieve zero-copy if the tensor is contiguous | ||
return batch[0].contiguous() | ||
|
||
def _expect_same_shape(tensor: torch.Tensor): | ||
return tensor.shape[:self.dim] + tensor.shape[self.dim + 1:] | ||
dim = self.dim + (self.dim < 0) * len(batch[0].shape) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The extra self.dim < 0
check allows negative dim
to be passed to this field
@@ -51,6 +53,13 @@ def __post_init__(self): | |||
def num_tokens(self) -> int: | |||
return self.num_prompt_tokens + len(self.output_token_ids) | |||
|
|||
# Temporary back-compatibility for plugins that define model runner |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signed-off-by: DarkLight1337 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM, just leave some nits.
Signed-off-by: DarkLight1337 <[email protected]>
Added ready label just to check CI, please don't merge yet as this is pending discussion with @ywang96 @WoosukKwon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mark MultiModalKwargs class as deprecated?
It is still used by |
Signed-off-by: DarkLight1337 <[email protected]>
Signed-off-by: DarkLight1337 <[email protected]>
Signed-off-by: DarkLight1337 <[email protected]>
Signed-off-by: DarkLight1337 <[email protected]>
Essential Elements of an Effective PR Description Checklist
supported_models.md
andexamples
for a new model.Purpose
Follow-up to #22457, in preparation for moving processing cache from P0 to P1.
Key changes:
MultiModalKwargsItem
can now contain empty data.MultiModalKwargsItem
, and modifiesMultiModalKwargsItem
in place.EngineCoreRequest
,Request
,NewRequestData
,CachedRequestState
now usemm_kwargs: list[MultiModalKwargsItem]
instead ofmm_inputs: list[MultiModalKwargs]
. (cc @wangxiyuan please update vllm/vllm-ascend accordingly after this PR)merge_and_sort_multimodal_metadata -> argsort_mm_positions
andgroup_mm_inputs_by_modality -> group_mm_kwargs_by_modality
with new semantics to enhance code reuse.pin_memory
argument for mergingMultiModalFieldElem
s (unused for now, see comment insidegroup_mm_kwargs_by_modality
)Test Plan
Test Result
(Optional) Documentation Update