Repository navigation
The .local fix turns the RMSNorm forward tile over, and only the forward (#70) - #78
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the RMSNorm half of #70. The
kittenspin is #76'sc648c67and 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
.localdepot 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.rsshapes, three warmups and twenty timed iterations per row, one container:rms_norm_forwardrms_norm_backward_xfused_classifier_forward_bf16Against #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:
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_tileandrms_norm_backward_x_tilecome out of ptxas with no.localdeclaration 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_WARPSbarely 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_sumbeing 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 oneright_fillon 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, becausesetunder a data-dependent condition keeps the slot array addressable. ferro-kittens#180 did not cover it;src/reg.rshas no__unroll_configanywhere.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_tileand the fiveNORM_TILE_*knobs a--sweepturns.rms_norm_forward_fastis untouched and stays the arm every non-dividing shape takes.gpu/ops/src/main.rs:check_rms_norm_tile, against the same CPURmsNormoraclecheck_rms_normuses, at an aligned1024 x 192— the tile kernel takes its divisibility from the launcher and bounds-checks nothing, so the shape that exercises it is notcheck_rms_norm's deliberately unaligned one.192divides by everyNORM_TILE_CHUNKup 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 toreport_onecarrying, 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.