Skip to content

Commit 831db9c

Browse files
committed
Throw sys.exit(1) if Helion kernel throws error in main process after autotuning
1 parent 3e098e0 commit 831db9c

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

benchmarks/run.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,22 @@ def _inner() -> Callable[..., Any] | object:
469469
tb_args, unknown_args = tb_parser.parse_known_args(tritonbench_args)
470470

471471
# Use tritonbench's _run function which handles arg processing
472-
_run(tb_args, unknown_args)
472+
result = _run(tb_args, unknown_args)
473+
474+
# Check if any errors occurred during benchmarking
475+
if hasattr(result, "result"):
476+
for _, impl_results in result.result:
477+
for impl_name, metrics in impl_results.items():
478+
# Only sys.exit for Helion kernels.
479+
# If a Helion kernel crashes in main process after autotuning, re-running it in a new process will usually work.
480+
# sys.exit(1) here helps the outside script detect the error and re-run it.
481+
if (
482+
impl_name.startswith("helion")
483+
and hasattr(metrics, "error_msg")
484+
and metrics.error_msg
485+
):
486+
print(f"Error in {impl_name}: {metrics.error_msg}", file=sys.stderr)
487+
sys.exit(1)
473488

474489
# Force garbage collection multiple times to ensure memory is freed
475490
for _ in range(3):

0 commit comments

Comments
 (0)