Settings#
The Settings class controls compilation behavior and debugging options for Helion kernels.
- class helion.Settings(**settings)[source]#
Bases:
_SettingsSettings 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.
- Parameters:
settings (
object) –
- copy(**overrides)[source]#
Copy values and origins, marking supplied structural overrides explicit.
Like dataclasses.replace, ordinary mutable field values are shared. In contrast, dataclasses.replace and Settings(**settings.to_dict()) supply every effective field to the constructor and therefore record every structural value as explicit, even when its value is unchanged.
- property cute_structural_origins: CuteStructuralOrigins#
Immutable origins captured at construction and explicit writes.
- get_cute_structural_policy()[source]#
Snapshot effective booleans without resolving or activating a policy.
- Return type:
CuteStructuralPolicy
- get_rebenchmark_threshold()[source]#
Get the effective rebenchmark threshold. Uses the explicit setting if provided, otherwise falls back to the effort profile default.
- Returns:
The rebenchmark threshold value.
- Return type:
-
backend:
str# Code generation backend. One of ‘triton’ (default), ‘pallas’ (JAX/Pallas), ‘cute’ (CUTLASS CuTe DSL), or ‘metal’ (Apple Metal MSL). Set HELION_BACKEND=<backend> to override.
-
ignore_warnings:
list[type[BaseWarning]]# Subtypes of exc.BaseWarning to ignore when compiling. Set HELION_IGNORE_WARNINGS=WarningA,WarningB (names from helion.exc) to configure via env.
-
index_dtype:
dtype|None# The dtype to use for index variables. Default auto-selects torch.int32 or torch.int64 based on input sizes. Override with HELION_INDEX_DTYPE=<dtype> (or set to ‘auto’).
-
dot_precision:
Literal['tf32','tf32x3','ieee','default','high','highest']# Precision for dot products. For Triton backend, see triton.language.dot (can be ‘tf32’, ‘tf32x3’, ‘ieee’). For JAX/Pallas backend, accepted values emit Pallas default precision on TPU. Unified mappings exist so that any value can be used on any backend.
-
cute_rng_stream:
Literal['auto','word0','philox4']# auto (CuTe default) uses philox4 for explicit hl.rand and preserves other RNG operations. philox4 maps logical offset i to Philox(seed, i // 4)[i % 4], independently of configuration. Set word0 for the previous reproducible stream; other backends default to word0. Explicit philox4 rejects unsupported RNG operations. Override with HELION_CUTE_RNG_STREAM.
- Type:
CuTe RNG policy
-
fast_math:
bool# If True, enable fast math approximations (Helion-level, including the CuTe flash-attention polynomial exp2 packets, and Inductor-level). May reduce numerical precision and change NaN/Inf behavior. Set HELION_FAST_MATH=1 to enable.
-
cute_flash_env_overrides:
dict[str,str]# HELION_CUTE_FLASH_* variables the kernel resolves as if set in the environment. The channel is captured once when the kernel binds (the process environment overlaid with this mapping); later environment changes do not reach the bound kernel.
- Type:
CuTe flash-attention knob channel
-
static_shapes:
bool# If True, use static shapes for all tensors. This is a performance optimization. Set HELION_STATIC_SHAPES=0 to disable.
-
persistent_reserved_sms:
int# Number of streaming multiprocessors to reserve when launching persistent kernels. Set HELION_PERSISTENT_RESERVED_SMS=N (default 0) or pass persistent_reserved_sms=N to helion.kernel.
-
autotune_force_persistent:
bool# If True, restrict pid_type choices to persistent kernels only during config selection. Set HELION_AUTOTUNE_FORCE_PERSISTENT=1 to force persistent kernel autotuning globally.
-
distributed:
bool# Force distributed compilation behavior (persistent-only PID types, signal-pad SM limits, and process-group resolution). Normally auto-detected from symmetric-memory tensor arguments; set this for distributed kernels whose symmetric memory is not passed as a detectable tensor. Set HELION_DISTRIBUTED=1 to force globally.
-
autotune_log_level:
int# Log level for autotuning using Python logging levels. Default is logging.INFO. Use HELION_AUTOTUNE_LOG_LEVEL to override or set 0 to disable output.
-
autotune_log:
str|None# Base filename for autotune logs. Set HELION_AUTOTUNE_LOG=/tmp/run to write /tmp/run.csv and /tmp/run.log with per-config metrics and debug logs.
-
autotune_log_details:
bool# Opt-in (HELION_AUTOTUNE_LOG_DETAILS=1) to write /tmp/run.trace.jsonl with config evaluations, rebenchmarks, selection, exact LLM prompts/responses, and timestamps, plus the cost-model dataset sidecar /tmp/run.meta.jsonl (kernel identity and configs keyed by config_id). Off by default; needs autotune_log.
-
autotune_handoff:
bool# Hand configuration search to a native-source agent automatically. Off by default; enable with HELION_AUTOTUNE_HANDOFF=1. Uses the existing search budget or search completion, then saves validated standalone source beside the autotune logs.
-
autotune_handoff_budget_seconds:
int# Wall-clock budget for the native-source agent session, excluding search and export. Default 1500 seconds; override with HELION_AUTOTUNE_HANDOFF_BUDGET_SECONDS.
-
autotune_compile_timeout:
int# a candidate past it is killed and recorded as failed to compile, and the search goes on. Default is 60 seconds. In-process compiles cannot be interrupted by it; the autotune budget bounds them instead.
- Type:
Timeout in seconds for one autotune precompile subprocess (autotune_precompile); a CuTe render worker past it is given up and its config rendered in-process instead (never failed for the timeout alone). Also the benchmark worker’s deadline for a candidate’s compile and first call (the backend JIT; never below autotune_benchmark_timeout, armed once the worker is ready so a fresh worker’s start is not the candidate’s; lowered along with the setting by autotune_adaptive_timeout)
-
autotune_benchmark_subprocess:
bool# Run the autotune benchmark phase in a long-lived spawn subprocess so a hung/slow kernel can be killed without losing autotune progress. Enabled by default. Set HELION_AUTOTUNE_BENCHMARK_SUBPROCESS=0 to disable.
-
autotune_benchmark_timeout:
int# Per-config wall-clock timeout in seconds for the subprocess benchmark phase, counted once the candidate’s compile and first call are done (those have autotune_compile_timeout). Only applies when autotune_benchmark_subprocess is enabled. Default 30 seconds, raised automatically on environments with a heavier subprocess cold-start.
-
autotune_worker_start_timeout:
int|None# twice the worker’s compile deadline, at least 120 seconds. Set HELION_AUTOTUNE_WORKER_START_TIMEOUT to override.
- Type:
Seconds a fresh benchmark worker may take to start (the spawned interpreter, its imports and the device initialization) before it is killed and the candidate recorded as a worker failure. The start is never charged to the candidate’s compile deadline (autotune_compile_timeout), which is armed once the worker reports ready. Default None
-
autotune_precompile:
Optional[Literal['spawn','fork']]# ‘fork’, ‘spawn’, or falsy/None to disable. Defaults to ‘fork’ on non-Windows platforms. With a pool a batch of configs is generated, precompiled in parallel, then timed; without one (disabled, or a backend such as CuTe that has no pool) each config is compiled and timed in turn, so results arrive as the batch runs and the autotune budget can stop it between configs. CuTe generates each candidate’s code in forked workers ahead of its turn in ‘fork’ mode (its only mode; ‘spawn’ disables the workers), so the serial part per config is the module load, the DSL JIT at first call and the timing.
- Type:
Autotuner precompile mode
-
autotune_precompile_jobs:
int|None# Maximum concurrent Triton precompile processes, default to cpu count. Also the number of CuTe render workers alive at once, which default to the CPUs this process may run on, divided by the autotuning processes of the host (LOCAL_WORLD_SIZE or the process group size), capped at 32. Does not affect results or the autotune cache key.
-
autotune_random_seed:
int# Seed used for autotuner random number generation. Defaults to HELION_AUTOTUNE_RANDOM_SEED or a time-based seed.
-
autotune_best_of_k:
int# When > 1, run autotuning K times with different random seeds and keep the config with the best benchmark performance. Each trial uses
seed = autotune_random_seed + ifor i in range(K), so two runs with the same base seed produce the same K configs. Cost is K× the autotune wall time. Cache entries are keyed on K, so a K≥2 result will not be overwritten by a later K=1 run and vice versa. Default 1 (current single-trial behavior). Set HELION_AUTOTUNE_BEST_OF_K=N to override.
-
autotune_accuracy_check:
bool# If True, validate candidate configs against the baseline kernel output before accepting them during autotuning. Unless autotune_baseline_fn is set, the baseline is the output of the config the kernel runs by default (a compiler-promoted default when there is one, else the conservative autotuning reference, which is also the fallback when the promoted default fails to compile or run).
-
autotune_rebenchmark_threshold:
float|None# If a config is within threshold*best_perf, re-benchmark it to avoid outliers. Defaults to effort profile value. Set HELION_REBENCHMARK_THRESHOLD to override.
-
autotune_suspicious_rebenchmark_ratio:
float|None# When subprocess benchmarking is enabled, recheck rebenchmark timings below ratio*previous_timing before accepting them. Defaults to 0.9. Set HELION_AUTOTUNE_SUSPICIOUS_REBENCHMARK_RATIO=0 to disable.
-
autotune_search_acf:
list[str]# List of PTXAS Advanced Controls Files (ACFs) to search during autotuning. ACFs are highly specialized configurations for specific hardware and use cases; when autotuning with ACFs, default -O3 is always considered. Empty list disables.
-
autotune_progress_bar:
bool# If True, show progress bar during autotuning. Default is True. Set HELION_AUTOTUNE_PROGRESS_BAR=0 to disable.
-
autotune_max_generations:
int|None# Override the maximum number of generations for Pattern Search and Differential Evolution Search autotuning algorithms with HELION_AUTOTUNE_MAX_GENERATIONS=N or @helion.kernel(autotune_max_generations=N).
-
autotune_budget_seconds:
int|None# once a few configs have been timed and one has succeeded, the measured cost per config decides how many more are attempted and the rest are skipped, never below a CuTe flash surface’s structural coverage rows, so slow-compiling kernels keep time for the search generations. A population that fits its share is evaluated in full. Set with HELION_AUTOTUNE_BUDGET_SECONDS=N or @helion.kernel(autotune_budget_seconds=N). Default None (no budget).
- Type:
Wall-clock budget in seconds for the entire autotune. When the budget is exceeded the search returns the best config found so far. The budget is checked between generations and before each config’s compile (with a precompile pool also before each config’s timing; without one a config is timed right after its compile). Once it is out nothing further is compiled or timed, except that while no config has been measured successfully the search still attempts up to 3 more candidates, so a budget that runs out early returns a config when one of those works; the overrun is bounded by those attempts (and, with a pool, by the precompile wait of the batch in flight). Without a precompile pool the initial population may take at most half of the search phase (the budget minus the time kept for the final selection), counted from the start of each of its batches
-
autotune_ignore_errors:
bool# If True, skip logging and raising autotune errors. Set HELION_AUTOTUNE_IGNORE_ERRORS=1 to enable globally. The one-line summary of the initial population (configs measured, failed, skipped for the budget, and the wall time per config) and the end-of-run failure counts are logged either way.
-
autotune_adaptive_timeout:
bool# CuTe render workers keep the configured autotune_compile_timeout (a worker past it is rendered in-process), and a timeout fitted on one shape’s render times would be shared by every shape of the kernel. The benchmark worker’s compile deadline follows the lowered setting.
- Type:
If True, set the compile timeout threshold to be smaller for Triton compilation,based on a quantile of initial compile times (with a lower bound). Lower bound and quantile are set by the effort profile. Set HELION_AUTOTUNE_ADAPTIVE_TIMEOUT=0 to disable. Applies only to a Triton-style precompile pool
-
pallas_collective_id:
int|None# Optional Pallas collective namespace override. Distributed kernels derive a stable ID automatically; set this only when otherwise identical kernels use incompatible runtime communication groups.
-
pallas_interpret:
bool# If True, run Pallas kernels in interpret mode on CPU (no TPU needed). Defaults to HELION_PALLAS_INTERPRET env var.
-
pallas_topk_recall_target:
float# Recall target for the Pallas approximate top-k lowering. Must be in (0, 1]; use 1.0 when exact top-k results are required. Default 0.99.
-
cute_region_fission:
bool# If True, distribute proven row-independent materialized regions into ordered CuTe launches with independently tuned tile axes. Defaults to HELION_CUTE_REGION_FISSION (False).
-
cute_materialize_transformed_operands:
bool# If True, materialize proven pure reused matrix operands before a CuTe GEMM, with independent producer and consumer tile axes. Input dimensions used by the proof are specialized with normal runtime guards. Defaults to HELION_CUTE_MATERIALIZE_TRANSFORMED_OPERANDS (False).
-
cute_full_slice_matmul_tiling:
bool# If True, give eligible direct full-slice half/BF16 matmuls an explicit, tunable contraction tile loop on CuTe. Defaults to HELION_CUTE_FULL_SLICE_MATMUL_TILING (False).
-
cute_segmented_matmul_tiling:
bool# If True, expose proven offset-delimited independent matrix rows to the CuTe grouped scheduler. Defaults to HELION_CUTE_SEGMENTED_MATMUL_TILING (False).
-
cute_flatten_nested_reductions:
bool# If True, flatten proven FP32 joint jagged/feature reductions and independent fresh-output stores on CuTe. Defaults to HELION_CUTE_FLATTEN_NESTED_REDUCTIONS (False).
-
cute_graph_cse:
bool# If True (the default), merge duplicate reductions and the pure chains between them in the traced device IR before CuTe code generation (one amax/exp/sum per operand for a softmax and a log_softmax of it). Results are bitwise unchanged; set False (HELION_CUTE_GRAPH_CSE=0) to bisect a structural-matcher regression against the traced graph.
-
cute_stage_unaligned_operands:
bool# If True (the default), the CuTe backend copies a static-shape matmul operand whose outer strides are not 16-byte multiples (e.g. odd-sized bf16 rows; a misaligned base offset is not visible to the pass) into a padded row-major buffer on the host before the launch, so the tcgen05 pipeline keeps its TMA producers instead of the scalar shared-memory producers. Set False (HELION_CUTE_STAGE_UNALIGNED_OPERANDS=0) to run such operands in place.
-
cute_flat_edge_tma:
bool# If True (the default), flat one-CTA tcgen05 matmul kernels load partial output tiles and the K tail through TMA (zero-filled past the extents) and store them with predicated vector copies. Set False (HELION_CUTE_FLAT_EDGE_TMA=0) for the scalar shared-memory edge staging those tiles used before.
-
cute_exact_division:
bool# the IEEE round-to-nearest quotient bit for bit, without one div.rn expansion per element. Set False (HELION_CUTE_EXACT_DIVISION=0) to keep the plain per-element division; the config knob cute_exact_div_form picks the form (redo / plain) per kernel. Independent of fast_math, whose fp32 division is approximate.
- Type:
If True (the default), an fp32 division by a loop-invariant scalar (a row sum, a scalar kernel argument) on CuTe hoists the divisor’s correctly rounded reciprocal and admission window out of the element loop and divides with the Markstein sequence, re-running the loop with div.rn when a dividend left the window
-
cute_promote_half_atomic_outputs:
bool# If True, a fresh float16 allocation that the CuTe kernel only ever writes through hl.atomic_add is accumulated in a float32 twin and cast to float16 once on return (one extra elementwise kernel per call). False (the default, HELION_CUTE_PROMOTE_HALF_ATOMIC_OUTPUTS=0) adds into the float16 storage itself, rounding to float16 on every add as the program and the Triton backend do; the vector collective epilogues use native packed half atomics, the scalar half atomic is a compare-and-swap loop on sm_100.
-
triton_do_not_specialize:
bool# If True, pass do_not_specialize for every dynamic size/stride/symbol arg so a single Triton binary handles any value, avoiding Triton-level recompiles when shapes cross 0/1 or alignment boundaries. Disables Triton’s value/alignment specializations and can significantly slow memory-bound kernels (vectorized loads rely on inner stride being specialized to constexpr 1). Only takes effect when static_shapes=False. Set HELION_TRITON_DO_NOT_SPECIALIZE=1 to enable globally.
-
print_repro:
bool# If True, print Helion kernel code, config, and caller code to stderr as a standalone repro script.
-
output_origin_lines:
bool# If True, annotate generated Triton code with source-origin comments. Set HELION_OUTPUT_ORIGIN_LINES=0 to disable.
-
force_autotune:
bool# If True, force autotuning even if a config is provided. The result is still written to the cache so subsequent runs can reuse it. Set HELION_SKIP_CACHE=1 instead to skip both reading and writing the cache.
-
autotune_config_overrides:
dict[str,object]# 4}’.
- Type:
Dictionary of config key/value pairs forced during autotuning. Accepts HELION_AUTOTUNE_CONFIG_OVERRIDES=’{“num_warps”
-
autotune_seed_configs:
Union[Config,dict[str,object],CuteStructuralConfig,Sequence[Config|dict[str,object] |CuteStructuralConfig],None]# A Config or sequence of Configs to seed the autotuner initial population without constraining the search space.
-
disable_autotuner_heuristics:
bool# If True, disable compiler seed generation and promotion. Correctness fact hooks still run so explicit configs normalize safely. User-provided autotune_seed_configs are unaffected. Set HELION_DISABLE_AUTOTUNER_HEURISTICS=1 to disable globally.
-
ref_mode:
RefMode# Reference mode for kernel execution. Can be RefMode.OFF or RefMode.EAGER.
-
autotuner_fn:
AutotunerFunction# Function to create an autotuner. Override by passing a callable to @helion.kernel(…, autotuner_fn=…).
-
autotune_effort:
Literal['none','quick','full']# Autotuning effort preset. One of ‘none’, ‘quick’, ‘full’.
-
autotune_baseline_fn:
Optional[Callable[...,object]]# Custom baseline function for computing baseline output during autotuning. If provided, this function will be called instead of running the default config. Should have the same signature as the kernel function. Pass as @helion.kernel(…, autotune_baseline_fn=my_baseline_fn).
-
autotune_baseline_atol:
float|None# Absolute tolerance for baseline output comparison during autotuning accuracy checks. When unset, defaults to 1e-2 scaled per output tensor by max(1, rms(baseline)) so large-magnitude reductions tolerate accumulation-order noise, or 0.0 for fp8 dtypes under autotune_fp8_accuracy=’bitwise’. Setting an explicit value disables the RMS scaling and is applied exactly; an explicit 0 together with autotune_baseline_rtol=0 compares fp8 outputs bitwise. Pass as @helion.kernel(…, autotune_baseline_atol=1e-3).
-
autotune_baseline_rtol:
float|None# Relative tolerance for baseline output comparison during autotuning accuracy checks. Defaults to 1e-2, or 0.0 for fp8 dtypes under autotune_fp8_accuracy=’bitwise’. Pass as @helion.kernel(…, autotune_baseline_rtol=1e-3). See autotune_baseline_atol for how the absolute-tolerance floor scales when unset.
-
autotune_fp8_accuracy:
Literal['ulp','bitwise']# every element must lie within one fp8 ulp of max(|actual|, |baseline|) plus the atol/rtol tolerances (atol scaled by the baseline RMS as usual), and the one-ulp differences must not be systematically one-directional. This admits the one-bucket flips a kernel that quantizes an intermediate to fp8 (e.g. an online-softmax P) produces when its reduction blocking changes, while still rejecting multi-ulp and biased differences. ‘bitwise’ requires identical bytes whenever every output is fp8 and no explicit tolerance is set (the previous behavior). Explicit zero tolerances (autotune_baseline_atol=0 with autotune_baseline_rtol=0) ask for exact outputs and select ‘bitwise’ whatever this setting says. Set HELION_AUTOTUNE_FP8_ACCURACY=bitwise to override.
- Type:
How autotuning accuracy checks compare fp8 output tensors against the baseline. ‘ulp’ (default) compares dequantized values
-
autotune_baseline_accuracy_check_fn:
Optional[Callable[[object,object],None]]# object, expected: object) -> None. Should raise AssertionError on mismatch. When set, replaces the default torch.testing.assert_close-based check (atol/rtol settings are ignored). Useful for scenarios where a small fraction of elements may have large relative differences, e.g. checking that mismatch percentage < X AND max relative diff < Y. A built-in utility
helion._testing.assert_close_with_mismatch_toleranceis provided for this common pattern; usefunctools.partial(assert_close_with_mismatch_tolerance, ...)to customize thresholds. Pass as @helion.kernel(…, autotune_baseline_accuracy_check_fn=my_check_fn).- Type:
Custom accuracy check function for comparing autotuning candidate outputs against the baseline. Signature
- Type:
(actual
-
autotune_cache:
str# The name of the autotuner cache class to use. Set HELION_AUTOTUNE_CACHE=StrictLocalAutotuneCache to enable strict caching. Set HELION_AUTOTUNE_CACHE=RemoteAutotuneCache (or StrictRemoteAutotuneCache) and HELION_REMOTE_CACHE_BACKEND=mypackage.module.MyBackend to enable remote caching via a user-provided RemoteCacheBackend subclass. Defaults to ‘LocalAutotuneCache’.
-
autotune_benchmark_fn:
Optional[Callable[...,list[float]]]# list[Callable[[], object]], *, repeat: int, desc: str | None = None) -> list[float]. If None (default), uses the built-in benchmark function.
- Type:
Custom benchmark function for rebenchmarking during autotuning. Should have the following signature
- Type:
(fns
-
autotune_best_available_max_configs:
int# Maximum number of cached configs to use for FROM_BEST_AVAILABLE initial population and for helion.from_cache() warm-start in FiniteSearch. Set HELION_BEST_AVAILABLE_MAX_CONFIGS=N to override. Default is 20.
-
autotune_best_available_max_cache_scan:
int# Maximum number of cache files to scan when searching for matching configs in FROM_BEST_AVAILABLE strategy. Set HELION_BEST_AVAILABLE_MAX_CACHE_SCAN=N to override. Default is 500.
-
autotune_initial_population_strategy:
Optional[Literal['from_random','from_best_available']]# ‘from_random’, ‘from_best_available’. When set, takes precedence over the HELION_AUTOTUNER_INITIAL_POPULATION env var and the effort profile default.
- Type:
Override the initial population strategy for autotuning. Valid values
-
torch_compile_fusion:
bool# If True, allow torch.compile to fuse this Helion kernel with surrounding Inductor ops (prologue/epilogue) when used inside torch.compile. Default False. Set HELION_TORCH_COMPILE_FUSION=1 to enable globally.
-
autotune_config_filter:
Optional[Callable[[Config],Config|None]]# Optional callable
(config: Config) -> Config | Nonethat the autotuner calls on every candidate config before compiling or benchmarking it. If the callable returns None, the config is skipped entirely (no compilation, no benchmarking). If it returns a Config (which may be a modified copy of the original), that config is used for benchmarking. Also filters the explicitconfigs=[...]list when one is provided. Pass as @helion.kernel(…, autotune_config_filter=my_filter_fn).
-
autotune_with_torch_compile_fusion:
bool# If True, autotuning benchmarks the fused kernel (with epilogue/prologue) to pick configs optimal for the actual fused workload. Default False. Has no effect unless torch_compile_fusion is also True. Set HELION_AUTOTUNE_WITH_TORCH_COMPILE_FUSION=1 to enable globally.
-
autotune_log_search_space:
bool# If True, log search space analysis after autotuning including which features were enabled/disabled, total search space size, and coverage metrics. Off by default; set HELION_AUTOTUNE_LOG_SEARCH_SPACE=1 to enable.
-
autotune_log_search_space_verbose:
bool# If True, additionally log each search-space restriction (disabled pid_types, tcgen05 narrowing, etc.) live at INFO the moment it is applied during compilation, on top of the end-of-run summary. Implies autotune_log_search_space. Off by default; set HELION_AUTOTUNE_LOG_SEARCH_SPACE_VERBOSE=1 to enable.
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
If both are provided, decorator arguments take precedence.
Note
Helion reads the environment variables for Settings when the
@helion.kernel decorator defines the function (typically at import
time). One can modify Kernel.settings to change settings
for an already defined kernel.
Configuration Examples#
Using Environment Variables#
env HELION_PRINT_OUTPUT_CODE=1 HELION_AUTOTUNE_EFFORT=none my_kernel.py
Using Decorator Arguments#
import logging
import helion
import helion.language as hl
@helion.kernel(
autotune_effort="none", # Skip autotuning
print_output_code=True, # Debug: show generated Triton code
print_repro=True, # Debug: show Helion kernel code, config, and caller code as a standalone repro script
)
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
Settings Reference#
Core Compilation Settings#
-
Settings.index_dtype:
dtype|None# The dtype to use for index variables. Default auto-selects torch.int32 or torch.int64 based on input sizes. Override with HELION_INDEX_DTYPE=<dtype> (or set to ‘auto’).
The data type used for index variables in generated code. By default Helion auto-selects between
torch.int32andtorch.int64based on whether any input tensor exceedstorch.iinfo(torch.int32).maxelements. Override viaHELION_INDEX_DTYPE=<dtype>(or set it toautoto keep the automatic behavior).
-
Settings.dot_precision:
Literal['tf32','tf32x3','ieee','default','high','highest']# Precision for dot products. For Triton backend, see triton.language.dot (can be ‘tf32’, ‘tf32x3’, ‘ieee’). For JAX/Pallas backend, accepted values emit Pallas default precision on TPU. Unified mappings exist so that any value can be used on any backend.
Precision mode for dot product operations. - For Triton backend, this is initialized from the
TRITON_F32_DEFAULTenvironment variable (defaulting to"tf32"). - For Pallas backend, this is initialized from theJAX_DEFAULT_MATMUL_PRECISIONenvironment variable (defaulting to"default").Supported values depend on the backend: - Triton (GPU):
"tf32","tf32x3","ieee"- Pallas (TPU):"default","high","highest"and portable Triton aliases are accepted.However, unified mappings exist so you can use any value on any backend: - On Triton:
"default"maps to"tf32","high"maps to"tf32x3", and"highest"maps to"ieee". - On Pallas/TPU: all values currently emit JAX default precision. JAX"high"/"highest"fp32 dot precision is not used because it is less compatible with PyTorch eager references on the supported TPU stack.
-
Settings.cute_rng_stream:
Literal['auto','word0','philox4']# auto (CuTe default) uses philox4 for explicit hl.rand and preserves other RNG operations. philox4 maps logical offset i to Philox(seed, i // 4)[i % 4], independently of configuration. Set word0 for the previous reproducible stream; other backends default to word0. Explicit philox4 rejects unsupported RNG operations. Override with HELION_CUTE_RNG_STREAM.
- Type:
CuTe RNG policy
CuTe defaults to
"auto". Explicithl.randuses all four Philox outputs: logical offsetiselects wordi % 4from counteri // 4. The stream depends on the seed and logical offset, independently of tile size or packet vectorization. This changes the sequence from the earlier CuTe default.Set
cute_rng_stream="word0"orHELION_CUTE_RNG_STREAM=word0to retain the previous sequence. Other backends still default to"word0". Under"auto", implicit Torch random operations,hl.randintandhl.rand4xretain their existing behavior. Explicit"philox4"selects the same uniform stream but rejects these other RNG operations. The policy is serialized with settings and emitted reproduction decorators.
-
Settings.cute_graph_cse:
bool# If True (the default), merge duplicate reductions and the pure chains between them in the traced device IR before CuTe code generation (one amax/exp/sum per operand for a softmax and a log_softmax of it). Results are bitwise unchanged; set False (HELION_CUTE_GRAPH_CSE=0) to bisect a structural-matcher regression against the traced graph.
CuTe only. When
True(the default) duplicate reductions of the traced device IR, and the pure chains between them, are merged before code generation: asoftmaxand alog_softmaxof one operand share theiramax,expandsumsweeps. Two identical pure operators on the same inputs are bitwise identical, so results never change. Setcute_graph_cse=FalseorHELION_CUTE_GRAPH_CSE=0to keep the graph as traced, which bisects a structural-matcher regression against the pass. The two graphs roll different reduction sweeps, so their configs differ in shape; printed repros record the value in their@helion.kerneldecorator and replay the graph they were emitted from whatever the replay environment.
-
Settings.cute_promote_half_atomic_outputs:
bool# If True, a fresh float16 allocation that the CuTe kernel only ever writes through hl.atomic_add is accumulated in a float32 twin and cast to float16 once on return (one extra elementwise kernel per call). False (the default, HELION_CUTE_PROMOTE_HALF_ATOMIC_OUTPUTS=0) adds into the float16 storage itself, rounding to float16 on every add as the program and the Triton backend do; the vector collective epilogues use native packed half atomics, the scalar half atomic is a compare-and-swap loop on sm_100.
CuTe only.
hl.atomic_addinto a float16 tensor rounds to float16 on every add (the reference semantics, what the Triton backend emits). WhenTruethe CuTe backend instead accumulates a fresh float16 allocation that the kernel only ever writes throughhl.atomic_addin a float32 twin and casts it to float16 once on return: more accurate (one rounding instead of one per add), at the price of one extra elementwise kernel per call (about 1.5 us in a CUDA graph) and results that differ from the other backends.False(the default,HELION_CUTE_PROMOTE_HALF_ATOMIC_OUTPUTS=0) keeps the requested float16 storage; the collective vector epilogues then use native packedf16x2/bf16x2reductions (the scalar half atomic is a compare-and-swap loop on sm_100, so a lane-loop fallback is slow).With the promotion off, a split-K kernel’s rounding depends on the config the autotuner picks: the atomic routes (the collective vector epilogue, and the split-K workspace schedule’s reducer-free epilogue,
cute_split_k_atomic_epilogue) round each K partition’s fp32 partial to float16 as it is added, while the workspace schedule’s reducer form sums the fp32 partials and rounds once; two configs of the same kernel can thus differ by a few float16 ulps on large-K outputs.Truerestores config-independent fp32 accumulation (every route accumulates the fp32 twin and casts once) at the cost of the extra cast kernel.
-
Settings.cute_exact_division:
bool# the IEEE round-to-nearest quotient bit for bit, without one div.rn expansion per element. Set False (HELION_CUTE_EXACT_DIVISION=0) to keep the plain per-element division; the config knob cute_exact_div_form picks the form (redo / plain) per kernel. Independent of fast_math, whose fp32 division is approximate.
- Type:
If True (the default), an fp32 division by a loop-invariant scalar (a row sum, a scalar kernel argument) on CuTe hoists the divisor’s correctly rounded reciprocal and admission window out of the element loop and divides with the Markstein sequence, re-running the loop with div.rn when a dividend left the window
CuTe only. When
True(the default) an fp32 division by a scalar that is invariant across an element loop (a softmax row sum, a kernel-wide temperature) hoists the divisor’s correctly rounded reciprocal and its admission window out of the loop and divides with the Markstein sequence (q = RN(x*y),r = RN(x - d*q),RN(q + r*y)), speculated over the loop: when some dividend left the window the loop runs again as written, withdiv.rn.f32itself. The result is the IEEE round-to-nearest quotient bit for bit (helion/_compiler/cute/exact_division.pystates the argument); setcute_exact_division=FalseorHELION_CUTE_EXACT_DIVISION=0to keep onediv.rnexpansion per element; the config knobcute_exact_div_form("redo","plain") picks the form per kernel, so the autotuner can keep the plain division where a kernel sits at the register cap (the knob is exposed for every kernel whose traced graph divides fp32 by a scalar or a broadcast row value; a loop the redo form cannot re-execute keeps its plain division, and where the pass proves no divisor loop-invariant both forms render identically).fast_mathis unaffected: its fp32 division is the approximatecute.math.div.
-
Settings.static_shapes:
bool# If True, use static shapes for all tensors. This is a performance optimization. Set HELION_STATIC_SHAPES=0 to disable.
When enabled, tensor shapes are treated as compile-time constants for optimization. Default is
True. SetHELION_STATIC_SHAPES=0the default if you need a compiled kernel instance to serve many shape variants.
-
Settings.fast_math:
bool# If True, enable fast math approximations (Helion-level, including the CuTe flash-attention polynomial exp2 packets, and Inductor-level). May reduce numerical precision and change NaN/Inf behavior. Set HELION_FAST_MATH=1 to enable.
If
True, enable fast math approximations. This activates both Helion-level optimizations (e.g. fast sigmoid, the CuTe flash-attention polynomial exp2 packets) and Inductor-level fast math (flush-to-zero exp, fast online softmax, etc.). May reduce numerical precision and change NaN/Inf behavior. Default isFalse. Controlled byHELION_FAST_MATH=1.
-
Settings.cute_flash_env_overrides:
dict[str,str]# HELION_CUTE_FLASH_* variables the kernel resolves as if set in the environment. The channel is captured once when the kernel binds (the process environment overlaid with this mapping); later environment changes do not reach the bound kernel.
- Type:
CuTe flash-attention knob channel
CuTe flash-attention knob channel: a mapping of
HELION_CUTE_FLASH_*names to values the kernel resolves as if they were set in the environment. The channel is captured once when the kernel binds (the process environment overlaid with this mapping); environment changes made after the bind do not reach the bound kernel. Default is{}.
-
Settings.persistent_reserved_sms:
int# Number of streaming multiprocessors to reserve when launching persistent kernels. Set HELION_PERSISTENT_RESERVED_SMS=N (default 0) or pass persistent_reserved_sms=N to helion.kernel.
Reserve this many streaming multiprocessors when launching persistent kernels. Default is
0(use all SMs). Configure globally withHELION_PERSISTENT_RESERVED_SMSor per-kernel via@helion.kernel(..., persistent_reserved_sms=N).
Autotuning Settings#
-
Settings.force_autotune:
bool# If True, force autotuning even if a config is provided. The result is still written to the cache so subsequent runs can reuse it. Set HELION_SKIP_CACHE=1 instead to skip both reading and writing the cache.
Force autotuning even when explicit configs are provided. Default is
False. Controlled byHELION_FORCE_AUTOTUNE=1. The result is still saved to the cache so subsequent runs can reuse it. UseHELION_SKIP_CACHE=1instead to skip both reading and writing the cache.
-
Settings.autotune_force_persistent:
bool# If True, restrict pid_type choices to persistent kernels only during config selection. Set HELION_AUTOTUNE_FORCE_PERSISTENT=1 to force persistent kernel autotuning globally.
Restrict
pid_typechoices to the persistent strategies ("persistent_blocked"or"persistent_interleaved"). Default isFalse. Enable globally withHELION_AUTOTUNE_FORCE_PERSISTENT=1or per kernel via@helion.kernel(..., autotune_force_persistent=True).
-
Settings.autotune_log_level:
int# Log level for autotuning using Python logging levels. Default is logging.INFO. Use HELION_AUTOTUNE_LOG_LEVEL to override or set 0 to disable 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
0to completely disable all autotuning output. Controlled byHELION_AUTOTUNE_LOG_LEVEL.
-
Settings.autotune_log:
str|None# Base filename for autotune logs. Set HELION_AUTOTUNE_LOG=/tmp/run to write /tmp/run.csv and /tmp/run.log with per-config metrics and debug logs.
When set, Helion writes per-config telemetry (run id, timestamp, config id, generation, status, perf, compile time, config) to
<value>.csvand mirrors the autotune log to<value>.log(for population-based autotuners:PatternSearch,DifferentialEvolution). Both append, so runs sharing one base path accumulate. CSV rows join to.meta.jsonlvia two hashes:run_idfor the invocation — hash(kernel source, shapes, dtypes, hardware, codegen settings) — andconfig_idfor the config. The codegen settings hashed intorun_idare: backend, dot_precision, fast_math, static_shapes, index_dtype, allow_warp_specialize, triton_do_not_specialize, pallas_interpret, debug_dtype_asserts, persistent_reserved_sms (the full settings are recorded in.meta.jsonl). Same config_id across started/ok/error and re-benchmarks. The full config is written inline in the trailingconfigcolumn of the CSV; it is also stored in the.meta.jsonlconfigs map, which is written only whenautotune_log_detailsis enabled (see below). Controlled by HELION_AUTOTUNE_LOG.
-
Settings.autotune_log_details:
bool# Opt-in (HELION_AUTOTUNE_LOG_DETAILS=1) to write /tmp/run.trace.jsonl with config evaluations, rebenchmarks, selection, exact LLM prompts/responses, and timestamps, plus the cost-model dataset sidecar /tmp/run.meta.jsonl (kernel identity and configs keyed by config_id). Off by default; needs autotune_log.
Opt-in to the cost-model dataset sidecar. When enabled (
HELION_AUTOTUNE_LOG_DETAILS=1) andautotune_logis set, Helion appends one JSON record per run to<autotune_log>.meta.jsonl: the kernel identity (run_id, name, source, shapes, dtypes, hardware), the fullhelion.settings(JSON-safe viajson.dumps(default=str), sotorch.dtype/callables become strings), anir_graph(see below), and aconfigsmap fromconfig_idto the config tested.ir_graphis a config-independent, node-link dump of the kernel’s device IR (the per-tile computation lowered to the Triton kernel body), captured once per run. Load it withnetworkx.node_link_graph(record["ir_graph"], edges="edges")(requiresnetworkx>=3.4). It isnullwhen the device IR is unavailable or extraction fails. Block dimensions stay symbolic in the dump; recover concrete tile sizes by joining with each config’sblock_sizes. Because the device IR is a function ofrun_id’s inputs, every record sharing arun_idcarries an identicalir_graph. Recover a measured(config, perf)sample by joining a CSV row to its record:meta[run_id]["configs"][row["config_id"]].run_idmay recur (re-runs, processes,autotune_best_of_k), but theconfigsmaps are union-safe (sameconfig_idimplies the same config), so de-duplicating onrun_idis lossless. Searches restricted to user-pinnedconfigs(withoutforce_autotune) are excluded as a biased slice (.csv/.logstill written); setting this withoutautotune_logcollects nothing and warns once. Controlled byHELION_AUTOTUNE_LOG_DETAILS.This flag also appends
<autotune_log>.trace.jsonlwith timestamped search stages, config evaluations, rebenchmarks, selection, and exact LLM prompts and responses. Recording is disabled by default; setHELION_AUTOTUNE_LOG=/tmp/runandHELION_AUTOTUNE_LOG_DETAILS=1before importing the kernel. Each trace uses a per-searchrun_id, distinct from the identity used by the CSV and metadata.
-
Settings.autotune_log_search_space:
bool# If True, log search space analysis after autotuning including which features were enabled/disabled, total search space size, and coverage metrics. Off by default; set HELION_AUTOTUNE_LOG_SEARCH_SPACE=1 to enable.
Enable search space analysis logging after autotuning. When enabled, Helion logs:
Search space summary: Total search space size, enabled/disabled features with reasons, shape constraints
Coverage metrics: Configs tested vs. total space, coverage percentage
Feature exploration report: Per-feature statistics showing how many options were tested (e.g., “pid_type: 2/8 options tested (25.0%)”)
Exploration quality: Average and minimum feature coverage, highlighting poorly explored features (<50%)
The total search space size is the exact combinatorial product of every dimension’s cardinality (an arbitrary-precision integer, so for large kernels it can be very large); it is reported as
unknownonly when some dimension’s cardinality cannot be determined.Default is
False. Controlled byHELION_AUTOTUNE_LOG_SEARCH_SPACE(set to1to enable).See Autotuner Module for example output and the
helion.autotuner.search_space_loggermodule for implementation details.
-
Settings.autotune_log_search_space_verbose:
bool# If True, additionally log each search-space restriction (disabled pid_types, tcgen05 narrowing, etc.) live at INFO the moment it is applied during compilation, on top of the end-of-run summary. Implies autotune_log_search_space. Off by default; set HELION_AUTOTUNE_LOG_SEARCH_SPACE_VERBOSE=1 to enable.
Additionally log each individual search-space restriction live (at
INFO) the moment it is applied during kernel compilation, on top of the end-of-run summary. This surfaces why the search space shrank as it happens, for example:Autotuner feature restriction: pid_type='xyz' disabled (data-dependent loop bounds require a persistent kernel ...)Autotuner feature restriction: tcgen05 search narrowed to validated configs (matmul kernel with CuTe tcgen05 backend)
Enabling this implies
autotune_log_search_space(the summary is produced as well). Default isFalse. Controlled byHELION_AUTOTUNE_LOG_SEARCH_SPACE_VERBOSE(set to1to enable).
-
Settings.autotune_log_search_space_path:
str|None# Optional path to save search space analysis JSON. Set HELION_AUTOTUNE_LOG_SEARCH_SPACE_PATH=/path/to/analysis.json to save.
Optional path to save search space analysis as JSON. When set, Helion writes one JSON file per autotuned kernel/shape. The kernel name and the autotuner’s stable cache hash are injected into the filename stem (matching the
.best_configcache key) so distinct kernels/shapes do not overwrite each other:<stem>.<kernel>.<hash>.json: a single report combining the search-space description (dimensions, possible values, constraints, total size) with the exploration outcome (per-dimension observed values and coverage, configs tested, valid/invalid attempts).
For example,
autotune_log_search_space_path="/tmp/analysis.json"yields a file like/tmp/analysis.my_kernel.3f9a1c2e.json. A directory (existing path or trailing separator) is also accepted, in which case the defaultautotune_search_space.jsonfilename is used inside it. Requiresautotune_log_search_spaceto be enabled. Default isNone(only logs to console). Controlled byHELION_AUTOTUNE_LOG_SEARCH_SPACE_PATH.
-
Settings.autotune_compile_timeout:
int# a candidate past it is killed and recorded as failed to compile, and the search goes on. Default is 60 seconds. In-process compiles cannot be interrupted by it; the autotune budget bounds them instead.
- Type:
Timeout in seconds for one autotune precompile subprocess (autotune_precompile); a CuTe render worker past it is given up and its config rendered in-process instead (never failed for the timeout alone). Also the benchmark worker’s deadline for a candidate’s compile and first call (the backend JIT; never below autotune_benchmark_timeout, armed once the worker is ready so a fresh worker’s start is not the candidate’s; lowered along with the setting by autotune_adaptive_timeout)
Timeout in seconds for one precompile subprocess during autotuning, and the benchmark worker’s deadline for a candidate’s compile and first call (never below
autotune_benchmark_timeout; a candidate past it is recorded as failed to compile and the search goes on). The worker’s deadline is armed once the worker is ready, so a fresh worker’s start is not the candidate’s, andautotune_adaptive_timeoutdoes not lower it. Default is60. Controlled byHELION_AUTOTUNE_COMPILE_TIMEOUT.
-
Settings.autotune_worker_start_timeout:
int|None# twice the worker’s compile deadline, at least 120 seconds. Set HELION_AUTOTUNE_WORKER_START_TIMEOUT to override.
- Type:
Seconds a fresh benchmark worker may take to start (the spawned interpreter, its imports and the device initialization) before it is killed and the candidate recorded as a worker failure. The start is never charged to the candidate’s compile deadline (autotune_compile_timeout), which is armed once the worker reports ready. Default None
Seconds a fresh benchmark worker may take to start (the spawned interpreter, its imports and the device initialization) before it is killed and the candidate recorded as a worker failure. Default is
None: twice the worker’s compile deadline, at least120. Controlled byHELION_AUTOTUNE_WORKER_START_TIMEOUT.
-
Settings.autotune_precompile:
Optional[Literal['spawn','fork']]# ‘fork’, ‘spawn’, or falsy/None to disable. Defaults to ‘fork’ on non-Windows platforms. With a pool a batch of configs is generated, precompiled in parallel, then timed; without one (disabled, or a backend such as CuTe that has no pool) each config is compiled and timed in turn, so results arrive as the batch runs and the autotune budget can stop it between configs. CuTe generates each candidate’s code in forked workers ahead of its turn in ‘fork’ mode (its only mode; ‘spawn’ disables the workers), so the serial part per config is the module load, the DSL JIT at first call and the timing.
- Type:
Autotuner precompile mode
Select the autotuner precompile mode, which adds parallelism and checks for errors/timeouts.
"fork"(default) is faster but does not include the error check run,"spawn"runs kernel warm-up in a fresh process including running to check for errors, or None to disables precompile checks altogether. Controlled byHELION_AUTOTUNE_PRECOMPILE.
-
Settings.autotune_random_seed:
int# Seed used for autotuner random number generation. Defaults to HELION_AUTOTUNE_RANDOM_SEED or a time-based seed.
Seed used for autotuner random number generation. Defaults to
HELION_AUTOTUNE_RANDOM_SEEDif set, otherwise a time-based value.
-
Settings.autotune_precompile_jobs:
int|None# Maximum concurrent Triton precompile processes, default to cpu count. Also the number of CuTe render workers alive at once, which default to the CPUs this process may run on, divided by the autotuning processes of the host (LOCAL_WORLD_SIZE or the process group size), capped at 32. Does not affect results or the autotune cache key.
Cap the number of concurrent Triton precompile subprocesses.
None(default) uses the machine CPU count. Controlled byHELION_AUTOTUNE_PRECOMPILE_JOBS. When using"spawn"precompile mode, Helion may automatically lower this cap if free GPU memory is limited.
-
Settings.autotune_max_generations:
int|None# Override the maximum number of generations for Pattern Search and Differential Evolution Search autotuning algorithms with HELION_AUTOTUNE_MAX_GENERATIONS=N or @helion.kernel(autotune_max_generations=N).
Override the default number of generations set for Pattern Search and Differential Evolution Search autotuning algorithms with HELION_AUTOTUNE_MAX_GENERATIONS=N or @helion.kernel(autotune_max_generations=N).
Lower values result in faster autotuning but may find less optimal configurations.
-
Settings.autotune_budget_seconds:
int|None# once a few configs have been timed and one has succeeded, the measured cost per config decides how many more are attempted and the rest are skipped, never below a CuTe flash surface’s structural coverage rows, so slow-compiling kernels keep time for the search generations. A population that fits its share is evaluated in full. Set with HELION_AUTOTUNE_BUDGET_SECONDS=N or @helion.kernel(autotune_budget_seconds=N). Default None (no budget).
- Type:
Wall-clock budget in seconds for the entire autotune. When the budget is exceeded the search returns the best config found so far. The budget is checked between generations and before each config’s compile (with a precompile pool also before each config’s timing; without one a config is timed right after its compile). Once it is out nothing further is compiled or timed, except that while no config has been measured successfully the search still attempts up to 3 more candidates, so a budget that runs out early returns a config when one of those works; the overrun is bounded by those attempts (and, with a pool, by the precompile wait of the batch in flight). Without a precompile pool the initial population may take at most half of the search phase (the budget minus the time kept for the final selection), counted from the start of each of its batches
Wall-clock budget in seconds for autotuning. When the budget is exceeded, Helion returns the best configuration found so far. Controlled by
HELION_AUTOTUNE_BUDGET_SECONDS.
-
Settings.autotune_handoff:
bool# Hand configuration search to a native-source agent automatically. Off by default; enable with HELION_AUTOTUNE_HANDOFF=1. Uses the existing search budget or search completion, then saves validated standalone source beside the autotune logs.
Enable automatic native-source optimization after configuration search with
HELION_AUTOTUNE_HANDOFF=1. Off by default. Uses the existing search budget or search completion, then runs one continuous Codex session and saves standalone kernels beside the autotune logs. Each candidate submission records a round.
-
Settings.autotune_handoff_budget_seconds:
int# Wall-clock budget for the native-source agent session, excluding search and export. Default 1500 seconds; override with HELION_AUTOTUNE_HANDOFF_BUDGET_SECONDS.
Time budget for native-source rounds, excluding search and export. Defaults to 1500 seconds. Controlled by
HELION_AUTOTUNE_HANDOFF_BUDGET_SECONDS.
-
Settings.autotune_ignore_errors:
bool# If True, skip logging and raising autotune errors. Set HELION_AUTOTUNE_IGNORE_ERRORS=1 to enable globally. The one-line summary of the initial population (configs measured, failed, skipped for the budget, and the wall time per config) and the end-of-run failure counts are logged either way.
Continue autotuning even when candidate configurations raise recoverable runtime errors (for example, GPU out-of-memory). Default is
False. Controlled byHELION_AUTOTUNE_IGNORE_ERRORS.
-
Settings.autotune_accuracy_check:
bool# If True, validate candidate configs against the baseline kernel output before accepting them during autotuning. Unless autotune_baseline_fn is set, the baseline is the output of the config the kernel runs by default (a compiler-promoted default when there is one, else the conservative autotuning reference, which is also the fallback when the promoted default fails to compile or run).
Validate each candidate configuration against a baseline output before accepting it. Default is
True. Controlled byHELION_AUTOTUNE_ACCURACY_CHECK.
-
Settings.autotune_baseline_atol:
float|None# Absolute tolerance for baseline output comparison during autotuning accuracy checks. When unset, defaults to 1e-2 scaled per output tensor by max(1, rms(baseline)) so large-magnitude reductions tolerate accumulation-order noise, or 0.0 for fp8 dtypes under autotune_fp8_accuracy=’bitwise’. Setting an explicit value disables the RMS scaling and is applied exactly; an explicit 0 together with autotune_baseline_rtol=0 compares fp8 outputs bitwise. Pass as @helion.kernel(…, autotune_baseline_atol=1e-3).
Absolute tolerance for baseline output comparison during autotune accuracy checks. Default is
1e-2.
-
Settings.autotune_baseline_rtol:
float|None# Relative tolerance for baseline output comparison during autotuning accuracy checks. Defaults to 1e-2, or 0.0 for fp8 dtypes under autotune_fp8_accuracy=’bitwise’. Pass as @helion.kernel(…, autotune_baseline_rtol=1e-3). See autotune_baseline_atol for how the absolute-tolerance floor scales when unset.
Relative tolerance for baseline output comparison during autotune accuracy checks. Default is
1e-2.
-
Settings.autotune_fp8_accuracy:
Literal['ulp','bitwise']# every element must lie within one fp8 ulp of max(|actual|, |baseline|) plus the atol/rtol tolerances (atol scaled by the baseline RMS as usual), and the one-ulp differences must not be systematically one-directional. This admits the one-bucket flips a kernel that quantizes an intermediate to fp8 (e.g. an online-softmax P) produces when its reduction blocking changes, while still rejecting multi-ulp and biased differences. ‘bitwise’ requires identical bytes whenever every output is fp8 and no explicit tolerance is set (the previous behavior). Explicit zero tolerances (autotune_baseline_atol=0 with autotune_baseline_rtol=0) ask for exact outputs and select ‘bitwise’ whatever this setting says. Set HELION_AUTOTUNE_FP8_ACCURACY=bitwise to override.
- Type:
How autotuning accuracy checks compare fp8 output tensors against the baseline. ‘ulp’ (default) compares dequantized values
How autotune accuracy checks compare fp8 output tensors against the baseline.
"ulp"(default) compares dequantized values: each element must lie within one fp8 ulp plus the tolerances, and the one-ulp differences must not be systematically one-directional."bitwise"requires identical bytes whenever every output is fp8 and no explicit tolerance is set. Explicit zero tolerances (autotune_baseline_atol=0withautotune_baseline_rtol=0) select"bitwise"whatever this setting says. Controlled byHELION_AUTOTUNE_FP8_ACCURACY.
-
Settings.autotune_search_acf:
list[str]# List of PTXAS Advanced Controls Files (ACFs) to search during autotuning. ACFs are highly specialized configurations for specific hardware and use cases; when autotuning with ACFs, default -O3 is always considered. Empty list disables.
List of PTXAS config file paths to search during autotuning. Empty list (default) disables the feature. An empty string entry represents not passing a config. Controlled by
HELION_AUTOTUNE_SEARCH_ACF(comma-separated paths).
-
Settings.autotune_rebenchmark_threshold:
float|None# If a config is within threshold*best_perf, re-benchmark it to avoid outliers. Defaults to effort profile value. Set HELION_REBENCHMARK_THRESHOLD to override.
Controls how aggressively Helion re-runs promising configs to avoid outliers. Default is
1.5(re-benchmark anything within 1.5x of the best).
-
Settings.autotune_progress_bar:
bool# If True, show progress bar during autotuning. Default is True. Set HELION_AUTOTUNE_PROGRESS_BAR=0 to disable.
Toggle the interactive progress bar during autotuning. Default is
True. Controlled byHELION_AUTOTUNE_PROGRESS_BAR.
-
Settings.autotune_config_overrides:
dict[str,object]# 4}’.
- Type:
Dictionary of config key/value pairs forced during autotuning. Accepts HELION_AUTOTUNE_CONFIG_OVERRIDES=’{“num_warps”
Dict of config key/value pairs to force during autotuning. Useful for disabling problematic candidates or pinning experimental options. Provide JSON via
HELION_AUTOTUNE_CONFIG_OVERRIDES='{"num_warps": 4}'for global overrides.
-
Settings.autotune_effort:
Literal['none','quick','full']# Autotuning effort preset. One of ‘none’, ‘quick’, ‘full’.
Select the autotuning effort preset. Available values:
"none"– skip autotuning and run the default configuration."quick"– limited search for faster runs with decent performance. Usesfrom_best_availableinitial population strategy (no random padding)."full"– exhaustive autotuning (current default behavior). Usesfrom_randominitial population strategy.
Each preset also sets a default initial population strategy (see Deployment and Autotuning for details). Users can still override individual
autotune_*settings; explicit values win over the preset. Controlled byHELION_AUTOTUNE_EFFORT.
-
Settings.autotune_best_available_max_configs:
int# Maximum number of cached configs to use for FROM_BEST_AVAILABLE initial population and for helion.from_cache() warm-start in FiniteSearch. Set HELION_BEST_AVAILABLE_MAX_CONFIGS=N to override. Default is 20.
Maximum number of cached configs to use when seeding the initial population with the
from_best_availablestrategy. Default is20. Controlled byHELION_BEST_AVAILABLE_MAX_CONFIGS.
-
Settings.autotune_best_available_max_cache_scan:
int# Maximum number of cache files to scan when searching for matching configs in FROM_BEST_AVAILABLE strategy. Set HELION_BEST_AVAILABLE_MAX_CACHE_SCAN=N to override. Default is 500.
Maximum number of cache files to scan when searching for matching configs in the
from_best_availablestrategy. Default is500. Controlled byHELION_BEST_AVAILABLE_MAX_CACHE_SCAN.
Autotuning Cache#
Helion stores the best-performing configs discovered during autotuning in an on-disk cache so subsequent runs can skip the search.
HELION_CACHE_DIR: Override the directory used to store cache entries. Defaults to PyTorch’storch._inductorcache path (typically/tmp/torchinductor_$USER/helion).HELION_SKIP_CACHE: Set to1to skip both reading and writing the autotuning cache. Useful for one-off experiments that should not affect cached state. To re-tune and save the result, useHELION_FORCE_AUTOTUNE=1instead.TRITON_STORE_BINARY_ONLY: During autotuning, Helion sets this Triton environment variable to1by default, skipping storage of intermediate representations (.ttir,.ttgir,.llir, etc.) and keeping only compiled binaries and metadata. This reduces Triton cache disk usage by approximately 40%. To retain IRs for debugging, setTRITON_STORE_BINARY_ONLY=0before running.HELION_KEEP_CACHE: Set to1to keep the backend compile-cache entries for all candidate configs evaluated during autotuning. By default, Helion uses an ephemeral cache directory during autotuning (TRITON_CACHE_DIRfor the Triton backend,CUTE_DSL_CACHE_DIRfor the CuTe backend) and only preserves the winning config’s cache entry, avoiding significant disk bloat. Enable this if you need to inspect the compiled artifacts of non-winning configs for debugging. (HELION_KEEP_TRITON_CACHEis a deprecated alias that still works for the Triton backend.)
See :class:helion.autotuner.LocalAutotuneCache for details on cache keys and behavior.
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.print_repro:
bool# If True, print Helion kernel code, config, and caller code to stderr as a standalone repro script.
Print Helion kernel code, config, and caller code to stderr as a standalone repro script. Default is
False. Controlled byHELION_PRINT_REPRO=1.
-
Settings.output_origin_lines:
bool# If True, annotate generated Triton code with source-origin comments. Set HELION_OUTPUT_ORIGIN_LINES=0 to disable.
Annotate generated Triton code with
# src[<file>:<line>]comments indicating the originating Helion statements. Default isTrue. Controlled byHELION_OUTPUT_ORIGIN_LINES(set to0to disable).
-
Settings.ignore_warnings:
list[type[BaseWarning]]# Subtypes of exc.BaseWarning to ignore when compiling. Set HELION_IGNORE_WARNINGS=WarningA,WarningB (names from helion.exc) to configure via env.
List of warning types to suppress during compilation. Default is an empty list. Accepts comma-separated warning class names from
helion.excviaHELION_IGNORE_WARNINGS(for example,HELION_IGNORE_WARNINGS=TensorOperationInWrapper).
Device Execution Modes#
-
Settings.allow_warp_specialize:
bool# If True, allow warp specialization for tl.range calls on CUDA devices.
Allow warp specialization for
tl.rangecalls. Default isTrue. Controlled byHELION_ALLOW_WARP_SPECIALIZE.
-
Settings.ref_mode:
RefMode# Reference mode for kernel execution. Can be RefMode.OFF or RefMode.EAGER.
Select the reference execution strategy.
RefMode.OFFruns compiled kernels (default);RefMode.EAGERruns the interpreter for debugging. Controlled byHELION_INTERPRET.
Autotuner Hooks#
-
Settings.autotuner_fn:
AutotunerFunction# Function to create an autotuner. Override by passing a callable to @helion.kernel(…, autotuner_fn=…).
Override the callable that constructs autotuner instances. Accepts the same signature as
helion.runtime.settings.default_autotuner_fn(). Pass a replacement callable via@helion.kernel(..., autotuner_fn=...)orhelion.kernel(autotuner_fn=...)at definition time.
-
Settings.autotune_benchmark_fn:
Optional[Callable[...,list[float]]]# list[Callable[[], object]], *, repeat: int, desc: str | None = None) -> list[float]. If None (default), uses the built-in benchmark function.
- Type:
Custom benchmark function for rebenchmarking during autotuning. Should have the following signature
- Type:
(fns
Custom benchmark function for rebenchmarking during autotuning. Should have the signature
(fns: list[Callable[[], object]], *, repeat: int, desc: str | None = None) -> list[float]. IfNone(default), uses the built-in benchmark function. Pass a replacement callable via@helion.kernel(..., autotune_benchmark_fn=...)at definition time.
Built-in values for HELION_AUTOTUNER include "LFBOTreeSearch" (default), "LFBOPatternSearch", "DESurrogateHybrid", "PatternSearch", "DifferentialEvolutionSearch", "FiniteSearch", and "RandomSearch".
Environment Variable Reference#
Environment Variable |
Maps To |
Description |
|---|---|---|
|
|
Sets default floating-point precision for Triton dot products ( |
|
|
Accepts JAX matmul precision values for Pallas dot products ( |
|
|
Choose the index dtype (accepts any |
|
|
Set to |
|
|
Set to |
|
|
Reserve this many streaming multiprocessors when launching persistent kernels ( |
|
|
Force the autotuner to run even when explicit configs are provided. The result is saved to the cache. |
|
|
Restrict |
|
|
Hard-disable autotuning; kernels must supply explicit configs when this is |
|
|
Maximum seconds for one precompile subprocess, and for a candidate’s compile and first call in the benchmark worker (a candidate past it is recorded as failed to compile). |
|
|
Maximum seconds a fresh benchmark worker may take to start before it is killed; the start is never charged to a candidate’s compile deadline. Default: twice the compile deadline, at least |
|
|
Adjust logging verbosity; accepts names like |
|
|
Base filename for per-config CSV telemetry and mirrored autotune logs. |
|
|
Enable cost-model dataset sidecar ( |
|
|
Enable search space analysis logging (default |
|
|
Also log each search-space restriction live at |
|
|
Optional path to save search space analysis JSON files. |
|
|
Select the autotuner precompile mode ( |
|
|
Cap the number of concurrent Triton precompile subprocesses. |
|
|
CuTe RNG policy: |
|
|
Set to |
|
|
Set to |
|
|
Set to |
|
|
Seed used for randomized autotuning searches. |
|
|
Upper bound on generations for Pattern Search and Differential Evolution. |
|
|
Wall-clock budget for an autotune run. |
|
|
Automatically hand configuration search to a native-source agent (default off). |
|
|
Native-source session budget in seconds (default 1500). |
|
(source agent) |
Agent CLI: |
|
(source agent) |
Model override; defaults to |
|
(source agent) |
Reasoning effort supported by the selected CLI; defaults to |
|
|
Toggle baseline validation for candidate configs. |
|
|
Select autotuning preset ( |
|
|
Comma-separated list of PTXAS config file paths to search during autotuning. |
|
(effort profile) |
Override the initial population strategy ( |
|
|
Maximum cached configs to seed when using |
|
|
Maximum cache files to scan when using |
|
|
Re-run configs whose performance is within a multiplier of the current best. |
|
(effort profile |
Rounds of the full-effort final selection, which picks the returned config with harness-grade windows after the search (and after the finishing phase and any backend refinement): a 5 s thermal warmup, one 500+500 ms screen of the retained shortlist when it is longer than the finalists, then the best 8 survivors plus the best seed and the search’s incumbent run 4 rounds of 500+500 ms steady windows in alternating order; the median across rounds decides and a finalist that misses a round cannot win. Where the kernel’s surface names family knobs (knobs whose value picks a distinct kernel body, such as the CuTe flash pipeline family), the best shortlisted config of up to 2 families the ranking would drop, each within 1.25x of the best reading, joins the shortlist and the survivors ( |
|
(effort profile |
The L2 regime the full-effort final selection selects by. The search times candidates in the regime of |
|
|
Enable or disable the progress bar UI during autotuning. |
|
|
Continue autotuning even when recoverable runtime errors occur. |
|
|
Supply JSON forcing particular autotuner config key/value pairs. |
|
Triton (autotuning) |
Set to |
|
|
Override the on-disk directory used for cached autotuning artifacts. |
|
|
When set to |
|
|
When set to |
|
|
Cache class to use ( |
|
(used by |
Fully-qualified class path to a |
|
(benchmarking) |
Wrap |
|
(benchmarking) |
Before the first CUDA graph a benchmark captures, drive the process into its steady graph-dispatch state (16 eager launches on side streams, kept alive; |
|
|
Print generated Triton code to stderr for inspection. |
|
|
Print Helion kernel code, config, and caller code to stderr as a standalone repro script. |
|
|
Include |
|
|
Comma-separated warning names defined in |
|
|
Permit warp-specialized code generation for |
|
|
Inject dtype assertions after each lowering step. |
|
|
Run kernels through the reference interpreter when set to |
|
|
Select which autotuner implementation to instantiate. Default is |
|
|
Code generation backend ( |
See Also#
Config - Kernel optimization parameters
Exceptions - Exception handling and debugging
Autotuner Module - Autotuning configuration