Skip to content

Commit bb71ced

Browse files
authored
[Frontend] Print out config when autotune fails (#5117)
Printing out config when autotune fails under `TRITON_PRINT_AUTOTUNING `. This will allow kernel developers to narrow down a problematic config and remove it to unblock themselves. This could also help compiler developers focus on debugging that config.
1 parent 21119e3 commit bb71ced

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

python/triton/runtime/autotuner.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ def _post_hook(kwargs, exception):
131131
def _bench(self, *args, config, **meta):
132132
from ..compiler.errors import CompileTimeAssertionFailure
133133

134+
verbose = os.environ.get("TRITON_PRINT_AUTOTUNING", None) == "1"
135+
if verbose:
136+
print(f"Autotuning kernel {self.base_fn.__name__} with config {config}")
137+
134138
# check for conflicts, i.e. meta-parameters both provided
135139
# as kwargs and by the autotuner
136140
conflicts = meta.keys() & config.kwargs.keys()
@@ -161,7 +165,9 @@ def kernel_call():
161165

162166
try:
163167
return self.do_bench(kernel_call, quantiles=(0.5, 0.2, 0.8))
164-
except (OutOfResources, CompileTimeAssertionFailure, PTXASError):
168+
except (OutOfResources, CompileTimeAssertionFailure, PTXASError) as e:
169+
if verbose:
170+
print(f"Autotuning failed with {e}")
165171
return [float("inf"), float("inf"), float("inf")]
166172

167173
def run(self, *args, **kwargs):

0 commit comments

Comments
 (0)