guychuk commited on
Commit
d1f1ebf
·
verified ·
1 Parent(s): 7f095f2

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +114 -101
README.md CHANGED
@@ -1,104 +1,117 @@
1
  ---
2
- dataset_info:
3
- - config_name: kernel_commits
4
- features:
5
- - name: repo
6
- dtype: string
7
- - name: commit
8
- dtype: string
9
- - name: date
10
- dtype: string
11
- - name: pr_number
12
- dtype: int64
13
- - name: pr_url
14
- dtype: string
15
- - name: title
16
- dtype: string
17
- - name: message
18
- dtype: string
19
- - name: path
20
- dtype: string
21
- - name: language
22
- dtype: string
23
- - name: before_code
24
- dtype: string
25
- - name: after_code
26
- dtype: string
27
- - name: diff
28
- dtype: string
29
- - name: lines_added
30
- dtype: int64
31
- - name: lines_removed
32
- dtype: int64
33
- - name: files_in_commit
34
- dtype: int64
35
- - name: models_mentioned
36
- list: string
37
- - name: hardware_mentioned
38
- list: string
39
- - name: speedup_claims
40
- list: string
41
- splits:
42
- - name: train
43
- num_bytes: 89931604
44
- num_examples: 1376
45
- - name: test
46
- num_bytes: 12592140
47
- num_examples: 153
48
- download_size: 31563045
49
- dataset_size: 102523744
50
- - config_name: tuned_configs
51
- features:
52
- - name: repo
53
- dtype: string
54
- - name: commit
55
- dtype: string
56
- - name: config_path
57
- dtype: string
58
- - name: kernel_file
59
- dtype: string
60
- - name: kernel_name
61
- dtype: string
62
- - name: kernel_source
63
- dtype: string
64
- - name: device_name
65
- dtype: string
66
- - name: dtype
67
- dtype: string
68
- - name: block_shape
69
- dtype: string
70
- - name: triton_version
71
- dtype: string
72
- - name: shape
73
- dtype: string
74
- - name: M
75
- dtype: int64
76
- - name: candidate_models
77
- list: string
78
- - name: best_config
79
- dtype: string
80
- - name: prompt
81
- dtype: string
82
- splits:
83
- - name: train
84
- num_bytes: 386513390
85
- num_examples: 17561
86
- - name: test
87
- num_bytes: 33347832
88
- num_examples: 1726
89
- download_size: 26750592
90
- dataset_size: 419861222
91
  configs:
92
- - config_name: kernel_commits
93
- data_files:
94
- - split: train
95
- path: kernel_commits/train-*
96
- - split: test
97
- path: kernel_commits/test-*
98
- - config_name: tuned_configs
99
- data_files:
100
- - split: train
101
- path: tuned_configs/train-*
102
- - split: test
103
- path: tuned_configs/test-*
104
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ license: apache-2.0
3
+ language: [en, code]
4
+ pretty_name: Kernel-Opt RL (vLLM / SGLang / FlashInfer)
5
+ size_categories: [10K<n<100K]
6
+ task_categories: [text-generation]
7
+ tags: [cuda, triton, gpu-kernels, kernel-optimization, reinforcement-learning, autotuning, vllm, sglang, flashinfer]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  configs:
9
+ - config_name: tuned_configs
10
+ data_files:
11
+ - {split: train, path: tuned_configs/train-*}
12
+ - {split: test, path: tuned_configs/test-*}
13
+ - config_name: kernel_commits
14
+ data_files:
15
+ - {split: train, path: kernel_commits/train-*}
16
+ - {split: test, path: kernel_commits/test-*}
 
 
 
 
17
  ---
18
+
19
+ # Kernel-Opt RL
20
+
21
+ Real-world GPU kernel optimization data mined from production LLM inference engines
22
+ ([vLLM](https://github.com/vllm-project/vllm), [SGLang](https://github.com/sgl-project/sglang),
23
+ [FlashInfer](https://github.com/flashinfer-ai/flashinfer)). It's built for RL: given a base kernel and a
24
+ concrete deployment (model shape, GPU, dtype, batch size), choose the optimization.
25
+
26
+ Inference engines ship one generic kernel and specialize it per model and per GPU. Most of that
27
+ specialization is not new code. It is **autotuned launch parameters** checked in as JSON
28
+ (`E=8,N=14336,device_name=NVIDIA_H100_80GB_HBM3.json`), plus a stream of **perf commits** that rewrite
29
+ kernels for specific models and hardware. This dataset turns both into training signal.
30
+
31
+ ## Subsets
32
+
33
+ ### `tuned_configs`: kernel + deployment → best launch config (verifiable)
34
+
35
+ | | |
36
+ |---|---|
37
+ | rows | 19,287 (17,561 train / 1,726 test) |
38
+ | tuned config files | 1,138 |
39
+ | GPUs | 48 (NVIDIA A100 → B300/GB300, AMD MI300X/MI325X/MI355X, Intel Arc, …) |
40
+ | kernels | `fused_moe_kernel` (vLLM + SGLang), `fused_moe_kernel_gptq_awq`, `_w8a8_triton_block_scaled_mm`, `_w8a8_block_fp8_matmul`, `_w8a8_block_int8_matmul`, `_selective_scan_update_kernel` |
41
+ | dtypes | bf16/fp16, fp8_w8a8 (per-tensor + 128×128 block), int8_w8a8, int8_w8a16, int4_w4a16 |
42
+ | M (tokens) | 1 … 262,144 |
43
+
44
+ One row is one (config file, batch size M) entry. `prompt` is ready to use: it contains the Triton kernel
45
+ source, the hardware, the problem shape, and the MoE models whose shape matches under TP/EP
46
+ (`candidate_models`, resolved against 32 MoE model configs on the Hub). `best_config` is the
47
+ autotuned answer (`BLOCK_SIZE_M/N/K`, `GROUP_SIZE_M`, `num_warps`, `num_stages`, …).
48
+
49
+ Fields: `repo, commit, config_path, kernel_file, kernel_name, kernel_source, device_name, dtype,
50
+ block_shape, triton_version, shape (JSON), M, candidate_models, best_config (JSON), prompt`.
51
+
52
+ **Split:** grouped by config filename (hash), so a given (shape, GPU, dtype) never appears in both
53
+ train and test, whatever the repo, Triton version or M.
54
+
55
+ ### `kernel_commits`: before → after kernel rewrites from perf commits
56
+
57
+ | | |
58
+ |---|---|
59
+ | rows | 1,529 file-level pairs (1,376 train / 153 test) from 873 commits |
60
+ | languages | CUDA (`.cu/.cuh`), C++, Triton, CuTe DSL |
61
+ | date range | 2023-04 → 2026-10 |
62
+
63
+ Selected from non-merge commits that touch kernel directories and carry a performance signal in the
64
+ title (`[Perf]`, optimize, speedup, faster, tune, throughput, latency, …), excluding build, CI, docs,
65
+ tests and reverts. Only modified kernel files are kept: ≤10 per commit, ≤120 KB per file, ≤800 changed
66
+ lines. Each row is tagged with the `models_mentioned` (DeepSeek, Qwen, Kimi, Mamba, GLM, …), the
67
+ `hardware_mentioned` (SM90/SM100/SM120, B200, H100, MI355X, CPU, …), and the `speedup_claims` parsed
68
+ from the message.
69
+
70
+ Fields: `repo, commit, date, pr_number, pr_url, title, message, path, language, before_code,
71
+ after_code, diff, lines_added, lines_removed, files_in_commit, models_mentioned,
72
+ hardware_mentioned, speedup_claims`.
73
+
74
+ **Split:** temporal. The newest ~10% of rows are test (2026-10-18 onward), the code least likely to be in
75
+ a model's pretraining data.
76
+
77
+ ## Using it for RL
78
+
79
+ **`tuned_configs`** gives a verifiable reward without any execution harness:
80
+ - *offline proxy*: score the predicted config against `best_config`. Exact match is sparse, so partial
81
+ credit per parameter (or log-distance on the power-of-two tile sizes) works better.
82
+ - *on hardware*: launch `kernel_source` with the predicted config at the given shape and reward
83
+ `t_best / t_pred`. Note that the tuned config is only the best among the tuner's search space, so a
84
+ model can beat it.
85
+
86
+ **`kernel_commits`** suits:
87
+ - *edit-style RL / SFT warm start*: `before_code` + `title` (+ model/hardware context) → `after_code`;
88
+ - *preference pairs*: (`before_code`, `after_code`) as (rejected, chosen) for the stated workload;
89
+ - *execution reward*: compile, check correctness and benchmark through an execution environment such as
90
+ [KernelGYM](https://github.com/hkust-nlp/KernelGYM). Watch for reward hacking (timer exploits, cached
91
+ outputs; see the [CUDA-L1](https://github.com/ornith-ai/CUDA-L1) notes).
92
+
93
+ ```python
94
+ from datasets import load_dataset
95
+ ds = load_dataset("guychuk/kernel-opt-rl", "tuned_configs", split="train")
96
+ print(ds[0]["prompt"]); print(ds[0]["best_config"])
97
+ ```
98
+
99
+ ## Limitations
100
+
101
+ - Tuned configs record only the *winner*, not the full latency table, so offline rewards are a proxy.
102
+ - `candidate_models` comes from shape matching (`E == experts`, `N == intermediate / TP`, or
103
+ `E == experts / EP`). Shapes are shared across models, e.g. DeepSeek-V3, Kimi-K2 and MiMo-V2-Flash.
104
+ - Commit messages from squash merges often omit the PR body, so `speedup_claims` is sparse. The
105
+ `pr_url` points to the full benchmark discussion.
106
+ - Snapshots are from each repo's HEAD at build time (see `commit`). Rebuild with `build.py` for fresher data.
107
+
108
+ ## Related datasets
109
+
110
+ [KernelBench](https://huggingface.co/datasets/ScalingIntelligence/KernelBench) (eval; keep held out),
111
+ [KernelBook](https://huggingface.co/datasets/GPUMODE/KernelBook) (PyTorch→Triton pairs),
112
+ [Nemotron-SFT-CUDA-v1](https://huggingface.co/datasets/nvidia/Nemotron-SFT-CUDA-v1) (CUDA SFT with tests),
113
+ [CUDA-L1](https://github.com/ornith-ai/CUDA-L1) (RL-optimized KernelBench solutions per GPU).
114
+
115
+ ## License
116
+
117
+ Source code is from vLLM, SGLang and FlashInfer, all Apache-2.0. This compilation is Apache-2.0.