Suppress debug output when AMD_TRITON_NPU_DEBUG is off#55
Merged
Conversation
…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>
Contributor
There was a problem hiding this comment.
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
debugto the process-globalnpu_configwith_UNSET+ env var fallback semantics. - Gate C++ launcher verbosity and previously unguarded
std::coutoutput onnpu_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.
- 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
[INFO]messages) and C++ launcher verbosity (Loading ELF,Running Kernel, etc.) were always printed regardless of theAMD_TRITON_NPU_DEBUGflagdebugproperty tonpu_config(following the existing_UNSET-backed pattern) so it can be controlled both via env var and programmaticallyg++,aircc, andtriton-shared-optsubprocesses when not in debug mode; prints captured output to stderr on failure so error messages are never lostint verbosityto0/1based onnpu_config.debugin both_generate_launcher()(xclbin) and_generate_elf_launcher()(ELF)std::coutin the xclbin kernel-search lambdaTest plan
examples/vec-add/: no output whenAMD_TRITON_NPU_DEBUGis unsetexamples/vec-add/: full verbose output whenAMD_TRITON_NPU_DEBUG=1aiecc)🤖 Generated with Claude Code