"""List the released tasks or run one frozen task pack with its normal GPU grader.""" import argparse import json from pathlib import Path import subprocess import tempfile ROOT = Path(__file__).resolve().parent KB = ROOT / "kernel_bench" PACKS = KB / "taskpacks/v0.8.1-kernels" def main(): catalog = json.loads((KB / "kernel_catalog_v081.json").read_text())["tasks"] tasks = {row["id"]: row for row in catalog} parser = argparse.ArgumentParser(description=__doc__) commands = parser.add_subparsers(dest="command", required=True) commands.add_parser("list") for command in ("smoke", "run"): run = commands.add_parser(command) run.add_argument("task", choices=sorted(tasks)) run.add_argument("--device", help="GPU index, or comma-separated indices for EP=8") run.add_argument("--out", type=Path, required=True) run.add_argument("--candidate", type=Path, required=(command == "run")) run.add_argument("--timeout", type=int, default=600) args = parser.parse_args() if args.command == "list": for task, row in tasks.items(): hardware = "8xB200" if task == "shared_mega_moe" else "1xH100" print(f"{row['group']} {hardware:8} {task}") return 0 device = args.device or ("0,1,2,3,4,5,6,7" if args.task == "shared_mega_moe" else "0") candidate = args.candidate if candidate is None: if args.task in ("csa2_reindex_reuse", "shared_mega_moe"): candidate = KB / "candidates" / args.task / "control.py" else: candidate = KB / "submissions/public_control.py" suite = PACKS / args.task / "public_cases.json" with tempfile.TemporaryDirectory() as tmp: if args.command == "smoke": data = json.loads((KB / "suites/kernel_v081_smoke.json").read_text()) data["cases"] = [c for c in data["cases"] if c["task"] == args.task] suite = Path(tmp) / "smoke.json" suite.write_text(json.dumps(data)) return subprocess.call([str(ROOT / "python-gpu"), "-m", "kernel_bench", "run", "--suite", str(suite), "--candidate", str(candidate.resolve()), "--device", device, "--out", str(args.out.resolve()), "--timeout", str(args.timeout)]) if __name__ == "__main__": raise SystemExit(main())