| # KernelSight Dataset |
|
|
| This document describes the on-disk dataset produced by the data pipeline: |
| file layout, the 24-channel input tensor, the per-bin and per-segment labels, |
| the vocabularies, and the splits. The model side (ViT, baselines) consumes |
| this dataset; the pipeline itself runs on profile artifacts collected via |
| `crun` on H100 / H200 nodes. |
|
|
| For the data pipeline state and outstanding TODOs, see `README.md`. For |
| operational notes (CUPTI Range Profiler quirks, nsys clock alignment), see |
| `CLAUDE.md` §"CUPTI operational notes". |
|
|
| ## 1. Snapshot count and motifs |
|
|
| The dataset is the set of `(tensor_input.npz, labels.npz)` pairs living under |
| `kernels/<motif>/_out/**/` on shared NFS — one per profiled kernel snapshot. |
| The motif families: |
|
|
| | Motif family | Notes | |
| |---|---| |
| | Microbenchmarks | `vector_add`, `gather`, `reduction`, `scatter`, `wgmma` (one class each) | |
| | Megakernel | 4-phase sequential workload (`elementwise → memory_movement → reduction → matmul`) | |
| | KernelBench L1 | Single-op problems (`level1/*`), one labeled segment each | |
| | KernelBench L2 | Op-sequence problems (`level2/*`), one segment per op in the chain | |
| | CUTLASS Tier-1 | `cutlass_gemm` (TF32 WS-GEMM, 278 snaps), `cutlass_fmha` (FA3, 85 snaps), `cutlass_fp8_gemm` (FP8 WS-GEMM, 14 snaps), `cutlass_sparse_gemm` (2:4 sparse, 18 snaps), `cutlass_grouped_gemm` (grouped → `matmul_bmm`, 12 snaps). Each a prebuilt CUTLASS example as one labeled black-box anchor, **parameter-swept** over M/N/K and motif-specific axes. | |
| | CUTLASS WS-overlap PoC | `cutlass_ws_overlap` — real CUTLASS ex.48 WS-GEMM; device `%globaltimer` markers → multi-hot overlap baked into its corpus `labels.npz`. **Parameter-swept**: 472 snapshots, all `multihot_has_overlap = 1`. | |
|
|
| The 6 CUTLASS motifs are **parameter-swept** (`dev/launch_cutlass_sweep.sh` |
| → `dev/postprocess_sweep.sh`). The KB corpus is also swept (selective dtype/seed). |
| Exact snapshot and split counts are **regenerated by `tools/build_splits.py` |
| after each collection** — see the `n` field in each `splits/*.json` (currently |
| **1444 traces**: train 1124 / val 160 / test 160; param_ood 956, iid 433, |
| composed 1124). See `scale.md` (repo root, local-only) for how to grow further. |
| |
| ## 2. File layout |
| |
| Per snapshot: |
| |
| ``` |
| kernels/<motif>/_out/ |
| ├── crun_submit.log # SLURM submission log |
| ├── kernel_meta.json # Per-launch identity metadata (KB only) |
| ├── cupti/ # CUPTI Range Profiler output |
| │ └── range_raw.json # Per-launch warp-stall taxonomy + pipe-util |
| │ # metrics (kernel-replay) |
| ├── nvbit/ # NVBit region profiler output |
| │ ├── region_stats_<kernel>_<id>.json # Per-region inst_class + counters |
| │ ├── pcmap_<kernel>_<id>.json # PC → region attribution |
| │ ├── hotspots_<kernel>_<id>.json # Per-BB exec counts |
| │ ├── sass_all_<kernel>_<id>.sass # Raw SASS dump |
| │ └── summary_<kernel>_<id>.txt |
| ├── nsys/ |
| │ └── <motif>.{nsys-rep,sqlite} # Nsight Systems trace |
| ├── input/ |
| │ ├── tensor_input.npz # [24, 512] model input — see §3 |
| │ ├── tensor_ncu.npz # Per-source side artifact (Range: stall + pipe-util) |
| │ ├── tensor_nsys.npz # Per-source side artifact (nsys system/BW) |
| │ ├── heatmap_*.png # Per-source heatmaps |
| │ ├── heatmap_combined.png # All sources stacked |
| │ └── timeseries_*.png |
| └── labels/ |
| └── labels.npz # Per-bin + per-segment labels — see §4 |
| ``` |
| |
| Optional side artifacts (NOT built automatically by `run.sh`; need separate |
| invocations of the respective `tools/` scripts): |
| |
| ``` |
| kernels/<motif>/_out/ |
| ├── fingerprint/fingerprint.npz # 32-D instruction-mix vector — §6 |
| └── sass/sass_modality.npz # [N_pc, 9] per-kernel SASS matrix — §7 (RETIRED: builder removed) |
| ``` |
| |
| ## 3. Input tensor: `tensor_input.npz` |
| |
| ### 3.1 Shape and time binning |
| |
| ``` |
| data [24, 512] float32 — 24 counter channels × 512 timesteps |
| counter_names [24] object — string name per row |
| time_edges_ns [513] int64 — bin boundary timestamps (ns) |
| kernels [K, 2] int64 — per-kernel-launch [start_ns, end_ns] |
| kernel_names [K] object — demangled name per launch |
| kernel_function_index [K] int64 — index into sass_modality kernel table |
| ``` |
| |
| The time axis is **512 equal-width bins covering each trace's kernel-active |
| window**: |
| |
| - The renderer clips to `[first_kernel_start - 50 ms, last_kernel_end + 50 ms]`. |
| - The clipped window is divided into 512 equal bins. |
| - So **bin width is per-trace, not global**. Observed widths: |
| |
| | Snapshot | Window | Bin width | |
| |---|---|---| |
| | `KB L1_P1` (matmul) | 253 ms | 0.50 ms/bin | |
| | `KB L2_P5` | 520 ms | 1.01 ms/bin | |
| | `gather` | 5.8 s | 11.28 ms/bin | |
| | `wgmma` | 5.9 s | 11.48 ms/bin | |
| | `vector_add` | 6.9 s | 13.45 ms/bin | |
| | `reduction` | 11.6 s | 22.74 ms/bin | |
| | `cutlass_fp8_gemm` (varies) | ~0.1–35 s | ~0.2–68 ms/bin | |
| | `scatter` | 15.3 s | 29.82 ms/bin | |
| |
| The 512-token sequence length stays constant; the ViT never sees absolute |
| time. If you need wall-clock per bin, use `time_edges_ns[i:i+2]`. |
| |
| ### 3.2 Channel layout |
| |
| All 24 channels carry live signal across the corpus — there are no |
| zero-by-construction placeholder rows. The layout is the source of truth |
| in `tools/render_model_input.py:CANONICAL_INPUT_CHANNELS`. |
| |
| (The pre-trim 64-channel layout had 39 dead channels from Hopper |
| uncollectable counters + deferred tiers + corpus-absent pipe types, plus |
| a `stall_total` pad row. Those 40 rows were removed after an empirical |
| audit of the pre-trim corpus.) |
| |
| #### Pipe signature (rows 0–6, PRIMARY operator-identity) |
| |
| Source: `ncu` (Range Profiler `.avg.pct_of_peak_sustained_active` form). |
| |
| | Row | Name | Semantics | |
| |---|---|---| |
| | 0 | `pipe: tensor_op_hmma` | HMMA tensor-core pipe utilization (FP16/BF16/TF32 matmul) | |
| | 1 | `pipe: xu` | XU pipe (transcendentals / type conversion) | |
| | 2 | `pipe: fma` | FMA pipe (FFMA / HFMA) | |
| | 3 | `pipe: alu` | ALU pipe (integer add/sub/mul) | |
| | 4 | `pipe: lsu` | LSU pipe (global / shared load-store) | |
| | 5 | `pipe: cbu` | CBU pipe (control / branch) | |
| | 6 | `pipe: tma` | TMA pipe (Hopper async bulk copy) | |
| |
| Three pipes from the old Tier A are absent from the corpus and removed: |
| `tensor_op_imma` (no INT8 tensor ops), `tensor_op_dmma` (no FP64 tensor |
| ops), `fp64` (no FP64 pipe activity). |
| |
| #### Memory access shape (rows 7–8) |
| |
| | Row | Name | Source | Semantics | |
| |---|---|---|---| |
| | 7 | `hit: l2` | `ncu` | L2 cache hit rate (`lts__t_sector_hit_rate.pct`) | |
| | 8 | `atom: lts_atomic_input_pct` | `ncu` | L2 atomic-input cycles, fraction of peak [0,1] (normalized via the `atom:` divisor) | |
| |
| #### Secondary discriminators (rows 9–12) |
| |
| | Row | Name | Source | Semantics | |
| |---|---|---|---| |
| | 9 | `stall: short_scoreboard` | `ncu` | Short-scoreboard stall ratio | |
| | 10 | `stall: barrier` | `ncu` | Barrier-wait stall ratio | |
| | 11 | `pred_on_per_inst_ratio` | `ncu` | Predicate-on fraction (catches masked attention) | |
| | 12 | `gmem_coalesce_ratio` | `nvbit` | Sectors-per-warp-load ratio from NVBit region_stats | |
| |
| #### System / BW from nsys (rows 13–16) |
| |
| Source: `nsys`. Pulled from the nsys `TARGET_INFO_GPU_METRICS` periodic |
| samples (~10 kHz, gh100 set). |
| |
| | Row | Name | Semantics | |
| |---|---|---| |
| | 13 | `SMs Active [Throughput %]` | Fraction of SMs active per sample | |
| | 14 | `DRAM Read Bandwidth [Throughput %]` | DRAM read BW % of peak | |
| | 15 | `DRAM Write Bandwidth [Throughput %]` | DRAM write BW % of peak | |
| | 16 | `Tensor Active [Throughput %]` | Tensor-core active fraction | |
| |
| #### Per-bin SASS modality (rows 17–23) |
| |
| Source: NVBit `inst_class` counts via `_compute_tier_i` (renderer), |
| coalesced to 7 live categories, normalized to fractions, tiled by |
| kernel-launch intervals. Two categories from the old 9-channel set |
| (`sass_compute_transcendental`, `sass_atomic`) are absent from the corpus |
| and removed. |
| |
| | Row | Name | NVBit `inst_class` source | |
| |---|---|---| |
| | 17 | `sass_compute_fma` | `alu_fp32` | |
| | 18 | `sass_compute_tensor` | `tensor_wgmma` | |
| | 19 | `sass_memory_global` | `ld_global + st_global` | |
| | 20 | `sass_memory_shared` | `ld_shared + st_shared` | |
| | 21 | `sass_memory_tma` | `special` (cp.async / TMA / ldgsts) | |
| | 22 | `sass_control` | `branch + call + ret` | |
| | 23 | `sass_misc` | `alu_int + barrier + membar + ld_local + st_local + other` | |
| |
| ### 3.3 Standardization |
| |
| Each row is divided by a physical-scale divisor (see `PHYSICAL_MAX` and |
| `PHYSICAL_DIVISOR_PATTERNS` in the renderer) so values typically land in |
| `[0, 1]` while preserving cross-channel magnitude differences. Examples: |
| |
| | Pattern | Divisor | Effect | |
| |---|---|---| |
| | `pipe:` | 100.0 | percent → fraction | |
| | `[Throughput %]` (nsys) | 100.0 | percent → fraction | |
| | `stall: …` | 64.0 | per-issue-active ratio → fraction of warps | |
| | `gmem_coalesce_ratio` | 8.0 | sectors/warp → normalized | |
| |
| Per-channel min/max normalization is intentionally avoided (would collapse |
| all rows to `[0, 1]` even when they share the same shape and lose |
| cross-channel magnitude information). |
| |
| ### 3.4 Active row count |
| |
| After the channel trim, all 24 rows carry signal on every motif that |
| exercises the underlying hardware feature. Per-motif active counts: |
| |
| | Motif | Active rows | |
| |---|---| |
| | `gather` | 15 / 24 | |
| | `vector_add` | 16 / 24 | |
| | `wgmma` | 19 / 24 | |
| | `scatter` | 20 / 24 | |
| | `reduction` | 22 / 24 | |
| | `cutlass_grouped_gemm` | varies per group | |
| |
| The remaining zeros on simpler motifs (e.g. `gather` doesn't use tensor |
| cores, so `pipe: tensor_op_hmma` = 0) reflect real hardware inactivity, |
| not uncollectable counters. |
| |
| ## 4. Labels: `labels.npz` |
| |
| 24 keys, all aligned to the same `[T=512]` time axis or per-segment `[S]` |
| arrays. Built by `tools/build_labels.py` from the nsys kernel timeline + |
| the motif-specific segmentation logic. The 4 multi-hot keys (§4.3) are |
| **additive**: they were introduced alongside the original 20 single-label |
| keys without changing any of them, so existing single-label consumers keep |
| working unchanged. |
| |
| ### 4.1 Per-bin arrays (length T = 512) |
| |
| | Key | dtype | Semantics | |
| |---|---|---| |
| | `workload_l1` | int32 | L1 class id per bin (–1 if unlabeled) | |
| | `workload_l2` | int32 | L2 class id per bin (–1 if unlabeled) | |
| | `workload_l1_multihot` | uint8 `[T, 12]` | per-bin multi-hot over L1 (overlapping labels — see §4.3) | |
| | `workload_l2_multihot` | uint8 `[T, 73]` | per-bin multi-hot over L2 | |
| | `multihot_n_active` | uint8 | # active L1 classes per bin (= L1 multi-hot row sum) | |
| | `segment_id` | int32 | 0-based segment ordinal per bin (–1 if no segment overlaps) | |
| | `mask_any_kernel` | uint8 | 1 if any kernel interval overlaps this bin | |
| | `mask_labeled` | uint8 | 1 if `workload_l1 >= 0` for this bin | |
| | `time_edges_ns` | int64 | `[T+1] = [513]` bin boundary timestamps | |
| |
| (`workload_l*_multihot` and `multihot_n_active` are `[T, *]` / `[T]` arrays; |
| the table groups them with the per-bin keys. There is also a scalar |
| `multihot_has_overlap` (uint8 `[]`) — see §4.3.) |
| |
| ### 4.2 Per-segment arrays (length S, motif-dependent) |
| |
| | Key | shape | dtype | Semantics | |
| |---|---|---|---| |
| | `segment_starts` | `[S]` | int64 | First bin index (inclusive) | |
| | `segment_ends` | `[S]` | int64 | Last bin index (exclusive) | |
| | `segment_label_l1` | `[S]` | int32 | L1 class id | |
| | `segment_label_l2` | `[S]` | int32 | L2 class id | |
| | `segment_kernel_names` | `[S]` | object | Demangled kernel name (or NVTX op label) | |
| | `segment_predecessor_l1` | `[S]` | int32 | L1 class of the preceding segment in start order (–1 for first) | |
| | `segment_predecessor_l2` | `[S]` | int32 | L2 class of the preceding segment | |
| | `segment_position` | `[S]` | int32 | 0-based ordinal of this segment within its L2 group (per-phase position) | |
| | `attribute_flags` | `[S, 8]` | uint8 | 0/1 per attribute (see §5) | |
| |
| `S` varies per snapshot: |
| |
| - Microbenchmarks: `S = 1` (single-class, single-kernel-family runs). |
| - KernelBench L1: `S = 1` per problem (single op). |
| - KernelBench L2: `S = 2..6` (op-sequence problems, one segment per op in the chain). |
| - Megakernel: `S ≈ 500` (one segment per inner `op_*` NVTX range, bin-resolvable subset). |
| |
| ### 4.3 Multi-label (overlapping) per-bin tracks — ADDITIVE |
| |
| The single-label fields (`workload_l1` / `workload_l2`) carry exactly **one** |
| class id per bin. Real fused, warp-specialized kernels run >1 workload phase |
| *concurrently* — e.g. a Hopper WS-GEMM's producer TMA-load phase |
| (`memory_movement`) overlaps its consumer WGMMA phase (`matmul`) in |
| wall-clock time. The multi-hot tracks let a bin carry 2+ classes at once. |
| |
| | Key | shape | dtype | Semantics | |
| |---|---|---|---| |
| | `workload_l1_multihot` | `[T, 12]` | uint8 | `[t, c] = 1` iff L1 class `c` is active in bin `t` | |
| | `workload_l2_multihot` | `[T, 73]` | uint8 | `[t, j] = 1` iff L2 class `j` is active in bin `t` | |
| | `multihot_n_active` | `[T]` | uint8 | # active L1 classes in bin `t` (= row sum of `workload_l1_multihot`) | |
| | `multihot_has_overlap` | `[]` | uint8 | 0 if every bin has ≤1 active class (sequential one-hot); 1 if any bin carries ≥2 | |
| |
| **Relationship to the single-label fields (a strict superset):** |
|
|
| - **Subsumption.** The bin's single label is always set in its multi-hot row |
| (`workload_l1_multihot[t, workload_l1[t]] == 1` wherever `workload_l1[t] ≥ 0`). |
| So `workload_l1` is the *dominant / argmax* class and is guaranteed to be a |
| member of the multi-hot set. A single-label consumer is never contradicted. |
| - **Degenerate on the sequential corpus.** Every sequential snapshot |
| (microbenchmarks, KernelBench L1/L2, the CUTLASS Tier-1 ops) is |
| one op at a time — so the multi-hot is exactly the **one-hot** of the single |
| label, every row sums to ≤ 1, and `multihot_has_overlap == 0`. The schema |
| subsumes the single-label case; it does not change it. (The two device-marker |
| GEMM PoCs are the exception — see below.) |
| - **`mask_labeled` interaction.** `multihot_n_active > 0` is the multi-label |
| analog of `mask_labeled`; on the sequential corpus the two are identical. |
| - **Hierarchy.** Wherever an L2 bit is set, its parent L1 bit |
| (`l2_parent_l1[j]`) is set too — the same L1/L2 hierarchy the single-label |
| fields obey, enforced by CI on the multi-hot rows. |
|
|
| **Where genuine overlap comes from.** Only device-instrumented fused kernels |
| produce ≥2 concurrent labels. Two device-`%globaltimer`-marker GEMM PoCs bin their region markers |
| (`produce_*` → `memory_movement`, `consume_*` → `matmul`, `epilogue` → |
| `memory_movement`) into the multi-hot tracks of their corpus `labels.npz` |
| (`build_corpus_labels.py`). After the parameter sweep, **29 snapshots carry |
| `multihot_has_overlap = 1`** (`cutlass_ws_overlap`: 1 baseline + 15 variants; |
| `cutlass_ws_overlap`: 1 baseline + 471 variants — each variant re-runs its marker |
| stage at the variant shape, so overlap depth tracks K / tile / problem size). |
| The two baselines, for reference: |
| - `cutlass_ws_overlap` (real CUTLASS ex.48 WS-GEMM) — overlap on all **28 |
| bins** of its labeled launch window (producer TMA-load ‖ consumer WGMMA). |
| - `cutlass_ws_overlap` (WS-GEMM with device markers) — **majority of bins carry |
| ≥2 labels (98.9 % of active bins)**. |
| The standalone `build_multihot_demo.py` → `labels_multihot.npz` path is a demo, |
| not part of the corpus output. The general ingestion |
| hook is `build_labels_for(out_dir, extra_spans=[(start_bin, end_bin, l1, l2), |
| …])`. **This multi-label (multi-hot) overlap track is the adopted labeling |
| scheme for overlapping phases.** See `mega-kernel-profiling.md` for the |
| per-warp marker analysis and the per-region channel decomposition. |
|
|
| **Labels are ground truth, not counter-derived (no leakage).** The multi-hot |
| labels are derived **only** from the `%globaltimer` device markers (warp role → |
| phase boundaries); they are **independent of the 24 counter input channels** in |
| §3. The model's task is to *predict* these labels **from** the counters, and |
| because the labels never read the counters there is no input↔label leakage. |
|
|
| **Model side (described, not implemented here).** The multi-hot tracks are |
| the adopted target for a **sigmoid / multi-label head** (per-class binary |
| cross-entropy over the 12 L1 / 73 L2 channels, masked by |
| `multihot_n_active > 0`); segmental F1 is then computed **per class** (each |
| class is its own on/off track / temporal IoU). The existing single-label |
| softmax head keeps training off `workload_l1` / `workload_l2` unchanged. |
|
|
| ### 4.4 Vocabularies (carried in every `labels.npz`) |
|
|
| | Key | shape | Notes | |
| |---|---|---| |
| | `vocab_l1` | `[12]` object | See §5.1 | |
| | `vocab_l2` | `[73]` object | See §5.2 | |
| | `attribute_flag_names` | `[8]` object | See §5.3 | |
| | `spatial_state_vocab` | `[5]` object | See §5.4 (vocab carried for model side; per-bin assignment is out of scope — no fused kernels) | |
| | `l2_parent_l1` | `[73]` int32 | `l2_parent_l1[j]` = L1 id of the parent class of L2 id `j` | |
|
|
| The vocabs are the **single source of truth** in |
| `tools/workload_taxonomy.py`. CI invariants in |
| `tests/test_tensor_invariants.py` enforce the cardinalities + hierarchy. |
|
|
| ## 5. Vocabularies |
|
|
| ### 5.1 L1 classes (12) |
|
|
| ``` |
| 0 matmul — GEMM / matvec / batched matmul kernels |
| 1 conv — 1D / 2D / 3D convolutions (depthwise, transposed, etc.) |
| 2 activation — ReLU, GELU, sigmoid, etc. |
| 3 normalization — BatchNorm, LayerNorm, RMSNorm, GroupNorm |
| 4 softmax — softmax / log_softmax / cross-entropy softmax stage |
| 5 pooling — max / avg / adaptive pooling |
| 6 reduction — sum / mean / max / argmax reductions |
| 7 attention — self / cross attention (Q·K^T, softmax(QK)V) |
| 8 loss — MSE / CE / NLL loss kernels |
| 9 elementwise — add / mul / fused elementwise epilogues |
| 10 memory_movement — copy / transpose / gather / scatter / permute / reshape |
| 11 other — dropout, indexing, misc |
| ``` |
|
|
| ### 5.2 L2 classes (73) |
|
|
| `VOCAB_L2` in `tools/workload_taxonomy.py`. Sample subclasses: |
|
|
| - `matmul/{bmm, gemm, matvec}` (3) |
| - `conv/{conv1d_standard, conv2d_depthwise, conv2d_standard, …, convtranspose3d}` (~13) |
| - `activation/{relu, gelu, sigmoid, …}` (~8) |
| - `normalization/{batchnorm, layernorm, rmsnorm, groupnorm, …}` (~6) |
| - `softmax/{softmax, logsoftmax, cross_entropy}` (~3) |
| - `pooling/{maxpool, avgpool, adaptive_avgpool, …}` (~6) |
| - `reduction/{sum, mean, max, argmax}` (~4) |
| - `attention/{qkv_matmul, attn_softmax, attn_v_matmul, mha_fused}` (~4) |
| - `loss/{mse, ce, nll, bce, smooth_l1}` (~5) |
| - `elementwise/{add, mul, fused_relu, fused_gelu, …}` (~8) |
| - `memory_movement/{copy, gather, scatter, transpose, permute}` (~5) |
| - `other/{dropout, misc}` (~2) |
|
|
| The full list with the L1 parent of each is in `VOCAB_L2` / |
| `L2_PARENT_L1`. The hierarchy invariant |
| `vocab_l1[l2_parent_l1[j]]` == L1-parent-of-`vocab_l2[j]` is checked by CI. |
|
|
| ### 5.3 Attribute flags (8, multi-label per segment) |
|
|
| ``` |
| sparse — Sparse layout / sparsity-aware kernel |
| tma — Uses Hopper TMA bulk-copy |
| cluster — Uses CGA (cluster) launch |
| masked — Has predicate-mask logic (e.g. causal attention) |
| persistent — Persistent-style loop body |
| vectorized_store — STG.128 / vectorized writes detected |
| atomic_accum — atomicAdd / red.add accumulation epilogue |
| ldgsts — Uses cp.async / LDGSTS (Ampere-style async copy) |
| ``` |
|
|
| `attribute_flags[s, k]` is 1 if segment `s` exhibits flag `k`. Derived by |
| `_attribute_flags_from_meta` from kernel-name pattern matching + NVBit |
| SASS dump scan. |
|
|
| ### 5.4 Spatial state (5, vocab only — per-bin derivation out of scope) |
|
|
| ``` |
| uniform — All SMs doing similar work |
| wavefront_transition — Producer / consumer wave transition |
| tail_effect — Last-wave imbalance |
| load_imbalanced — Persistent uneven distribution |
| hotspot — Single SM / SMSP doing most of the work |
| ``` |
|
|
| The vocab is exposed so the model side can define a 5-class head, but |
| **per-bin `spatial_state[T]` is NOT in `labels.npz`** — deriving it |
| reliably requires per-SM markers or per-SMSP instance data, which is |
| deferred along with Tier G (no fused kernels in the corpus to motivate |
| the C++ work). |
| |
| ## 6. Optional: 32-D fingerprint (`fingerprint.npz`) |
| |
| Built by `tools/build_fingerprint.py` from NVBit `region_stats_*.json`. |
| **Not produced by `run.sh` automatically** — invoke separately if needed |
| (the CUTLASS/PoC sweep's `dev/postprocess_sweep.sh` runs it for every variant): |
| |
| ```bash |
| python tools/build_fingerprint.py kernels/<motif>/_out |
| ``` |
| |
| Schema: |
| |
| ``` |
| vec [32] float32 — concatenation of: |
| 16-D normalized inst_class fractions |
| 16-D normalized inst_pipe fractions |
| class_names [16] object — inst_class names (parallel to vec[0:16]) |
| pipe_names [16] object — inst_pipe names (parallel to vec[16:32]) |
| ``` |
| |
| Used as a static per-trace embedding for retrieval / nearest-neighbor |
| sanity checks on the model side. |
| |
| ## 7. Optional: per-PC SASS modality (`sass_modality.npz`) |
| |
| **Historical / retired — not part of the current pipeline.** This artifact was |
| built by the since-removed `tools/build_sass_modality.py` from CUPTI `sassmetrics_*.json`, but the |
| per-PC SASS-metric injector (`ikp_cupti_sassmetrics`) was retired along with the |
| PM/PC-sampling injectors, so `sassmetrics_*.json` is no longer collected and |
| `sass_modality.npz` cannot be regenerated from the current tree. The in-tensor |
| SASS modality (§3.2 rows 17–23) comes from NVBit and is unaffected. The schema |
| below documents previously-collected files; `tensor_input.npz`'s |
| `kernel_function_index[K]` still indexes a `sass_modality.npz` kernel table when |
| one is present. |
|
|
| Schema: |
|
|
| ``` |
| column_names [F=9] object — see below |
| kernel_names [K] object — demangled kernel name per matrix |
| kernel_cubin_crcs [K] int64 — cubin CRC for rebuild disambiguation |
| pc_offsets [K] object — per-kernel int64[N_pc_k] of PC offsets |
| matrices [K] object — per-kernel float64[N_pc_k, F=9] matrix |
| source_files [K] object — per-kernel list[str] (source attribution per PC) |
| source_lines [K] object — per-kernel int64[N_pc_k] (source line per PC) |
| ``` |
|
|
| The 9 columns are: |
|
|
| ``` |
| raw (from CUPTI smsp__sass_*): |
| inst_executed |
| thread_inst_executed |
| thread_inst_executed_pred_on |
| inst_executed_op_global_ld |
| inst_executed_op_global_st |
| sectors_mem_global |
| sectors_mem_global_ideal |
| derived: |
| pred_on_ratio = pred_on / max(thread_inst_executed, 1) in [0, 1] |
| coalesce_per_pc = sectors_mem_global / max(sectors_ideal, 1) in [1, ~8] |
| ``` |
|
|
| The model side cross-attends from a bin embedding to a gathered |
| `[K, N_pc, 9]` tensor when the bin's kernel mapping is known (see |
| `tools/sass_dataloader_stub.py` for the wiring sketch). The |
| `tensor_input.npz` `kernel_function_index[K]` field gives the index into |
| `sass_modality.npz`'s `kernel_names` for each kernel launch. |
|
|
| ## 8. Splits |
|
|
| Built by `tools/build_splits.py`. Seven JSON files under `splits/`: |
|
|
| ``` |
| splits/ |
| ├── train.json — ~70% of labeled traces (L1-stratified) |
| ├── val.json — ~17% |
| ├── test.json — ~13% |
| ├── iid.json — random-stratified subset |
| ├── composed.json — multi-segment traces (KB L2 + CUTLASS) |
| ├── length_ood.json — long-tail segment-count traces |
| └── param_ood.json — CUTLASS/PoC parameter-sweep variants (fixed op binary, |
| unseen launch geometry / tile); 52 traces |
| ``` |
|
|
| (Per-split trace counts are regenerated by `build_splits.py` — read each |
| file's `n` field for the current numbers.) |
|
|
| Each split JSON has the shape: |
|
|
| ```json |
| { |
| "split": "iid", |
| "seed": 0, |
| "n": 62, |
| "traces": [ |
| { |
| "path": "kernels/gather/_out/input/tensor_input.npz", |
| "motif": "gather", |
| "n_kernels": 10001, |
| "n_unique_kernels": 1, |
| "T": 512, |
| "l1_labels": ["memory_movement"], |
| "l2_labels": ["memory_movement_gather"], |
| "dominant_l1": "memory_movement", |
| "dominant_l2": "memory_movement_gather" |
| }, |
| ... |
| ], |
| "notes": "..." |
| } |
| ``` |
|
|
| `path` is relative to the repo root. The matching `labels.npz` lives at |
| `<dir-of-path>/../labels/labels.npz`. |
|
|
| Splits are **L1-stratified** so each split sees every L1 class with at |
| least 3 examples (per `test_l1_strata_coverage`). KernelBench L2 problems |
| are routed to `composed` to exercise multi-segment / predecessor-context |
| inference. Megakernel goes to `length_ood` as the single longest-segment- |
| count trace in the corpus. `param_ood` holds the 52 CUTLASS/PoC |
| parameter-sweep variants (`_is_param_sweep_variant` in `build_splits.py`: |
| non-baseline `_out/<variant_tag>/` snapshots of a binary-fixed motif, |
| excluding KernelBench's dtype sweep) — a held-out fixed-op / unseen-geometry |
| generalization bin. The legacy four (`iid` / `param_ood` / `composed` / |
| `length_ood`) are overlapping *views* over the same corpus, orthogonal to the |
| disjoint `train` / `val` / `test` partition. |
|
|
| ## 9. Known limitations |
|
|
| The 24-channel tensor has no zero-by-construction placeholder rows — |
| every channel carries real signal somewhere in the corpus. The 40 dead |
| channels from the pre-trim 64-channel layout (Hopper-uncollectable |
| counters, deferred per-instance tiers, corpus-absent pipe types, and the |
| `stall_total` pad row) were removed after an empirical audit across the |
| full pre-trim corpus (4322 tensor files). |
|
|
| Remaining zeros reflect genuine hardware inactivity (e.g. `pipe: tma` |
| is zero on simple microbenchmarks that don't use TMA bulk copy). |
|
|
| The 5 microbench motifs + KB problems + CUTLASS ops together cover **all |
| 12 L1 classes and ~all 73 L2 classes**, so the label-side coverage is |
| strong. |
|
|
| ## 10. Loading examples |
|
|
| ### NumPy |
|
|
| ```python |
| import numpy as np |
| |
| t = np.load("kernels/wgmma/_out/input/tensor_input.npz", allow_pickle=True) |
| X = t["data"] # shape (24, 512), float32 |
| names = list(t["counter_names"]) |
| edges = t["time_edges_ns"] # shape (513,), bin boundaries |
| kernels = t["kernels"] # shape (K, 2), per-launch [start, end] ns |
| |
| l = np.load("kernels/wgmma/_out/labels/labels.npz", allow_pickle=True) |
| y_l1 = l["workload_l1"] # (512,) int32 |
| y_l2 = l["workload_l2"] # (512,) int32 |
| mask = l["mask_labeled"] # (512,) uint8 — 1 where y_l1 >= 0 |
| attrs = l["attribute_flags"] # (S, 8) uint8 |
| vocab_l1 = list(l["vocab_l1"]) |
| print(f"bin 256 → L1 = {vocab_l1[y_l1[256]]}") |
| |
| # Multi-label (overlapping) head target — sigmoid / BCEWithLogits over classes. |
| y_l1_mh = l["workload_l1_multihot"] # (512, 12) uint8, 0/1 |
| active = [vocab_l1[c] for c in np.nonzero(y_l1_mh[256])[0]] |
| print(f"bin 256 → active L1 set = {active} (n_active = {l['multihot_n_active'][256]})") |
| ``` |
|
|
| ### PyTorch Dataset sketch |
|
|
| ```python |
| import json, numpy as np, torch |
| from torch.utils.data import Dataset |
| |
| class KernelSightDataset(Dataset): |
| def __init__(self, split_path): |
| with open(split_path) as f: |
| split = json.load(f) |
| self.traces = split["traces"] |
| |
| def __len__(self): |
| return len(self.traces) |
| |
| def __getitem__(self, i): |
| rec = self.traces[i] |
| tpath = rec["path"] |
| lpath = tpath.replace("/input/", "/labels/").replace( |
| "tensor_input.npz", "labels.npz" |
| ) |
| t = np.load(tpath, allow_pickle=True) |
| l = np.load(lpath, allow_pickle=True) |
| X = torch.from_numpy(t["data"]).float() # (24, 512) |
| y_l1 = torch.from_numpy(l["workload_l1"]).long() # (512,) |
| y_l2 = torch.from_numpy(l["workload_l2"]).long() # (512,) |
| mask = torch.from_numpy(l["mask_labeled"]).bool() # (512,) |
| # Treat unlabeled bins as ignore_index by setting them to -100 |
| y_l1 = torch.where(mask, y_l1, torch.full_like(y_l1, -100)) |
| y_l2 = torch.where(mask, y_l2, torch.full_like(y_l2, -100)) |
| return X, y_l1, y_l2 |
| |
| train_ds = KernelSightDataset("splits/train.json") |
| val_ds = KernelSightDataset("splits/val.json") |
| test_ds = KernelSightDataset("splits/test.json") |
| ``` |
|
|
| ### ViT-on-heatmap framing (suggestion, not required) |
|
|
| ```python |
| # Treat X as a 24×512 single-channel "image". |
| # The dataloader stub's default patch_shape=(4, 16) tiles it into |
| # 6 channel groups × 32 time chunks = 192 patches of 4×16=64 values each. |
| patches = X.unfold(0, 4, 4).unfold(1, 16, 16) # (6, 32, 4, 16) |
| patches = patches.contiguous().view(6 * 32, 4 * 16) # (192, 64) |
| # Per-bin head (output 512 logits per class): un-patch the time dim back to 512. |
| ``` |
|
|
| With 24 channels, 4-row patches give 6 channel groups (24 = 6×4 exactly, |
| no padding): pipes (rows 0–6 + L2 hit rate), discriminators + nsys |
| (rows 8–16), SASS modality (rows 17–23). The smaller patch count |
| (192 vs 512 in the old 64-channel layout) makes inference cheaper. |
|
|
| ## 11. Pipeline references |
|
|
| - **Single source of truth for the tensor schema**: |
| `tools/render_model_input.py:CANONICAL_INPUT_CHANNELS` (24 entries). |
| - **Single source of truth for the label vocab**: |
| `tools/workload_taxonomy.py` (`VOCAB_L1`, `VOCAB_L2`, `ATTRIBUTE_FLAGS`, |
| `SPATIAL_STATE_VOCAB`, `L2_PARENT_L1`). |
| - **CI invariants**: `tests/test_tensor_invariants.py` (thousands of assertions |
| across every collected snapshot), `tests/test_label_smoke.py` (synthetic |
| end-to-end smoke), `tests/test_splits.py` (split coverage / disjointness). |
| - **Reproduction commands**: `kernels/<motif>/run.sh` per motif; |
| `dev/launch_parallel.sh` + `dev/launch_kernelbench.sh` for batched GPU |
| dispatch via `crun`. |
|
|