feat(hipblaslt): add host API for the fused GEMM + all-to-all epilogue #11342
<!-- therock-pr-bot-policy-check -->
✅ All Checks Passed — Ready for Review
| Check | Status | Details |
|---|:---:|---|
| 📝 PR Description | ✅ Pass | — |
| ⛔ Forbidden Files | ✅ Pass | — |
| 🧪 Unit Test | ✅ Pass | — |
| 🔎 pre-commit | ✅ Pass | — |
| 🚫 Draft PR | 🔜 To Be Enabled | — |
| 🚩 Feature Flag | 🔜 To Be Enabled | — |
| 📊 Code Coverage | 🔜 To Be Enabled | — |
| 🤖 therock-pr-bot | ✅ Pass | — |
🎉 All checks passed! This PR is ready for review.
📖 Need help? See the Policy FAQ for details on every check and how to fix failures.
<!-- therock-pr-bot-fix-policies -->
🎉 All checks passed! This PR is ready for review.
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
<details><summary>Additional details and impacted files</summary>
@@ Coverage Diff @@
## develop #11342 +/- ##
========================================
Coverage 70.29% 70.29%
========================================
Files 2812 2812
Lines 462769 462779 +10
Branches 68122 68124 +2
========================================
+ Hits 325271 325281 +10
Misses 113943 113943
Partials 23555 23555
| Flag | Coverage Δ | | Carryforward flag |
|---|---|---|---|
| TensileLite-CPP | 46.40% <ø> (ø) | | |
| TensileLite-Unit | 76.10% <100.00%> (+<0.01%) | :arrow_up: | |
| hipBLAS | 90.62% <ø> (ø) | | Carriedforward from 8011ff3 |
| hipBLASLt | 35.24% <ø> (ø) | | Carriedforward from 8011ff3 |
| hipCUB | 82.68% <ø> (ø) | | Carriedforward from 8011ff3 |
| hipDNN | 87.01% <ø> (ø) | | Carriedforward from 8011ff3 |
| hipFFT | 43.07% <ø> (ø) | | Carriedforward from 8011ff3 |
| hipRAND | 76.12% <ø> (ø) | | Carriedforward from 8011ff3 |
| hipSOLVER | 68.92% <ø> (ø) | | Carriedforward from 8011ff3 |
| hipSPARSE | 86.99% <ø> (ø) | | Carriedforward from 8011ff3 |
| rocBLAS | 48.31% <ø> (ø) | | Carriedforward from 8011ff3 |
| rocFFT | 47.88% <ø> (ø) | | Carriedforward from 8011ff3 |
| rocRAND | 57.42% <ø> (ø) | | Carriedforward from 8011ff3 |
| rocSOLVER | 76.83% <ø> (ø) | | Carriedforward from 8011ff3 |
| rocSPARSE | 74.61% <ø> (ø) | | Carriedforward from 8011ff3 |
| rocThrust | 91.60% <ø> (ø) | | Carriedforward from 8011ff3 |
This pull request uses carry forward flags. Click here to find out more.
| Files with missing lines | Coverage Δ | |
|---|---|---|
| ...ts/hipblaslt/library/include/hipblaslt/hipblaslt.h | 25.00% <ø> (ø) | |
| ...cts/hipblaslt/library/src/amd\_detail/hipblaslt.cpp | 63.50% <ø> (ø) | |
| ...rary/src/amd\_detail/rocblaslt/src/include/handle.h | 72.83% <ø> (ø) | |
| ...c/amd\_detail/rocblaslt/src/rocblaslt\_auxiliary.cpp | 68.40% <ø> (ø) | |
| ...rary/src/amd\_detail/rocblaslt/src/tensile\_host.cpp | 41.84% <ø> (ø) | |
| ...t/library/src/amd\_detail/rocblaslt/src/utility.cpp | 28.64% <ø> (ø) | |
| ...slt/tensilelite/Tensile/Common/GlobalParameters.py | 95.79% <ø> (ø) | |
| ...ite/Tensile/TensileCreateLibrary/ParseArguments.py | 100.00% <100.00%> (ø) | |
| ...lt/tensilelite/Tensile/TensileCreateLibrary/Run.py | 88.29% <100.00%> (+0.15%) | :arrow_up: |
</details>
<details><summary> :rocket: New features to boost your workflow: </summary>
</details>
The two peer branches are asymmetric: the cross-process one maps with hipIpcMemLazyEnablePeerAccess, the same-process one just stores the raw device pointer. Another device's pointer isn't addressable until peer access is enabled, so this branch faults once something reads device_comm_peer_flags — latent for now, since nothing does.
hipDeviceEnablePeerAccess needs the peer's ordinal, which DeviceCommExchange doesn't carry. Already-enabled counts as success.
Patch if it's useful: DDEle/rocm-libraries@02f1288
Some of the communicator state on the handle looks duplicated: device_comm_flags and device_comm_peer_flags[rank] hold the same pointer, and device_comm_registered carries the same bit as device_comm_world != 0 (world below 1 is rejected).
This reads well and the API surface matches what we agreed on. Two comments below. LGTM for other parts.
Good catch, and fixed in 1901f36 - thanks for the patch, I took it with one change.
hipDeviceEnablePeerAccess rejects a request to reach a device from itself, and two ranks in one process sharing a device is a configuration nothing here rejects - it is also the only shape a single-GPU machine can produce. So the call is guarded by peer.device != mine.device; the same device is addressable as it stands and needs nothing. The ordinal travels in DeviceCommExchange as you had it, already-enabled counts as success, and the NOT_SUPPORTED retval in the header now covers an unreachable peer device as well as an unmappable one.
I also added FusedA2ACommPeers.TwoRanksInOneProcessRegister to cover this branch, since nothing did: two handles rendezvousing through a real allgather, taking one device each where a second exists. The machine I test on has a single GPU, so the enable call itself still wants a multi-GPU run - your samples on #11413 will be the first thing to reach it in anger.
Both dropped in 1901f36.
device_comm_registered is now device_comm_world != 0. Registration rejects a world below one and publishes world last, once every peer's region is in hand, so nonzero carries exactly the bit the bool did.
device_comm_flags is gone too; the handle's own region is entry device_comm_rank of device_comm_peer_flags. It was doing one thing besides holding the pointer twice - marking which entry the handle frees - because mapped == false covers both the own allocation and a same-process peer, whose region belongs to another handle and must be left alone.
This is failing your windows CI: https://github.com/ROCm/rocm-libraries/actions/runs/33538807105/job/99959900567
This test does will not catch the issue it's supposed to since it will run on the 1 gpu runner and will havedeviceCount == 1. It needs to be set up to run on the 2gfx950 runner that was added for #10925.
Isn't this testing only that you could make the pointers, rather than also verifying that you can properly derefence/use them cross-device?
I'm still trying to wrap my head around it, but I'm not sure how this verifies that commit addresses the concern from https://github.com/ROCm/rocm-libraries/pull/11342/changes/f332481ff44020a375085f9a948e0f40ba536465#r3878647682 .
Trying to wrap my head around this.
For world > 1, “the callback is a memcpy” is ambiguous and conflicts with the preceding allgather contract. A same-process implementation still needs to collect every rank’s record and synchronize before returning. Is memcpy the world == 1 case, or can you describe an in-process allgather that uses shared rank-indexed storage.
Everything looks good to me now.
This is independently recreating the size of the flag block, it can get out of sync with what FusedA2AKernArg.hpp does.
We could also use a multi-process tests if the PR claims that this is supported
Nice catch. getpid() needs <process.h> on MSVC, so the include is platform-guarded now, matching what utility.cpp and logging.h already do.
I have split the test into a same-device test and a cross-device one that skips below two GPUs rather than approximating, plus a multi_gpu ctest category so a two-device runner can select it.
The test now asserts the state registration must leave behind. Each rank disables peer access to its peer's device first, establishing the precondition regardless of what ran earlier; after a successful registration, re-requesting the same direction has to report already-enabled.
Memcpy is the world == 1 case only. You're right that the sentence read as if it covered every single-process world. Reworded.
Fair point. In the revision, the host no longer derives the size — it asks for the kernel's FUSED_A2A_FLAG_BLOCK_BYTES through a Tensile-free declaration in rocblaslt-auxiliary.h, so there's a single definition and hipblaslt.cpp keeps no Tensile dependency.
A multi-process test can't just fork after HIP is initialised; it needs the test binary re-exec'd per rank plus a pipe or shm rendezvous for the allgather payloads, so I'll add that harness as a follow-up.
Approved these changes.
Approved these changes.
Would this be more appropriate for documentation?
llms tend to put verbose comments in code that cost tokens and bloat. If you feel that these comments are really necessary we can leave them but if not I would ask you agent to remove them and create a readme.
I assume that you have these no-ops because of a warning - this works too:
hipblasStatus_t failingAllgather(void*, const void*, void*, size_t)
{
That is, don't name the arguments then you don't have to use them.
RCCL already owns communicator topology and general peer transport. I understand that the fused packet emission must remain in TensileLite because it depends on GEMM tile completion and matrix layout.
Could we add a TODO and open a follow-up issue to move the RCCL-specific communicator and transport setup out of hipBLASLt? In particular, hipblasLtSetDeviceComm currently handles rank exchange, peer-access/IPC mapping, flag-region ownership, and SDMA queue registration. Those responsibilities risk becoming a second long-term communication ABI.
The follow-up should track moving this setup to RCCL or a shared transport layer while keeping only the GEMM-specific handoff and packet emission in hipBLASLt. RCCL’s current public collectives operate on completed device buffers, so this does not require moving the fused GEMM logic wholesale.
Please add a TODO referencing the new issue, for example:
// TODO(#ISSUE): Move communicator and peer-transport setup to RCCL or a shared transport layer; keep the fused GEMM handoff in hipBLASLt.
Trimmed the comments.
Good point. Trimmed this one and the other helper comments.
Good catch. Applied your suggestion, and did the same for the unused argument in memcpyAllgather, silentPeerAllgather and duplicatingAllgather.
HIPBLASLT_HAS_GEMM_A2A_FUSION is used to conditionally compile this feature in the installed public header, descriptor layout, attribute dispatch, and implementation files. Consequently, enabled and disabled builds expose different symbols and enum values, while every future change must preserve both configurations.
Are we required to exclude this feature at compile time? If not, compile it unconditionally and return HIPBLAS_STATUS_NOT_SUPPORTED when device support is unavailable. Keep the build option only for device-code generation.
If the implementation must remain optional, isolate it behind a stable interface and select enabled or stub translation units at build time. The disabled implementation should return NOT_SUPPORTED.
@talumbau
This change makes hipBLASLt own communication-transport work in addition to the GEMM-specific flag layout. That code becomes a long-term maintenance responsibility of the hipBLASLt team. rocSHMEM exposes the corresponding primitives today for one processing element per process: bootstrap, symmetric allocation, peer-address lookup, synchronization, and release. RCCL develop also exposes symmetric-window peer-pointer APIs.
I implemented the rocSHMEM path behind a separate C ABI adapter against the current PR head (ec9fb614ef2) and reran the evidence on 8 MI210 GPUs. The run passed peer-pointer all-to-all at 2, 4, and 8 ranks; four communicator-registration cases; seven ported communicator cases from the PR plus a repeated-registration case; descriptor and heuristic validation at 2, 4, and 8 ranks; and a peer hipMemcpyAsync visibility probe. The hipblaslt.cpp compile command contained no -fgpu-rdc; libhipblaslt.so contained no rocSHMEM symbols and recorded liba2a_transport.so as a runtime dependency. This demonstrates that the transport can live outside hipBLASLt; it does not establish production equivalence. No fused kernel exists yet, the hipBLASLt build does not build or install the adapter, the test that asserted hipDeviceEnablePeerAccess was replaced with a two-device registration test, and the tested rocSHMEM implementation supports one processing element per process plus collective allocation/free and process-global lifetime.
Current PR:
// Error handling and logging omitted.
if(j == rank || peer.pid == mine.pid)
{
if(j != rank && peer.device != mine.device)
hipDeviceEnablePeerAccess(peer.device, 0);
h->device_comm_peer_flags[j] = peer.flags;
h->device_comm_peer_flags_mapped[j] = false;
}
else
{
void* mapped = nullptr;
hipIpcOpenMemHandle(&mapped, peer.ipc, hipIpcMemLazyEnablePeerAccess);
h->device_comm_peer_flags[j] = mapped;
h->device_comm_peer_flags_mapped[j] = true;
}
External rocSHMEM adapter:
// Error handling omitted.
rocshmem_uniqueid_t uid{};
rocshmem_get_uniqueid(&uid); // rank 0 obtains it, then distributes it
rocshmem_init_attr_t attr{};
rocshmem_set_attr_uniqueid_args(rank, world, &uid, &attr);
rocshmem_init_attr(ROCSHMEM_INIT_WITH_UNIQUEID, &attr);
void* localFlags = rocshmem_malloc(bytes); // collective symmetric allocation
hipMemset(localFlags, 0, bytes);
rocshmem_barrier_all();
for(int peer = 0; peer < world; ++peer)
peerFlags[peer] = rocshmem_ptr(localFlags, peer);
// On coordinated teardown:
rocshmem_free(localFlags); // also collective
Approved these changes.
<!-- therock-bump-breadcrumb -->
TheRock Submodule Bump Activity
_Newest first_
DDEle
yzhang93
Motivation
The fused GEMM + all-to-all epilogue redistributes the leading run of D's feature dimension across the ranks of a device communicator from the GEMM's own store path, removing a separate collective pass. This lands the host side ahead of the TensileLite kernel so callers can build and validate a request, and so the family's enum and attribute ranges are reserved before the other fused-epilogue families arrive.
JIRA ID : ROCM-27524
Technical Details
HIPBLASLT_FUSEABLE_EPILOGUE_A2A_PREFIX(7, leaving 0-6 to the chainable families) and its five attributes (12-16), plushipblasLtSdmaQueue_t,hipblasLtA2ACompletionMode_t, and the sharedhipblasLtFusedEpilogueCreate/Add/SetAttribute/Destroybuilder. The builder documents family-neutral rules; per-family specifics stay on the enums.hipblasLtSetDeviceCommregisters a per-handle view of a device communicator, allocating the fine-grained flag regions and resolving peer addresses through a caller-supplied allgather, with IPC mapping for out-of-process peers. The flag-block layout is twinned withFUSED_A2A_FLAG_BLOCK_BYTESin the kernel'sFusedA2AKernArg.hpp.HIPBLASLT_MATMUL_DESC_FUSED_EPILOGUE(106, after develop'sUNIFORM_SUMMATION_ORDER_EXT) and is carried by_rocblaslt_matmul_descas a non-owning pointer.Add, required attributes at attach, and communicator, shape, and layout constraints before the heuristic and again at launch. No kernel is wired, so a well-formed request reportsHIPBLAS_STATUS_NOT_SUPPORTED.Test Plan
Build
hipblaslt-testand run--gtest_filter='FusedA2A*'on gfx950, covering descriptor lifecycle, builder composition rules, attribute range and width checks, communicator registration, attach-time completeness, and each dispatch-time rejection.Test Result
39 tests across 6 suites pass on gfx950. Nothing dispatches a GEMM: a valid request reports
NOT_SUPPORTED, confirming the validation chain runs to completion.Submission Checklist