[Multimodal] Skip encoder towers on later PP stages under V2 #60238
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.
pp size check not needed
Removed in f75c5cebf1. The llava PP=2 broadcast case and the single-GPU llava image case still pass.
Don't we have to update other deepstack models?
I think this is equivalent to not self.language_model_only and bool(config.vision_config.deepstack_visual_indexes) in self.use_deepstack.
Overall look reasonable. Leave some nits.
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.
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.
I see, can we align the deepstack checks? There're already several kinds of deepstack checks.
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.
No need to add PP test here.
Approved these changes.
/ci run
✅ 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.
/ci retry
✅ Triggered Buildkite CI #96640 for commit 505b40bfec7a, running 2 failed step(s) from Buildkite CI #96587.
@Isotr0py Thanks for reviewing and merging!
Isotr0py
lesj0610
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_modelpath.Claims
llava-broadcastrun with PP=2, and the existing PP comparison tests pass.Validation
All runs on main (
6ad2e06c4a) with and without this commit, two sm_80 GPUs, V2 runner, FlashInfer sampler off.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_generationcompares 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 at9213176726by 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_modelalready builds a tower on the meta device and wraps it inStageMissingLayerwhen--limit-mm-per-promptis 0 for all of its modalities, andAutoWeightsLoaderskips the weights of aStageMissingLayer. This adds a second condition to the same skip: the V2 runner and not the first stage. Under V2 the encoder only runs wheresupports_mm_inputs and is_first_pp_rankholds; the encoder cache, the encoder runner and the encoder CUDA graphs only exist on the first stage, and noget_mrope_input_positionsimplementation, which every stage runs, touches a tower. V1 is left out because itsprofile_runcallsembed_multimodalon every rank.Models that branch on a missing tower: Qwen3-VL, Qwen3-VL-MoE and Qwen3-Omni turn
use_deepstackoff on later stages, which do not use it since deepstack inputs are consumed on the first stage; the PPstart_layercheck of Qwen3-VL and Qwen3-VL-MoE reads the config, so it still runs, and Qwen3-Omni has none. Qwen4Exp gated that check onuse_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 emptydeepstack_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,StageMissingLayerand pipeline-parallel encoder or tower changes return nothing related.---
<details>
<summary> Pull Request Checklist </summary>
/pr-checklistskill. (Mandatory for agents, optional for humans).</details>