← Back to Pull requests

[Multimodal] Skip encoder towers on later PP stages under V2 #60238

Merged
lesj0610 merged 4 files (17 lines) on Oct 22, 2026 13:27 UTC
View on GitHub
lesj0610 lesj0610 commented on Oct 06, 2026 13:52 UTC
Author

Overview

Model Runner V2 runs multimodal encoders on the first pipeline stage only, but every stage still builds and loads the encoder towers. This skips them on the later stages through the existing _mark_tower_model path.

Claims

  • With PP under V2, later stages no longer allocate or load encoder towers: PP1 model loading drops by the tower size (0.58 GiB on LLaVA-1.5-7B, 0.62 GiB on Qwen3.5-4B, 0.85 GiB on Qwen3.6-35B-A3B, 1.27 GiB on Ultravox v0.5).

  • Outputs are unchanged: image outputs under PP match HF in llava-broadcast run with PP=2, and the existing PP comparison tests pass.

  • Encoder tower construction and loading are unchanged for PP=1, the first stage and the V1 runner.
  • Validation

    All runs on main (6ad2e06c4a) with and without this commit, two sm_80 GPUs, V2 runner, FlashInfer sampler off.

    pytest tests/distributed/test_pipeline_parallel.py -k test_tp_multimodal_generation   # 3 passed (main and this change)
    pytest tests/models/qwen4_exp/test_config.py                                          # 9 passed
    

    llava-broadcast (image outputs compared against HF) was also run with PP=2 instead of TP=2. It checks short eager image generations under PP; it passes on main too, so it does not guard the memory saving, which the loading numbers below show. test_tp_multimodal_generation compares text completions only; it does not send image or audio inputs. Ultravox's Llama-3.2-1B-Instruct backbone is gated for this account, so it was taken from the ModelScope mirror, checked byte-identical to the Hugging Face repository at 9213176726 by file hashes, and run offline.

    PP0 / PP1 model loading:

    | Model | main | this change | without PP |
    |---|---|---|---|
    | LLaVA-1.5-7B | 6.86 / 6.86 GiB | 6.86 / 6.28 GiB | |
    | InternVL3-1B | 1.17 / 1.17 GiB | 1.17 / 0.59 GiB | 1.76 GiB |
    | Ultravox v0.5 (Llama 3.2 1B) | 2.68 / 2.68 GiB | 2.68 / 1.41 GiB | 3.59 GiB |

    What remains above the single-stage size on Ultravox is the input embedding and LM head that PP keeps on separate stages.

    Serving Qwen3.5-4B (BF16) and Qwen3.6-35B-A3B-NVFP4 with PP=2 (--max-model-len 16384 --max-num-seqs 8), five greedy chat requests (two text, two with one image, one with two images) with logprobs; main was served twice per model:

    | | Qwen3.5-4B main | this change | Qwen3.6-35B-A3B main | this change |
    |---|---|---|---|---|
    | PP1 model loading | 5.27 GiB | 4.65 GiB | 11.28 GiB | 10.43 GiB |
    | PP1 memory in use (nvidia-smi) | 58,612 / 58,632 MiB | 57,960 MiB | 58,824 / 58,852 MiB | 57,970 MiB |
    | PP0 model loading | 5.27 GiB | 5.27 GiB | 11.01 GiB | 11.01 GiB |
    | KV cache | 2,746,044 tokens | 2,746,044 tokens | 3,349,038 tokens | 3,349,038 tokens |

    Qwen3.5-4B is identical in tokens and logprobs on all five requests across both main runs and this change. Qwen3.6-35B-A3B is not deterministic on main itself (the two main runs diverge on two requests, at tokens 47 and 119); against the second main run this change diverges on the other two (tokens 14 and 120) and the remaining three have the same tokens with slightly different logprobs, so these runs do not separate the effect of the change from run-to-run noise on that model. The KV cache is sized by PP0, which still holds the tower, so it does not grow there; the first main run of each model compiled from a cold cache and is left out of the KV row.

    The compiled extensions came from a build that adds two unrelated kernels to main's sources; no kernel these models use differs from main.

    Details

    _mark_tower_model already builds a tower on the meta device and wraps it in StageMissingLayer when --limit-mm-per-prompt is 0 for all of its modalities, and AutoWeightsLoader skips the weights of a StageMissingLayer. This adds a second condition to the same skip: the V2 runner and not the first stage. Under V2 the encoder only runs where supports_mm_inputs and is_first_pp_rank holds; the encoder cache, the encoder runner and the encoder CUDA graphs only exist on the first stage, and no get_mrope_input_positions implementation, which every stage runs, touches a tower. V1 is left out because its profile_run calls embed_multimodal on every rank.

    Models that branch on a missing tower: Qwen3-VL, Qwen3-VL-MoE and Qwen3-Omni turn use_deepstack off on later stages, which do not use it since deepstack inputs are consumed on the first stage; the PP start_layer check of Qwen3-VL and Qwen3-VL-MoE reads the config, so it still runs, and Qwen3-Omni has none. Qwen4Exp gated that check on use_deepstack, so it now reads the config, matching Qwen3-VL and Qwen3-VL-MoE, including when multimodal inputs are disabled. The checked Qwen4Exp checkpoints have an empty deepstack_visual_indexes, so the assertion passes for them. Pixtral and Llama 4 only use a missing tower to skip its weights.

    About 100 model files build their towers through this helper; the GPU runs above cover the models listed.

    No open PR covers this: searches for _mark_tower_model, StageMissingLayer and pipeline-parallel encoder or tower changes return nothing related.

    ---

    <details>
    <summary> Pull Request Checklist </summary>

  • 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.

  • </details>

    Diff: 17 lines (+13 / -4) across 4 files Reviewer: Isotr0py Review duration: 23015m
    All Vouch review confidence checks passed
    Residual risk 0.03 = Change Risk (0.25) × (1 − Review Confidence (0.88)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.25 · 17 lines diff across 4 files
    0.25
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.85 · 5 substantive comment(s)
    0.85
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    88%
    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.173
    Real PR Conversation Timeline
    18 items
    claude[bot] claude[bot] commented on Oct 06, 2026 13:53 UTC
    Reviewer

    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.

    njhill njhill commented on code on Oct 06, 2026 22:46 UTC
    Code Review
    vllm/model_executor/models/interfaces.py:1
    @@ -377,6 +379,11 @@ def _mark_tower_model(
                         targets=targets,
                     )
                     if all(mm_config.get_limit_per_prompt(m) == 0 for m in modalities)
    +                or (
    +                    vllm_config.parallel_config.pipeline_parallel_size > 1

    pp size check not needed

    lesj0610 lesj0610 commented on code on Oct 06, 2026 23:04 UTC
    Code Review
    vllm/model_executor/models/interfaces.py:1
    @@ -377,6 +379,11 @@ def _mark_tower_model(
                         targets=targets,
                     )
                     if all(mm_config.get_limit_per_prompt(m) == 0 for m in modalities)
    +                or (
    +                    vllm_config.parallel_config.pipeline_parallel_size > 1

    Removed in f75c5cebf1. The llava PP=2 broadcast case and the single-GPU llava image case still pass.

    Isotr0py Isotr0py commented on code on Oct 14, 2026 03:04 UTC
    Code Review
    vllm/models/qwen4_exp/nvidia/model.py:1

    Don't we have to update other deepstack models?

    Isotr0py Isotr0py commented on code on Oct 14, 2026 03:05 UTC
    Code Review
    vllm/models/qwen4_exp/amd/model.py:1
    @@ -906,7 +906,9 @@ def __init__(self, *, vllm_config: VllmConfig, prefix: str = "model") -> None:
             self.make_empty_intermediate_tensors = (
                 self.language_model.make_empty_intermediate_tensors
             )
    -        if not get_pp_group().is_first_rank and self.use_deepstack:
    +        if not get_pp_group().is_first_rank and any(
    +            multimodal_config.get_limit_per_prompt(m) for m in ("image", "video")

    I think this is equivalent to not self.language_model_only and bool(config.vision_config.deepstack_visual_indexes) in self.use_deepstack.

    Isotr0py Isotr0py commented on Oct 14, 2026 03:06 UTC
    Reviewer

    Overall look reasonable. Leave some nits.

    lesj0610 lesj0610 commented on code on Oct 14, 2026 04:05 UTC
    Code Review
    vllm/models/qwen4_exp/nvidia/model.py:1

    Only Qwen4Exp needs this adjustment. Qwen3-VL and Qwen3-VL-MoE gate their PP start_layer checks on the config, and Cohere Compass's use_deepstack depends only on the config, so those checks remain active when the tower is skipped. The other deepstack models have no such check, and their later-stage paths don't call the tower.

    lesj0610 lesj0610 commented on code on Oct 14, 2026 04:05 UTC
    Code Review
    vllm/models/qwen4_exp/amd/model.py:1
    @@ -906,7 +906,9 @@ def __init__(self, *, vllm_config: VllmConfig, prefix: str = "model") -> None:
             self.make_empty_intermediate_tensors = (
                 self.language_model.make_empty_intermediate_tensors
             )
    -        if not get_pp_group().is_first_rank and self.use_deepstack:
    +        if not get_pp_group().is_first_rank and any(
    +            multimodal_config.get_limit_per_prompt(m) for m in ("image", "video")

    They differ when both image and video limits are 0 without --language-model-only. The flag remains false, but the tower is skipped, so main disables the assertion. The proposed expression enables it and rejects splits where start_layer < len(deepstack_visual_indexes). The limit check preserves main's behavior in this case too.

    Isotr0py Isotr0py commented on code on Oct 14, 2026 04:08 UTC
    Code Review
    vllm/models/qwen4_exp/nvidia/model.py:1

    I see, can we align the deepstack checks? There're already several kinds of deepstack checks.

    lesj0610 lesj0610 commented on code on Oct 14, 2026 08:20 UTC
    Code Review
    vllm/models/qwen4_exp/nvidia/model.py:1

    Aligned in 69eca90d1d: Qwen4Exp now gates the check on hasattr(config.vision_config, "deepstack_visual_indexes"), like Qwen3-VL and Qwen3-VL-MoE, so it also runs when multimodal inputs are disabled. The Qwen4Exp checkpoints I checked have an empty deepstack_visual_indexes, so the check passes for them either way.

    Isotr0py Isotr0py commented on code on Oct 22, 2026 06:29 UTC
    Code Review
    tests/models/multimodal/generation/test_common.py:1
    @@ -1032,6 +1032,11 @@ def _mark_splits(
         return new_test_settings
     
     
    +VLM_TEST_SETTINGS["llava-pp-broadcast"] = VLM_TEST_SETTINGS["llava-broadcast"]._replace(
    +    tensor_parallel_size=1,
    +    distributed_executor_backend="mp",
    +    vllm_runner_kwargs={"pipeline_parallel_size": 2},
    +)


    No need to add PP test here.

    Isotr0py Isotr0py approved these changes on Oct 22, 2026 06:31 UTC
    Approved Reviewer

    Approved these changes.

    Isotr0py Isotr0py commented on Oct 22, 2026 06:31 UTC
    Contributor

    /ci run

    github-actions[bot] github-actions[bot] commented on Oct 22, 2026 06:33 UTC
    Bot

    ✅ Triggered Buildkite CI #96587 for commit 860e4e4d9ce4.

    ℹ️ This PR is 1042 commits behind upstream main. Merged upstream main into this branch as 860e4e4d9ce4 before starting CI. Pull the branch before pushing more changes.

    Isotr0py Isotr0py commented on Oct 22, 2026 12:27 UTC
    Contributor

    /ci retry

    github-actions[bot] github-actions[bot] commented on Oct 22, 2026 12:28 UTC
    Bot

    ✅ Triggered Buildkite CI #96640 for commit 505b40bfec7a, running 2 failed step(s) from Buildkite CI #96587.

    lesj0610 lesj0610 commented on Oct 22, 2026 14:08 UTC
    Author

    @Isotr0py Thanks for reviewing and merging!

    Reviewers
    Assignees
    lesj0610 lesj0610
    Labels
    risk: low confidence: 88.5% 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: 24.7% (LOW) · Higher = larger blast radius
    24.7%
    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: 88.5% · Lower = rushed or shallow review
    88.5%
    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: 2.8% · Safe to merge
    2.8%