Article
KernelTSLM
Winner · TimeNet Online Hackathon, Round 1While a kernel runs, an NVIDIA H100 records 24 hardware counters over time. KernelTSLM, a fine-tuned time-series language model, reads them the way a doctor reads an ECG, and writes down what slows the kernel down. Below, six test kernels it never saw in training play one after another.
Reading by the model
The project
- Problem
- GPU profilers record dozens of hardware counters while a kernel runs. Turning them into an answer to "why is this kernel slow?" (memory bandwidth, tensor cores, idle gaps between launches, or something else) takes an expert.
- Who it helps
- Engineers who write or tune GPU kernels in CUDA, Triton or PyTorch and want a first diagnosis before they open a profiler.
- What it does
- Reads 24 counters, each sampled 512 times over a kernel's run, and answers four questions in plain words. Every fact it states is a number you can check against the counters.
- How it uses TimeNet
- We wrote the TimeNet connector that loads KernelSight (OpenTSLM/TimeNet PR #835). It also adds a train/test split grouped by problem, so a near-copy of a test kernel can't end up in training.
- Data
- KernelSight: 1,444 kernel traces from one H100 (GEMMs, attention, convolutions and fused KernelBench problems), 24 counters over 512 time bins each, with a workload label per bin. We split them into 862 training, 291 validation and 291 test traces, keeping each problem on one side.
- Model
- OpenTSLM-Flamingo on Gemma 3 4B, with the language model frozen. One fine-tune on 6,158 questions per epoch across all four tasks: 2 epochs, 64 minutes on one Nebius H100.
- Terms on this page
- A counter is one hardware measurement, such as DRAM read bandwidth. The limiter is the part of the GPU that caps a kernel's speed. Test kernels come from problems the model never saw in training. Reference answers come from fixed rules over the counters; the model learns to give the same answers in words.
Data and TimeNet: the conversion, checked
- 1,444
- traces converted to TimeNet
- 34,656
- counter signals
- 601,292
- TimeNet tasks
- 0
- values changed: every array checked bit for bit against the source
- 0
- records missing, duplicated or in two splits
Four use cases, one model
Each answers a question an engineer asks about a kernel trace. The examples are the model's answers on the Matmul + activation kernel from the demo; the timeline shows the reference answer.
ADiagnose a slow kernel
For a kernel that is slower than it should be. It names the limiter, states up to three facts with numbers, and suggests one thing to try.
What limits this kernel, and what should I try?
78.7% right limiter. Right next step 69.8%; 82.5% of stated facts match the counters.
BLay out what ran when
For a run with several phases or unexpected idle time. It marks which of the 512 time bins are busy or idle and names the work in each.
What ran when?
89.7% of time bins right. Busy or idle right in 91.9%.
CAnswer timing questions
For how one counter behaves over the run: rising or falling, peak before or after a point, length of the longest idle gap.
80.3% of 1,000 questions right, up from 25% before fine-tuning.
DName the kind of work
For sorting traces from unknown kernels: matmul, attention, convolution, softmax, pooling and six more types.
What kind of work is this kernel doing?
88.7% right; 74.7% when each of the 11 types counts equally.
How we trained it
We fine-tuned OpenTSLM-Flamingo (Gemma 3 4B) with the model code and training recipe of the AWS sample opentslm-finetune-arfbench: the language model stays frozen and only the parts that read the time series learn. What we added: our data and four question sets, all four tasks in one run, time-reversed training questions, and tests that break the trace.
- 1
- training run
- 4
- tasks at once
- 6,158
- questions per epoch
- 2
- epochs
- 64 min
- on one H100
The shortcut: our first models read the summary, not the signal.
Each counter arrives as a text line with its mean and standard deviation, plus the curve itself. Shown: the real lines for the Matmul + activation test kernel. In four early one-epoch pilots, the model answered from the text lines and did not read the timeline.
We break the trace, and keep the text the same.
If the answer doesn't change when only the curve changes, the model isn't reading the curve. Curves shown: SMs active of the Matmul + activation test kernel; swapped from LeakyReLU.
The fix: train it so the shortcut stops working.
- All four tasks in one run, for two epochs.
- Time-reversed copies of the trend questions, with the answer flipped, so "usually rising" is no longer a safe guess.
| Test score | One task only | All four tasks |
|---|---|---|
| Diagnosis, right limiter | 78.0% | 78.7% |
| Work type, balanced | 73.1% | 74.7% |
One model for four tasks costs nothing: it matches the single-task fine-tunes.
How it compares
Scores on the test set. On every task a model built for that task alone scores higher. KernelTSLM answers all four with one model, in plain words, with facts you can check.
Diagnosis, base model:0valid (20 tried)fine-tuned:78.7%right
Does it read the trace?
A model could score well from averages alone. We broke the traces by shuffling their time order or swapping in another kernel's counters, then asked again.
Filled dots: real traces. Open dots: broken ones. On the last row each trend question was asked on the trace and on the trace reversed; a model that ignores time order would get both right 0% of the time.
What we found
The diagnosis predicts which kernels speed up.
The dataset has each kernel in two number formats, fp32 and the half-size bf16. Kernels the reference calls memory-bound in fp32 ran 1.68 times faster in bf16, because they move half the bytes. Kernels it calls ALU-bound ran 1.01 times as fast. So a "memory-bound" diagnosis tells you that switching to bf16 is worth trying.
68 and 18 kernel pairs, measured from kernel timingThe dataset's own split leaks test kernels into training.
120 of the 160 official test traces have a near-copy in official training: the same problem with a different number format, random seed or launch setting. MiniRocket scores 0.999 on that split and 0.940 on ours, which keeps each problem on one side. Our TimeNet connector adds this grouped split.
84 of 401 problems cross the official splitA released model explains things its input doesn't show.
We tested OpenTSLM's released activity-recognition model. Its answers use time order: accuracy falls from 0.58 to 0.265 when we shuffle the input. Its explanations don't: it calls the motion periodic in 46.5% of shuffled windows, almost as often as in real ones (49.5%), although shuffled data has no rhythm. So we made every fact in our readings checkable against the counters.
gemma-3-270m-pt-har-flamingo, 400 test windowsLimits and next steps
What to keep in mind
- Reference diagnoses come from fixed rules on the counters. No performance engineer labelled them.
- Much of the answer is in the counter averages. Logistic regression on them names the limiter 93.8% of the time.
- The model often misses rare limiters. Counting each limiter equally, it is right 50.3% of the time.
- All traces come from one H100 and cover one short kernel each. Results come from a single training run.
Next
- Diagnoses labelled by performance engineers, to replace the rules.
- Traces from more GPUs and from multi-kernel workloads.
- More seeds, to put error bars on the fine-tune.
Reproduce
uv run usecases/<task>/build.py uv run baselines.py # training on one H100: # see gpu/README.md
Every number on this page comes from a file in runs/; the README names each one.