Datasets:
File size: 2,404 Bytes
5d12def | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | """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())
|