Skip to content

Sweep the GEMM's pair tile and pipeline depth: [256,256] at three stages should dominate on paper #87

Closed

Description

@feitreim

The GEMM's pair tile is [256, 128] — BLOCK_M = 128 per CTA over a 2-CTA
cluster, BLOCK_N = 128 for the pair, BLOCK_K = 64, STAGES = 3. Nobody has
swept it. #84 gave us the tool that makes the sweep predictable rather than
exploratory: residency is exactly min(512/columns, shared_per_SM/plan) at
all fourteen rungs measured, so the occupancy half of every candidate can be
computed before it is built and then counted to confirm.

Arithmetic intensity for a pair tile [M, N] is M·N/(M+N), so:

pair tile stages intensity shared CTA/SM A+B traffic at 1081 TF at 2200 TF
[256,128] 2 85.3 49216 4 12.7 TB/s 25.8
[256,128] 3 — today 85.3 73792 3 12.7 TB/s 25.8
[256,128] 4 85.3 98368 2 12.7 TB/s 25.8
[256,256] 2 128.0 65600 2 8.4 TB/s 17.2
[256,256] 3 128.0 98368 2 8.4 TB/s 17.2
[256,256] 4 128.0 131136 1 8.4 TB/s 17.2

One K stage is 24576 B at BLOCK_N = 128 (ATile 128x64 plus BTile 64x64,
bf16) and 32768 B at 256. Shared per SM taken as 233472 B — derive this rather
than trusting it
, #84's census brackets it and the exact figure matters here.

Two things the table says that are not obvious

Doubling N buys 1.5x, not 2x. M·N/(M+N) is not linear in N.

BLOCK_N = 256 is the first place the TMEM term binds. 256 accumulator
columns a CTA means 512/columns = 2 before shared memory is even consulted —
every kernel in this repo so far was capped by the shared term. Which makes
[256,256] @ STAGES = 3 the standout: TMEM already caps it at 2 CTAs/SM, so
the third stage is free, costing shared memory that residency was not going to
use. Same 98368 B and same 2 CTAs/SM as [256,128] @ STAGES = 4, at 1.5x the
intensity — it strictly dominates that rung.

Why this is not a free win

Against today's kernel it trades one CTA/SM for a third less traffic, and
which way that lands depends on whether the kernel is bandwidth- or
latency-bound. #86 is the prerequisite and this issue should not start
before it answers. Lower residency is exactly what #47 and #67 both measured as
expensive when a kernel has nothing in flight.

Note also that MmaShape must have the rung: the walk is M256_N128 today.
Check what tcgen05 and the library actually support before designing around a
shape that cannot be issued.

Scope

Acceptance

Exact at every size before any timing (modal run modal_app.py::examples), a
counted residency per rung, and a recommendation with the losing rungs' numbers
kept rather than dropped. A rung that is slower is a finding.

Related: #86 (the bound, and the prerequisite), #84 (the residency formula and
the census), #83 (the current table), #63.

Activity

  1. added
    area:compute
    on Jul 28, 2026
  2. feitreim commented on Jul 28, 2026

    @feitreim
    OwnerAuthor

    Closed by #104.

    Shipped: [256, 256] @ STAGES = 3 — 1457.1 TFLOP/s at 8192³ and 1622.5 at 16384³, which is 0.826 and 0.886 of cuBLASLt against 0.740 and 0.728. All five rungs kept in bench --case tile; the old tile stays launchable as the control.

    The prediction in this issue was right for the wrong reason, and the coordinator's brief was wrong outright. #87 argued from arithmetic intensity and I briefed the agent that boundary count would be the stronger mechanism. Intensity is the whole win: re-running gemm-depth on the new tile moves the fit's slope +21–23% and moves its intercept the wrong way, +74%. Halving the tiles does not halve the boundaries on the critical path, because the occupancy step halves the clusters too — items per cluster fall only 10 → 7, while a boundary draining twice the columns costs more than twice as much.

    A control this issue did not propose is what makes the result attributable. [256,128] @ STAGES = 4 has the same shared plan and the same residency as the winner at an unchanged tile, so it prices the occupancy step alone at −7.7% / +2.1% — leaving the tile worth +20.8% / +19.2% net.

    The ~1460 TFLOP/s band was a property of the tile, not the device. Four numbers by three routes had converged on 1437–1480; [256,256] measures 1718.5 at K = 32768, straight through it. Three shapes agreeing meant one shared term bound them, and all three had the same tile.

    The TMEM half of min(512/columns, shared_per_SM/plan) binds for the first time in this repo. [256,256] @ s2 is the first rung where resident ≠ holding — 3 resident, 2 holding, with a 100.0 µs wait against 0.9 µs on every shared-bound rung. Predicted and counted agree at all four rungs.

    Two findings nobody asked for: a fourth pipeline stage nearly pays for the CTA it costs (#98 priced that step at 13.6–16.1% on dead bytes; with a live stage it is 7.7% and −2.1%), and the reverse trade is a disaster — [256,128] @ s2 steps residency up to 4 CTAs/SM with the best wave efficiency and best reuse in the table and loses 35%.

    Costs, stated rather than buried: n % 256 == 0 where 128 used to do, and 1024³ regresses 18% — everything at and above 2048³ improves. Both are tile quantization, and both are #105.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:compute

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions