Integrate MXFP4 hipblaslt GEMM support #697
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #697"
general
weight: 0.35
aris134
Description
Adds a native MXFP4 GEMM path through hipBLASLt (F4F4 kernels) on gfx950 / ROCm ≥ 7.13 /
hipBLASLt ≥ 1.3, alongside the existing AITER
a4w4backend. Until now an MXFP4 GEMM alwaysrouted to AITER and never reached
rocm_gemm.cu; hipBLASLt 1.3 now ships FP4×FP4 + UE8M0block-32 kernels, so this wires MXFP4 into the hipBLASLt path (mirroring the MXFP8 native path)
behind an opt-in toggle, enabling A/B benchmarking against AITER.
The new path is opt-in and regression-safe: with
NVTE_ROCM_USE_HIPBLASLT_MXFP4unset,MXFP4 still routes to AITER with the existing shuffled quantization, so current behavior and
tests are unchanged.
Fixes # (N/A — internal ROCm enablement)
Type of change
Changes
Please list the changes introduced in this PR:
transformer_engine/common/gemm/rocm_gemm.cu):- Map
DType::kFloat4E2M1 → HIP_R_4F_E2M1inget_hipblaslt_dtype()and the algo-cachetype_name_map.- Route MXFP4 through the shared
is_mxfp_scalingcanonicalization and the existingVEC32_UE8M0block-scale arm (wires A/B scale pointers/modes); no separate branch needed.- Gate the FP4 dequant→BF16 fallback on the scaling mode (
use_nvfp4) so NVFP4 keeps thefallback while MXFP4 stays native.
- Add an MXFP4 capability gate in
cublas_gemm: compile-time hipBLASLt ≥ 1.3, runtimegfx950,
K % 256,M/N % 32, BF16/FP32 output only, no bias/GELU,beta == 0.pytorch/cpp_extensions/gemm.py): route MXFP4 to hipBLASLt whenNVTE_ROCM_USE_HIPBLASLT_MXFP4=1, otherwise AITERa4w4(default).pytorch/quantization.py):MXFP4BlockScalingRecipeState.make_quantizersemitsplain (un-shuffled) FP4 data + plain UE8M0 scales when the toggle is on, so operand layout
matches the GEMM backend by construction (AITER-shuffled otherwise).
tests/cpp/operator/test_cublaslt_gemm.cu):OperatorTestMXFP4compares thenative MXFP4 GEMM against a BF16 reference built by CPU-dequantizing the same operands (TN,
BF16/FP32 output, K%256; no MXFP4
nvte_dequantizeexists on ROCm).tests/pytorch/mxfp4/test_mxfp4_gemm_exact.py): parametrized over bothbackends (routed automatically via
monkeypatch, no env var required) vsMXFP4QuantizerRef,plus a direct hipBLASLt-vs-AITER cross-check.
MXFP4 GEMM Performance: hipBLASLt vs AITER
Speedup = aiter_ms / hipblaslt_ms (> 1.0 means the hipBLASLt variant is faster than AITER).
Summary (hipBLASLt vs AITER)
hipblaslt_plain
| Pass | Configs | Median speedup | Geomean speedup | hipBLASLt wins |
|---|---|---|---|---|
| forward (TN) | 30 | 0.68x | 0.60x | 0/30 |
| dgrad (NN) | 30 | 0.68x | 0.62x | 0/30 |
| wgrad (NT) | 30 | 0.66x | 0.62x | 0/30 |
| Overall | 90 | 0.67x | 0.61x | 0/90 |
hipblaslt_swizzled
| Pass | Configs | Median speedup | Geomean speedup | hipBLASLt wins |
|---|---|---|---|---|
| forward (TN) | 30 | 0.95x | 0.96x | 7/30 |
| dgrad (NN) | 30 | 0.95x | 0.95x | 5/30 |
| wgrad (NT) | 30 | 0.91x | 0.92x | 2/30 |
| Overall | 90 | 0.94x | 0.94x | 14/90 |
Takeaways
NVTE_ROCM_USE_HIPBLASLT_MXFP4unset) is justified; hipBLASLt (swizzled) is a competitive alternative that additionally offers native BF16/FP32 output and the full four-layout set including TT.Figures
Geometric-mean speedup vs AITER by pass (dashed line = AITER parity).
<img width="1184" height="734" alt="performance_summary" src="https://github.com/user-attachments/assets/d051f225-f4b5-4772-9750-2a38afb9c119" />
Per-config hipBLASLt-swizzled speedup vs AITER across contraction sizes (K); most configs land within ~10% of AITER, with several at or above parity.
<img width="1184" height="735" alt="performance_speedup_vs_k" src="https://github.com/user-attachments/assets/4e166a35-f1b8-42c6-9a42-47d5d53ca9c9" />
Script:
benchmark_mxfp4_hipblaslt_vs_aiter.py