Skip to content

[Bugfix][Multimodal] Scope cache hash kwargs by modality - #54918

Merged
DarkLight1337 merged 1 commit into
vllm-project:mainfrom
waizuichougou:fix/multimodal-cache-kwargs-by-modality
Sep 2, 2026
Merged

[Bugfix][Multimodal] Scope cache hash kwargs by modality#54918
DarkLight1337 merged 1 commit into
vllm-project:mainfrom
waizuichougou:fix/multimodal-cache-kwargs-by-modality

Conversation

@waizuichougou

@waizuichougou waizuichougou commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Purpose

Fix unnecessary multimodal processor cache misses caused by unrelated
modality options being included in every media item's cache hash.

The production trigger chain is:

request/config media_io_kwargs or mm_processor_kwargs
  -> renderer._process_multimodal()
  -> ProcessorInputs
  -> ProcessorInputs.get_mm_hashes()
  -> multimodal processor cache hit/miss check
  -> preprocessing of cache-missing media items

get_mm_hashes() currently builds one global hash-factor dictionary containing
all media_io_kwargs and all HF processor kwargs, then applies it to every
modality. Consequently, a video-only option changes an image hash. For
example, an image-only request can inherit:

--media-io-kwargs '{"video":{"num_frames":16}}'

With multimodal processor caching enabled, repeating that request needlessly
reprocesses the image. The same issue occurs in mixed image/video requests:
changing num_frames or videos_kwargs invalidates the image cache entry.
This is a real online performance and latency bug; it does not independently
change model output.

This change scopes hash factors for ordinary modalities:

  • image uses only image media_io_kwargs and images_kwargs;
  • video uses only video media_io_kwargs and videos_kwargs;
  • audio uses only audio media_io_kwargs and audio_kwargs;
  • flat HF processor kwargs remain included because they are shared.

vision_chunk remains conservative because one list can contain both images
and videos and ProcessorInputs does not currently carry each item's original
modality. It may still have extra cache misses, but this change does not create
incorrect cache reuse.

Test Plan

Run the focused multimodal processing and renderer hash tests:

python -m pytest tests/multimodal/test_processing.py -m cpu_test -q
python -m pytest tests/renderers/test_multimodal_hashes.py -m cpu_test -q

Run lint, formatting, and whitespace checks:

ruff check vllm/multimodal/processing/inputs.py \
  tests/multimodal/test_processing.py
ruff format --check vllm/multimodal/processing/inputs.py \
  tests/multimodal/test_processing.py
git diff --check

The regression tests compare identical media with changed modality-specific
options. They verify that changing video options preserves the image hash,
changing image options preserves the video hash, and video-only options are
ignored for an image-only request.

Test Result

tests/multimodal/test_processing.py -m cpu_test       98 passed
tests/renderers/test_multimodal_hashes.py -m cpu_test  1 passed
ruff check                                               passed
ruff format --check                                      passed
git diff --check                                         passed

The focused tests demonstrate the expected behavior at the hash boundary used
by the production cache. No media decoding or model inference semantics are
changed.

AI-assisted contribution

This contribution was developed with AI assistance.


Essential Elements of an Effective PR Description Checklist
  • The purpose and production trigger chain are explained.
  • The test plan includes focused test and lint commands.
  • The test results include the focused regression results.
  • Documentation update considered; none is needed for this internal cache
    hash fix.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@mergify mergify Bot added multi-modality Related to multi-modality (#4194) bug Something isn't working labels Sep 2, 2026
Signed-off-by: waizuichougou <2082431897@qq.com>
@waizuichougou
waizuichougou force-pushed the fix/multimodal-cache-kwargs-by-modality branch from 3c6b743 to 1d9443a Compare September 2, 2026 08:00

@DarkLight1337 DarkLight1337 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great!

@DarkLight1337
DarkLight1337 enabled auto-merge (squash) September 2, 2026 08:07
@github-actions github-actions Bot added the ready ONLY add when PR is ready to merge/full CI is needed label Sep 2, 2026
@DarkLight1337

Copy link
Copy Markdown
Member

/ci run

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

✅ Triggered Buildkite CI #86823 for commit 1d9443ad005e.

@waizuichougou

Copy link
Copy Markdown
Contributor Author

/ci retry

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

✅ Queued 1 failed job(s) for retry in Buildkite CI #86823.

@DarkLight1337
DarkLight1337 merged commit c6bca6e into vllm-project:main Sep 2, 2026
81 checks passed
mylibrar pushed a commit to tanyuqian/vllm that referenced this pull request Sep 3, 2026
sheralskumar pushed a commit to sheralskumar/vllm that referenced this pull request Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working multi-modality Related to multi-modality (#4194) ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants