Skip to content

A map walk's frame is a band that does not fit, and groupnorm_tile streams its own (#166) - #181

Merged
feitreim merged 2 commits into
mainfrom
probe/map-walk-remainder
Aug 3, 2026
Merged

feitreim merged 2 commits into
mainfrom
probe/map-walk-remainder

Conversation

@feitreim

@feitreim feitreim commented Aug 3, 2026

Copy link
Copy Markdown
Owner

The second of #166's three remainder kernels, and the one whose fix is not unrolling. A reg.rs map walk's .local frame is a register tile that does not fit — groupnorm_tile held its whole [32, 128] band, 128 fp32 a thread against a 168-register cap — so the cure is the one layernorm_rows already proved: stream the band a CHUNK at a time so it never exists whole.

First, the check. groupnorm_tile had no launcher and no reference ("a rewrite nothing can check is not an improvement" — docs/kernels/layernorm.md), so the first commit builds run_group/check_group/bench_group on the existing seed: three tile statistics cover every grid the way three class statistics cover the row check, and the error is absolute because the outputs are zero-mean unit-variance with nothing holding one away from zero. The unmodified whole-band kernel passes its first-ever check — worst absolute error 7.76e-3, which is 0.99 × 2⁻⁷, half a bf16 ulp at the seed's largest normalized outputs in [2, 4); tolerance 2⁻⁶, one doubling above.

Then the rewrite, all measured on B200 in-container:

groupnorm_tile regs frame blocks/SM GB/s at 8192 blocks
whole band, as filed 168 1536 B 3 594
streamed at CHUNK 48 0 6 5996

A factor of 10.1 at a bit-identical worst error, 8% above layernorm_rows' 5539 (same traffic minus two parameter vectors), launch floor 21.9 µs → 9.6 µs. The carry across chunks is one scalar per statistic — a chunk's tile_sum is already a number the warp agrees on. launch_bounds moves 3 → 6: shared memory is the binding term now, same as the sibling, and at 48 registers the 168-vs-236 crate-composition hazard that forced the old cap is gone (both crates read identical 48).

The depot census now reads 1 of 12 shipped kernels carry local memory — flash_forward alone, whose accumulator band is the algorithm's own live state; its launcher/reference (#85 prerequisite) is in flight separately.

Validation: build, examples (all checks pass, occupancy table shows 6), bench --case groupnorm (table above), regcount (all gates green, occupancy gate reads the new literal: 48 regs against an 80 ceiling).

@feitreim feitreim added the gpu-ci Run the B200 device-test tier on this PR (costs GPU minutes) label Aug 3, 2026
@feitreim
feitreim merged commit c83091b into main Aug 3, 2026
4 checks passed
feitreim added a commit that referenced this pull request Aug 6, 2026
…, and both 256-wide entries take it now (#197)

* The warpgroup split lost to a `.local` depot rather than to the lanes, and both 256-wide entries take it now

`bench sol-ablate`'s table 6 recorded the epilogue's column split losing 1.4 to
1.8% at 4096³ and winning 0.3 to 0.4% at 8192³, and the reading offered was
hardware: warps 0 and 4 own the same 32 tensor-memory lanes, so splitting an
accumulator's columns puts two requesters on each of four sub-partitions rather
than spreading over eight.

That argument is still true and it was not what the table measured. Every row
of it was taken through a `.local` depot the library no longer emits —
`store_tile_x4` homed each drained band to local memory until the rolled walks
were marked (#166, landed in #180/#181/#184), and a band *is* the frame, a
`RegTile<32, 64>` being 64 f32 being 256 B. The split pays that frame twice per
accumulator where one warpgroup pays it once, so the arm doing more of the
broken thing read as the arm that was worse.

Re-run at f64a27b, same table, same two round-robin passes, `regcount` reading
zero stack and zero spill on every `gemm_sol` rung:

  4096³ [256, 256]   launch +0.8%, +0.9%   drain 3.35 -> 3.10, 3.28 -> 3.17 us
  8192³ [512, 256]   launch +2.1%, +2.1%   drain 4.72 -> 3.05, 4.70 -> 3.04 us

The sign reverses at both entries and both passes, and the term that was blamed
is the term that moves: the drain gets 35% cheaper at [512, 256] rather than
slower. The `no drain` control at its own 320 threads still matches the
192-thread one to a tenth of a percent, so the extra warps remain free when
they do nothing.

`SHIPPED_GROUPS` is `TWO_WARPGROUPS` for `gemm_sol_m256` and `gemm_sol_m512`.
The shared plan is byte-identical either way — eight warps stage half the
columns each — so no `dynamic_shared` moves; what moves is the block, to 320,
which is why `Variant::threads` now sits beside `Variant::shared_bytes` and the
launcher asks the variant instead of reading one `THREADS`.

`gemm_sol_m256_n128` keeps one warpgroup. The split is legal there and the
asserts cover it; table 6 simply has no `[256, 128]` arm, and shipping it would
be shipping a geometry nothing here has timed.

The ablation and watch probes are pinned to `ONE_WARPGROUP` explicitly rather
than following `SHIPPED_GROUPS`. They were reading the shipped constant to mean
"the geometry this ladder is held at", and those are two different facts: with
`SHIPPED_GROUPS` flipped, thirty-three probe kernels would have silently
reshaped and every historical arm would have stopped comparing to itself.

The three entries join `GATED_KERNELS`. Their residency is fixed by the shared
plan and no register count can raise it, but at 320 threads a thread may have
168 registers before an SM cannot place one CTA at all — a launch the driver
refuses rather than a slow one. They read 82 and 83 against that step.

* The PR number the three notes point at is 197
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gpu-ci Run the B200 device-test tier on this PR (costs GPU minutes)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant