Skip to content

[NPU] add device print#28126

Open
zhaozx-cn wants to merge 6 commits into
sgl-project:mainfrom
zhaozx-cn:add_device_print
Open

[NPU] add device print#28126
zhaozx-cn wants to merge 6 commits into
sgl-project:mainfrom
zhaozx-cn:add_device_print

Conversation

@zhaozx-cn

@zhaozx-cn zhaozx-cn commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Motivation

This PR adds device print support for npu graph mode. The main use case is debugging, especially when investigating and fixing accuracy issues on npu.

Modifications

add device_print func.

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

Signed-off-by: zhaozx-cn <zhaozx2116@163.com>
@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!

@iforgetmyname iforgetmyname self-assigned this Jun 14, 2026
_ensure_device_print_registered()

if isinstance(value, torch.Tensor):
torch.ops.npu.device_print_tensor(value)

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.

in sgl-kernel-npu?

@zhaozx-cn zhaozx-cn Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +357 to +360
except AttributeError as exc:
raise RuntimeError(
"device_print requires _C_ascend.device_print ops to be available "
"when custom ops are enabled in the current Ascend build."

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.

please tell user how to install sgl_kernel_npu when they faced import issue

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@ping1jing2

Copy link
Copy Markdown
Collaborator

please solve the lint issue

Signed-off-by: zhaozx-cn <zhaozx2116@163.com>
Signed-off-by: zhaozx-cn <zhaozx2116@163.com>
Signed-off-by: zhaozx-cn <zhaozx2116@163.com>
try:
# Mark device_print ops side-effectful so FX/Inductor does not DCE or reorder these debug callbacks.
import sgl_kernel_npu # noqa: F401

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.

move import to top

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

maybe need to lazy init here

zhaozx-cn and others added 2 commits June 22, 2026 09:48
Signed-off-by: zhaozx-cn <zhaozx2116@163.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants