Add SM103 FP8 block128 MegaMoE training backend - #8
Conversation
d529ad5 to
5b2aa57
Compare
| w2_master, | ||
| w3_master, | ||
| group=dist.group.WORLD if world_size > 1 else None, | ||
| ) |
There was a problem hiding this comment.
Benchmark skips transport setup
Medium Severity
The structured performance script runs fp8_block128_mega_moe under torchrun with a multi-rank process group but never calls _configure_fp8_block128_mega_moe_transport. The DeepEP path requires a pre-registered context token capacity, so multi-rank runs fail at buffer lookup instead of benchmarking.
Reviewed by Cursor Bugbot for commit 5b2aa57. Configure here.
5b2aa57 to
1f8b001
Compare
| scales[route * num_blocks_k + block_k] = scale; | ||
| } | ||
| output[route * hidden + column] = __nv_fp8_e4m3(value / scale); | ||
| #endif |
There was a problem hiding this comment.
Route quantize skips power-of-two scales
High Severity
The new sm103_route_scale_quantize_group128_kernel and sm103_expanded_route_scale_quantize_group128_kernel store block scales as raw amax / 448, while sm103_quantize_bf16_e4m3_group128_kernel, sm103_swiglu_quantize_group128_kernel, and persistent input prep round scales up to the next power of two. The capability manifest advertises fp32_power_of_two scales, so backward route quantization can disagree with forward and MMA scale expectations.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit c84bbed. Configure here.
| const PersistentWorkspaceLayout layout( | ||
| buffer.data_ptr(), | ||
| static_cast<uint32_t>(num_ranks), | ||
| static_cast<uint32_t>(context_tokens_per_rank)); |
There was a problem hiding this comment.
Prepare forward rank count mismatch
Medium Severity
sm103_fp8_block128_prepare_persistent_inputs sizes the symmetric workspace from its num_ranks argument, while sm103_fp8_block128_persistent_forward and backward rebuild PersistentWorkspaceLayout from buffer_ptrs.size(). If those counts differ, preparation writes quantized inputs and route metadata at the wrong offsets while the persistent kernel interprets the same buffer with a different layout, corrupting routing and activations without a hard error when the buffer is large enough.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 9c63f41. Configure here.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 4 total unresolved issues (including 3 from previous reviews).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 06246eb. Configure here.
| } | ||
| padded_offsets[expert] = static_cast<int32_t>(padded_end); | ||
| group_counts[expert] = static_cast<int32_t>(end - start); | ||
| #endif |
There was a problem hiding this comment.
Empty expert PSUM traps GPU
High Severity
In sm103_prepare_expanded_wgrad_metadata_kernel, each expert’s valid row range starts at the 128-aligned successor of the previous PSUM end. When an expert receives no tokens, its PSUM end equals the prior end; if that value is not already 128-aligned, the computed start exceeds end, the kernel hits asm trap, and grouped_bf16_wgrad_expanded can hard-fail on common empty-expert routing.
Reviewed by Cursor Bugbot for commit 06246eb. Configure here.


What changed
deep_gemm.__git_commit__and expose a non-launching, fail-closed capability manifestWhy
FireTitan's GLM-5.2 FP8-block128 training path needs a single routed backend that preserves E4M3 weights and FP32 128 × 128 inverse scales. Existing MegaMoE paths use FP4 or BF16 weights and do not provide this forward/backward contract.
This backend deliberately targets compute capability 10.3 only. The extension contains only an
sm_103acubin and rejects every other runtime capability; there is no fallback.Validation
1 passed22 passed1 passedcuobjdump --list-elf: exactly_C.cpython-312-x86_64-linux-gnu.1.sm_103a.cubinD=6144,H=2048, top-8, 15,625 tokens, 16 local experts): median complete forward/backward 51.741 ms on L20D/SM103The FireTitan integration will pin exact commit
a0cba68c6e1701023ce93e3eaef5ad08d9b5d23fand validate the installed extension SHA separately.Note
High Risk
Large new training-critical CUDA surface (routing, EP transport, autograd) with strict SM103-only behavior and tight coupling to persistent Mega MoE kernels; mistakes affect numerical correctness and distributed training.
Overview
Adds an SM103-only (
cc 10.3, no fallback) FP8 E4M3 / 128×128 block-scale routed MoE training path: Python exposesfp8_block128_mega_moe, capability introspection, and W13 layout helpers; the native extension registers a largesm103_fp8_block128API surface and embedsdeep_gemm.__git_commit__.The new
csrc/sm103_fp8_block128.custack owns persistent workspace layout, input prep, EP2/EP16 persistent forward/backward (reusing SM100 Mega MoE device code with FP8 block128 / canonical W13 wiring), grouped CUTLASS blockwise GEMMs, SwiGLU/route/combine helpers, and grouped BF16 wgrad with 128-row padding handling.Smaller cross-cutting tweaks: README documents SM103 and the backend; grouped BF16 k-GEMM allows optional
c; UE8M0 pack accepts column-major scale tensors when using PSUM layout; SM100fp8_fp4_mega_moeJIT launch gains token source metadata, runtime ring sizes, and bitwise-stable activation-clamp constants; shared enums add route/combine modes.Reviewed by Cursor Bugbot for commit 5018de9. Bugbot is set up for automated code reviews on this repo. Configure here.