Settings
The Settings
class controls compilation behavior and debugging options for Helion kernels.
- class helion.Settings(**settings)[source]
Bases:
_Settings
Settings can be passed to hl.kernel as kwargs and control the behavior of the compilation process. Unlike a Config, settings are not auto-tuned and set by the user.
- Parameters:
settings (
object
)
- __init__(**settings)[source]
Initialize the Settings object with the provided dictionary of settings. If no settings are provided, the default settings are used (see set_default_settings).
- Parameters:
settings (
object
) – Keyword arguments representing various settings.
- static default()[source]
Get the default Settings object. If no default settings are set, create a new one.
- Returns:
The default Settings object.
- Return type:
-
ignore_warnings:
list
[type
[BaseWarning
]] Subtypes of exc.BaseWarning to ignore when compiling.
-
dot_precision:
Literal
['tf32'
,'tf32x3'
,'ieee'
] Precision for dot products, see triton.language.dot. Can be ‘tf32’, ‘tf32x3’, or ‘ieee’.
-
static_shapes:
bool
If True, use static shapes for all tensors. This is a performance optimization.
-
use_default_config:
bool
For development only, skips all autotuning and uses the default config (which may be slow).
-
autotune_log_level:
int
Log level for autotuning using Python logging levels. Default is logging.INFO. Use 0 to disable all output.
-
autotune_compile_timeout:
int
Timeout for Triton compilation in seconds used for autotuning. Default is 60 seconds.
Overview
Settings control the compilation process and development environment for Helion kernels.
Key Characteristics
Not autotuned: Settings remain constant across all kernel configurations
Meta-compilation: Control the compilation process itself, debugging output, and development features
Environment-driven: Often configured via environment variables
Development-focused: Primarily used for debugging, logging, and development workflow optimization
Settings vs Config
Aspect |
Settings |
Config |
---|---|---|
Purpose |
Control compilation behavior |
Control execution performance |
Autotuning |
❌ Never autotuned |
✅ Automatically optimized |
Examples |
|
|
When to use |
Development, debugging, environment setup |
Performance optimization |
Settings can be configured via:
Environment variables
Keyword arguments to
@helion.kernel
Global defaults via
helion.set_default_settings()
Configuration Examples
Using Environment Variables
env HELION_PRINT_OUTPUT_CODE=1 HELION_USE_DEFAULT_CONFIG=1 my_kernel.py
Using Decorator Arguments
import logging
import helion
import helion.language as hl
@helion.kernel(
use_default_config=True, # Skip autotuning
print_output_code=True, # Debug output
)
def my_kernel(x: torch.Tensor) -> torch.Tensor:
result = torch.zeros_like(x)
for i in hl.grid(x.size(0)):
result[i] = x[i] * 2
return result
Global Configuration
import logging
import helion
# Set global defaults
with helion.set_default_settings(
ignore_warnings=[helion.exc.TensorOperationInWrapper],
autotune_log_level=logging.WARNING
):
# All kernels in this block use these settings
@helion.kernel
def kernel1(x): ...
@helion.kernel
def kernel2(x): ...
Settings Reference
Core Compilation Settings
-
Settings.index_dtype:
dtype
The dtype to use for index variables. Default is torch.int32.
The data type used for index variables in generated code. Default is
torch.int32
.
Autotuning Settings
-
Settings.use_default_config:
bool
For development only, skips all autotuning and uses the default config (which may be slow).
Skip autotuning and use default configuration. Default is
False
. Controlled byHELION_USE_DEFAULT_CONFIG=1
.
-
Settings.force_autotune:
bool
If True, force autotuning even if a config is provided.
Force autotuning even when explicit configs are provided. Default is
False
. Controlled byHELION_FORCE_AUTOTUNE=1
.
-
Settings.autotune_log_level:
int
Log level for autotuning using Python logging levels. Default is logging.INFO. Use 0 to disable all output.
Controls verbosity of autotuning output using Python logging levels:
logging.CRITICAL
: No autotuning outputlogging.WARNING
: Only warnings and errorslogging.INFO
: Standard progress messages (default)logging.DEBUG
: Verbose debugging output
You can also use
0
to completely disable all autotuning output.
Debugging and Development
-
Settings.print_output_code:
bool
If True, print the output code of the kernel to stderr.
Print generated Triton code to stderr. Default is
False
. Controlled byHELION_PRINT_OUTPUT_CODE=1
.
-
Settings.ignore_warnings:
list
[type
[BaseWarning
]] Subtypes of exc.BaseWarning to ignore when compiling.
List of warning types to suppress during compilation. Default is an empty list.
Advanced Optimization
Functions
- helion.set_default_settings(settings)[source]
Set the default settings for the current thread and return a context manager that restores the previous settings upon exit.
- Parameters:
settings (
Settings
) – The Settings object to set as the default.- Returns:
A context manager that restores the previous settings upon exit.
- Return type:
AbstractContextManager[None, None]
See Also
Config - Kernel optimization parameters
Exceptions - Exception handling and debugging
Autotuner Module - Autotuning configuration