← Back to Pull requests

feat(hipblaslt): add skinny MXFP8 TN GEMMs (m or n <= 4) on gfx950 #14512

Closed
unknown closed this pull request without merging on Nov 20, 2026 06:15 UTC
View on GitHub
unknown unknown commented on Oct 27, 2026 20:16 UTC
Author

JIRA ID: AIHPBLAS-5259, AIHPBLAS-5669, AIHPBLAS-5670

Motivation

The generic MXFP8 kernels serve LLM decode GEMMs, where one extent is 1 to
4, poorly: their tiles are wide in both dimensions, so most of the work is
padding. This adds five skinny MXFP8 TN custom kernels for gfx950 and routes
the decode shapes to them. While testing them, two host/client bugs that
affect all architectures were found and are fixed here (see Bug fixes).

Technical Details

Kernels: five custom kernels for gfx950 (f8 E4M3 A/B, E8M0 32-block
HostPreSwizzle scales, bf16 C/D, f32 compute and f32 alpha/beta). Four are
scaled-MFMA persistent kernels that require min(m, n) <= 4 and one is a VALU
kernel that only takes skinny n (m > 4, n < 5). Each reduces all of K inside
one workgroup in a fixed order, so all five declare uniformSummationOrder and
are selected in hipBLASLt's default mode. They take a 96-byte kernarg segment
with byte leading strides, have no split-K (GlobalSplitU 1), launch a
TilesXYBatch grid and require batch 1. The .s files are generated out of
tree; the m, n and k kernarg names in their metadata were renamed to m_size,
n_size and k_size (some LLVM versions parse a bare n as a YAML boolean) and
the custom.config produced by AddCustomConfig from the Tensile test YAMLs was
appended. No instruction was edited: the s_nop 11 after the last tail MFMA
already gives the 12 wait states the scaled MFMA needs on gfx950. Each .s
starts with a header listing these edits, the constraints the predicates
encode and the num_records invariant below.

Routing: an Equality shard routes 138 (m, n, batch 1, k) keys, the 74 decode
shapes and their mirrors minus 5 shapes an earlier tuning round found faster
on the generic kernels. It is the output of one TensileLite LibraryLogic run
with every solution fully validated on every size, with two hand edits: its
geometry and Assert keys were aligned with each kernel's embedded
custom.config (which wins at runtime; a test checks they agree), and
AssertMXScalesPreSwizzled was added. Problems outside the shard, with K not a
multiple of 32, batched, or with bias, activation or a scale-alpha vector run
the generic kernels.

Other constraints:

  • Scales: the kernels read only the pre-swizzled scale layout. The new

  • MXScalesPreSwizzled predicate rejects packed scales. hipBLASLt already
    refuses plain 32-block scales (--scaleA 3 --scaleB 3) before solution
    predicates run, so the predicate is defense in depth.
  • K: for K below the prefetch depth or not a multiple of the K step, loads

  • run past the end of K. This is safe only because each kernel builds its
    buffer SRDs with a num_records that never exceeds the tensor extent and the
    hardware range-checks soffset against it. The K predicates are not
    tightened.
  • Chip ids: the shard lists DeviceNames [Device 75a0] (MI350X) and serves

  • other gfx950 chip ids, such as 0x75a3 (MI355X), through
    SUPPORTED_CHIP_ID_FALLBACKS. Both chip ids were exercised (see Test
    Result). A later gfx950_idXXXX/ logic file for the same ProblemType would
    shadow the shard; a unit test fails if one is added.

    Host support:

  • AssertStrideAMultiple/AssertStrideBMultiple (leading dimension

  • divisibility), AssertTensorBytesLessThan (2^31 for these kernels, also
    bounding the leading stride) and AssertMXScalesPreSwizzled predicates, in
    Python and C++.
  • custom.config Features with SupportsBias/Activation/ScaleAlpha false give

  • the solution its own ProblemType that rejects such problems, while the logic
    file's shared ProblemType stays unchanged; custom.config is read once per
    solution.
  • An AssertAnySizeLessThan predicate (an Or of SizeLessThan), with which the

  • MFMA kernels require min(m, n) <= 4.
  • A warning when a custom.config predicate replaces a different value

  • declared in the logic file.
  • AddCustomConfig carries MXScaleFormat, AssertTensorBytesLessThan,

  • AssertAnySizeLessThan and AssertMXScalesPreSwizzled.

    Bug fixes: both are host/client code and apply to all architectures, not just
    gfx950.

  • Custom-kernel byte leading strides (StrideA/B/C/D0Bytes), computed in

  • tensilelite/src/ContractionSolution.cpp (generateCustomCall), were computed
    as a float product, which rounds to 24 bits and corrupted leading
    dimensions above 2^24, and were silently truncated to the kernarg type.
    They are now computed in integers and a value that does not fit the
    declared kernarg type throws.
  • In a TensileLite client run with several problem sizes

  • (tensilelite/client/src/DataInitialization.cpp and Rotating.cpp), the
    rotating buffer sized every problem's copies from the pristine buffers of
    the largest problem, so smaller problems did not get the number of rotating
    copies their own size calls for. The copies are now sized per problem,
    while the first slot still holds the pristine inputs. The slot count is not
    capped by maxRotatingBufferNum, which is unknown when the inputs are
    allocated.

    Known bugs: nine beta != 0 shapes (AIHPBLAS-5511, not shard keys) stay
    quarantined in known_bugs.yaml until the C-load over-read fix lands (#15501,
    to be confirmed). Review by 2026-12-15. These nine cases are not among the 42
    skinny gtests reported below.

    Snapshots: two .ambr files changed, +37/-0, additions only; nothing was
    removed or altered. These changes are intended, and as the characterization
    README requires, each is explained here.

  • ValidParameters/__snapshots__/test_builders_char.ambr (+25): the

  • validParameters key roster and structure gain 5 keys, AssertAnySizeLessThan,
    AssertMXScalesPreSwizzled, AssertStrideAMultiple, AssertStrideBMultiple and
    AssertTensorBytesLessThan, each recorded as type int, value -1 (the skip
    sentinel). They were added in Common/ValidParameters.py as registry entries,
    not solution defaults, which is why only the key roster and structure
    snapshots move.
  • ValidParameters/__snapshots__/test_validators_char.ambr (+12): two new

  • snapshots, test_assert_multiple_map_invalid_raises[negative] and
    [zero_after_skip], pinning the messages of the new
    checkAssertMultipleMapIsValid.

    Tests: a Tensile test YAML per kernel, matmul gtests (routed shapes in both
    orientations, alpha 1/beta 0 and alpha 1.5/beta 0.5, padded ldc, and
    fallbacks for shapes outside the shard, batch 2, bias and activation), a
    row-uniformity gtest case per routed kernel and orientation, and C++ and
    Python unit tests for the predicates, the shard (including its consistency
    with the kernels' custom.config), the .s headers and the kernel metadata.
    Regression tests for the two bug fixes, in tensilelite/tests/CustomKernel_test.cpp
    and RotatingBuffer_test.cpp:

  • CustomKernelTest.ByteStridesAreExactBeyondTheFloatMantissa (leading

  • dimension 16,777,219 for BF16 and 2^26+4 for FP8).
  • CustomKernelTest.ByteStridesMustFitTheirKernelArgumentType.

  • RotatingBufferSizing.EachProblemRotatesAccordingToItsOwnSize (Mode0Beta and

  • Mode1NoBeta).

    Performance (gfx950, hipblaslt-bench, 50 iterations and 15 cold iterations,
    speedup over a build without these kernels) over the 74 decode shapes:
    geomean 1.62x, median 1.45x, min 0.99x. The 69 shapes that run a skinny
    kernel: geomean 1.68x, median 1.48x, min 1.03x, max 3.35x (1792x2x5120); the
    other 5 run the generic kernels in both builds.

    Test Plan

  • MI355X (gfx950, PCI chip id 0x75a3), from projects/hipblaslt/build/release/clients:

  • HIP_VISIBLE_DEVICES=0 ./hipblaslt-test --gtest_filter='
    matmul_skinny_mxfp8'.
    The build used was make -j16 hipblaslt-test hipblaslt-test-data tensilelite-device-libraries
    in build/release (gfx950, TENSILELITE_LOGIC_FILTER=
    F8).
  • Math CI precheckin: all 42 matmul_skinny_mxfp8 cases on an MI350X (0x75a0).

  • Python unit suite, from projects/hipblaslt/tensilelite, with FORCE_COLOR and

  • CLICOLOR_FORCE unset: pytest -m unit -n4 -q -p no:cacheprovider tensilelite/Tests/unit.
  • Targeted shard test: pytest -q -p no:cacheprovider tensilelite/Tests/unit/test_skinny_mxfp8_logic.py -k test_shard_wins_every_key.

  • C++ regression tests for the two bug fixes: build tensilelite-tests with

  • TENSILELITE_BUILD_TESTING=ON and run CustomKernelTest.ByteStrides
    and
    RotatingBufferSizing.
  • CI notes: the TheRock gfx950 job on hipBLASLt PRs currently runs only the

  • quick suite (temporary override in therock-multi-arch-ci.yml), so it does not
    run the new skinny gtests; Math CI is the real evidence. For deeper coverage,
    dispatch the workflow manually with linux_amdgpu_families=gfx950,
    windows_amdgpu_families=none, pr_labels=test:hipblaslt,test_filter:comprehensive.
    A test_filter: PR label will not work because the per-family override wins.
  • Regression-test lane (M1): the bug-fix regression tests are C++ unit tests

  • in tensilelite/tests. Whether the tensilelite C++ tests run in a shared
    lane is not confirmed by me; the codecov/project/TensileLite-CPP check
    suggests they do.

    Test Result

    Local MI355X run, binary built from HEAD fa6e453385c at the time of writing
    (hipblaslt git version fa6e453385c; the SHA changes if the branch is amended
    or rebased):

    [==========] 42 tests from 1 test suite ran. (47832 ms total)
    [  PASSED  ] 42 tests.
    

    0 failed, 0 skipped. The 9 beta != 0 cases quarantined in known_bugs.yaml are
    not among the 42.

    Math CI precheckin ran all 42 matmul_skinny_mxfp8 cases on an MI350X (0x75a0)
    and passed. Together with the MI355X run, both chip ids are covered; the shard
    lists DeviceNames [Device 75a0] and serves other chip ids through fallbacks.
    Nothing else is claimed about Math CI.

    Python unit suite: 16044 passed, 20 failed, 806 snapshots passed in a
    single-process run (24 failed and 16040 passed with FORCE_COLOR set, because
    ANSI codes break 4 CLI help tests). The same 20 fail identically on clean
    local develop 02433ce8085 (run in a temporary worktree), so none are
    attributable to this branch. They are environment-related on my machine and
    expected to pass in CI, which I have not confirmed:

  • 14 source_only wheel/sdist tests (no setuptools/wheel in the venv, network

  • blocked).
  • 5 test_package_cli.py::test_every_installed_command_has_canonical_help

  • cases (console script not installed in the venv).
  • test_parallel_char.py::test_parallel_maps_use_worker_processes_with_two_threads

  • (not root-caused; environment).

    Targeted: test_skinny_mxfp8_logic.py::test_shard_wins_every_key_it_shares_with_an_equality_file_of_its_library
    passes (1 passed) on this branch.

    C++ regression tests, HIP_VISIBLE_DEVICES=0, tensilelite-tests built with
    TENSILELITE_BUILD_TESTING=ON, with the fix hunks reverted in a temporary
    worktree and the regression tests kept:

  • With the fixes: 4 of 4 pass.

  • Without the fixes:

  • - ByteStridesAreExactBeyondTheFloatMantissa fails: C/D bytes 33554440
    instead of 33554438; A/B bytes 67108864 instead of 67108868.
    - ByteStridesMustFitTheirKernelArgumentType fails: emits 2147483648 where
    2147483646 is expected, the EXPECT_THROWs throw nothing, and the uint32
    stride is 0 instead of 4294967294.
    - RotatingBufferSizing Mode0Beta fails with Rotating buffer size: 0 is not
    enough for rotating buffer size: 114688 * 9 = 1032192
    , then
    std::runtime_error.
    - RotatingBufferSizing Mode1NoBeta segfaults (exit 139).

    Coverage (Codecov, head fa6e453 against base 02433ce): patch coverage is
    85.48% and project coverage is 78.05%, a change of 0.03%. The uncovered patch
    lines are in ContractionSolution.cpp (13), DataInitialization.cpp (9) and
    Rotating.cpp (1); the Python files are fully covered. Codecov reports CI as
    passed.

    Submission Checklist


  • Look over the contributing guidelines at https://github.com/ROCm/TheRock/blob/main/GOVERNANCE.md#pull-requests.
  • Risk level

    Medium.

  • The new kernels are gated to gfx950, and routing is an Equality shard of 138

  • keys with a fallback to the generic kernels.
  • Two host-side fixes touch code that runs on all architectures: byte stride

  • computation now throws if a value does not fit the kernarg type, and client
    rotating buffer sizing changes.
  • Known quarantine: nine beta != 0 shapes (AIHPBLAS-5511, W-KNOWN-BUG flow,

  • review by 2026-12-15).

    🤖 Generated with Claude Code

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: yzhang93 Review duration: 33719m
    All Vouch review confidence checks passed
    Residual risk 0.23 = Change Risk (0.57) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.57 · 650 lines diff across 8 files
    0.57
    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
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #14512"
    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: 57% (MEDIUM) · Higher = larger blast radius
    57%
    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: 22.5% · Safe to merge
    22.5%