Skip to content

Conversation

ywang96
Copy link
Member

@ywang96 ywang96 commented Mar 27, 2025

Partially unblock #15130 - the current workaround can be inefficient in case there are a large number of interleaved items in the current batch (e.g, <image><video><image><video><image>), but this should be a rare case as typically these embeddings are individually fairly big.

Note use_audio_in_video is not yet covered by this PR and will require a bit of more work, since it will require mixing of modality items/interleaved embeddings.

ywang96 added 5 commits March 27, 2025 00:55
Signed-off-by: Roger Wang <[email protected]>
Signed-off-by: Roger Wang <[email protected]>
Signed-off-by: Roger Wang <[email protected]>
Signed-off-by: Roger Wang <[email protected]>
Signed-off-by: Roger Wang <[email protected]>
Copy link

👋 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 fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

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 ready label to the PR or enable auto-merge.

🚀

@mergify mergify bot added multi-modality Related to multi-modality (#4194) v1 labels Mar 27, 2025
ywang96 added 2 commits March 27, 2025 01:38
Signed-off-by: Roger Wang <[email protected]>
Signed-off-by: Roger Wang <[email protected]>
@DarkLight1337
Copy link
Member

DarkLight1337 commented Mar 27, 2025

We still need to update get_multimodal_embeddings to support interleaved modality inputs e2e, am I correct?

@ywang96
Copy link
Member Author

ywang96 commented Mar 27, 2025

We still need to update get_multimodal_embeddings to support interleaved modality inputs e2e, am I correct?

No I don't think we need to - this is because model runner will try to batch only consecutive inputs of the same modality, or otherwise execute encoder individually.

# Batch mm inputs as much as we can: if a request in the batch has
# multiple modalities or a different modality than the previous one,
# we process it separately to preserve item order.
# FIXME(ywang96): This is a hacky way to deal with multiple modalities
# in the same batch while still being able to benefit from batching
# multimodal inputs. The proper solution should be reordering the
# encoder outputs.
grouped_mm_inputs_list = group_mm_inputs_by_modality(mm_inputs)
encoder_outputs = []
for grouped_mm_inputs in grouped_mm_inputs_list:
batched_mm_inputs = MultiModalKwargs.batch(grouped_mm_inputs)
batched_mm_inputs = MultiModalKwargs.as_kwargs(batched_mm_inputs,
device=self.device)
# Run the encoder.
# `curr_group_outputs` is either of the following:
# 1. A tensor of shape (num_items, feature_size, hidden_size)
# in case feature_size is fixed across all multimodal items.
# 2. A list or tuple (length: num_items) of tensors, each of shape
# (feature_size, hidden_size) in case the feature size is dynamic
# depending on the input multimodal items.
curr_group_outputs = self.model.get_multimodal_embeddings(
**batched_mm_inputs)
for output in curr_group_outputs:
encoder_outputs.append(output)

@DarkLight1337
Copy link
Member

DarkLight1337 commented Mar 27, 2025

Hmm in that case, can we add a test to verify this e2e? We can use llava-hf/llava-onevision-qwen2-0.5b-ov-hf which lets us fit interleaved image and videos in memory even in CI environment.

ywang96 added 2 commits March 27, 2025 02:30
Signed-off-by: Roger Wang <[email protected]>
Signed-off-by: Roger Wang <[email protected]>
@ywang96
Copy link
Member Author

ywang96 commented Mar 27, 2025

Hmm in that case, can we add a test to verify this e2e? We can use llava-hf/llava-onevision-qwen2-0.5b-ov-hf which lets us fit interleaved image and videos in memory even in CI environment.

Yea we can - I'll add a test for this during the day

@DarkLight1337
Copy link
Member

Let's also update the V1 User Guide to remove the part about interleaved modality not supported.

@ywang96
Copy link
Member Author

ywang96 commented Mar 27, 2025

llava-hf/llava-onevision-qwen2-0.5b-ov-hf

Interestingly - this model seems to ignore the order of modalities from the frontend and the processor will always group modalities together

@DarkLight1337
Copy link
Member

llava-hf/llava-onevision-qwen2-0.5b-ov-hf

Interestingly - this model seems to ignore the order of modalities from the frontend and the processor will always group modalities together

By "frontend" are you referring to online inference? I think this is because the chat template is detected as "string" format which disables interleaved inputs.

Copy link
Member

@DarkLight1337 DarkLight1337 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There appears to be an issue with the test runners for validating mixed-modality inputs.

As discussed offline, let's merge this PR first to unblock Qwen2.5-Omni, and work on fixing this in another PR.

@DarkLight1337 DarkLight1337 enabled auto-merge (squash) March 29, 2025 06:23
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label Mar 29, 2025
ywang96 added 2 commits March 29, 2025 00:20
Signed-off-by: Roger Wang <[email protected]>
Signed-off-by: Roger Wang <[email protected]>
@mergify mergify bot added the ci/build label Mar 29, 2025
@ywang96
Copy link
Member Author

ywang96 commented Mar 29, 2025

Add a simple test to verify interleaving modalities generates a different result in greedy decoding.

Comment on lines 761 to 770
for i in range(len(inputs)):
inputs[i]["multi_modal_data"] = {}
if images is not None and (image := images[i]) is not None:
inputs[i]["multi_modal_data"]["image"] = image

if audios is not None:
for i, audio in enumerate(audios):
if audio is not None:
inputs[i]["multi_modal_data"] = {"audio": audio}
if videos is not None and (video := videos[i]) is not None:
inputs[i]["multi_modal_data"]["video"] = video

if audios is not None and (audio := audios[i]) is not None:
inputs[i]["multi_modal_data"]["audio"] = audio
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test model runner previously didn't support testing with multiple modalities and this PR fixed it.

@vllm-bot vllm-bot merged commit c67abd6 into main Mar 29, 2025
59 of 61 checks passed
@vllm-bot vllm-bot deleted the v1-interleaved branch March 29, 2025 13:30
@github-project-automation github-project-automation bot moved this from In Progress to Done in Multi-modality Core Mar 29, 2025
Alex4210987 pushed a commit to LeiWang1999/vllm-bitblas that referenced this pull request Apr 5, 2025
lulmer pushed a commit to lulmer/vllm that referenced this pull request Apr 7, 2025
lk-chen pushed a commit to lk-chen/vllm that referenced this pull request Apr 29, 2025
shreyankg pushed a commit to shreyankg/vllm that referenced this pull request May 3, 2025
RichardoMrMu pushed a commit to RichardoMrMu/vllm that referenced this pull request May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci/build multi-modality Related to multi-modality (#4194) ready ONLY add when PR is ready to merge/full CI is needed v1
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants