williamhtan commited on
Commit
7ac4192
·
verified ·
1 Parent(s): 1ed455d

Add README.md

Browse files
Files changed (1) hide show
  1. README.md +332 -0
README.md ADDED
@@ -0,0 +1,332 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ pretty_name: KernelSight v4 — Per-Timestep GPU Workload Traces
4
+ size_categories:
5
+ - 1K<n<10K
6
+ task_categories:
7
+ - other
8
+ tags:
9
+ - gpu
10
+ - cuda
11
+ - profiling
12
+ - performance
13
+ - kernel
14
+ - hopper
15
+ - h100
16
+ - cutlass
17
+ - kernelbench
18
+ - time-series
19
+ - sequence-labeling
20
+ - systems
21
+ viewer: false
22
+ ---
23
+
24
+ # KernelSight v4
25
+
26
+ **Per-timestep workload labels for GPU execution traces.**
27
+
28
+ KernelSight pairs every GPU workload trace with a dense, per-timestep workload
29
+ labeling. Each snapshot is a `[24, 512]` counter image — 24 hardware-counter
30
+ channels sampled across 512 equal-width time bins — paired with per-bin labels
31
+ drawn from a two-level hierarchy of **12 coarse (L1)** and **73 fine (L2)**
32
+ workload classes. The goal is to label *what a kernel is doing at each instant*
33
+ (matmul, attention, reduction, memory movement, …) rather than the single
34
+ coarse bottleneck label a profiler assigns per launch.
35
+
36
+ All counters are collected on a single **NVIDIA H100 80GB HBM3** (Hopper,
37
+ `sm_90a`). No data augmentation is applied: each snapshot is the trace as
38
+ measured, and class imbalance is handled at training time rather than by
39
+ resampling.
40
+
41
+ | | |
42
+ |---|---|
43
+ | **Snapshots** | 1,444 |
44
+ | **Tensor shape** | `[24, 512]` (24 channels × 512 time bins) |
45
+ | **Label vocab** | 12 L1 classes · 73 L2 classes |
46
+ | **Labeled segments** | 45,860 |
47
+ | **Overlap ground truth** | 472 snapshots (`has_overlap=1`) |
48
+ | **Standard split** | train 1,124 / val 160 / test 160 |
49
+ | **Hardware** | NVIDIA H100 80GB HBM3 (`sm_90a`) |
50
+ | **On-disk size** | ~68 MB (4,332 `.npz` files) |
51
+ | **License** | Apache-2.0 |
52
+
53
+ ---
54
+
55
+ ## Quick start
56
+
57
+ The dataset ships as raw NumPy `.npz` files in a fixed directory layout, indexed
58
+ by JSON split files. It is **not** loadable through `datasets.load_dataset()`;
59
+ download the folder and read the `.npz` files directly with NumPy.
60
+
61
+ ```python
62
+ from huggingface_hub import snapshot_download
63
+ import numpy as np, json, os
64
+
65
+ root = snapshot_download(repo_id="williamhtan/kernelsight", repo_type="dataset")
66
+
67
+ # Load a split (paths inside are relative to `root`)
68
+ split = json.load(open(os.path.join(root, "splits/train.json")))
69
+ rec = split["traces"][0]
70
+
71
+ # Input tensor
72
+ t = np.load(os.path.join(root, rec["path"]), allow_pickle=True)
73
+ X = t["data"] # (24, 512) float32
74
+
75
+ # Labels live alongside the input
76
+ lpath = rec["path"].replace("/input/", "/labels/").replace("tensor_input.npz", "labels.npz")
77
+ l = np.load(os.path.join(root, lpath), allow_pickle=True)
78
+ y_l1 = l["workload_l1"] # (512,) int32, -1 where unlabeled
79
+ y_l2 = l["workload_l2"] # (512,) int32
80
+ mask = l["mask_labeled"] # (512,) uint8
81
+ y_mh = l["workload_l1_multihot"] # (512, 12) uint8, multi-label overlap track
82
+ ```
83
+
84
+ A reference PyTorch `Dataset` is bundled at `tools/sass_dataloader_stub.py`, and
85
+ the label vocabularies live in `tools/workload_taxonomy.py` (single source of
86
+ truth). Full schema documentation is in [`data_info.md`](data_info.md).
87
+
88
+ ---
89
+
90
+ ## Directory layout
91
+
92
+ ```
93
+ kernelsight_dataset_v4/
94
+ ├── README.md # this card
95
+ ├── MANIFEST_v4.md # release notes / per-class counts
96
+ ├── data_info.md # full on-disk schema reference
97
+ ├── splits/ # 7 split JSONs (see Splits)
98
+ ├── tools/
99
+ │ ├── workload_taxonomy.py # 12 L1 + 73 L2 + 8 flags + 5 spatial (source of truth)
100
+ │ └── sass_dataloader_stub.py
101
+ └── kernels/<motif>/_out/<variant>/
102
+ ├── input/tensor_input.npz # [24, 512] profiler heatmap + metadata
103
+ ├── labels/labels.npz # per-bin + per-segment L1/L2 labels, vocabs
104
+ └── fingerprint/fingerprint.npz # 32-D instruction-mix fingerprint
105
+ ```
106
+
107
+ Each `<variant>` is one snapshot (e.g. parameter-swept geometry like
108
+ `cutlass_gemm/_out/m8192_n1024_k4096_.../`). Split JSON `path` fields are
109
+ relative to the dataset root and point at `.../input/tensor_input.npz`.
110
+
111
+ ---
112
+
113
+ ## Input tensor — `tensor_input.npz`
114
+
115
+ - `data` — `[24, 512]` float32: 24 counter channels × 512 time bins.
116
+ - `time_edges_ns` — `[513]` int64: bin-boundary timestamps (bins are equal-width
117
+ *per trace*, ~0.5 ms for fast matmul up to ~30 ms for long scatter; the window
118
+ is clipped to the kernel-active span).
119
+ - `counter_names` — `[24]`: channel names. `kernels`, `kernel_names`,
120
+ `kernel_function_index` — per-launch identity metadata.
121
+
122
+ Channels divide into five semantic groups. Each channel is divided by a fixed
123
+ physical-scale divisor (pipe/throughput ÷100, warp-stall ÷64, coalescing ÷8) so
124
+ values land in ~`[0, 1]` while *preserving* magnitude differences (no per-channel
125
+ min/max rescale).
126
+
127
+ | Rows | Group | Source | Channels |
128
+ |---|---|---|---|
129
+ | 0–6 | Pipe signature | CUPTI | `tensor_op_hmma`, `xu`, `fma`, `alu`, `lsu`, `cbu`, `tma` |
130
+ | 7–8 | Memory access | CUPTI/ncu | `hit: l2`, `atom: lts_atomic_input_pct` |
131
+ | 9–12 | Discriminators | ncu/NVBit | `short_scoreboard`, `barrier`, `pred_on_per_inst_ratio`, `gmem_coalesce_ratio` |
132
+ | 13–16 | System bandwidth | Nsight Systems | `SMs Active %`, `DRAM Read %`, `DRAM Write %`, `Tensor Active %` |
133
+ | 17–23 | SASS modality | NVBit | `compute_fma`, `compute_tensor`, `memory_global`, `memory_shared`, `memory_tma`, `control`, `misc` |
134
+
135
+ ---
136
+
137
+ ## Labels — `labels.npz`
138
+
139
+ **Per-bin arrays** (length `T = 512`):
140
+
141
+ | Key | dtype | Meaning |
142
+ |---|---|---|
143
+ | `workload_l1` | int32 | L1 class id per bin (`-1` if unlabeled) |
144
+ | `workload_l2` | int32 | L2 class id per bin (`-1` if unlabeled) |
145
+ | `workload_l1_multihot` | uint8 `[T,12]` | Multi-hot per-bin L1 (overlap track) |
146
+ | `workload_l2_multihot` | uint8 `[T,73]` | Multi-hot per-bin L2 |
147
+ | `multihot_n_active` | uint8 `[T]` | # active L1 classes per bin |
148
+ | `multihot_has_overlap` | uint8 `[]` | 1 if any bin asserts ≥2 classes |
149
+ | `segment_id` | int32 `[T]` | 0-based segment ordinal per bin (`-1` if none) |
150
+ | `mask_any_kernel` | uint8 `[T]` | 1 if a kernel interval overlaps this bin |
151
+ | `mask_labeled` | uint8 `[T]` | 1 if `workload_l1 >= 0` |
152
+ | `time_edges_ns` | int64 `[T+1]` | Bin boundaries |
153
+
154
+ **Per-segment arrays** (length `S`, varies by motif): `segment_starts`,
155
+ `segment_ends`, `segment_label_l1`, `segment_label_l2`, `segment_kernel_names`,
156
+ `segment_predecessor_l1/l2`, `segment_position`, `attribute_flags` `[S,8]`.
157
+
158
+ **Vocabularies** (carried in *every* `labels.npz`): `vocab_l1[12]`,
159
+ `vocab_l2[73]`, `attribute_flag_names[8]`, `spatial_state_vocab[5]`,
160
+ `l2_parent_l1[73]`.
161
+
162
+ The single-label fields are always a subset of the multi-hot tracks. On the
163
+ sequential corpus the multi-hot is effectively one-hot; genuine overlap comes
164
+ from 472 `cutlass_ws_overlap` snapshots whose producer (TMA load →
165
+ `memory_movement`) and consumer (WGMMA → `matmul`) phases co-occur, derived from
166
+ device `%globaltimer` markers (independent of the 24 counter channels — no label
167
+ leakage).
168
+
169
+ ---
170
+
171
+ ## Label taxonomy
172
+
173
+ **L1 (12):** `matmul`, `conv`, `activation`, `normalization`, `softmax`,
174
+ `pooling`, `reduction`, `attention`, `loss`, `elementwise`, `memory_movement`,
175
+ `other`.
176
+
177
+ **L2 (73), nested under L1 parents:**
178
+
179
+ | L1 | L2 classes |
180
+ |---|---|
181
+ | matmul | `bmm`, `gemm`, `matvec` |
182
+ | conv | `conv1d_standard`, `conv2d_depthwise`, `conv2d_pointwise`, `conv2d_standard`, `conv3d_standard`, `convtranspose1d`, `convtranspose2d`, `convtranspose3d` |
183
+ | activation | `elu`, `gelu`, `hardsigmoid`, `hardswish`, `hardtanh`, `leaky_relu`, `mish`, `other`, `relu`, `selu`, `sigmoid`, `softplus`, `softsign`, `swish`, `tanh` |
184
+ | normalization | `batchnorm`, `frobeniusnorm`, `groupnorm`, `instancenorm`, `l1norm`, `l2norm`, `layernorm`, `rmsnorm` |
185
+ | softmax | `log_softmax`, `logsumexp`, `softmax` |
186
+ | pooling | `avg_pool`, `global_avg_pool`, `max_pool` |
187
+ | reduction | `argmax`, `argmin`, `cumprod`, `cumsum`, `max`, `mean`, `min`, `prod`, `sum` |
188
+ | attention | `scaled_dot_product` |
189
+ | loss | `cross_entropy`, `hinge`, `huber`, `kldiv`, `mse`, `triplet_margin` |
190
+ | elementwise | `add`, `bias_add`, `cast`, `clamp`, `div`, `mul`, `residual_add`, `scalar_multiplication`, `scaling`, `sub` |
191
+ | memory_movement | `copy`, `embedding`, `gather`, `scatter`, `transpose` |
192
+ | other | `dropout`, `misc` |
193
+
194
+ **Attribute flags (8, multi-label per segment):** `sparse`, `tma`, `cluster`,
195
+ `masked`, `persistent`, `vectorized_store`, `atomic_accum`, `ldgsts`.
196
+
197
+ **Spatial-state vocab (5, exposed for the model side):** `uniform`,
198
+ `wavefront_transition`, `tail_effect`, `load_imbalanced`, `hotspot`.
199
+
200
+ ---
201
+
202
+ ## Corpus composition
203
+
204
+ | Source | Motif | Snapshots | Notes |
205
+ |---|---|---|---|
206
+ | Microbench | `vector_add` | 20 | coalesced BW-bound elementwise |
207
+ | Microbench | `gather` | 17 | random-indexed memory movement |
208
+ | Microbench | `reduction` | 16 | tree + atomic reductions |
209
+ | Microbench | `scatter` | 31 | atomic histogram scatter |
210
+ | Microbench | `wgmma` | 1 | tensor-core GEMM baseline |
211
+ | KernelBench | `kernelbench` | 480 | PyTorch L1 + L2 ops (11 populated L1 classes) |
212
+ | CUTLASS | `cutlass_gemm` | 278 | ex48 TF32 warp-specialized GEMM |
213
+ | CUTLASS | `cutlass_fmha` | 85 | ex88 FlashAttention-3 |
214
+ | CUTLASS | `cutlass_ws_overlap` | 472 | ex48 + device `%globaltimer` markers |
215
+ | CUTLASS | `cutlass_fp8_gemm` | 14 | ex54 FP8 WS-GEMM |
216
+ | CUTLASS | `cutlass_sparse_gemm` | 18 | ex62 2:4 structured sparsity |
217
+ | CUTLASS | `cutlass_grouped_gemm` | 12 | ex57 grouped GEMM |
218
+
219
+ **Per-L1 distribution** (snapshots containing each class / labeled segments):
220
+ matmul 849 / 3,257 · activation 147 / 11,654 · reduction 125 / 7,155 · conv 98 /
221
+ 6,418 · attention 92 / 295 · elementwise 86 / 2,887 · normalization 79 / 6,546 ·
222
+ pooling 62 / 2,019 · memory_movement 48 / 48 · loss 42 / 4,860 · softmax 28 /
223
+ 721. The corpus is heavily imbalanced (matmul dominates bin count via long
224
+ CUTLASS traces), which motivates a class-balanced objective and macro-F1.
225
+
226
+ ---
227
+
228
+ ## Splits
229
+
230
+ Each split JSON is `{split, seed, n, traces, notes}`; every `traces[i]` records
231
+ `path`, `motif`, `n_kernels`, `n_unique_kernels`, `T`, `l1_labels`, `l2_labels`,
232
+ `dominant_l1`, `dominant_l2`.
233
+
234
+ **Standard disjoint partition** (L2-stratified, trace-level leak-free):
235
+
236
+ | Split | n |
237
+ |---|---|
238
+ | `train.json` | 1,124 |
239
+ | `val.json` | 160 |
240
+ | `test.json` | 160 |
241
+
242
+ This measures *within-kernel generalization*: most test traces share kernel
243
+ identity with training and differ in geometry/precision/sweep parameters.
244
+
245
+ **Overlapping analysis tags** (views over the same corpus, not a partition):
246
+
247
+ | Tag | n | Selects |
248
+ |---|---|---|
249
+ | `iid.json` | 433 | random IID sample |
250
+ | `param_ood.json` | 956 | parameter-sweep variants (fixed op, unseen geometry) |
251
+ | `composed.json` | 1,124 | multi-kernel / multi-segment traces |
252
+ | `length_ood.json` | 0 | reserved (empty in v4) |
253
+
254
+ ---
255
+
256
+ ## Collection methodology
257
+
258
+ Workloads come from three sources — hand-written CUDA microbenchmarks isolating
259
+ canonical GPU behaviors, the [KernelBench](https://github.com/ScalingIntelligence/KernelBench)
260
+ Level-1 / Level-2 problem suite, and [CUTLASS](https://github.com/NVIDIA/cutlass)
261
+ Hopper examples (the single largest contributor, ~61% of the corpus) spanning six
262
+ warp-specialized datapaths (TF32, FP8, 2:4-sparse, grouped GEMM,
263
+ FlashAttention-3, and WS-GEMM with device markers).
264
+
265
+ Each workload is profiled by three complementary collectors and fused onto one
266
+ time grid:
267
+
268
+ 1. **NVBit** — SASS-level dynamic binary instrumentation: per-PC instruction mix
269
+ and coalescing statistics.
270
+ 2. **CUPTI Range Profiler** — replays each kernel for a 19-metric warp-stall
271
+ taxonomy (stall reasons, pipe utilizations, occupancy).
272
+ 3. **Nsight Systems** — samples system throughput at ~10 kHz alongside the
273
+ CUDA/NVTX timeline; the only natively time-resolved source, so it defines the
274
+ time grid.
275
+
276
+ Labels come from NVTX markers + kernel boundaries, with kernel-name + SASS
277
+ pattern matching resolving the L2 class. The full collector fork and per-motif
278
+ `run.sh` reproduction harness are part of the KernelSight project (not bundled in
279
+ this dataset distribution, which ships the rendered tensors, labels, and splits).
280
+
281
+ ---
282
+
283
+ ## Changes from v3.1
284
+
285
+ - Dropped `megakernel` (1 PoC snapshot) and `tiled_gemm_poc` (590 hand-written
286
+ PoC snapshots).
287
+ - Added three CUTLASS Hopper datapaths: FP8 (ex54), 2:4 sparse (ex62), grouped
288
+ (ex57).
289
+ - Selective KernelBench expansion (activation, normalization, pooling, reduction,
290
+ elementwise) and geometry sweeps over microbenchmarks and CUTLASS GEMM/FMHA.
291
+ - Corpus 262 → 1,444 snapshots; overlap ground truth 29 → 472 snapshots.
292
+ - CI: 26,996 assertions passed, 0 failed.
293
+
294
+ See [`MANIFEST_v4.md`](MANIFEST_v4.md) for full release notes.
295
+
296
+ ---
297
+
298
+ ## Limitations
299
+
300
+ - Counters are from a **single H100** (`sm_90a`); cross-architecture transfer is
301
+ out of scope.
302
+ - Overlap timing is coarse: device-marker spans resolve producer/consumer
303
+ *envelopes* (≈ whole launch), so overlap is annotated at launch granularity.
304
+ - All 24 channels carry real signal, but many rows are legitimately zero where
305
+ the hardware is inactive for a given motif.
306
+ - The `spatial_state` vocab is exposed for the model side; per-bin spatial-state
307
+ derivation is not provided.
308
+
309
+ ---
310
+
311
+ ## License & provenance
312
+
313
+ Released under **Apache-2.0**. Derived workloads retain their upstream licenses:
314
+
315
+ - **KernelBench** problems — MIT (Scaling Intelligence Lab, Stanford University).
316
+ - **CUTLASS** examples — BSD-3-Clause (NVIDIA Corporation).
317
+
318
+ The profiler tooling builds on the Intra-Kernel Profiler (NVBit / CUPTI / Nsight
319
+ Systems). This release contains only derived, aggregated counter tensors and
320
+ labels — no third-party source code.
321
+
322
+ ## Citation
323
+
324
+ ```bibtex
325
+ @misc{tan2026kernelsight,
326
+ title = {KernelSight: Per-Timestep Workload Labeling of GPU Execution Traces},
327
+ author = {Tan, William},
328
+ year = {2026},
329
+ note = {CS231N project, Stanford University},
330
+ howpublished = {\url{https://huggingface.co/datasets/williamhtan/kernelsight}}
331
+ }
332
+ ```