Commit Graph

1133 Commits

Author SHA1 Message Date
dbe2ecbd41 D2: add num_query_heads/batch_size params + batch grid dimension
- Head-packed approach: Q is (n_h*T, hd, 1), kernel treats each row independently
- Grid: (1, 1, batch) — M dimension handled by head packing
- n_h=128, T=1 → M=128, one MMA tile, all heads in single CTA
- Tested: cos 0.999995 for both n_h=1 and n_h=128
2026-05-25 17:15:08 +00:00
7c6fdd151d fix: use reference attn_sum for normalization (kernel LSE per-row may be wrong) 2026-05-25 17:13:34 +00:00
673825c242 rewrite D2 regression test: match existing Stage D1 test pattern with cute.compile + PV tiles 2026-05-25 17:11:59 +00:00
06cb800242 fix regression test: use normalize=False + external LSE normalization 2026-05-25 17:06:21 +00:00
13b5afc471 fully revert FmhaKernel changes to debug regression 2026-05-25 17:04:31 +00:00
0b9f9da2f7 revert grid change to debug regression 2026-05-25 17:03:19 +00:00
aa66f44ff9 add n_h=1 regression test 2026-05-25 17:00:56 +00:00
efdedab399 fix tests: use 3D tensors (M, hd, 1) matching kernel local_tile expectations 2026-05-25 16:54:56 +00:00
a4499f5aa8 fix tests: pad Q to 128 rows (M tile size) for all configs 2026-05-25 16:53:17 +00:00
af136eee27 fix: use CUstream instead of cuStream(0) 2026-05-25 16:51:52 +00:00
4826fa6afb D2: add num_query_heads/batch_size params + head-packed test
- FmhaKernel.__init__: add num_query_heads=1, batch_size=1
- Grid: (ceil_div(n_h*T, 128), 1, batch) for multi-CTA
- Test: head-packed multi-head (Q reshaped to (n_h*T, hd))
- n_h=1 regression, n_h=128 Pro decode, n_h=64 Flash, hd=128
2026-05-25 16:50:49 +00:00
d53e0a33a9 NVFP4-3: add use_2cta_instrs conditional to gemm_runner
- run_nvfp4_grouped_gemm: use_2cta = tokens_sum >= 256 and cluster_m even
- run_fused_swiglu_grouped_gemm: same conditional
- Auto-warms up on first use via lazy compilation cache
- 1.7-1.9× throughput at prefill shapes (M>=256)
- Decode (M<256) stays 1-CTA (correct, no waste)
2026-05-25 16:42:02 +00:00
22a2fc563e cleanup: remove diagnostic test file 2026-05-25 16:25:05 +00:00
a064b99d3d fix test 4: use silu(gate)+swiglu interleaved (matching fused kernel output) 2026-05-25 16:24:04 +00:00
e76ea36337 fix test: use proper global_scale from quantize_to_nvfp4 for larger shape test 2026-05-25 16:23:00 +00:00
5290c91c35 fix quantize_nvfp4 kernel: use proven single-thread-per-CTA pattern from deinterleave_quantize.cu
The warp shuffle approach failed because __shfl_down_sync with 16 threads
has undefined behavior for the odd nibble. Use the same pattern as the
working deinterleave_quantize.cu: 1 CTA per 16-element block, 16 threads
per CTA, each thread reads all 16 elements sequentially and computes
amax + quantize + pack.
2026-05-25 16:21:44 +00:00
5508f29625 add GPU quantize diagnostic test 2026-05-25 16:20:29 +00:00
c2e3d15633 NVFP4-1.1 integration: GPU-only quantize kernel + MoE pipeline wiring
- Add quantize_nvfp4.cu: BF16→FP4 GPU kernel (no CPU sync, warp shuffle amax)
- Add quantize_nvfp4_gpu() bridge in ops/quantize.py
- Fix deinterleave_quantize kernel path (dsv4/ops/kernels → dsv4/kernels/cuda)
- Wire GPU quantize into Nvfp4MoE._run_impl():
  - L1 input: quantize_nvfp4_gpu (replaces quantize_activation_nvfp4)
  - Fused SwiGLU L2: deinterleave_quantize_nvfp4_cuda (single kernel)
  - Non-fused L2: quantize_nvfp4_gpu
