Skip to content

Commit eaacd26

Browse files
wychifacebook-github-bot
authored andcommitted
Route benchmark subprocess through the PAR bootstrap
Summary: The kernel benchmark subprocess in `benchmark.py` launched the child as bare `sys.executable`. Inside a Buck PAR `sys.executable` is the static-linked `#native-main#` interpreter; re-exec'ing it directly leaves it un-bootstrapped (no `LD_LIBRARY_PATH`/`PYTHONPATH`/`LD_PRELOAD` from the PAR `_bootstrap.sh`), so the benchmark child fails to load bundled shared libraries (e.g. `libevict-thrift-py3-extensions.so`). Every candidate then benchmarks as `inf` and `opt_manager` reports "did not produce an improved kernel". KA already ships the bootstrap hook: `setup_internal_environment()` sets `KERNEL_PROFILER_PYTHON` to the PAR `_bootstrap.sh` (which rebuilds the env from `$0` before exec-ing the native main), but only `ncu_profiler.py` honored it. Route the benchmark child through the same hook, falling back to `sys.executable` when unset (OSS / non-PAR). Differential Revision: D107483498
1 parent 6c32826 commit eaacd26

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

  • triton_kernel_agent/opt_worker_component/benchmarking

triton_kernel_agent/opt_worker_component/benchmarking/benchmark.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import json
2222
import logging
23+
import os
2324
import subprocess
2425
import sys
2526
import traceback
@@ -129,8 +130,12 @@ def benchmark_kernel(
129130
results_json = self.artifacts_dir / "benchmark_results.json"
130131
benchmark_script = Path(__file__).parent / "kernel_subprocess.py"
131132

133+
# Use KERNEL_PROFILER_PYTHON (the PAR bootstrap) when set, like
134+
# ncu_profiler.py; bare sys.executable is un-bootstrapped in a PAR.
135+
bench_python = os.environ.get("KERNEL_PROFILER_PYTHON") or sys.executable
136+
132137
cmd = [
133-
sys.executable,
138+
bench_python,
134139
str(benchmark_script),
135140
"--problem",
136141
str(problem_file),

0 commit comments

Comments
 (0)