Skip to content

The .local fix turns the RMSNorm forward tile over, and only the forward (#70) - #78

Merged
feitreim merged 2 commits into
mainfrom
feat/ops-tile-relook
Aug 4, 2026
Merged

feitreim merged 2 commits into
mainfrom
feat/ops-tile-relook

Conversation

@feitreim

@feitreim feitreim commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Closes the RMSNorm half of #70. The kittens pin is #76's c648c67 and unchanged here.

#70 measured tile ports of RMSNorm and the fused classifier on a B200 and left both flat. The norms peaked at 0.83x/0.91x and fell off a cliff to 0.165x past 32 columns, which #70 identified as a .local depot rather than a register limit and could not fix from this side. ferro-kittens#180 unrolled every mover walk and that depot is gone. This re-measures both families against the fixed pin.

One of the three kernels turns over. The RMSNorm forward now wins by 1.243x and ports. The backward and the classifier still lose, and the reason they lose is the same fact that makes the forward win.

What the clock says

modal run modal_app.py::main --kernel ops --bin bench, bin/train.rs shapes, three warmups and twenty timed iterations per row, one container:

kernel shipped tile
rms_norm_forward 0.2174 ms, 4167 GB/s 0.1749 ms, 5179 GB/s 1.243x
rms_norm_backward_x 0.2680 ms, 5635 GB/s 0.2716 ms, 5560 GB/s 0.997x, not ported
fused_classifier_forward_bf16 1.4796 ms, 1675 GB/s 3.3491 ms, 740 GB/s 0.442x, not ported

Against #70's numbers for the same kernels: forward 0.837x → 1.243x, backward 0.905x → 0.997x, classifier 0.430x → 0.442x.

The cliff moved, it did not vanish

Sweeping the chunk width is the whole result, because chunk width is the only knob that puts more loads in a lane:

rows/warp chunk forward backward_x #70's forward
16 48 1.061x 0.865x —
16 64 1.246x 0.988x 0.280x
16 96 0.387x 0.249x —
16 192 0.345x 0.217x 0.116x
32 64 1.026x 0.818x 0.165x

64 columns went from 0.165x to 1.026x at 32 rows and to 1.246x at 16, and the new edge is at 96. That edge is a different failure from #70's: rms_norm_forward_tile and rms_norm_backward_x_tile come out of ptxas with no .local declaration at all at 64, so what breaks at 96 is a [16, 96] fp32 band no longer fitting the register file — ferro-kittens#181's category, not #180's. 64 sits under it.

NORM_TILE_WARPS barely matters (2 and 4 measure the same, 8 gives up the win), which is what you expect from warps that never talk to each other.

Why the forward wins and the backward cannot

#70 said the reduction was never what these kernels were waiting on, and that is still right — RegTile::row_sum being two shuffles against a shared-memory tree and eight barriers is not where the 1.243x comes from. What the tile buys is loads in flight, and it buys enough of them to beat a 64x cut in thread count: 6.3M threads become 98k, and a lane carries 64 columns where the block-per-row kernel carries 12.

The forward was the kernel with room for that. At 4167 GB/s against the 5635 the backward reaches over the same buffers on the same card, work per thread was the whole of the gap — #70 said so in as many words and proposed a two-rows-per-block variant of the existing kernel to collect it. The tile collects it instead, and lands at 5179.

Which is why the backward has no tile arm: it was already at the roof the forward just reached. Its tile version measured 0.985–0.997x across four shapes — the same rate from the same side, and matching is not winning.

The classifier is not close, and its frame is not why

0.442x at 64 classes per chunk, 0.224x at 128, 0.206x at 256, 0.367x at 32 rows per warp. It is the one kernel here that still carries a frame — 400 bytes — and the frame is real: RegTile::mask, behind the one right_fill on the vocabulary's ragged last chunk, walks slots by a runtime index and homes the whole 32-register tile once per chunk, all 786 of them, because set under a data-dependent condition keeps the slot array addressable. ferro-kittens#180 did not cover it; src/reg.rs has no __unroll_config anywhere.

Deleting that one call removes the depot and moves the kernel to 0.563x — so the frame is 27% of its runtime, and it is still not what decides the family. 24576 CTAs become 384. No tile shape reaches that, and the forward settles both directions because they share one reduction and one row walk.

Filed as feitreim/ferro-kittens#184 with the PTX and both numbers. I wrote the fix and did not push it: it drops examples/flash_forward's frame 1824 → 1568 bytes and takes it from 165 to 255 registers, which is ferro-kittens#181's band-that-does-not-fit surfacing honestly rather than a win, and no kernel I have gets faster from it. That is on the issue for the owner to call.

What is in the diff

  • gpu/ops/src/lib.rs: rms_norm_forward_tile and the five NORM_TILE_* knobs a --sweep turns. rms_norm_forward_fast is untouched and stays the arm every non-dividing shape takes.
  • gpu/ops/src/main.rs: check_rms_norm_tile, against the same CPU RmsNorm oracle check_rms_norm uses, at an aligned 1024 x 192 — the tile kernel takes its divisibility from the launcher and bounds-checks nothing, so the shape that exercises it is not check_rms_norm's deliberately unaligned one. 192 divides by every NORM_TILE_CHUNK up to 64.
  • gpu/model/src/lib.rs: norm_tiles(rows, columns) returns a launch only when the shape divides, and is the single place that is decided. One call site — GpuRmsNorm::forward_into. The training shape divides (24576 / 64, 3072 / 64).
  • gpu/ops/src/bin/bench.rs: a tile row for the forward; the backward and the classifier go back to report_one carrying, in the source, the rate and the ratio that left them flat.

Gates

  • modal run modal_app.py::main --kernel ops — green, no warnings.
  • modal run modal_app.py::main --kernel model — all fourteen green, including the Dense forward/backward-vs-CPU and both overfit gates. The tile arm is live in the training path.

…ard (#70)

#70 measured the RMSNorm and classifier tile ports on a B200 and left both
flat, with the best norm shapes at 0.83x/0.91x and a cliff to 0.165x past 32
columns that it identified as a `.local` depot rather than registers.
ferro-kittens#180 unrolled every mover walk and that depot is gone; this
re-measures the two families against the fixed pin (`c648c67`).

At 24576 x 3072 fp32, 3 warmups and 20 timed iterations, one container:

| kernel | shipped | tile | |
| --- | --- | --- | --- |
| `rms_norm_forward` | 0.2174 ms, 4167 GB/s | 0.1749 ms, 5179 GB/s | **1.243x** |
| `rms_norm_backward_x` | 0.2680 ms, 5635 GB/s | 0.2716 ms, 5560 GB/s | 0.997x |
| `fused_classifier_forward_bf16` | 1.4796 ms, 1675 GB/s | 3.3491 ms, 740 GB/s | 0.442x |

The forward ports. The other two do not, and the reason they do not is the
same fact that makes the forward win.

The cliff moved rather than vanished: 64 columns went from 0.165x to 1.026x at
32 rows and to 1.246x at 16, and the new edge is at 96, where a `[16, 96]` fp32
band stops fitting the register file. That is a different failure from the one
#70 hit — a band that does not fit, not a rolled walk — and 64 sits under it.

What the extra columns buy is the thing #70 correctly said the reduction was
not: loads in flight. This kernel trades 6.3M threads for 98k and wins anyway,
because a lane now carries 64 columns where the block-per-row kernel carries
12. The forward was at 4167 GB/s while the *backward*, over the same buffers on
the same card, was at 5635; work per thread was the whole of that gap, and
collecting it lands the forward at 5179.

Which is also why the backward has no tile arm. It was already at the roof the
forward just reached, and its tile version measured 0.985-0.997x across four
shapes — the same rate from the same side. Matching is not winning.

The classifier is not close and no shape helps: 0.442x at 64 classes per chunk,
0.224x at 128, 0.367x at 32 rows. It carries a 400 B frame that the rest do not
-- `RegTile::mask`, behind `right_fill`, walks slots by a runtime index and
homes the whole tile once per vocabulary chunk, which ferro-kittens#180 did not
cover because `src/reg.rs` has no `__unroll_config` anywhere. Deleting the
`right_fill` call removes the frame and reaches 0.563x, so the frame is real
and is not what decides this: 24576 CTAs become 384, and no tile shape reaches
that. Filed on ferro-kittens; the kernel stays flat either way.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant