| """TaskSpec — everything that varies between kernel-generation tasks. |
| |
| Scaling this lane to ~150 kernels means writing ONLY the parts that are genuinely per-kernel. Everything |
| else (Dockerfile, measure.py, the grader with its anti-cheat, test.sh, task.toml, RUN.md, the precision + |
| faithfulness policy, the grading-transparency section) is generated from these fields by `build.py`. |
| |
| A new task is therefore: a reference implementation, an input generator, a FLOP/byte formula, shape lists, |
| and a few paragraphs of prose. Everything in this file is data; nothing here runs on the GPU. |
| """ |
| from dataclasses import dataclass, field |
|
|
|
|
| @dataclass |
| class TaskSpec: |
| |
| name: str |
| title: str |
| blurb: str |
| keywords: list[str] = field(default_factory=list) |
|
|
| |
| module: str = "" |
| func: str = "" |
| signature: str = "" |
| returns_doc: str = "" |
|
|
| |
| reference_src: str = "" |
| reference_imports: str = "" |
| make_inputs_src: str = "" |
| flops_src: str = "" |
| flops_formula: str = "" |
| |
| |
| |
| |
|
|
| |
| metric: str = "TFLOP/s" |
| compare: str = "tensor" |
| tol: float = 2e-2 |
| tuple_names: tuple = () |
| row_pass: float = 0.98 |
| grader_shapes: list = field(default_factory=list) |
| measure_shapes: list = field(default_factory=list) |
| measure_quick_shapes: list = field(default_factory=list) |
| correct_shapes: list = field(default_factory=list) |
| shape_names: tuple = () |
|
|
| |
| spec_md: str = "" |
| contract_md: str = "" |
| regime_md: str = "" |
| perf_md: str = "" |
| precision_md: str = "" |
| correctness_md: str = "" |
|
|
| |
| base_image: str = "pytorch/pytorch:2.11.0-cuda12.8-cudnn9-devel" |
| pip_extra: str = "einops nvidia-cutlass-dsl" |
| gpus: int = 1 |
| agent_timeout_sec: float = 14400.0 |
| verifier_timeout_sec: float = 1800.0 |
| memory_mb: int = 65536 |
|
|
| def validate(self): |
| assert self.name and self.module and self.func, "name/module/func are required" |
| assert self.compare in ("tensor", "tuple", "rowwise"), self.compare |
| assert self.metric in ("TFLOP/s", "GB/s", "tokens/s"), self.metric |
| assert self.grader_shapes and self.correct_shapes, "shape lists are required" |
| if self.compare == "tuple": |
| assert self.tuple_names, "compare='tuple' needs tuple_names" |
| for s in self.grader_shapes + self.correct_shapes + self.measure_shapes: |
| assert len(s) == len(self.shape_names), f"shape {s} vs names {self.shape_names}" |
| return self |
|
|