| { |
| "$schema": "https://json-schema.org/draft/2020-12/schema", |
| "$id": "https://huggingface.co/datasets/ZMC2019/KBench/schema/task.schema.json", |
| "title": "KBench task", |
| "description": "A kernel-generation task. DEFINITION (the maths, the graded interface, the correctness policy) is deliberately separate from WORKLOAD (the shapes it is graded at), so one definition can be graded at several workloads -- a synthetic regime sized for measurement, and shapes captured from a real serving or sampling run -- without duplicating the task.", |
| "type": "object", |
| "required": [ |
| "name", |
| "family", |
| "definition", |
| "workloads", |
| "grading" |
| ], |
| "additionalProperties": false, |
| "properties": { |
| "name": { |
| "type": "string", |
| "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$" |
| }, |
| "family": { |
| "type": "string", |
| "description": "Catalog grouping, e.g. 'Quantization & low-precision GEMM'." |
| }, |
| "description": { |
| "type": "string" |
| }, |
| "keywords": { |
| "type": "array", |
| "items": { |
| "type": "string" |
| } |
| }, |
| "difficulty": { |
| "type": "object", |
| "description": "How hard it is to IMPROVE on the best available implementation -- headroom x technique depth. NOT structural complexity: a dense GEMM is a one-liner and near-unbeatable.", |
| "required": [ |
| "tier" |
| ], |
| "properties": { |
| "tier": { |
| "enum": [ |
| "T1", |
| "T2", |
| "T3", |
| "T4" |
| ], |
| "description": "T1 fuse several passes into one. T2 shared-memory tiling, warp reductions, online single-pass reformulation. T3 async copy/TMA, double buffering, warp specialisation, hand-written MMA. T4 out-engineer a vendor kernel already at the hardware limit." |
| }, |
| "rationale": { |
| "type": "string" |
| }, |
| "reviewed_by_hand": { |
| "type": "boolean", |
| "description": "T4 asserts near-unbeatability, so that set is hand-reviewed rather than left to a heuristic." |
| } |
| } |
| }, |
| "definition": { |
| "type": "object", |
| "description": "The maths and the graded interface. Independent of any particular shape.", |
| "required": [ |
| "entry_point", |
| "inputs", |
| "outputs", |
| "reference" |
| ], |
| "additionalProperties": false, |
| "properties": { |
| "entry_point": { |
| "type": "string", |
| "description": "Function the grader imports from the submitted module." |
| }, |
| "module": { |
| "type": "string", |
| "description": "File the agent edits, e.g. 'kda.py'." |
| }, |
| "signature": { |
| "type": "string" |
| }, |
| "inputs": { |
| "type": "array", |
| "items": { |
| "$ref": "#/$defs/tensorSpec" |
| } |
| }, |
| "outputs": { |
| "type": "array", |
| "description": "In return order. For a tuple return this IS the tuple order.", |
| "items": { |
| "$ref": "#/$defs/tensorSpec" |
| } |
| }, |
| "reference": { |
| "type": "object", |
| "description": "The numerical specification: correct, deliberately unfused, and slow. Its speed has no bearing on the score.", |
| "required": [ |
| "language", |
| "source" |
| ], |
| "properties": { |
| "language": { |
| "const": "python/pytorch" |
| }, |
| "source": { |
| "type": "string" |
| } |
| } |
| }, |
| "read_only_inputs": { |
| "type": "boolean", |
| "default": true |
| }, |
| "in_place_outputs": { |
| "type": "array", |
| "items": { |
| "type": "string" |
| }, |
| "description": "Names of inputs mutated in place (e.g. a KV cache appended to)." |
| } |
| } |
| }, |
| "workloads": { |
| "type": "object", |
| "description": "Named shape sets. 'synthetic' is sized so the kernel dominates rather than launch overhead; a 'captured' workload holds shapes recorded from a real run.", |
| "minProperties": 1, |
| "additionalProperties": { |
| "$ref": "#/$defs/workload" |
| } |
| }, |
| "grading": { |
| "type": "object", |
| "required": [ |
| "metric", |
| "reward", |
| "tolerance" |
| ], |
| "additionalProperties": false, |
| "properties": { |
| "metric": { |
| "enum": [ |
| "TFLOP/s", |
| "GB/s", |
| "tokens/s", |
| "barriers/s", |
| "instructions/s", |
| "verified-positions/s" |
| ] |
| }, |
| "reward": { |
| "type": "object", |
| "properties": { |
| "kind": { |
| "const": "absolute-uncapped", |
| "description": "reward = achieved metric, 0 if incorrect. Absolute rather than a speedup versus a baseline, so it is hardware-portable and there is no oracle to re-benchmark." |
| }, |
| "canonical_work": { |
| "type": "string", |
| "description": "Work attributed to the kernel, from SHAPE ALONE -- never from the data, so every submission is credited identically." |
| } |
| } |
| }, |
| "tolerance": { |
| "type": "object", |
| "required": [ |
| "value", |
| "comparator" |
| ], |
| "properties": { |
| "value": { |
| "type": "number", |
| "minimum": 0 |
| }, |
| "comparator": { |
| "enum": [ |
| "relative-frobenius", |
| "relative-frobenius-tuple-max", |
| "rowwise", |
| "exact" |
| ] |
| }, |
| "row_pass": { |
| "type": "number", |
| "description": "For 'rowwise': fraction of rows that must pass." |
| }, |
| "measured_floor_E": { |
| "type": "number", |
| "description": "Relative error between the reference and an INDEPENDENT correct implementation. The tolerance must sit above this or it rejects correct kernels." |
| }, |
| "measured_drop_D": { |
| "type": "number", |
| "description": "Relative error of a variant that ignores the task's distinguishing feature. The tolerance must sit far below this or the feature is not graded." |
| }, |
| "basis": { |
| "type": "string", |
| "description": "How E and D were measured." |
| } |
| } |
| }, |
| "extra_gates": { |
| "type": "array", |
| "description": "Additional measured gates, e.g. the megakernel family's kernels-per-step and dominant-share.", |
| "items": { |
| "type": "object", |
| "properties": { |
| "name": { |
| "type": "string" |
| }, |
| "limit": { |
| "type": "number" |
| }, |
| "direction": { |
| "enum": [ |
| "max", |
| "min" |
| ] |
| }, |
| "rationale": { |
| "type": "string" |
| } |
| } |
| } |
| } |
| } |
| }, |
| "environment": { |
| "type": "object", |
| "properties": { |
| "base_image": { |
| "type": "string" |
| }, |
| "gpus": { |
| "type": "integer", |
| "minimum": 1 |
| }, |
| "min_compute_capability": { |
| "type": "string", |
| "default": "9.0" |
| }, |
| "offline": { |
| "type": "boolean", |
| "default": true |
| }, |
| "note": { |
| "type": "string", |
| "description": "The exact GPU is deliberately NOT specified; tasks tell the agent to query the device." |
| } |
| } |
| } |
| }, |
| "$defs": { |
| "tensorSpec": { |
| "type": "object", |
| "required": [ |
| "name", |
| "shape", |
| "dtype" |
| ], |
| "additionalProperties": false, |
| "properties": { |
| "name": { |
| "type": "string" |
| }, |
| "shape": { |
| "type": "array", |
| "description": "Symbolic dims are names bound by the workload, e.g. ['B','T','H','D'].", |
| "items": { |
| "type": [ |
| "string", |
| "integer" |
| ] |
| } |
| }, |
| "dtype": { |
| "type": "string", |
| "enum": [ |
| "bfloat16", |
| "float16", |
| "float32", |
| "float64", |
| "float8_e4m3fn", |
| "float8_e5m2", |
| "int8", |
| "uint8", |
| "int32", |
| "int64", |
| "bool" |
| ] |
| }, |
| "meaning": { |
| "type": "string" |
| }, |
| "layout": { |
| "type": "string" |
| }, |
| "quantized": { |
| "type": "object", |
| "description": "Pre-quantised input. The reference MUST dequantise these exact bytes -- charging the agent for quantisation error inflates the apparent error by ~10x.", |
| "properties": { |
| "format": { |
| "type": "string" |
| }, |
| "scale_granularity": { |
| "enum": [ |
| "per-tensor", |
| "per-row", |
| "per-block", |
| "per-channel" |
| ], |
| "description": "Per-tensor scales must be exactly representable: their rounding error multiplies the whole output coherently instead of averaging out." |
| }, |
| "block_size": { |
| "type": "integer" |
| } |
| } |
| } |
| } |
| }, |
| "workload": { |
| "type": "object", |
| "required": [ |
| "dims", |
| "graded", |
| "correctness" |
| ], |
| "additionalProperties": false, |
| "properties": { |
| "source": { |
| "enum": [ |
| "synthetic", |
| "captured" |
| ], |
| "default": "synthetic" |
| }, |
| "provenance": { |
| "type": "string", |
| "description": "For 'captured': what run these shapes came from." |
| }, |
| "dims": { |
| "type": "array", |
| "items": { |
| "type": "string" |
| }, |
| "description": "Names of the symbolic dims, in the order the shape tuples list them." |
| }, |
| "graded": { |
| "type": "array", |
| "items": { |
| "$ref": "#/$defs/shape" |
| }, |
| "description": "Timed shapes. Sized so the roofline exceeds 250 us and the kernel dominates." |
| }, |
| "correctness": { |
| "type": "array", |
| "items": { |
| "$ref": "#/$defs/shape" |
| }, |
| "description": "Small shapes run many times; include ragged cases so tails are exercised." |
| }, |
| "measure": { |
| "type": "array", |
| "items": { |
| "$ref": "#/$defs/shape" |
| }, |
| "description": "Shapes for the agent's own self-assessment tool." |
| }, |
| "roofline_us": { |
| "type": "number", |
| "description": "Implied runtime of a perfect kernel at the largest graded shape." |
| } |
| } |
| }, |
| "shape": { |
| "type": "array", |
| "items": { |
| "type": [ |
| "integer", |
| "boolean", |
| "array", |
| "number" |
| ] |
| }, |
| "description": "Dim values in the order given by the workload's `dims`. May include config flags (e.g. a causal bool) or nested lists (e.g. per-group counts for a variable-M GEMM)." |
| } |
| } |
| } |
|
|