Skip to content

[Bug Fix] GLM-5.1: drop constexpr on page_indice_batch_offset, skip offloader post_init on draft worker, support N=32 in copy_to_gpu_no_ce - #23550

Merged
ispobock merged 7 commits into
sgl-project:mainfrom
zRzRzRzRzRzRzR:glm-offload
May 9, 2026

Conversation

@zRzRzRzRzRzRzR

@zRzRzRzRzRzRzR zRzRzRzRzRzRzR commented Apr 23, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Several issues were blocking the GLM-5.1 expert-offload path and causing excessive Triton recompilation on long-sequence / per-batch runs. This PR bundles the minimal fixes required to unblock it.

Modifications

  • NSA get_k_and_s kernel: drop tl.constexpr from page_indice_batch_offset and pass it as a regular int. Its value is page_indices.shape[1], which varies at runtime (long seqlen / per-batch), so keeping it as constexpr forces a Triton JIT recompile for every new value.
  • model_runner: skip get_offloader().post_init() on draft workers, so MTP does not re-initialize and fight with the target model's offloader state.
  • sgl-kernel copy.cu: add an N == 32 case to copy_to_gpu_no_ce, required by the GLM-5.1 expert-offload path (previously hit unexpected N).

@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 updates the Triton kernel for NSA by removing the constexpr constraint on the page index batch offset, ensures the offloader is not post-initialized for draft workers in the model runner, and adds support for a block size of 32 in the CUDA copy kernel. I have no feedback to provide.

@zRzRzRzRzRzRzR zRzRzRzRzRzRzR changed the title Fix graceful-exit hang and tensor top-logprobs; support GLM-5 expert offload and disable offloader when MTP [Bug Fix] GLM-5.1: drop constexpr on page_indice_batch_offset, skip offloader post_init on draft worker, support N=32 in copy_to_gpu_no_ce Apr 23, 2026
@zRzRzRzRzRzRzR

Copy link
Copy Markdown
Contributor Author

page_indice_batch_offset is dropped from tl.constexpr because its value is derived from page_indices.shape[1], which changes across batches in serving. Keeping it as a compile-time constant forces Triton to JIT-recompile the kernel for every new value and inflates the kernel cache, while the parameter is only used in a scalar multiply and a scalar compare — neither benefits from constexpr folding. Passing it as a runtime int yields a single kernel variant with no measurable overhead.

@JustinTong0323

Copy link
Copy Markdown
Collaborator

/tag-and-rerun-ci

@github-actions github-actions Bot added the run-ci CI: run the baseline test suite on this PR label Apr 29, 2026
@ispobock
ispobock merged commit d49fc09 into sgl-project:main May 9, 2026
242 of 298 checks passed
@zRzRzRzRzRzRzR
zRzRzRzRzRzRzR deleted the glm-offload branch May 10, 2026 19:39
Chronostasys pushed a commit to MindLab-Research/sglang that referenced this pull request Aug 24, 2026
…ffloader post_init on draft worker, support N=32 in copy_to_gpu_no_ce (sgl-project#23550)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-ci CI: run the baseline test suite on this PR sgl-kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants