← Back to Pull requests

[gfx1250] MXFP8 quantize: 2D block scaling and GEMM-swizzled scales #801

Open
unknown opened this pull request with 449 lines diff across 5 files
View on GitHub
unknown unknown commented on Nov 12, 2026 01:27 UTC
Author

Description

Fixes ROCm MXFP8 quantize issues found by the C++ operator tests. The tests skip on MI300/MI350 (compute capability < 100), so gfx1250 is the first ROCm target to run them. The branch is merged with the latest dev, including the TDM quantize kernels (#778).

  • The ROCm MXFP8 kernels ignored mxfp8_2d_quantization and always wrote 1D (1x32 / 32x1) scales instead of one scale per 32x32 tile.

  • The ROCm MXFP8 quantize paths ignored with_gemm_swizzled_scales and wrote compact scales into tensors flagged as GEMM-swizzled: single-tensor and grouped quantize.
  • Fixes # (issue)

    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

  • MXFP8 quantize (single and grouped): add an IS_2D_SCALING template flag. The rowwise and colwise scales use the 32x32 tile amax, and the flag is dispatched the same way as on CUDA. The tile amax is a butterfly reduction within each warp (rocm_subwarp_allreduce, which now takes an optional lowest offset), followed by one shared-memory exchange between warps.

  • MXFP8 quantize: when swizzled scales are requested, the generic kernel writes them directly in the swizzle_scaling_factors_mx layout and fills the padding with the E8M0 identity value (127). GEMM-swizzled outputs skip the TDM quantize until it writes swizzled scales (#789).

  • MXFP8 grouped quantize: swizzled scales are written per tensor, in the same layout, at each tensor's compact offset, as on CUDA. Tensor dimensions must be multiples of 128 (checked on the host where known). Swizzled grouped outputs use the generic kernel.

  • Move mx_preswizzle_scale_idx to rocm_device_utils.cuh so quantize and dequantize share it.

  • The CUDA paths are unchanged. The padded scale stride in dequantize and multi-tensor quantize is fixed in #812; swizzled multi-tensor outputs are handled in #789.
  • Known: the opt-in CK MX grouped GEMM ignores with_gemm_swizzled_scales and needs a separate fix. The emulated gfx1250 CI still skips SwizzledScalesFusedCastMXFP8TestSuite until #789 removes its KNOWN_FAILURES entry.

    Tests (gfx1250, strict):

  • New: OperatorTest_FusedCastMXFP8_Swizzled.MatchesSwizzledCompactCast (2D, GeLU and dbias casts, padded scale tensors), OperatorTest_GroupedFusedCastMXFP8.SwizzledScales, SwizzledScales2D and SwizzledScalesRejectUnaligned.

  • GPU (MI455X, gfx1250-strict): RocmTdmTest 3/3, CastCSTestSuite 96/96, swizzled suites 16/16, MultiQuantizeMXFP8 54/54.

  • C++ non-GEMM (CK MX grouped GEMM tests excluded): 9,299 tests, 0 failed, both with TDM on and with NVTE_USE_TDM=0. Same outcome as before the dev merge for all 9,298 shared tests.

  • C++ GEMM: 3,965 tests, 0 failed. The extra skips since the dev merge come from dev's GELU GEMM skip (#799).
  • Checklist:

  • I have read and followed the contributing guidelines

  • The functionality is complete

  • I have commented my code, particularly in hard-to-understand areas

  • I have made corresponding changes to the documentation

  • My changes generate no new warnings

  • I have added tests that prove my fix is effective or that my feature works

  • New and existing unit tests pass locally with my changes
  • Diff: 449 lines (+336 / -113) across 5 files Reviewer: matthiasdiener Review duration: 27256m
    All Vouch review confidence checks passed
    Residual risk 0.26 = Change Risk (0.45) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 449 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    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.366
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #801"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% 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: 45.4% (MEDIUM) · Higher = larger blast radius
    45.4%
    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: 43.0% · Lower = rushed or shallow review
    43.0%
    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: 25.9% · Safe to merge
    25.9%