@@ -80,6 +80,14 @@ def _inject_default_simt_stack_limit(options: Dict[str, object], stack_limit: in
8080 options ["simt_stack_limit" ] = stack_limit
8181
8282
83+ def _format_autotune_timing (timing ) -> str :
84+ """Format the timing returned by the active autotune benchmarker."""
85+ if isinstance (timing , (tuple , list )):
86+ labels = ("p50" , "p20" , "p80" )
87+ return ", " .join (f"{ label } ={ value :.4f} ms" for label , value in zip (labels , timing ))
88+ return f"mean={ timing :.4f} ms"
89+
90+
8391def _get_constexpr_candidates_from_fn (fn ) -> List [str ]:
8492 """
8593 Returns all constexpr parameter names from the kernel function definition.
@@ -2131,6 +2139,7 @@ def benchmark():
21312139 if self .print_autotuning and did_benchmark :
21322140 print (f"Triton autotuning for function { self .base_fn .__name__ } finished after "
21332141 f"{ self .bench_time :.2f} s; best config selected: { self .best_config } ;" )
2142+ self ._print_benchmark_results (self .configs_timings )
21342143
21352144 if did_benchmark and self .auto_profile_dir is not None :
21362145 self ._profile (* args , config = self .best_config , ** kwargs )
@@ -2173,6 +2182,15 @@ def _try_ubtuner(self, *args, config, excp, run_fns, **kwargs):
21732182 if self .print_autotuning :
21742183 print (f"[WARN] encounter exception when try ubtune, Details: { e } " )
21752184
2185+ def _print_benchmark_results (self , timings ) -> None :
2186+ if not self .print_autotuning :
2187+ return
2188+
2189+ print (f"Triton autotuning benchmark results for function { self .base_fn .__name__ } :" )
2190+ for config , timing in timings .items ():
2191+ selected = " [selected]" if config == self .best_config else ""
2192+ print (f" config={ config } ; { _format_autotune_timing (timing )} { selected } " )
2193+
21762194 def _batch_bench (self , * args , configs , ** kwargs ):
21772195 from triton .compiler .errors import CompileTimeAssertionFailure , MLIRCompilationError
21782196 from triton .runtime .errors import OutOfResources
@@ -2607,7 +2625,8 @@ def kernel(x_ptr, x_size, **META):
26072625
26082626 If the environment variable :code:`TRITON_PRINT_AUTOTUNING` is set to
26092627 :code:`"1"`, Triton will print a message to stdout after autotuning each
2610- kernel, including the time spent autotuning and the best configuration.
2628+ kernel, including the benchmark timing for each valid configuration, the
2629+ time spent autotuning, and the best configuration.
26112630
26122631 :param configs: a list of :code:`triton.Config` objects
26132632 :type configs: list[triton.Config]
0 commit comments