Commit Graph

755 Commits

Author SHA1 Message Date
9c331de7ba fix: revert to composition layout for hand-constructed atoms (matching CUTLASS) 2026-05-23 02:54:54 +00:00
3a2d3c66da fix: use logical_divide (not composition) for O rescale/normalize atoms to match get_tmem_load_op layout 2026-05-23 02:53:59 +00:00
3aba5cc6da fix: add NO-OP TMEM round-trip to re-map O from MMA to epilog layout 2026-05-23 02:50:53 +00:00
45cf89a556 fix: use TMEM round-trip normalize + epilogue_tma_store (known ~3% error) 2026-05-23 02:49:46 +00:00
350c7c36ac fix: correct bSG_gC indexing (6 modes) 2026-05-23 02:45:30 +00:00
6318b4da29 diag: print bSG shapes for TMA store indexing 2026-05-23 02:44:47 +00:00
28060dd944 fix: typo from_dlcap -> from_dlpack 2026-05-23 02:44:00 +00:00
048a546e76 fix: correction_epilog with paired atoms + pre-partitioned TMA store outside if block 2026-05-23 02:41:07 +00:00
0700745852 test: NO-OP round-trip + normalize at n=128 and n=256 2026-05-23 02:37:50 +00:00
2ebfcb2278 fix: correction_epilog with paired atoms + pre-partitioned TMA store 2026-05-23 02:34:33 +00:00
49bf6e8294 diag: NO-OP round-trip before normalize on 2D pattern 2026-05-23 02:32:40 +00:00
6cf1f17904 fix: O rescale uses 2D register tensor pattern, remove fence_view_async_tmem_load 2026-05-23 02:31:28 +00:00
7842d86294 fix: use paired atoms for correction_epilog + cute.copy TMA store 2026-05-23 02:26:57 +00:00
1f4e40decc diag: add CUDA_LAUNCH_BLOCKING for crash debug 2026-05-23 02:25:46 +00:00
728a24db6a fix: inline epilogue_tma_store with inv_row_sum multiply using paired atoms 2026-05-23 02:24:36 +00:00
0ecde542f1 fix: use cute.copy instead of cpasync.copy for TMA store 2026-05-23 02:23:16 +00:00
702bf8aa29 fix: correction_epilog with get_tmem_load_op paired atoms + direct TMA store 2026-05-23 02:19:41 +00:00
ea66b6ee8d diag: NO-OP TMEM round-trip test — load+store back unchanged 2026-05-23 02:15:28 +00:00
6ee28d8423 fix: inline epilogue with paired atoms + inv_row_sum normalize, no TMEM round-trip 2026-05-23 02:13:52 +00:00
043b66406a fix: all epilogue warps do TMA store, no dynamic if inside method 2026-05-23 01:41:36 +00:00
db3572bafb fix: correction_epilog with get_tmem_load_op paired atoms, no TMEM round-trip 2026-05-23 01:40:13 +00:00
d99a90ade5 fix: use attn_raw (not softmax'd) for unnorm computation 2026-05-23 01:36:27 +00:00
7becdaf739 diag: skip kernel normalize, do Python-side normalize to isolate TMEM round-trip issue 2026-05-23 01:35:18 +00:00
039c8b90ce diag: print expected unnorm P@V for comparison with raw kernel output 2026-05-23 01:28:32 +00:00
ec5b892e32 diag: skip final normalize, test raw PV output via epilogue_tma_store 2026-05-23 01:27:03 +00:00
e50644afde fix: O rescale uses 2D register tensor pattern (matching CUTLASS correction_rescale) 2026-05-23 01:25:53 +00:00
b77c8d83f5 fix: pre-compute tmem_load_epi_atom in __call__, pass to kernel 2026-05-23 01:24:33 +00:00
c9271ffbf4 fix: index into TMA partitioned tensors for copy 2026-05-23 01:23:04 +00:00
e01ff282b7 fix: use flat_divide+group_modes(0,2) for TMA store, matching CUTLASS 2026-05-23 01:22:22 +00:00
5efa9c9297 fix: use gC not tCgC for TMA partition, group modes 0-3 2026-05-23 01:20:52 +00:00
7a894c4bf6 fix: use tma_partition for TMA store in correction_epilog 2026-05-23 01:20:09 +00:00
3c134f7e90 fix: replace TMEM round-trip normalize with CUTLASS correction_epilog pattern 2026-05-23 01:18:56 +00:00
690fd77e6c diag: inv_row_sum=1.0 to test raw PV, n=128 only 2026-05-23 01:17:14 +00:00
2b93b10199 diag: test original code n=128+256 to confirm baseline 2026-05-23 01:13:29 +00:00
9bcddb68e1 diag: disable O rescale properly, test n=128+256 baseline 2026-05-23 01:12:50 +00:00
0ef41266de diag: test n=128 and n=256 both with rescale disabled 2026-05-23 01:12:00 +00:00
dc44fa187a fix: indentation error in diag disable 2026-05-23 01:11:25 +00:00
a9cace316d diag: disable O rescale to isolate the issue (n=256 only) 2026-05-23 01:11:00 +00:00
08d4af90ca debug: add wide-search diagnostics for n=256 O rescale 2026-05-23 01:02:33 +00:00
f026c1824c 🚀 MULTI-TILE SOFTMAX + O RESCALE WORKING: n=128 cos 0.999998, n=256 cos 0.80
Fixed ALL loops to use self.n_kv_tiles (Python int) instead of
cute.size(gK, mode=[3]) which returned 1 for all n values.

Results:
  n=128: cos 0.999998  PASS (single tile, full softmax + normalize)
  n=256: cos 0.801156 (2 tiles, O rescale partially working)
  n=512: CUDA launch failure (pipeline can't cycle past kv_stage=2)

The n=256 improvement (0.71 → 0.80) confirms:
  1. TMA fix (None,0,None,0) loads both KV tiles correctly
  2. Softmax processes both tiles with online row_max/row_sum tracking
  3. O rescale (O *= acc_scale for kt > 0) is partially working
  4. Final normalize (O *= 1/row_sum) works correctly

Remaining:
  - n=256 cos 0.80 → 0.9999: O rescale precision issue
  - n≥384: pipeline cycling (kv_stage=2 can only hold 2 tiles)
  - Need to increase kv_stage or fix pipeline state cycling
2026-05-23 00:35:42 +00:00
d511ebe387 Debug: add row_sum/inv_row_sum printf at final normalize 2026-05-23 00:34:38 +00:00
c2ff8e072e Fix ALL loops: use self.n_kv_tiles everywhere
The MMA loop (cutlass.range) and MMA consumer loop (range) also used
cute.size(gK, mode=[3]) which returns 1 for all n. Fixed all 3 loops:
1. TMA load loop (cutlass.range, line 215)
2. MMA consumer loop (range, line 231)
3. Softmax loop (range, line 324)

This was causing the deadlock — MMA only produced S[0] while softmax
waited for S[1].
2026-05-23 00:33:38 +00:00
a63f452c86 Fix softmax loop: use self.n_kv_tiles not cute.size(gK, mode=[3])
cute.size(gK, mode=[3]) returns 1 for ALL n values — mode 3 is batch,
not KV tiles. self.n_kv_tiles = s_k // 128 is the correct Python int.
This is why softmax only processed kt=0 for all n.
2026-05-23 00:30:49 +00:00
195b0506af auto: pre-test commit 2026-05-23 00:29:49 +00:00
88b66e9dca Add O rescale with pre-built paired atoms (corr_tile_size=16)
Setup the correction_rescale atoms BEFORE the softmax loop so they can be
shared between per-tile O rescale and final normalize. Uses the working
2D register tensor pattern for final normalize. O rescale uses simple
1D rmem tensor per sub-tile (same as example10).
2026-05-23 00:28:44 +00:00
fae9f6fbb5 Reset to working_softmax_maybe.py + TMA fix only
Previous O rescale attempt broke n=128 (0.464773).
Revert to known-good softmax code, only apply TMA fix:
tBgK[(None,None,0,0)] → tBgK[(None,0,None,0)]

Expected: n=128 cos 0.999998 (same as working), n=256 cos 0.71 (TMA fix loads 2 tiles but no O rescale)
2026-05-23 00:27:41 +00:00
524b5b1840 Fix final normalize: use working 2D register tensor pattern from working_softmax_maybe.py
The make_rmem_tensor(tTMEM_LOADcO.shape) creates a 1D tensor that doesn't
match the paired atom layout. The working pattern uses a 2D register tensor
with sub-tile composition (tTMrO_i_ = tTMrO[None, i] + composition).
2026-05-23 00:25:16 +00:00
85973743d6 Fix: add self.n_kv_tiles to __init__ 2026-05-23 00:23:38 +00:00
261f23e698 Add per-tile O rescale (O *= acc_scale) to softmax loop
- Moves correction_rescale atom setup before softmax loop (needed for O rescale)
- Adds O *= acc_scale for kt > 0, before softmax_done_bar.arrive()
- Uses same paired Ld32x32bOp/St32x32bOp(corr_tile_size=16) atoms as final normalize
- Final normalize (O *= 1/row_sum) uses same atoms, no duplicate setup
- Fixes softmax loop to use self.n_kv_tiles (Python int) not n_kv_tiles (CuTeDSL symbolic)
- This should fix n=256 cos 0.71 → 0.9999
2026-05-23 00:22:12 +00:00
524f0bdfb4 Clean up: archive diagnostics and superseded tests
Kept:
- example10 (CUTLASS LLM, O rescale + final normalize)
- example9 (SSA kv_coord version)
- working_softmax_maybe.py (working softmax snapshot from before the nuke)
- test_fmha_v3_stage_c.py (identity softmax baseline, n=128 cos 0.999998)
- test_fmha_v3.py (Stage A+B baseline)
- layertest.py, cudagraph_test.py (required)
- test_cutedsl.py, test_fp4_roundtrip.py (NVFP4 tests)

Archived: diag_tma_*, example8, test_diag_multitile, test_reference_fmha,
test_ref_minimal, test_tma_coord, test_fmha_v3_diag*, test_fmha_v3_12w,
test_dense_router, test_interleave*, test_fused_step1, test_router,
test_cache, test_compile_custom_op, test_custom_op, test_layer_schedule
2026-05-23 00:17:07 +00:00