Skip to content

support GLM-5.2 MTP index sharing with prefill CP - #30992

Merged
Fridge003 merged 6 commits into
sgl-project:mainfrom
zRzRzRzRzRzRzR:glm5cp
Jul 14, 2026
Merged

Fridge003 merged 6 commits into
sgl-project:mainfrom
zRzRzRzRzRzRzR:glm5cp

Conversation

@zRzRzRzRzRzRzR

@zRzRzRzRzRzRzR zRzRzRzRzRzRzR commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

This PR complements #30839 by adding prefill context-parallel support for GLM-5.2 MTP IndexShare, ensuring correct DSA top-k gathering and draft-extend seed selection after CP sharding and reordering.


CI States

Latest PR Test (Base): ⏳ Run #29302053605
Latest PR Test (Extra): ⏳ Run #29302053513

Gather and restore DSA top-k indices before selecting draft-extend seeds under context parallelism. Pad uneven interleaved shards and resolve canonical CP arguments against the final DSA backend.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enables context-parallel prefill support for DeepSeek NextN models by introducing gathering and padding of DSA top-k indices during context-parallel prefill, fixing legacy argument resolution, and removing the restriction on seeding DSA top-k indices from draft-extend under context-parallel prefill. The review feedback highlights two important issues: first, topk_indices should be padded with -1 regardless of the CP split strategy to prevent silent routing bugs to Expert 0 under zigzag split; second, getattr should be used to retrieve dsa_seed_topk_capture from spec_info to avoid potential AttributeError crashes when the attribute is not set.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +72 to +75
if (
is_dsa_prefill_cp_round_robin_split()
and topk_indices.shape[0] < local_num_tokens
):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

In _gather_dsa_topk_indices_for_cp, the padding of topk_indices to local_num_tokens with -1 is only performed when is_dsa_prefill_cp_round_robin_split() is True. However, if the user configures the context-parallel prefill mode to zigzag split (in-seq-split), is_dsa_prefill_cp_round_robin_split() will be False but topk_indices.shape[0] can still be less than local_num_tokens due to padded or skipped tokens.\n\nIf we do not pad topk_indices to local_num_tokens with -1 first, cp_all_gather_rerange_output will call cp_all_gather_reorganized_into_tensor, which pads the tensor to max_len using 0 as the constant value. Since 0 is a valid expert index, the padded tokens (from topk_indices.shape[0] to local_num_tokens) will be incorrectly assigned to Expert 0, leading to silent correctness and routing bugs.\n\nTo prevent this, we should pad topk_indices to local_num_tokens with -1 regardless of the CP split strategy.

    if topk_indices.shape[0] < local_num_tokens:

Comment on lines +261 to +265
seed_buf = (
forward_batch.spec_info.dsa_seed_topk_capture
if forward_batch.forward_mode.is_extend(include_draft_extend_v2=True)
else None
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Directly accessing forward_batch.spec_info.dsa_seed_topk_capture can raise an AttributeError if dsa_seed_topk_capture is not set on spec_info. In eagle_worker_v2.py, dsa_seed_topk_capture is only dynamically set when seed_from_extend is True. If seed_from_extend is False, the attribute is never defined on spec_info.\n\nTo make this more robust and prevent potential AttributeError crashes, we should use getattr to safely retrieve dsa_seed_topk_capture with a default value of None.

            seed_buf = (\n                getattr(forward_batch.spec_info, 'dsa_seed_topk_capture', None)\n                if forward_batch.forward_mode.is_extend(include_draft_extend_v2=True)\n                else None\n            )

@yiminghub2024

Copy link
Copy Markdown

@zRzRzRzRzRzRzR hi ,could you please add my wechat : yiminghub2012 ,i have meet the same problem, we can have a talk ,i want to know what's the root cause . i have many questions ablout glm-5.2 difference version ,

@JustinTong0323 JustinTong0323 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CP gather still leaves padded rows on draft-extend; crop them before copying into the original-size EAGLE seed buffer.

Copy link
Copy Markdown
Collaborator

Unfused DSA top-k accuracy validation

I tested the current PR head (cbc7fd5637) on the GB300 devbox with fused top-k disabled externally:

SGLANG_DSA_FUSE_TOPK=0 python3 test/registered/cp/test_glm52_cp_single_node.py

The run used nvidia/GLM-5.2-NVFP4 with TP=4, attention CP=4, prefill CP enabled, the interleave CP strategy, and EAGLE speculative decoding. The server log confirmed:

Enabled DSA context parallel: strategy=interleave, tp_size=4, attn_cp_size=4

Results:

  • GSM8K score: 0.946 (threshold: 0.935)
  • Mean acceptance length: 3.2794 (threshold: 3.0)
  • Output throughput: 423.052 tokens/s
  • Evaluation latency: 124.904 s
  • Full test: 1/1 passed in 356.001 s

Target-verify CUDA graph capture also completed on all four ranks. This validates the unfused top-k path with CP enabled.

@Fridge003 Fridge003 added run-ci CI: run the baseline test suite on this PR run-ci-extra CI: also run the extra suite (requires run-ci) labels Jul 14, 2026
@Fridge003

Copy link
Copy Markdown
Collaborator

/rerun-test test/registered/cp/test_glm52_cp_index_share.py test/registered/cp/test_deepseek_v3_cp_single_node.py test/registered/cp/test_deepseek_v32_cp_single_node.py

@github-actions

github-actions Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Results for /rerun-test test/registered/cp/test_glm52_cp_index_share.py test/registered/cp/test_deepseek_v3_cp_single_node.py test/registered/cp/test_deepseek_v32_cp_single_node.py:

🚀 4-gpu-b200 (1 test): ❌ View workflow run

cd test/ && python3 registered/cp/test_glm52_cp_index_share.py

🚀 8-gpu-h200 (2 tests): ❌ View workflow run

cd test/ && python3 registered/cp/test_deepseek_v3_cp_single_node.py
cd test/ && python3 registered/cp/test_deepseek_v32_cp_single_node.py

Copy link
Copy Markdown
Collaborator

Unfused DSA top-k E2E rerun

Reran the registered GLM-5.2 CP E2E test on a GB300 devbox at PR head 51449808cb8b67c046c56bd352d75fe316ab3585.

SGLANG_DSA_FUSE_TOPK=0 python3 test/registered/cp/test_glm52_cp_index_share.py

Configuration:

  • Model: nvidia/GLM-5.2-NVFP4
  • TP4 / attention CP4, --cp-strategy interleave
  • EAGLE: 3 steps, top-k 1, 4 draft tokens
  • Live process environment confirmed SGLANG_DSA_FUSE_TOPK=0
  • Server log confirmed CP active: Enabled DSA context parallel: strategy=interleave ... tp_size=4, attn_cp_size=4
  • Resolved args confirmed enable_dsa_prefill_context_parallel=True

Results:

  • PASS — Ran 1 test in 443.202s / OK
  • GSM8K score: 0.960 (threshold: 0.935)
  • Mean speculative acceptance length: 3.2811 (threshold: 3.0)
  • Output throughput: 401.887 token/s
  • GSM8K latency: 132.032s

No CUDA errors, kernel assertions, or distributed rank failures were observed. The test also cleaned up all server/scheduler GPU processes after completion.

@Fridge003
Fridge003 merged commit 7e229e2 into sgl-project:main Jul 14, 2026
120 of 166 checks passed
Fridge003 added a commit that referenced this pull request Jul 14, 2026
@zRzRzRzRzRzRzR
zRzRzRzRzRzRzR deleted the glm5cp branch July 14, 2026 05:01
Chronostasys pushed a commit to MindLab-Research/sglang that referenced this pull request Aug 24, 2026
Chronostasys pushed a commit to MindLab-Research/sglang that referenced this pull request Aug 24, 2026
Edward-lyz pushed a commit to Edward-lyz/sglang that referenced this pull request Nov 10, 2026
…fill CP

来源提交(1 个):0b3bb0cbe3
原标题:[Cherry-pick to release/v0.5.15] support GLM-5.2 MTP index sharing with prefill CP (sgl-project#30992) (sgl-project#31106)
作者:Baizhou Zhang,日期:2026-07-13
luno:-
开关:-
默认:无开关
改动规模:7 files changed, 527 insertions(+), 51 deletions(-)
主要目录:python/sglang/srt/layers, python/sglang/srt/models, python/sglang/srt/server_args.py, python/sglang/srt/speculative
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bypass-fastfail deepseek high priority post version patch run-ci CI: run the baseline test suite on this PR run-ci-extra CI: also run the extra suite (requires run-ci)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants