← Back to Pull requests

[TE][HipKittens] Require K % 128 for blockwise FP8 GEMMs #788

Open
unknown opened this pull request with 340 lines diff across 4 files
View on GitHub
unknown unknown commented on Oct 30, 2026 20:41 UTC
Author

Description

ROCm-wide rules for blockwise FP8 GEMMs, from the #773 discussion: K % 128 != 0 now raises instead of computing (callers pad), and A/B data must be 128-byte aligned (sanity check; TE allocations always are). The #773 gfx942 workaround for unaligned rows is removed, since these checks make it unreachable. The checks run in HipKittens builds (USE_HIPKITTENS_GEMM, on in all CI and wheel builds); without HipKittens, blockwise FP8 GEMMs are rejected as before.

Applies to all ROCm GPUs, as agreed with the HipKittens owners. ROCm/Megatron-LM#167 pads MLA kv_down (576 -> 640) and MoE splits to 128. Models with other dims that are not multiples of 128 per rank (e.g. GPT-OSS, hidden 2880) can't use blockwise FP8 on ROCm.

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

  • rocm_gemm.cu: K % 128 and 128-byte A/B alignment checks for blockwise FP8 (HipKittens builds)

  • cublaslt_gemm.cu: blockwise grouped GEMMs run per GEMM (the CK/HipKittens grouped backends computed them wrong); every GEMM is checked before launch

  • kittens/cdna3: revert the #773 unaligned-row workaround

  • quantization.py: blockwise align size 128 on ROCm, also with the Triton grouped GEMM (it falls back to HipKittens when ineligible)

  • Tests:

  • - ROCm blockwise cases use K % 128 == 0, including test_fusible_ops test_layernorm_mlp
    - distributed TransformerLayer numerics compares in bf16 for ROCm blockwise (fp16 Q/K gradients underflow at these sizes, which flipped the zero-tensor check on gfx942)
    - new rejection tests (C++, PyTorch); large-K and fp16-output pow2-scale C++ cases
  • Docs: README, Fp8Padding/Fp8Unpadding docstrings
  • Tested on gfx950 (MI355X) and gfx942 (MI300X): C++ blockwise/grouped GEMM tests and every CI PyTorch file that reaches blockwise FP8, in the CI env variants, single- and multi-GPU, pass.

    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: 340 lines (+255 / -85) across 4 files Reviewer: wangye805 Review duration: 45378m
    All Vouch review confidence checks passed
    Residual risk 0.27 = Change Risk (0.49) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.49 · 340 lines diff across 4 files
    0.49
    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%
    44%
    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.349
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #788"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.7% 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: 49.3% (MEDIUM) · Higher = larger blast radius
    49.3%
    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: 44.7% · Lower = rushed or shallow review
    44.7%
    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: 27.3% · Safe to merge
    27.3%