Repository navigation
Fix persistent flash forward stream-B regression (HD=128); restore it as the model forward - #48
Merged
Merged
Conversation
Stream B ran on warps 2-3 (warpgroup-0 positions 2-3), but a tcgen05.ld warp reaches only TMEM lanes (warp%4)*32..+32 and a 64-row tile's M128 accumulator keeps its real rows in lanes 0..63. Stream B thus drained the undrained phantom rows (lanes 64..127): the inflated max underflowed every P=exp2(s-m_ref) to ~0, so y=0 with a corrupted LSE. The TILE 128->64 conversion shrank each stream from a 4-warp warpgroup to 2 warps and left B off a warpgroup boundary. Move stream B to warps 4-5 (warpgroup-1 positions 0-1 -> lanes 0..63) and the TMA/MMA warps to 2-3; pure relabel, block stays 192. Re-include persistent in both parity harnesses and switch the model forward back to forward_persistent (it profiles ~20% faster than pipelined: forward.attention.flash 3.07 -> 2.45 ms at the sec-13.9 shape). Partially addresses #47 (item 1); item 2 (M64 operand-K mispairing) left open with findings in an issue comment.
feitreim
added a commit
that referenced
this pull request
Jul 23, 2026
…lock model Integrates the two parallel lines: the L=12 multi-block MoE refactor and the tcgen05 flash HD=128 conversion. Canonical profile/train config is L=12 D=3072 H=24 HD=128 FF=4096 B=12 T=2048 C=6144; tiny gates keep the D=512/H=4/HD=128 shapes and raised overfit budgets from #46.
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.
Fixes the persistent (phase-3) forward's stream-B regression from the HD=128 conversion (#46), re-includes it in both parity gates, and switches the model back onto it — it profiles faster than the pipelined forward it temporarily replaced.
Partially addresses #47 — lands item 1 (stream-B regression). Item 2 (M64 operand-K mispairing) is left open with findings posted as a comment on the issue.
Root cause: a TMEM lane-access / warp-placement bug
Stream B (query tile
2p+1) output exactly0and a too-large LSE; stream A was correct. It was not a TMEM-column overlap or an operand bug — the column layout (S_A 0..64, S_B 64..128, O_A 128..256, O_B 256..384) is correct and fits 512.A
tcgen05.ldwarp can only reach TMEM lanes(warp_id % 4) * 32 .. +32. A 64-row tile'sM128accumulator keeps its real rows in lanes 0..63 (the phantom rows 64..127 are never drained). When the conversion droppedTILEfrom 128 to 64, each stream shrank from a full 4-warp warpgroup to 2 warps, and the dispatch left stream B on warps 2–3 (warpgroup-0 positions 2–3 → hardware lanes 64..127). So stream B's softmax drained the phantom rows: the garbage inflated the running max, everyP = exp2(s − m_ref)underflowed to ~0, andycame out0with a corrupted LSE — which is why bothyandlsewere wrong, not justy. The stalelaunch_bounds(320)over a 192-thread block was the tell: at HD=64/TILE=128 the streams were warps 0–3 and 4–7, each naturally draining all 128 lanes.Fix: move stream B to warps 4–5 (warpgroup-1 positions 0–1 → lanes 0..63) and put the TMA/MMA warps on 2–3. A pure relabel of the dispatch; the block stays 192 threads and every per-stream offset is unchanged.
Model switched back to persistent (it's faster)
Kernel bench
[32,1024,24,128]: persistent 1.937 ms / 226.2 TFLOP/s vs pipelined 2.425 ms / 180.7 TFLOP/s vs sync 3.526 ms / 124.2. Soflash_attention_forward_intois restored toforward_persistent+flash_persistent_config(reverting 3e2c823).Item 2 (M64 operand-K mispairing): not addressed
Not cracked and not shipped — the
M128-over-64-row workaround stays. It's a genuine operand-K addressing issue, distinct from the item-1 lane bug; doc research + analysis are written up in a comment on #47 for a future pass. (transpose_b_probeis retained.)Gates (B200)
./run.sh flash-attn flash— sync + pipelined + persistent forwards and both backward kernels vs the staged-bf16 CPU reference overT ∈ {128,256,384,512,1024},B·Hup to 152; probes green (swizzle, score_mma 1.9e-6, exp2/log2). Persistent max abs: y 1.5e-3, lse 7.3e-5../run.sh flash-attn— cross-oracle parity incl. persistent vs per-row and tiled oracles: y 2.4e-3, lse 1.2e-3../run.sh model— all 15 gates green with the model on the persistent forward (Dense fwd/bwd+AdamW, Muon, Newton–Schulz, expert/MoE parity, MoE overfit 2.94→5e-6, AdamW/Muon tiny overfit →0, block linears overfit →7e-6/0, checkpoint v3 bit-identical).BASELINE_REF=main ./run.sh model profile— apples-to-apples vs main (both HD=128; baseline main runs the pipelined forward, candidate runs persistent) at §13.9 (B=12 T=2048 D=3072 H=24 HD=128, single block):Only the forward changed (backward kernels are identical on both branches); the persistent forward saves ~0.62 ms/block on attention.