Repository navigation
The dW epilogue never reads C: reduction TMA stores for the fp32 accumulate path (#80 remedy 1) - #82
Merged
Merged
Conversation
… through the copy engine (#80 remedy 1) The fold read C back at +25-29% over its own store at K=6144 and made the two per-expert dW rows the worst in the table (0.666x/0.588x of cuBLASLt). It is replaced by ferro-kittens #42's reduction TMA store: the accumulate kernel's drain scatters each [16, 64] fp32 half-band into the staging tile the bf16 drain already planned (byte-identical 4096 B, SHARED_BYTES unchanged) and cp.reduce.async.bulk.tensor.add adds it into C in fp32 - SPEC decision #20's precision, one engine-side add per element per launch, one CTA per tile, so the element-wise order is as deterministic as the register fold's was. The split pays twice: the new gemm_tcgen05_f32_accumulate is 80 regs with no local frame, and the store kernel drops 120/512 to 102/0 because it no longer monomorphizes a C load beside the band - both ratchets down in the same change. C reaches the kernel as a rank-2 fp32 tensor map (box [16,32]) built and cached host-side per (address, n, m); the f32_accumulate* adapters keep their signatures, so gpu/model needs only the kittens pin bump its #[path] include of this source forces (c648c67 -> 969d7f4, the delta being ferro #183's scatter_tile and the #42 store itself). Measured (B200, model_shapes vs cuBLASLt 13.0): the four f32 acc-T rows 0.666->0.886, 0.588->0.777, 0.881->0.952, 0.892->0.942, with the fold premium collapsed to +0.3..+9.8% and bwd down dW's accumulate now cheaper than its own store (-1.1%); every f32 store row improves too on the 102-reg kernel. Full tables in the PR.
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.
Remedy 1 from #80: the fp32 accumulate fold — the epilogue that read
Cback at +25–29% over its own store at K=6144 — is deleted. The accumulate path now reduce-stores: each warp scatters its[16, 64]fp32 half-band into the staging tile the bf16 drain already planned (byte-identical 4096 B,SHARED_BYTESunchanged) andcp.reduce.async.bulk.tensor.2d...addadds it intoCat the copy engine.Cis never read by a thread.Ferro side: feitreim/ferro-kittens#187 (issue #42's sanctioned scoped fallback —
add, rank 2 only; upstream admission filed as NVIDIA/cuda-rust#660).gpu/gemmandgpu/modelpin that branch rev (969d7f4) until it reaches ferro main; thegpu/modelbump is forced by its#[path]include of gemm's source, and the pin delta beyond #187 is only ferro #183 (scatter_tile) + docs. The ferro branch must not be deleted until swap to a main rev.model_shapes, before (#80 baseline) → after (two runs, separate containers)
The decompose sweep is the diagnosis confirmed: the fold premium over store-T collapsed from +25–29% to +0.3…+9.8%, and on the worst row (
bwd down dW) the accumulate is now cheaper than its own store (−1.1% / −2.2% across the runs). What remains below 0.90 on those rows is the store/walk baseline at shallow K — #80's remedy 2 (drain–MMA overlap), untouched here.The f32 store rows improved without being targeted: removing the fold from the shared kernel body dropped
gemm_tcgen05_f32_optimizedfrom 120 regs / 512 B local frame to 102 / 0 (the frame was ferro #174's "band plusCbeside it"). The newgemm_tcgen05_f32_accumulateis 80 regs / 0 — below even the bf16 drain. Both ratchets down in this PR.The two bf16 rows are byte-identical kernels (82 regs before and after); their drift (0.937→0.905/0.921 on bf16 acc-T, with cuBLASLt itself −3–5% in the same containers) is cross-container variance, not this diff. bf16 reduce-store was checked before building and skipped: the row's gap is 0.3 ms/step.
Full-step A/B — same container,
--baseline-ref da32b09Base rev note: this branch (and its A/B baseline) is
da32b09, the pre-#81 main; #81 (MoE routing fusion) merged during verification and merges cleanly with this diff (no overlapping hunks). The A/B below isolates this diff's delta.No profile row regresses (largest positive delta +0.006 ms). The −10.4 ms on dW rows lands in the predicted −10–15 ms band; the −6.5 ms on store rows is the register/frame windfall on top.
Numerics (SPEC decision #20)
.addon an fp32 tensor map is an fp32 round-to-nearest add — weight-gradient accumulation stays fp32 end to end, nothing rounded on the way through.old + new, the same shape as the register fold's — deterministic.C, tolerance and bitwise agreement checks) pass, but it is a semantic difference from the register fold in the last bit of the denormal range.model_shapes' from-zero bitwise agreement check (store-T vs one acc-T launch) still passes: the reduce adds exact values to exact zeros.Gates
gemmcorrectness (Modal B200): green — including the transposed f32 accumulate against a nonzero seededC(check_tcgen05_bf16_transposed,uniform_vec-seeded initial) and the bf16 fold-into-nonzero check; a zero-seeded accumulate could not tell store-with-add from store, and none of the accumulate gates are zero-seeded.modelparity: green (block linears match CPU forward/backward, overfit + Muon overfit pass).benchregression check: f32 accumulate 0.813/0.926/0.896 of cuBLASLt at 2048³/8192³/16384³, at or above the store mode's own ratios at depth; no store row regresses.tma reduce-add store— a seeded destination reduce-stored twice reads backseed + 2·valuebit-exactly on a B200, which no overwrite can fake (51/51 cases green).KernelBudgetratchets: bf16 82/0 (unchanged), f32 store 120/512 → 102/0, f32 accumulate pinned at 80/0.Closes nothing yet: #80 stays open for remedy 2 (drain–MMA overlap), which now owns the residual on every sub-0.90 row.