Commit 5632a28
committed
feat(fp8): §19 MEASURED on gb10 sm_121 — fp8 GEMM RUNS; TE per-tensor e4m3 = real 1.6-1.8x tensor-core win; in-house cuda twin correct but unoptimized
Closes the §18 "fp8 UNRUNNABLE on sm_121" gap with MEASURED numbers at the four
prod bs4 transformer-block GEMM shapes (M=16384). Two distinct fp8 paths now run:
R1 TE per-tensor E4M3 (DelayedScaling -> cuBLASLt fp8 MMA): the REAL fp8
tensor-core win — 1.57-1.84x over bf16 MEASURED (52.1-61.8 fp8 TFLOPs vs
33.3-34.3 bf16), rel-err 0.0375 honest over ALL elements (<=0.10 ceiling). Only
MXFP8 block-scaling stays upstream-blocked ("not supported on 12.0+"); per-tensor
works once libnvrtc-builtins.so.13.3 is on the loader path.
R2 in-house dequant->half->T.gemm CUDA fragment-C twin
(fp8_scaled_matmul_path_c_cuda_prim): COMPILES + RUNS + parity-passes (0.0375,
native fp8_e4_t->half_t decode verified in emitted CUDA) — but 0.18-0.42x as-is:
its MMA runs on the decoded fp16 values (mma_sync<kFloat16,...>, not an fp8-input
MMA) on an untuned 32x64x32 single-128-thread tile. It is the proven MEMORY lever
(2.0x operand-byte halving MEASURED) + the on-CUDA optimization target, NOT a
speed lever as-is. Attribution explicit: throughput belongs to TE-cuBLASLt fp8.
Two port fixes were needed for R2 to run on CUDA (RULE #1, no fallback):
- fp8_matmul_path_c.py: the Metal T.alloc_var("float32") decode scratch lowered
to a non-assignable float[1] on codegen_cuda ("expression must be a modifiable
lvalue"). Replaced with a register-fragment stage (T.copy e4m3 global->fragment
with disable_tma=True, then per-element T.cast->fp16) — keeps the native
per-element decode, emits a valid CUDA lvalue (F2-forward CUDA-twin pattern).
- fp8_gemm_microbench.py: the prim's operand param is typed float8_e4m3; feeding
a .view(torch.uint8) tensor segfaults the tvm_ffi adapter on the dtype
mismatch. Fixed _quantize_pertensor_fp8 to pass native torch.float8_e4m3fn
(the 1-byte storage IS the 2.0x halving regardless of the dtype tag).
cppmega_mlx/_gb10_nvrtc_env.py (NEW, stdlib-only): self-healing NVRTC loader-path
guard — prepends /usr/local/cuda-13.3/.../lib and re-execs once so TE's NVRTC can
dlopen libnvrtc-builtins.so.13.3 (the R1 tensorwise route's only loader blocker);
no-op on non-gb10. Validated end-to-end on gb10 with env -u LD_LIBRARY_PATH.
docs: RELAX-GRAPH-VS-MEGATRON.md §19 (full table + GO verdict + e2e EXTRAPOLATION
+ corrected memory synergy bs4-fp8 ~= 2x bs1-fp16); FP8-ACTIVATIONS-PATHC.md
TL;DR/status updated with the MEASURED fp8 GEMM numbers.
GO: a REAL fp8 e4m3 tensor-core GEMM runs on sm_121 with a measured ~1.8x
speedup and honest 0.0375 parity. Measured 2026-06-04 gb10 tvm.cuda(0).1 parent cb94526 commit 5632a28
5 files changed
Lines changed: 313 additions & 16 deletions
File tree
- cppmega_mlx
- nn/_tilelang
- docs
- scratch
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
259 | 259 | | |
260 | 260 | | |
261 | 261 | | |
| 262 | + | |
| 263 | + | |
262 | 264 | | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
263 | 287 | | |
264 | | - | |
265 | | - | |
266 | | - | |
| 288 | + | |
267 | 289 | | |
268 | | - | |
269 | | - | |
270 | | - | |
| 290 | + | |
271 | 291 | | |
272 | 292 | | |
273 | 293 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
4 | 24 | | |
5 | 25 | | |
6 | 26 | | |
| |||
22 | 42 | | |
23 | 43 | | |
24 | 44 | | |
25 | | - | |
| 45 | + | |
26 | 46 | | |
27 | | - | |
28 | | - | |
29 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
30 | 54 | | |
31 | 55 | | |
32 | 56 | | |
| |||
79 | 103 | | |
80 | 104 | | |
81 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
82 | 113 | | |
83 | 114 | | |
84 | 115 | | |
| |||
0 commit comments