Add get_npu_cache_dir() to expose NPU binary cache path#45
Merged
Conversation
The NPU backend stores hardware artifacts (xclbin/elf, insts.bin, dispatch .so) in a separate triton cache directory from the main compiler cache. Users had no way to programmatically retrieve this path after compilation. Add a callback mechanism in compile_module() and expose it through a public get_npu_cache_dir() utility function that returns the cache directory given a CompiledKernel. Closes #41 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 exposes the NPU backend’s binary cache directory for a given compiled Triton kernel by capturing the cache directory during first launch and providing a helper to retrieve it from the compiled kernel object.
Changes:
- Extend
compile_module()with anon_cache_resolvedcallback invoked with the NPU cache directory. - Store the resolved cache directory on
NPULauncherinstances at launch time. - Add
get_npu_cache_dir(compiled_kernel)utility to return the captured cache directory (orNonebefore first launch).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- List per-format artifacts (xclbin vs elf) instead of a single list - Clarify when None is returned vs when TypeError is raised 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
get_npu_cache_dir(compiled_kernel)utility function that returns the path to the NPU binary cache directory containingaie.xclbin/aie.elf,insts.bin, and__npu_dispatch.soon_cache_resolvedcallback mechanism incompile_module()soNPULaunchercaptures the cache directory on first kernel launchamd_triton_npu/backend/driver.pyis modifiedUsage
Closes #41
Test plan
_run, wrong_runtype raises TypeError)get_npu_cache_dirreturns valid cache directory withaie.xclbin,insts.bin,__npu_dispatch.so🤖 Generated with Claude Code