Skip to content

[Fix] Avoid applying cuda graph input-buffer registry on non-cuda devices - #27549

Merged
ch-wan merged 3 commits into
sgl-project:mainfrom
ZailiWang:fix-non-cuda
Jun 9, 2026
Merged

ch-wan merged 3 commits into
sgl-project:mainfrom
ZailiWang:fix-non-cuda

Conversation

@ZailiWang

@ZailiWang ZailiWang commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Motivation

The feature introduced in PR #27407 is not compatible with non-CUDA devices (at least not for Xeon CPU). Xeon CI failure is observed after the merging of this PR.

Modifications

Add gating logics so that the feature can be applied only on cuda device.

Accuracy Tests

N/A

Speed Tests and Profiling

N/A

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 #27127564313
Latest PR Test (Extra): ❌ Run #27127564042

@ZailiWang

Copy link
Copy Markdown
Contributor Author

/tag-run-ci-label

@github-actions github-actions Bot added the run-ci label Jun 8, 2026

@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 restricts the eager input-buffer view creation in forward_decode, forward_extend, and forward_idle to when the device is 'cuda'. The reviewer noted that using self.device == 'cuda' is too restrictive as it disables the eager input-buffer registry on other platforms that support CUDA graphs, such as 'musa' or out-of-tree platforms. They suggested broadening the check to support these platforms consistently with the rest of the codebase.

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.

pp_proxy_tensors=None,
) -> Union[LogitsProcessorOutput, PPProxyTensors]:
if not self.server_args.enable_pdmux:
if not self.server_args.enable_pdmux and self.device == 'cuda':

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

Using self.device == 'cuda' is too restrictive and will disable the eager input-buffer registry on other platforms that support CUDA graphs, such as musa or out-of-tree platforms. To maintain consistency with the rest of the codebase (e.g., the CUDA graph recapture check at line 1719), we should allow all platforms that support CUDA graphs.

Suggested change
if not self.server_args.enable_pdmux and self.device == 'cuda':
if not self.server_args.enable_pdmux and (self.device in ["cuda", "musa"] or (current_platform.is_out_of_tree() and current_platform.support_cuda_graph())):

return (ret, can_run_graph)

if not self.server_args.enable_pdmux:
if not self.server_args.enable_pdmux and self.device == 'cuda':

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

Using self.device == 'cuda' is too restrictive and will disable the eager input-buffer registry on other platforms that support CUDA graphs, such as musa or out-of-tree platforms. To maintain consistency with the rest of the codebase (e.g., the CUDA graph recapture check at line 1719), we should allow all platforms that support CUDA graphs.

Suggested change
if not self.server_args.enable_pdmux and self.device == 'cuda':
if not self.server_args.enable_pdmux and (self.device in ["cuda", "musa"] or (current_platform.is_out_of_tree() and current_platform.support_cuda_graph())):

# indices and trigger SWA mapping use-after-free.
if forward_batch.batch_size > 0:
if not self.server_args.enable_pdmux:
if not self.server_args.enable_pdmux and self.device == 'cuda':

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

Using self.device == 'cuda' is too restrictive and will disable the eager input-buffer registry on other platforms that support CUDA graphs, such as musa or out-of-tree platforms. To maintain consistency with the rest of the codebase (e.g., the CUDA graph recapture check at line 1719), we should allow all platforms that support CUDA graphs.

Suggested change
if not self.server_args.enable_pdmux and self.device == 'cuda':
if not self.server_args.enable_pdmux and (self.device in ["cuda", "musa"] or (current_platform.is_out_of_tree() and current_platform.support_cuda_graph())):

@ZailiWang

Copy link
Copy Markdown
Contributor Author

Hi @ch-wan would you help review this PR? Does the approach that Gemini suggests make more sense? Thanks.

@ch-wan ch-wan self-assigned this Jun 9, 2026
@ch-wan
ch-wan merged commit d981b7b into sgl-project:main Jun 9, 2026
101 of 138 checks passed
@ch-wan

ch-wan commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Based on codex, the error is caused by dtype mismatch in seq_lens and seq_lens_cpu. I will prepare a correct fix later.

@ZailiWang
ZailiWang deleted the fix-non-cuda branch June 9, 2026 07:27
Fridge003 pushed a commit that referenced this pull request Jun 9, 2026
…t-buffer registry on non-cuda devices (#27549) (#27711)

Co-authored-by: Zaili Wang <109502517+ZailiWang@users.noreply.github.com>
Chronostasys pushed a commit to MindLab-Research/sglang that referenced this pull request Aug 24, 2026
jakki-amd pushed a commit to jakki-amd/sglang that referenced this pull request Sep 9, 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