Skip to content

prefix caching for MM - #1039

Open
nikheal2 wants to merge 7 commits into
torch-spyre:mainfrom
nikheal2:prefix_caching_mm
Open

prefix caching for MM#1039
nikheal2 wants to merge 7 commits into
torch-spyre:mainfrom
nikheal2:prefix_caching_mm

Conversation

@nikheal2

@nikheal2 nikheal2 commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator

This PR enables caching vision encoder outputs keyed by image has (mm_hash)

Description

Related Issues

Test Plan

Checklist

  • [ x] I have read the contributing guidelines
  • [ x] My code follows the project's code style (run bash format.sh)
  • [ x] I have added tests for my changes (if applicable)
  • I have updated the documentation (if applicable)
  • [ x] My commits include a Signed-off-by: line (DCO compliance)

Signed-off-by: nikheal2 <suryawanshin74@gmail.com>

changing logger from debug to info

Signed-off-by: nikheal2 <suryawanshin74@gmail.com>

changing logger to vllm logger

Signed-off-by: nikheal2 <suryawanshin74@gmail.com>

refcatoring cache count logic

Signed-off-by: nikheal2 <suryawanshin74@gmail.com>

fixing metrics

Signed-off-by: nikheal2 <suryawanshin74@gmail.com>

adding test cases

Signed-off-by: nikheal2 <suryawanshin74@gmail.com>

adding debug log

Signed-off-by: nikheal2 <suryawanshin74@gmail.com>

adding debug log

Signed-off-by: nikheal2 <suryawanshin74@gmail.com>

fix image identifier

Signed-off-by: nikheal2 <suryawanshin74@gmail.com>

fix logging

Signed-off-by: nikheal2 <suryawanshin74@gmail.com>
@github-actions

Copy link
Copy Markdown

👋 Hi! Thank you for contributing.
Just a reminder: Make sure that your code passes all the linting checks, otherwise your PR won't be able to be merged. To do so, run ./format.sh.
Now you are good to go 🚀.

We also recommend installing prek and configuring it to check your code before every local commit.

@nikheal2
nikheal2 requested a review from gkumbhat July 26, 2026 22:43
Signed-off-by: nikheal2 <suryawanshin74@gmail.com>
Comment thread tests/v1/worker/test_scheduler_tkv_limits.py
Comment thread tests/v1/worker/test_scheduler_tkv_limits.py Outdated
Comment thread sendnn_inference/multimodal/mm_mappings/llava_next.py
Comment thread sendnn_inference/multimodal/mm_mappings/mistral3.py
Comment thread sendnn_inference/multimodal/mm_mappings/llava_next.py
Comment thread sendnn_inference/v1/worker/mm_encoder_process.py
Comment thread sendnn_inference/v1/worker/mm_encoder_process.py Outdated
# by the inline fallback encode path (TP=1 / async encoder off / warmup).
# The async encoder subprocess has its own cache. Per-worker and
# deterministic across ranks (identical request stream), so no coordination.
self.mm_encoder_cache = MMEncoderCache(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This should only be used for inline, so should we put this initialization conditional on when this is going to be used ?

Comment thread sendnn_inference/v1/worker/mm_encoder_cache.py Outdated
Signed-off-by: nikheal2 <suryawanshin74@gmail.com>
Signed-off-by: nikheal2 <suryawanshin74@gmail.com>
Signed-off-by: nikheal2 <suryawanshin74@gmail.com>
@nikheal2
nikheal2 marked this pull request as ready for review August 4, 2026 18:58
Comment thread sendnn_inference/v1/worker/mm_encoder_process.py Outdated
Comment thread sendnn_inference/v1/worker/mm_encoder_cache.py Outdated
Comment thread sendnn_inference/v1/worker/mm_encoder_cache.py Outdated
Signed-off-by: nikheal2 <suryawanshin74@gmail.com>
Signed-off-by: nikheal2 <suryawanshin74@gmail.com>

@gkumbhat gkumbhat left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. Thanks for adding this feature.. Will wait on some test results and will merge after that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants