Repository navigation
support GLM-5.2 MTP index sharing with prefill CP - #30992
Conversation
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.
There was a problem hiding this comment.
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.
| if ( | ||
| is_dsa_prefill_cp_round_robin_split() | ||
| and topk_indices.shape[0] < local_num_tokens | ||
| ): |
There was a problem hiding this comment.
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:| seed_buf = ( | ||
| forward_batch.spec_info.dsa_seed_topk_capture | ||
| if forward_batch.forward_mode.is_extend(include_draft_extend_v2=True) | ||
| else None | ||
| ) |
There was a problem hiding this comment.
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 )|
@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
left a comment
There was a problem hiding this comment.
CP gather still leaves padded rows on draft-extend; crop them before copying into the original-size EAGLE seed buffer.
Unfused DSA top-k accuracy validationI tested the current PR head ( SGLANG_DSA_FUSE_TOPK=0 python3 test/registered/cp/test_glm52_cp_single_node.pyThe run used Results:
Target-verify CUDA graph capture also completed on all four ranks. This validates the unfused top-k path with CP enabled. |
|
/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 |
|
Results for 🚀 🚀 |
Unfused DSA top-k E2E rerunReran the registered GLM-5.2 CP E2E test on a GB300 devbox at PR head SGLANG_DSA_FUSE_TOPK=0 python3 test/registered/cp/test_glm52_cp_index_share.pyConfiguration:
Results:
No CUDA errors, kernel assertions, or distributed rank failures were observed. The test also cleaned up all server/scheduler GPU processes after completion. |
…th prefill CP (#30992) (#31106) Co-authored-by: zRzRzRzRzRzRzR <[email protected]>
…th prefill CP (sgl-project#30992) (sgl-project#31106) Co-authored-by: zRzRzRzRzRzRzR <[email protected]>
Co-authored-by: Baizhou Zhang <[email protected]>
…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
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