Skip to content

[BugFix] Fix DS/Kimi crash on non-first PP ranks when resolving input length - #31752

Merged
ch-wan merged 2 commits into
sgl-project:mainfrom
ZhengWG:py/fix-dsv2-pp-git
Jul 24, 2026
Merged

ch-wan merged 2 commits into
sgl-project:mainfrom
ZhengWG:py/fix-dsv2-pp-git

Conversation

@ZhengWG

@ZhengWG ZhengWG commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Motivation

DeepseekV2ForCausalLM.forward computes len_input_ids for prefill CP metadata before the model body runs. The previous fallback only covered the multimodal case (input_ids is None → use input_embeds). With pp_size > 1, non-first PP ranks receive activations via pp_proxy_tensors and both input_ids and input_embeds are None, which triggers an AttributeError on .shape. This blocks DeepSeek / Kimi serving under pipeline parallelism.

Modifications

In python/sglang/srt/models/deepseek_v2.py, resolve sequence length as:

  1. input_ids.shape[0] when present
  2. else input_embeds.shape[0] (multimodal)
  3. else pp_proxy_tensors["hidden_states"].shape[0] (non-first PP rank)

No behavior change on PP rank 0 or single-stage PP.

Accuracy Tests

Speed Tests and Profiling

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

CI States

Latest PR Test (Base): ❌ Run #29720769565
Latest PR Test (Extra): ❌ Run #29720769440

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@ZhengWG ZhengWG changed the title [BugFix] fix none-type error with pp_size > 1 for Ds/Kimi [BugFix] Fix DS/Kimi crash on non-first PP ranks when resolving input length Jul 20, 2026
@ZhengWG

ZhengWG commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator Author

@Fridge003 Could you review this when you get a chance? Thanks!

@ch-wan
ch-wan merged commit be7c13a into sgl-project:main Jul 24, 2026
97 of 113 checks passed
jinzhenfan pushed a commit to jinzhenfan/sglang that referenced this pull request Jul 29, 2026
jakki-amd pushed a commit to jakki-amd/sglang that referenced this pull request Sep 9, 2026
Atituiset pushed a commit to Atituiset/sglang that referenced this pull request Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants