Skip to content

[CI][Benchmarks] Fix exit on benchmark failure #19290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions devops/scripts/benchmarks/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,22 @@ def run_iterations(
print(f"running {benchmark.name()}, iteration {iter}... ", flush=True)
bench_results = benchmark.run(env_vars)
if bench_results is None:
failures[benchmark.name()] = "benchmark produced no results!"
break
if options.exit_on_failure:
raise RuntimeError(f"Benchmark {benchmark.name()} produced no results!")
else:
failures[benchmark.name()] = "benchmark produced no results!"
break

for bench_result in bench_results:
if not bench_result.passed:
failures[bench_result.label] = "verification failed"
print(f"complete ({bench_result.label}: verification failed).")
continue
if options.exit_on_failure:
raise RuntimeError(
f"Benchmark {benchmark.name()} failed: {bench_result.label} verification failed."
)
else:
failures[bench_result.label] = "verification failed"
print(f"complete ({bench_result.label}: verification failed).")
continue

print(
f"{benchmark.name()} complete ({bench_result.label}: {bench_result.value:.3f} {bench_result.unit})."
Expand Down Expand Up @@ -220,7 +228,6 @@ def main(directory, additional_env_vars, save_name, compare_names, filter):
benchmark.setup()
if options.verbose:
print(f"{benchmark.name()} setup complete.")

except Exception as e:
if options.exit_on_failure:
raise e
Expand Down Expand Up @@ -405,7 +412,9 @@ def validate_and_parse_env_args(env_args):
"--verbose", help="Print output of all the commands.", action="store_true"
)
parser.add_argument(
"--exit-on-failure", help="Exit on first failure.", action="store_true"
"--exit-on-failure",
help="Exit on first benchmark failure.",
action="store_true",
)
parser.add_argument(
"--compare-type",
Expand Down
1 change: 1 addition & 0 deletions devops/scripts/benchmarks/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class Options:
current_run_name: str = "This PR"
preset: str = "Full"
build_jobs: int = multiprocessing.cpu_count()
exit_on_failure: bool = False

# Options intended for CI:
regression_threshold: float = 0.05
Expand Down