Write all staging files and run eval_driver.py in a subprocess. Args: tmp_path: Temporary directory to use as the staging directory. kernel_code: Python source to write to kernel.py. bench_config: BenchmarkConfig overrides to write to config.json. Defaults to
(
tmp_path: Path,
kernel_code: str,
bench_config: Optional[dict] = None,
extra_env: Optional[dict] = None,
definition: Optional[dict] = None,
)
| 103 | |
| 104 | |
| 105 | def _run_eval_driver( |
| 106 | tmp_path: Path, |
| 107 | kernel_code: str, |
| 108 | bench_config: Optional[dict] = None, |
| 109 | extra_env: Optional[dict] = None, |
| 110 | definition: Optional[dict] = None, |
| 111 | ) -> list[dict]: |
| 112 | """Write all staging files and run eval_driver.py in a subprocess. |
| 113 | |
| 114 | Args: |
| 115 | tmp_path: Temporary directory to use as the staging directory. |
| 116 | kernel_code: Python source to write to kernel.py. |
| 117 | bench_config: BenchmarkConfig overrides to write to config.json. |
| 118 | Defaults to ``{"lock_clocks": False}`` to suppress nvidia-smi |
| 119 | warnings on machines where clock locking is not available. |
| 120 | extra_env: Additional environment variables for the subprocess. |
| 121 | definition: Problem definition dict. Defaults to ``_MINIMAL_DEFINITION``. |
| 122 | |
| 123 | Returns: |
| 124 | List of Trace dicts parsed from the driver's stdout. |
| 125 | """ |
| 126 | (tmp_path / "eval_driver.py").write_text(build_driver()) |
| 127 | (tmp_path / "definition.json").write_text( |
| 128 | json.dumps(definition if definition is not None else _MINIMAL_DEFINITION) |
| 129 | ) |
| 130 | (tmp_path / "workload.jsonl").write_text(json.dumps(_MINIMAL_WORKLOAD)) |
| 131 | (tmp_path / "solution.json").write_text(json.dumps(_SOLUTION_SPEC)) |
| 132 | (tmp_path / "kernel.py").write_text(kernel_code) |
| 133 | |
| 134 | # Default config: disable clock-locking (no nvidia-smi). |
| 135 | cfg = ( |
| 136 | bench_config |
| 137 | if bench_config is not None |
| 138 | else { |
| 139 | "lock_clocks": False, |
| 140 | } |
| 141 | ) |
| 142 | (tmp_path / "config.json").write_text(json.dumps(cfg)) |
| 143 | |
| 144 | env = {**os.environ, "SOL_EXECBENCH_CLOCKS_LOCKED": "0"} |
| 145 | if extra_env: |
| 146 | env.update(extra_env) |
| 147 | |
| 148 | result = subprocess.run( |
| 149 | [sys.executable, "eval_driver.py"], |
| 150 | cwd=tmp_path, |
| 151 | env=env, |
| 152 | capture_output=True, |
| 153 | text=True, |
| 154 | timeout=60, |
| 155 | ) |
| 156 | return parse_eval_result(result.stdout, result.stderr) |
| 157 | |
| 158 | |
| 159 | # --------------------------------------------------------------------------- |
no test coverage detected