Skip to content

[Perf][GEMM] Read less DRAM at the power cap: one raster group for q-b, fewest CTAs on uniform coop2 grids - #2794

Merged
lcy-seso merged 2 commits into
tile-ai:mainfrom
bigSheep123:gemm-power-2791-pr
Oct 30, 2026
Merged

lcy-seso merged 2 commits into
tile-ai:mainfrom
bigSheep123:gemm-power-2791-pr

Conversation

@bigSheep123

@bigSheep123 bigSheep123 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Part of #2791.

Summary

  • _group_size_m: when A fits in one L2 partition and B does not, one raster group spans every row, so each B tile is read from DRAM once instead of once per 16-row group. On ds-v3 prefill q-b (4096×24576×1536 NT), DRAM reads drop from 168 MB to 94 MB. _narrow_tiles bounds its split as a 16-row group does, so its pick does not change.
  • _persistent_ctas: a coop2 or coop2_swap grid with uniform tile widths launches ceil(tiles / ceil(tiles / sm_count)) CTAs instead of sm_count. The busiest CTA runs as many tiles either way, and each wave reads fewer distinct panels. Ping-pong, narrow and mixed-width grids keep sm_count.

Test plan

  • pre-commit run on the changed files
  • pytest tests/ops/test_gemm.py on H200: 212 passed, 24 skipped

Benchmark

Environment: H200, CUDA 13.2, PyTorch 2.13.0, TileLang 0.1.12

GemmFwdOp, busy time (bench_gemm.py)

main and this PR alternating, 4 rounds each, on two idle H200s (GPU A / GPU B); medians in µs. Ratio = best baseline / TileOPs.

Shape (M, N, K) layout dtype main this PR ratio main → PR
(4096, 24576, 1536) q-b NT bf16 403.8 / 405.5 402.4 / 404.7 1.002 → 1.004 / 0.998 → 1.000
(4096, 7168, 4096) wgrad-mlp-up TN bf16 333.0 / 333.5 330.7 / 332.1 1.010 → 1.017 / 1.007 → 1.011
(4096, 4096, 4096) square-4k-tt TT bf16 197.2 / 198.2 196.2 / 197.3 1.002 → 1.008 / 1.001 → 1.004

Every other manifest row keeps its config; on both GPUs all 24 rows read within noise of main (time new / main 0.989–1.008).

GemmFwdOp, back to back at the 700 W cap

Back-to-back calls of one op, clocks unlocked, 1 s warm-up then 1.5 s timed, alternating rounds; ratio = best baseline / TileOPs.

Shape (M, N, K) layout main this PR
(4096, 24576, 1536) q-b NT 0.986 0.998–1.000
(4096, 7168, 4096) wgrad-mlp-up TN 0.999 1.006
(4096, 4096, 4096) square-4k-tt TT 0.995 1.007

Off the manifest, the fewest-CTA grid is 0.4–2.8% faster in busy time on 15 of 16 coop2 / coop2_swap shapes across NT, TN and TT, and up to 2.5% faster back to back. Applied to ping-pong it measured no busy gain and 0.8–1.3% slower back to back on 3072×5120×4096, so ping-pong keeps sm_count.

Takeaways: q-b reaches cuBLASLt-best back to back, and the two TN/TT rows go from level to ahead. o-proj, down, mlp-up and wgrad-q-b still trail back to back; no selector change closes them without a busy-time regression, so they stay open under #2791 for kernel work.

…partition and B does not

At the power limit DRAM reads lower the clock. On ds-v3 prefill q-b
(4096x24576x1536 NT) B overflows one L2 partition while A fits, so a
16-row group re-reads each B tile from DRAM once per group. One group over
all rows reads it once: DRAM reads drop from 168 MB to 94 MB and
back-to-back time by 1.0-1.5%, level with cuBLASLt-best; busy time is
unchanged or better. _narrow_tiles bounds its split as a 16-row group
does, so its pick does not change.

Part of tile-ai#2791.
…rm coop2 grids

A persistent coop2 or coop2_swap grid with uniform tile widths now launches
ceil(tiles / ceil(tiles / sm_count)) CTAs instead of sm_count. The busiest CTA
runs as many tiles either way, while each wave reads fewer distinct panels.

- Manifest busy time: every row level or faster; 4096x4096x4096 TT and
  4096x7168x4096 TN 0.4-0.6% faster.
- Back to back at the power limit: the same two rows 0.3-1.0% faster.
- 16 off-manifest coop2/coop2_swap shapes: 0.4-2.8% faster in busy time.

Ping-pong grids, which the selector already sizes to fill their waves, keep
sm_count: they measured no busy gain and up to 1.3% slower back to back.
Narrow and mixed-width grids keep sm_count, which their widths were chosen for.

Part of tile-ai#2791
@bigSheep123
bigSheep123 requested a review from a team October 29, 2026 13:44
@github-actions github-actions Bot added the perf Performance improvements label Oct 29, 2026
@lcy-seso
lcy-seso merged commit 1301da6 into tile-ai:main Oct 30, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf Performance improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants