Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions helion/autotuner/base_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,7 @@ def autotune(self, *, skip_cache: bool = False) -> Config:
f" {kernel_decorator}\n",
level=logging.INFO + 5,
)
self.log(f"Code of selected kernel: {self.kernel.get_cached_path(best)}")
self.kernel.maybe_log_repro(self.log.warning, self.args, best)
if self.settings.print_output_code:
triton_code = self.kernel.to_triton_code(best)
Expand Down
20 changes: 20 additions & 0 deletions helion/runtime/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ def __init__(
self._run: Callable[..., _R] | None = None
self._config: Config | None = None
self._compile_cache: dict[Config, CompiledConfig] = {}
self._cache_path_map: dict[Config, str | None] = {}
self.env = CompileEnvironment(
_find_device(args),
self.kernel.settings,
Expand Down Expand Up @@ -552,8 +553,27 @@ def compile_config(
print(triton_code, file=sys.stderr)
rv = getattr(module, self.kernel.name)
self._compile_cache[config] = rv
self._cache_path_map[config] = module.__file__
return rv

def get_cached_path(self, config: ConfigLike | None = None) -> str | None:
"""
Get the file path of the generated Triton code for a specific configuration.

Args:
config: The configuration to get the file path for.
Returns:
str | None: The file path of the generated Triton code, or None if not found.
"""
if config is None:
config = self._require_implicit_config()
if not isinstance(config, Config):
config = Config(
# pyrefly: ignore [bad-argument-type]
**config
)
return self._cache_path_map.get(config, None)

def _debug_str(self) -> str:
"""
Generate a debug string for the kernel.
Expand Down
Loading