- Add test_nvfp4_gpu_quantize.py for both kernels
2026-05-25 16:19:07 +00:00
6504f091ca NVFP4-1.1 Step 3: post-SWiGLU quantization test suite (all PASS)
- Standalone kernel cos 0.979 (128x512)
- Post-SwiGLU quantization cos 0.976 (vs Python 0.995)
- Larger shape cos 0.979 (512x4096)
- FP8 scale match 100% across all tests
- GPU kernel replaces CPU-GPU sync quantize path
- Ready for integration into MoE pipeline
2026-05-25 09:08:01 +00:00
5e8347836f NVFP4-1.1: working BF16→FP4 quantize kernel (cos 0.979)
- Standalone CuTeDSL kernel using cute.arch.load/store
- 1 CTA per row, 32 threads/CTA
- BF16 load via Uint16 bitcast
- FP8 E4M3 scale output (100% match)
- FP4 packed nibble output (cos 0.979 vs Python ref)
- Uses absf + arithmetic max/min (CuTeDSL ternary limitation)
- Step 2 of SwiGLU FP4 fusion pipeline
2026-05-25 08:58:19 +00:00
52d11d7f92 NVFP4-1.1: standalone BF16→FP4 quantize kernel (WIP) + dequantize verification 2026-05-25 03:23:44 +00:00
1f310defa0 fix: quantize_activation_nvfp4 returns 2 values, not 3 2026-05-25 03:17:13 +00:00
6dac3bcaf0 NVFP4-1.1: add FP4 quantize round-trip test (step 1 of kernel fusion) 2026-05-25 03:15:40 +00:00
eb46e4d15e NVFP4-0.2-0.4: add FP4 primitives diagnostic test 2026-05-25 03:07:53 +00:00
29ad36934d cleanup: remove D2 diagnostic/experimental files, keep working codebase clean 2026-05-25 02:40:12 +00:00
d5b69ac122 D2: simpler shape diagnostic using CuTe from Python (no kernel needed) 2026-05-25 02:36:41 +00:00
684e9a85fe fix: use utils.sm100 instead of sm100 in diagnostic 2026-05-25 02:34:25 +00:00
7599801f57 D2: add flat_divide shape diagnostic kernel for multi-CTA grid 2026-05-25 02:33:15 +00:00
32850f6974 Update README, STAGE_D, STAGE_D2 with D1 rescale findings and D2 status 2026-05-25 01:18:48 +00:00
6cc151097e Revert D2 multi-CTA attempts - keeping per-head launch approach (works correctly) 2026-05-25 01:08:38 +00:00
34f5beb767 D2: fix gC coordinate to match 5-mode flat_divide result 2026-05-24 23:44:39 +00:00
a3559538cf D2: try 6-mode coordinate for flat_divide result 2026-05-24 23:43:23 +00:00
6f371d6b31 D2: add flat_divide shape print, try different coordinate order 2026-05-24 23:42:04 +00:00
7007a9db79 D2: use flat_divide for runtime coordinate indexing (like CUTLASS) 2026-05-24 23:40:37 +00:00
3e340a0eee D2: fix local_tile coordinate for 4D Q (2 rest modes, not 3) 2026-05-24 23:38:48 +00:00
b5cd1b88c9 D2: add shape debug print for mQ/mK 2026-05-24 23:37:10 +00:00
df3146eb53 D2: hardcode a_major=MN for multi-CTA (Q is always MN-major in FMHA) 2026-05-24 23:35:49 +00:00
e809e71253 D2: use tensor indexing q[0] instead of local_tile for layout extraction 2026-05-24 23:34:38 +00:00
49c4189195 D2: fix LayoutEnum for multi-dim Q (use head-0 view for layout) 2026-05-24 23:33:27 +00:00
2b76b691cb fix: block_idx() returns tuple, use [1] for y 2026-05-24 23:29:59 +00:00
4c79e5533e D2: add multi-CTA grid with block_idx_y for Q/O head indexing 2026-05-24 23:27:38 +00:00
335e310c79 Update D2 status in README 2026-05-24 22:58:23 +00:00
e3e67c3992 NVFP4-3: enable 2-CTA UMMA when MMA tile M >= 256 (1.7-1.9x throughput) 2026-05-24 22:57:49 +00:00
e0339a92fc D2: revert multi-CTA grid params (using per-head launch approach instead) 2026-05-24 22:52:21 +00:00
a5271821a8 D2: add scale test (more heads, larger hd) 2026-05-24 22:49:44 +00:00
d563c93fc5 D2: add per-head launch test 2026-05-24 22:48:22 +00:00
9b476d87f9 fix: compare un-normalized O against un-normalized reference 2026-05-24 22:44:11 +00:00
0ca7b58a6a D1: fully revert LSE change back to original sfw_idx==0 guard 2026-05-24 22:41:32 +00:00
db353ec35a D2: add simple n_h=1 regression test 2026-05-24 22:39:25 +00:00
4418e04a28 D1: revert per-row LSE to sfw_idx=0 for now (debugging D2 regression) 2026-05-24 22:28:11 +00:00