← Back to Pull requests

feat(sglang): route multimodal requests to standalone encoder sidecars #19246

Open
unknown opened this pull request with 615 lines diff across 7 files
View on GitHub
unknown unknown commented on Nov 20, 2026 07:16 UTC
Author

Overview

  • Dynamo could not schedule standalone SGLang encoder workers, so the frontend could not choose the encoder replica for a multimodal request.

  • The earlier revision relied on RPCs added to SGLang's Python encoder. SGLang review asked for that encoder to stay as it is, so this revision uses the unmodified native HTTP encoder.
  • Key Changes

  • Encode sidecar: registers an --encoder-only SGLang HTTP encoder as an Encode worker (--disaggregation-mode encode). It polls /health, sends one native /encode request per modality under <request id>_local_part_<k>, keeps the calls in flight, and returns a descriptor with the encoder URL and the item count per modality.

  • Language sidecar (--route-to-encoder): forwards the descriptor to SGLang in encoder_handoff and sends the same request id as rid. SGLang's own receiver then registers its ZMQ address with that encoder.

  • Frontend: the shared EncoderRouter selects the encoder, as it does for vLLM. A worker set that requires an encoder is ready only when a compatible encode set is present. vLLM behavior is unchanged.

  • Removed from the earlier revision: descriptor signing, layout validation, the transfer-mode and capability contract, sidecar media download, the vendored encoder proto and the NIXL option.

  • Scope: one or more encoders plus an aggregated language worker. --route-to-encoder is refused for prefill and decode workers.
  • Validation

  • cargo fmt, cargo check --all-targets and cargo clippy -D warnings pass for dynamo-sglang-sidecar, dynamo-sglang-generate, dynamo-generate-format-catalog and dynamo-llm.

  • Tests: dynamo-sglang-sidecar 122 passed; generate-format crates 23, 13, 3 and 2 passed; dynamo-llm --lib filtered to encoder, readiness, topology, model manager and model card tests, 247 passed. The one other test in that filter, an existing watcher test, failed on the test host because its home directory was full, on this branch and on the previous head alike; it passed when run with a writable home.

  • End to end on one GPU with Qwen2.5-VL-3B through launch/encoded.sh --encoders 2 --single-gpu and /v1/chat/completions: single images, two images in both orders, text only, and an image after text all answered correctly. Seven image requests produced seven encodes, split four and three across the two encoders.

  • The same deployment also answered native /generate requests (one image, two images, text only, one video) and chat requests with one video correctly.

  • lib/sidecar/sglang/tests/encoder_pipeline.py (wrapper tests/serve/test_sglang_encoder_pipeline.py) runs the real frontend and sidecars against fake HTTP encoders and a fake language worker, without a model. It checks round robin, the /encode request and its request id, the handoff and rid the language worker receives, image plus video part order, native /generate, encoder error statuses, release after a language refusal, readiness without an encoder and recovery after an encoder dies.

  • Not verified: audio, and the answer for a request that mixes an image and a video. Qwen2.5-VL-3B answers that prompt wrongly on an aggregated SGLang server too, so the model-free test is the only check of mixed-media part order.
  • Issues and Ongoing Work

    Part of DIS-3538. Part of #14124. Follows #13966. Wait for sgl-project/sglang#51754 and publication of sglang-api-types 0.2.0. Dynamo main adopted the published bindings in #19156, which do not carry encoder_handoff yet, so this branch still conflicts with main until that release.

  • Split one request across multiple E replicas and reassemble its embeddings in prompt order.

  • Split prefill and decode with an external encoder.

  • Retry a request on another encoder when the selected one is unreachable. Today it returns 503 until the frontend drops that encoder.

  • A request with media waits 200 ms after its encode calls are sent, to surface an immediate encoder failure before the language hop starts.
  • <details>
    <summary>Pull Request Checklist</summary>

  • I used Dynamo's /pr-checklist skill.
  • </details>

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    New Features
    Added support for routing staged images through standalone SGLang encoder workers, including deployments with split prefill and decode.
    Native SGLang /generate requests can now use ordered image URLs alongside token IDs.
    Added a configurable launcher for SGLang deployments with encoder services.
    Bug Fixes
    Improved validation of staged image inputs and rejected unsupported media and client-supplied internal routing data.
    Documentation
    Updated SGLang deployment notes with image support details and validation limits.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 615 lines (+461 / -154) across 7 files Reviewer: luckyq Review duration: 21731m
    All Vouch review confidence checks passed
    Residual risk 0.29 = Change Risk (0.55) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.55 · 615 lines diff across 7 files
    0.55
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.384
    Shallow Review Depth shallow_review_depth
    0.344
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #19246"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 55.2% (MEDIUM) · Higher = larger blast radius
    55.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 29.4% · Safe to merge
    29.4%