Commit 24ad1e9
ggml-cuda: add per-op GPU roofline profiling for the HIP backend
Optional profiler (GGML_HIP_ROOFLINE, off by default) that attributes each GPU
kernel's device-measured time to the ggml op that launched it and writes a JSON
report, one row per op invocation listing every kernel that op dispatched.
Aggregation (grouping identical ops, averaging, counting) is left to the consumer.
Activated at runtime by GGML_ROOFLINE_OUT=<path>; otherwise every entry point is a
no-op.
Kernel durations are read from device dispatch timestamps (the same source as
rocprofv3) and match rocprofv3's measurements. An earlier approach based on host
CUDA/HIP events (cudaEventElapsedTime around each op) was giving wrong results: it
included kernel-launch bubbles and overstated GPU time by roughly 1.7-3x.
Uses rocprofiler-sdk, loaded with dlopen and configured at runtime with symbols
resolved via dlsym (the library is not linked, since its constructors abort when
linked into an early-loaded shared object). Disables GPU graphs while active so each
op's kernels are dispatched individually, which is required for per-op attribution.
llama-bench calls ggml_cuda_roofline_reset() after its warmup run (via a weak symbol
that is a no-op in non-roofline builds), so the report covers only the measured run,
not warmup.
Each row carries the op's destination/source shapes and types, HBM byte traffic,
matmul dimensions, and the name and device time of every GPU kernel it dispatched.
Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>1 parent 4b5ac96 commit 24ad1e9
8 files changed
Lines changed: 507 additions & 0 deletions
File tree
- .github/workflows
- ggml
- src
- ggml-cuda
- ggml-hip
- tools/llama-bench
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
| 223 | + | |
223 | 224 | | |
224 | 225 | | |
225 | 226 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
| 222 | + | |
222 | 223 | | |
223 | 224 | | |
224 | 225 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
5 | 9 | | |
6 | 10 | | |
7 | 11 | | |
| |||
4380 | 4384 | | |
4381 | 4385 | | |
4382 | 4386 | | |
| 4387 | + | |
| 4388 | + | |
| 4389 | + | |
| 4390 | + | |
4383 | 4391 | | |
4384 | 4392 | | |
4385 | 4393 | | |
| |||
5648 | 5656 | | |
5649 | 5657 | | |
5650 | 5658 | | |
| 5659 | + | |
| 5660 | + | |
| 5661 | + | |
| 5662 | + | |
| 5663 | + | |
| 5664 | + | |
| 5665 | + | |
| 5666 | + | |
5651 | 5667 | | |
5652 | 5668 | | |
5653 | 5669 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
11 | 18 | | |
12 | 19 | | |
13 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
38 | 45 | | |
39 | 46 | | |
40 | 47 | | |
| |||
2355 | 2362 | | |
2356 | 2363 | | |
2357 | 2364 | | |
| 2365 | + | |
| 2366 | + | |
| 2367 | + | |
| 2368 | + | |
| 2369 | + | |
| 2370 | + | |
2358 | 2371 | | |
2359 | 2372 | | |
2360 | 2373 | | |
| |||
0 commit comments