Repository navigation
[Model][PP] Build the input embedding and lm_head of Qwen3-MoE, Qwen3-Next, Qwen3.5 and gpt-oss only on the pipeline stages that use them - #67349
Open
xsxszab wants to merge 2 commits into
Conversation
…-Next, Qwen3.5 and gpt-oss only on the pipeline stages that use them These models built the input embedding, and some of them also the final norm and lm_head, on every pipeline stage. Build them only where they are used, with the condition Llama uses: the input embedding on the first stage, and on the last stage when lm_head is tied to it or a drafter reuses it; the final norm and lm_head on the last stage. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Yifei Wang <yifei.w@inferact.ai>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Qwen3-MoE (including the Qwen3-VL-MoE and Qwen3-Omni language models), Qwen3-Next, Qwen3.5 and gpt-oss build the input embedding, and some of them also the final norm and
lm_head, on every pipeline stage. They now build these modules only on the stages that use them, as Llama does, so each stage loads 0.58 to 1.08 GiB less at PP=2.Claims
lm_headis tied to it or a drafter reuses it; the final norm andlm_headare built only on the last stage. This is the condition Llama and Qwen2 use.test_pp_tied_word_embeddingscovers Qwen3.5-0.8B, whoselm_headis tied to the input embedding.Validation
B300 GPUs, Model Runner V2.
The
qwen3_5case compares PP=2 with PP=1 logprobs on Qwen3.5-0.8B and passes on 2× B300. CI runs this file in the Pipeline + Context Parallelism step: nightly on NVIDIA L4 and on PRs through its AMD MI250 mirror.Greedy outputs with PP=2 (eager, one request at a time, 4 prompts) are identical to main token for token for Qwen3-30B-A3B (text) and Qwen3-VL-30B-A3B-Instruct-FP8 (3 images, 1 text prompt).
GSM8K (1319 questions, 5-shot, one run each) and model loading per stage,
-pp 2 --max-model-len 4096with torch.compile and CUDA graphs:gpt-oss-20b is evaluated through completions without its chat format, as in its GSM8K config (threshold 0.30). On main, Qwen3.5 already skips
lm_headon PP0, so only PP1 changes; the KV cache is sized by the stage with less free memory, which is now PP0.Other parallel layouts and speculative decoding
Same GSM8K setup:
RedHatAI/gpt-oss-20b-speculator.eagle3, 3 tokens), PP=2The EAGLE3 head reuses the target input embedding, so the last stage keeps it and only PP0 changes; the MTP drafter has its own embedding, so the target's is skipped on PP1.
Details
What each model built on every stage before this change:
lm_headlm_headlm_headmodels/qwen3_5.pyandmodels/qwen3_5/nvidia/model.py)The code follows Llama: the other stages get a
PPMissingLayer, andtie_weightsmoves into the last-stage branch.Qwen3MoeModelreadstie_word_embeddingsfromhf_config.get_text_config(), the config its causal LMs tie by: inside Qwen3-VL-MoE and Qwen3-Omni,with_hf_config(#38035) updateshf_configbut leaveshf_text_configwith the text config's own value, which defaults to True for Qwen3-VL-MoE.Limits:
load_format="sharded_state"before this change hold the skipped modules and fail to load with aKeyError; they must be saved again.classifier_from_tokenat PP>=3 fails on the middle stage, which has no input embedding to take the classifier rows from. Other tied models such as Qwen3-Reranker-0.6B already fail this way on main.No open PR changes where these models build these modules.
AI assistance (Claude Code) was used for this PR.
Pull Request Checklist
I used vLLM's
/pr-checklistskill. (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.