Skip to content

Add env HELION_PRINT_OUTPUT_CODE=1 #93

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 30, 2025
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
3 changes: 3 additions & 0 deletions helion/runtime/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import logging
import operator
import re
import sys
import types
from typing import TYPE_CHECKING
from typing import overload
Expand Down Expand Up @@ -343,6 +344,8 @@ def compile_config(self, config: ConfigLike) -> CompiledConfig:
triton_code = self.to_triton_code(config)
log.info("Output code: \n%s", triton_code)
log.debug("Debug string: \n%s", LazyString(lambda: self._debug_str()))
if self.settings.print_output_code:
print(triton_code, file=sys.stderr)
module = PyCodeCache.load(triton_code)
rv = getattr(module, self.kernel.name)
rv.make_precompiler = getattr(module, f"_{self.kernel.name}_make_precompiler")
Expand Down
2 changes: 2 additions & 0 deletions helion/runtime/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class _Settings:
autotune_log_level: int = logging.INFO
autotune_compile_timeout: int = 60
autotune_precompile: bool = sys.platform != "win32"
print_output_code: bool = os.environ.get("HELION_PRINT_OUTPUT_CODE", "0") == "1"


class Settings(_Settings):
Expand All @@ -75,6 +76,7 @@ class Settings(_Settings):
"autotune_log_level": "Log level for autotuning. 0 = no logging, 1 = only final config, 2 = default, 3 = verbose.",
"autotune_compile_timeout": "Timeout for Triton compilation in seconds used for autotuning. Default is 60 seconds.",
"autotune_precompile": "If True, precompile the kernel before autotuning. Requires fork-safe environment.",
"print_output_code": "If True, print the output code of the kernel to stderr.",
}
assert __slots__.keys() == {field.name for field in dataclasses.fields(_Settings)}

Expand Down
Loading