Skip to content

Suppress debug output when AMD_TRITON_NPU_DEBUG is off#55

Merged
erwei-xilinx merged 2 commits into
mainfrom
fix/suppress-debug-output-issue-52
Apr 20, 2026
Merged

Suppress debug output when AMD_TRITON_NPU_DEBUG is off#55
erwei-xilinx merged 2 commits into
mainfrom
fix/suppress-debug-output-issue-52

Conversation

@erwei-xilinx

@erwei-xilinx erwei-xilinx commented Apr 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Fixes [Bug] Debug output generated even when logging is off #52: subprocess output (Bootgen/xclbinutil banners, [INFO] messages) and C++ launcher verbosity (Loading ELF, Running Kernel, etc.) were always printed regardless of the AMD_TRITON_NPU_DEBUG flag
  • Adds debug property to npu_config (following the existing _UNSET-backed pattern) so it can be controlled both via env var and programmatically
  • Captures stdout/stderr from g++, aircc, and triton-shared-opt subprocesses when not in debug mode; prints captured output to stderr on failure so error messages are never lost
  • Sets C++ launcher int verbosity to 0/1 based on npu_config.debug in both _generate_launcher() (xclbin) and _generate_elf_launcher() (ELF)
  • Guards a previously unguarded std::cout in the xclbin kernel-search lambda

Test plan

  • Verified on NPU2 (Strix) with examples/vec-add/: no output when AMD_TRITON_NPU_DEBUG is unset
  • Verified on NPU2 (Strix) with examples/vec-add/: full verbose output when AMD_TRITON_NPU_DEBUG=1
  • CI build passes
  • Verify error messages are still visible when a subprocess fails (e.g., missing aiecc)

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings April 20, 2026 17:44
…UG is off

The AMD_TRITON_NPU_DEBUG flag only gated Python logger.debug() calls but
subprocess output (aircc → aiecc → xclbinutil banners) and C++ launcher
verbosity ("Loading ELF", "Running Kernel", etc.) were always printed.

- Add `debug` property to npu_config (config.py) with env var fallback
- Capture stdout/stderr from g++, aircc, and triton-shared-opt subprocesses
  when not in debug mode; print captured output to stderr on failure so
  error messages are never lost
- Set C++ launcher `int verbosity` to 0/1 based on npu_config.debug in
  both _generate_launcher() and _generate_elf_launcher()
- Guard the previously unguarded std::cout in the xclbin kernel-search
  lambda

Fixes #52

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Copilot AI 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.

Pull request overview

This PR makes the NPU backend’s verbosity honor AMD_TRITON_NPU_DEBUG (and a new programmatic npu_config.debug flag), suppressing subprocess banners and C++ launcher prints when debug is disabled.

Changes:

  • Add debug to the process-global npu_config with _UNSET + env var fallback semantics.
  • Gate C++ launcher verbosity and previously unguarded std::cout output on npu_config.debug.
  • Capture/suppress stdout+stderr from key subprocess invocations in non-debug mode while replaying captured output on failure.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
amd_triton_npu/backend/driver.py Switch logging/launcher verbosity to npu_config.debug; suppress subprocess output in non-debug mode and replay on failure.
amd_triton_npu/backend/config.py Introduce npu_config.debug with env-var fallback and set_config support.
amd_triton_npu/backend/compiler.py Suppress triton-shared-opt output in non-debug mode and replay on failure.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread amd_triton_npu/backend/driver.py
Comment thread amd_triton_npu/backend/driver.py
Comment thread amd_triton_npu/backend/driver.py
Comment thread amd_triton_npu/backend/compiler.py Outdated
- Update driver logger level in config.py debug setter so programmatic
  toggles via npu_config.debug take effect immediately
- Replace sys.stderr.buffer.write() with getattr fallback to handle
  environments where stderr lacks a buffer attribute (notebooks, test
  runners)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@erwei-xilinx erwei-xilinx merged commit fa84eb1 into main Apr 20, 2026
8 of 9 checks passed
@erwei-xilinx erwei-xilinx deleted the fix/suppress-debug-output-issue-52 branch April 20, 2026 20:01
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.

[Bug] Debug output generated even when logging is off

2 participants