Skip to content

feat(frontend): add exact MM routing for generate - #11588

Open
furionw wants to merge 5 commits into
mainfrom
qiwa/generate-mm-routing-frontend
Open

feat(frontend): add exact MM routing for generate#11588
furionw wants to merge 5 commits into
mainfrom
qiwa/generate-mm-routing-frontend

Conversation

@furionw

@furionw furionw commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Why

/inference/v1/generate accepts tokenized multimodal rollouts, but the frontend currently routes only on token IDs. Different images with identical placeholder layouts therefore appear equivalent to the KV router. Exact request hashing also requires the block size, LoRA identity, and worker capability from the same selected WorkerSet; a single engine-selection interface preserves that invariant without exposing irrelevant parsing options.

What Change

  • Project image identity into routing-only token sequences.
  • Gate exact projection on worker-advertised runtime capability.
  • Return generate engines and routing metadata through one atomic getter.

Test Plan

  • Run focused Generate, model discovery, and KV-router release tests.
  • Run pre-commit on all changed Rust files.

Summary by CodeRabbit

  • New Features

    • Improved multimodal request routing for image inputs, including support for exact token-based matching when available.
    • Added routing support that accounts for selected LoRA adapters and KV-cache configuration.
    • Added compatibility for vLLM multimodal identifiers and routing capabilities.
  • Bug Fixes

    • Added validation and safe fallback handling for malformed, unsupported, or inconsistent multimodal metadata.
    • Improved worker selection consistency when available workers or their capabilities change.

@github-actions github-actions Bot added feat frontend `python -m dynamo.frontend` and `dynamo-run in=http|text|grpc` labels Jul 13, 2026
@datadog-official

datadog-official Bot commented Jul 13, 2026

Copy link
Copy Markdown

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 45.57% (-4.14%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: b30d438 | Docs | Datadog PR Page | Give us feedback!

@furionw
furionw force-pushed the qiwa/generate-mm-routing-frontend branch from 85e8b3c to 0cd148f Compare July 13, 2026 04:29
@furionw
furionw marked this pull request as ready for review July 13, 2026 20:00
@furionw
furionw requested review from a team as code owners July 13, 2026 20:00
devin-ai-integration[bot]

This comment was marked as resolved.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 86cdbf81-6491-4968-a509-d1b873b003d2

📥 Commits

Reviewing files that changed from the base of the PR and between b13288e and ed101f9.

📒 Files selected for processing (6)
  • lib/kv-router/src/protocols.rs
  • lib/llm/src/discovery.rs
  • lib/llm/src/discovery/model.rs
  • lib/llm/src/discovery/model_manager.rs
  • lib/llm/src/http/service/generate.rs
  • lib/llm/src/local_model/runtime_config.rs

Walkthrough

Adds multimodal identifier hashing, richer generate-engine selection metadata, exact multimodal routing preprocessing, LoRA routing hints, capability-based fallback, and comprehensive validation tests for Generate requests.

Changes

Generate exact multimodal routing

Layer / File(s) Summary
Multimodal identifier hashing
lib/kv-router/src/protocols.rs
Adds hash_mm_identifier with empty, canonical 64-character hex, and xxh3_64 fallback handling, covered by unit tests.
Worker-specific engine selection
lib/llm/src/discovery/..., lib/llm/src/local_model/runtime_config.rs
Introduces GenerateEngineSelection, returns worker-set routing metadata atomically, exposes the exact-MM capability constant, and updates discovery APIs and tests.
Generate multimodal routing preprocessing
lib/llm/src/http/service/generate.rs
Parses vLLM image metadata, projects block-aligned routing tokens when supported, propagates LoRA hints, and falls back to token-only routing for invalid or unsupported metadata with corresponding tests.

Estimated code review effort: 4 (Complex) | ~60 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is missing the required Overview, Details, Where should reviewer start?, and Related Issues sections from the template. Rewrite it to match the template, add a reviewer-start file callout, and include the required issue linkage or confirmed no-issue checkbox.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly mentions exact MM routing for generate, which matches the main change, though the frontend scope is a bit misleading.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@biswapanda
biswapanda force-pushed the qiwa/generate-mm-routing-frontend branch from ed101f9 to 5df0396 Compare July 22, 2026 08:55
@biswapanda

Copy link
Copy Markdown
Contributor

/ok to test 5df0396

biswapanda

This comment was marked as resolved.

@biswapanda
biswapanda enabled auto-merge (squash) July 22, 2026 08:56
@biswapanda

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

biswapanda

This comment was marked as resolved.

biswapanda

This comment was marked as resolved.

@biswapanda
biswapanda disabled auto-merge July 22, 2026 09:12
@biswapanda
biswapanda enabled auto-merge (squash) July 22, 2026 09:26
biswapanda

This comment was marked as resolved.

@biswapanda
biswapanda requested a review from jthomson04 July 22, 2026 09:30
devin-ai-integration[bot]

This comment was marked as resolved.

biswapanda

This comment was marked as resolved.

@biswapanda
biswapanda requested a review from ishandhanani July 22, 2026 09:33
@biswapanda
biswapanda requested review from dagil-nvidia and tedzhouhk and removed request for dagil-nvidia, ishandhanani, jthomson04 and tedzhouhk July 22, 2026 09:51
furionw and others added 4 commits August 3, 2026 16:41
Signed-off-by: Qi Wang <qiwa@nvidia.com>
Signed-off-by: Biswa Panda <biswa.panda@gmail.com>
Signed-off-by: Biswa Panda <biswa.panda@gmail.com>
Signed-off-by: Biswa Panda <biswa.panda@gmail.com>
Signed-off-by: Biswa Panda <biswa.panda@gmail.com>
@furionw
furionw force-pushed the qiwa/generate-mm-routing-frontend branch from ac3e4ee to 332b77e Compare August 4, 2026 02:20
devin-ai-integration[bot]

This comment was marked as resolved.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

Open in Devin Review

Comment on lines +486 to +500
let mm_routing_info = if supports_exact_mm_routing {
match generate_mm_routing_info(&request, kv_cache_block_size) {
Ok(info) => info,
Err(reason) => {
tracing::debug!(
target: "mm_routing",
reason,
"invalid /generate multimodal routing metadata; using token-only routing"
);
None
}
}
} else {
None
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔍 Event-side pad normalization depends on a resolved image_token_id the capability flag does not cover

Exact matching only works when the KV-event normalizer was constructed with image_token_id (see KvEventSourceConfig::Zmq in lib/llm/src/kv_router/publisher/mod.rs:56-66); otherwise vLLM BlockStored events are hashed with block_mm_infos instead of pad substitution and can never match this projection. The chat path gates the same projection on self.routing_image_token_id (lib/llm/src/preprocessor.rs:1958-1962), whereas the /generate path relies solely on the worker-advertised vllm_exact_mm_routing flag. If a worker can advertise the capability while its event source lacks a resolved image token id, MM routing silently degrades rather than falling back. Worth confirming that whatever sets the capability also guarantees the normalizer's image token id.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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

Labels

feat frontend `python -m dynamo.frontend` and `dynamo-run in=http|text|grpc` size/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants