← Back to Pull requests

feat(hipblaslt): move fused GEMM + all-to-all into the experimental API tier #17289

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Dec 04, 2026 19:26 UTC
Author

JIRA ID : AIHPBLAS-6031

Motivation

hipBLASLt can fuse an all-to-all, the collective in which every rank (one GPU of a group) sends a different block of data to every other rank, into a matrix multiplication (GEMM). The fusion works in both directions: GEMM+A2A sends parts of the output D to the other ranks as the GEMM stores it, and A2A+GEMM gathers this rank's share of the input B from its peers before the GEMM's main loop.

Its whole API sat in hipblaslt.h behind #if HIPBLASLT_HAS_GEMM_A2A_FUSION, which the off-by-default CMake option HIPBLASLT_ENABLE_GEMM_A2A_FUSION set. No ROCm build declared it, and whether a program could compile against it depended on how hipBLASLt was built. RFC0016 names this feature as the first to move into the experimental API tier that #16403 added: an opt-in header, a revision number that consumers check, and a deadline by which the feature graduates or is removed.

Technical Details

  • Header and names. The API moves to hipblaslt/hipblaslt-experimental-gemm-a2a.h as feature GEMM_A2A, revision 1, and stays a C API. As RFC0016 requires, functions and types take the hipblasLtExperimental prefix (for example hipblasLtExperimentalFusionCreate, hipblasLtExperimentalSetDeviceComm and hipblasLtExperimentalSdmaQueue_t) and constants take the HIPBLASLT_EXPERIMENTAL_ prefix. A program sees the API only after it opts in, as the next section shows.

  • Both directions. GEMM+A2A attaches its descriptor through HIPBLASLT_EXPERIMENTAL_MATMUL_DESC_FUSED_EPILOGUE and A2A+GEMM through HIPBLASLT_EXPERIMENTAL_MATMUL_DESC_FUSED_PROLOGUE. Both share the descriptor type, the device communicator and the copy-engine queue attributes, so they form one feature with one revision.

  • Enum values. The two matmul descriptor attributes become experimental values of the stable hipblasLtMatmulDescAttributes_t, 0x40000003 and 0x40000004. The other A2A enumerators are renumbered 5 through 14, so no two A2A values coincide, and HIPBLASLT_EXPERIMENTAL_ENUM_HIGH_WATER rises from 2 to 14. In C++, converting a value outside an enum's range to the enum is undefined behavior, and the range of hipblasLtMatmulDescAttributes_t ended at 127. The stable enum therefore gains HIPBLASLT_MATMUL_DESC_EXPERIMENTAL_RESERVED (0x40000000), which extends its range over the experimental values. It is not an attribute, and hipblasLtMatmulDescSetAttribute rejects it. The enum's size and underlying type are unchanged.

  • Always built. The CMake option, the installed hipblaslt-opt-in-features.h and its HIPBLASLT_HAS_GEMM_A2A_FUSION macro are removed, and TensileCreateLibrary no longer drops logic files whose ProblemType sets FusedA2A. Every build now compiles the API in, and every gfx950 device library gains the two fused logic files, which hold 7 solutions. The library links nothing new.

  • Registry. library/experimental/features.cmake registers GEMM_A2A with owner @yzhang93 and tracking ticket AIHPBLAS-6031. It is introduced in ROCm 10.4 and may ship through 11.1, because release/therock-10.3 was cut on 2026-11-30.

  • Tests. Contract tests record a feature's promised behavior, and changing one requires a revision bump. The 62 tests in fused_a2a_gtest.cpp that check behavior the header documents move to clients/tests/src/experimental/contract_gemm_a2a_gtest.cpp, with shared fixtures in contract_gemm_a2a_helpers.hpp. A new contract test attaches both stages through attribute values loaded from a variable. With Clang, that file is built with the enum sanitizer in trap mode, so a load outside the enum's range stops the test, and it declares the attributes constexpr, which fails to compile in that case. The 24 tests that check implementation details (rocRoller, grouped GEMM, the extension API and the current kernels' limits) stay in fused_a2a_gtest.cpp. Two new tests there fail on gfx950 if the device library lacks the GEMM+A2A or the A2A+GEMM kernel. They skip on other GPUs, and when the build filters the logic files or uses a custom logic path. Math CI's single-GPU gfx950 lane builds the full library, so it runs them. Neither file creates a real copy-engine queue.

  • Clients. hipblaslt-bench-a2a, the multi-process tests and clients/samples/30_hipblaslt_a2a_sdma create copy-engine (SDMA) queues through hsakmt, the user-space library for the GPU kernel driver, which needs libnuma. They build with the new client option HIPBLASLT_ENABLE_A2A_SDMA_CLIENTS (Linux only, off by default; invoke build --a2a-sdma-clients), as TENSILELITE_ENABLE_SDMA already does for the TensileLite client. invoke build --gemm-a2a-fusion remains as a deprecated alias for it, so existing build scripts and Math CI's multi-GPU lane keep building these clients.

  • Conflict. #16923 changes the parameters of hipblasLtSetDeviceComm. If it lands after this change, the experimental API checker will require it to add a renamed _v2 function and bump the revision to 2.
  • Using the feature

    Link roc::hipblaslt_experimental in CMake, or define ROCM_ENABLE_EXPERIMENTAL_APIS=1 before the include. Check the revision at run time, because the loaded library may be a different build:

    #define ROCM_ENABLE_EXPERIMENTAL_APIS 1
    #include <hipblaslt/hipblaslt-experimental.h>
    
    if(hipblasLtExperimentalGetFeatureRevision("GEMM_A2A") != 1)
        return runUnfused();
    

    Then register the ranks with hipblasLtExperimentalSetDeviceComm, build a descriptor with hipblasLtExperimentalFusionCreate and hipblasLtExperimentalFusionAddEpilogue (GEMM+A2A) or hipblasLtExperimentalFusionAddPrologue (A2A+GEMM), set its attributes, and attach it through HIPBLASLT_EXPERIMENTAL_MATMUL_DESC_FUSED_EPILOGUE or HIPBLASLT_EXPERIMENTAL_MATMUL_DESC_FUSED_PROLOGUE. clients/samples/30_hipblaslt_a2a_sdma is a complete program.

    Test Plan

    On a node with MI350X GPUs (gfx950) and ROCm 7.2.1:

  • python3 tools/scripts/check_experimental_api.py --base upstream/develop, and pytest tools/scripts/tests.

  • invoke build -a gfx950 -c -f 'gfx950_Cijk_Alik_Bljk_BBS_BH_UserArgs' --a2a-sdma-clients, which builds the library, the clients, and a device library holding both plain and fused BF16 kernels. The build includes hipblaslt-c-headers-check, which compiles the public C headers as C11 with -Wall -Wextra -Werror.

  • hipblaslt-test --gtest_filter='gemm_a2a_contract:ExperimentalApiSmoke.:FusedA2A:arguments_a2a:partitioned_gemm_contract:-World/' on one GPU.

  • hipblaslt-test --gtest_filter='World/FusedA2AMultiProcess_multi_gpu.' on 8 GPUs.

  • The same build reconfigured with -DHIPBLASLT_ENABLE_A2A_SDMA_CLIENTS=OFF, followed by the single-GPU filter.

  • After the review changes: a rebuild, then hipblaslt-test --gtest_filter='gemm_a2a_contract:ExperimentalApiSmoke.:FusedA2A:-World/*' on one GPU, built once with HIPBLASLT_TEST_FULL_DEVICE_LIBRARY forced on (this filtered library holds both fused kernels) and once as configured.

  • Programs built against the install tree: one including only hipblaslt.h, one including hipblaslt-experimental.h without the switch, one with the switch, and a find_package(hipblaslt) project linking roc::hipblaslt_experimental.

  • The TensileLite unit tests that import the edited Python modules.
  • Test Result

  • Checker: passes. It reports only additions (27 declarations and 2 contract files) and the new feature at revision 1. pytest tools/scripts/tests: 93 passed.

  • Build: succeeded, with no compiler warnings from the changed files.

  • One GPU: 111 passed, 5 skipped. Four PartitionedGemm contract tests and one grouped MXFP8 test skipped because the filtered device library has no kernel for their problems. The dispatch tests that compare a fused algorithm with a plain one ran, which shows the default device library now holds the fused kernels.

  • Multi-GPU: 14 passed. GemmA2A and A2AGemm each pass with 2 through 8 ranks.

  • SDMA clients off: configure no longer looks for hsakmt or libnuma, hipblaslt-test does not link hsakmt, and hipblaslt-bench-a2a is not built. 91 passed, 1 skipped (the grouped MXFP8 test).

  • Programs: the old names no longer compile against hipblaslt.h, and the experimental header declares nothing without the switch. With the switch, the API runs, reports revision 1, and rejects the former attribute value 106 with HIPBLAS_STATUS_INVALID_VALUE. The find_package project builds and runs.

  • After the review changes: checker passes; build has no warnings from the changed files, and the contract tests compile with -fsanitize=enum -fsanitize-trap=enum. With the requirement forced on: 104 passed and 1 skipped (the grouped MXFP8 test, which has no kernel in the filtered library), including both gfx950 kernel tests, the new contract test and the rejection of the reserved value. As configured, the two gfx950 kernel tests skip.

  • TensileLite: 10716 passed, 12 skipped, 1 expected failure. Six gfx1250 cases in test_arch_steppings.py could not start, because their subprocess could not import rocisa.code from the local Python environment.

  • Not run: Windows, TheRock's build, gfx1250, and the Sphinx documentation build. Automated GitHub checks are pending.
  • Submission Checklist

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

    Medium (3/5). Plain GEMMs keep their kernel selection: a fused solution matches only a problem with a fused stage attached, and the tests that detach the stage get the plain algorithm back. The build changes more: every build now compiles the A2A code, Windows included, and every gfx950 device library carries the fused kernels. The A2A API itself changes names and values, but no ROCm release build declared it.

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: yzhang93 Review duration: 753m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)). 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.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    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.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #17289"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.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: 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: 46.7% · Lower = rushed or shallow review
    46.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.7% · Safe to merge
    27.7%