← Back to Pull requests

Integrate MXFP4 hipblaslt GEMM support #697

Closed
unknown closed this pull request without merging on Sep 09, 2026 22:42 UTC
View on GitHub
unknown unknown commented on Aug 07, 2026 15:04 UTC
Author

Description

Adds a native MXFP4 GEMM path through hipBLASLt (F4F4 kernels) on gfx950 / ROCm ≥ 7.13 /
hipBLASLt ≥ 1.3, alongside the existing AITER a4w4 backend. Until now an MXFP4 GEMM always
routed to AITER and never reached rocm_gemm.cu; hipBLASLt 1.3 now ships FP4×FP4 + UE8M0
block-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_MXFP4 unset,
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

  • Documentation change (change only to the documentation, either a fix or a new content)

  • Bug fix (non-breaking change which fixes an issue)

  • New feature (non-breaking change which adds functionality)

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

  • Infra/Build change

  • Code refactoring
  • Changes

    Please list the changes introduced in this PR:

  • C++ (transformer_engine/common/gemm/rocm_gemm.cu):

  • - Map DType::kFloat4E2M1 → HIP_R_4F_E2M1 in get_hipblaslt_dtype() and the algo-cache
    type_name_map.
    - Route MXFP4 through the shared is_mxfp_scaling canonicalization and the existing
    VEC32_UE8M0 block-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 the
    fallback while MXFP4 stays native.
    - Add an MXFP4 capability gate in cublas_gemm: compile-time hipBLASLt ≥ 1.3, runtime
    gfx950, K % 256, M/N % 32, BF16/FP32 output only, no bias/GELU, beta == 0.
  • Python (pytorch/cpp_extensions/gemm.py): route MXFP4 to hipBLASLt when

  • NVTE_ROCM_USE_HIPBLASLT_MXFP4=1, otherwise AITER a4w4 (default).
  • Python (pytorch/quantization.py): MXFP4BlockScalingRecipeState.make_quantizers emits

  • plain (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 (C++, tests/cpp/operator/test_cublaslt_gemm.cu): OperatorTestMXFP4 compares the

  • native MXFP4 GEMM against a BF16 reference built by CPU-dequantizing the same operands (TN,
    BF16/FP32 output, K%256; no MXFP4 nvte_dequantize exists on ROCm).
  • Tests (pytest, tests/pytorch/mxfp4/test_mxfp4_gemm_exact.py): parametrized over both

  • backends (routed automatically via monkeypatch, no env var required) vs MXFP4QuantizerRef,
    plus a direct hipBLASLt-vs-AITER cross-check.

    MXFP4 GEMM Performance: hipBLASLt vs AITER

  • Device: AMD Instinct MI355X

  • Backends: AITER a4w4 (shuffled weights + swizzled scales) vs hipBLASLt F4F4 in both plain (VEC32_UE8M0) and pre-swizzled (BLK32_UE8M0_32_8_EXT) scale modes. MXFP4, BF16 output.

  • Passes: forward (TN), dgrad (NN), wgrad (NT) -- true per-pass shapes (fwd contracts hidden, dgrad contracts out, wgrad contracts tokens); same FLOPs, different M/N/K.

  • Timing: CUDA events + leading kernel, 15 warmup / 50 iters; TFLOPS = 2·m·n·k / t

  • seqlen: 2048, mbs: [1, 2, 4]
  • 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

  • hipBLASLt with pre-swizzled scales (mode 1001) is ~0.94x AITER (geomean) -- effectively on par with the hand-tuned a4w4 ASM kernels.

  • hipBLASLt with plain UE8M0 scales is ~0.61x AITER (geomean); the pre-swizzled scale path is essential for competitive performance.

  • AITER remains marginally faster on aggregate, so keeping it the default (NVTE_ROCM_USE_HIPBLASLT_MXFP4 unset) 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

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: aris134 Review duration: 47978m
    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
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%