Skip to content

[Frontend][Multimodal] Skip encoder tensors for routing-only /render requests - #12

Open
guygir wants to merge 1 commit into
project-cb-lab:mainfrom
guygir:mm-render-routing-metadata
Open

guygir wants to merge 1 commit into
project-cb-lab:mainfrom
guygir:mm-render-routing-metadata

Conversation

@guygir

@guygir guygir commented Oct 12, 2026 •

Copy link
Copy Markdown

Overview

When /render is called with return_mm_kwargs=false, skip encoder-tensor
construction if the processor can still emit exact token_ids, mm_hashes,
and mm_placeholders. Complements vllm-project#60728 and vllm-project#46722; it does not change
return_mm_kwargs=true.

Production code under vllm/ (this PR only, base main): +227 / −10 (approx).

Claims

  • Routing-only /render can avoid materializing encoder tensors.
  • The fast path is fail-closed: custom or tensor-dependent processors keep
    full preprocessing.
  • Chat, completion, Messages, and Responses rendering pass
    routing_metadata_only=not return_mm_kwargs.

Validation

Local/cluster tests on the rebased commit. Result: 7 passed.

pytest -q tests/multimodal/test_processing.py -k routing_metadata \
  tests/entrypoints/scale_out/render/test_render.py -k \
  'return_mm_kwargs or test_render_responses_returns_generate_request_without_stored_state'

CI should cover tests/multimodal (misc.yaml) and
tests/entrypoints/scale_out (entrypoints.yaml).

This PR is the generic path only. Family speedups are in the follow-up
adapter PRs.

Details

return_mm_kwargs=false already drops tensors from the HTTP response
(vllm-project#60728), but MultiModalProcessor.apply() can still build them. Cache-aware
routers never use those tensors.

apply_routing_metadata() reuses existing prompt updates when they do not
read processed kwargs. Tensor-dependent updates, custom apply, custom
prompt finalization, encoder-decoder processors, and direct kwargs-data
access fall back to full apply().

No model-runner, scheduler, or KV-cache code changes. Default generate
behavior is unchanged.

AI assistance was used to implement and validate this change. A human
submitter reviewed the diff.


Pull Request Checklist
  • I used vLLM's /pr-checklist skill. (Mandatory for agents, optional for humans).

  • AI assistance was used during the creation of this PR.

  • Design Fit: Minimizes impact on core components, reuses existing functionality, and justifies added complexity.

  • Testing and Validation: Validates the change and ensures any added tests are meaningful and reliable, with CI coverage or documented CI resource constraints and validation performed outside CI.

  • Code Quality and Style: Keeps code and comments clear and concise, and updates relevant documentation and examples.

  • Pull Request Contents: Includes a brief summary and relevant links, supports claims with evidence, explains root causes and implementation trade-offs, and follows the contributing guide.

When return_mm_kwargs is false, use exact processor metadata so families
whose prompt updates already ignore processed kwargs skip HF tensor
construction, and fail closed to full apply otherwise.

Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: Guy Girmonsky <guygir@gmail.com>
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.

1 participant