← Back to Pull requests

feat(hipblaslt): add host API for the fused GEMM + all-to-all epilogue #11342

Merged
yzhang93 merged 22 files (2151 lines) on Sep 16, 2026 16:08 UTC
View on GitHub
yzhang93 yzhang93 commented on Aug 27, 2026 00:29 UTC
Author

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

  • Public API: HIPBLASLT_FUSEABLE_EPILOGUE_A2A_PREFIX (7, leaving 0-6 to the chainable families) and its five attributes (12-16), plus hipblasLtSdmaQueue_t, hipblasLtA2ACompletionMode_t, and the shared hipblasLtFusedEpilogueCreate / Add / SetAttribute / Destroy builder. The builder documents family-neutral rules; per-family specifics stay on the enums.

  • hipblasLtSetDeviceComm registers 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 with FUSED_A2A_FLAG_BLOCK_BYTES in the kernel's FusedA2AKernArg.hpp.

  • The descriptor attaches through HIPBLASLT_MATMUL_DESC_FUSED_EPILOGUE (106, after develop's UNIFORM_SUMMATION_ORDER_EXT) and is carried by _rocblaslt_matmul_desc as a non-owning pointer.

  • Validation is split three ways: stage composition at 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 reports HIPBLAS_STATUS_NOT_SUPPORTED.
  • Test Plan

    Build hipblaslt-test and 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

  • Look over the contributing guidelines at https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
  • Diff: 2151 lines (+2146 / -5) across 22 files Reviewer: DDEle Review duration: 29739m
    All Vouch review confidence checks passed
    Residual risk 0.09 = Change Risk (0.72) × (1 − Review Confidence (0.88)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.72 · 2151 lines diff across 22 files
    0.72
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.84 · 5 substantive comment(s)
    0.84
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    87%
    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.400
    Mass File Touch mass_file_touch
    0.080
    Real PR Conversation Timeline
    35 items
    therock-pr-bot[bot] therock-pr-bot[bot] commented on Aug 27, 2026 00:34 UTC
    Bot

    <!-- 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.

    🙋 Wish to Override Policy?

    therock-pr-bot[bot] therock-pr-bot[bot] commented on Aug 27, 2026 00:34 UTC
    Bot

    <!-- therock-pr-bot-fix-policies -->
    🎉 All checks passed! This PR is ready for review.

    codecov[bot] codecov[bot] commented on Aug 27, 2026 02:41 UTC
    Bot

    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>

  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

  • </details>

    DDEle DDEle commented on code on Aug 28, 2026 07:15 UTC
    Code Review
    projects/hipblaslt/library/src/amd_detail/hipblaslt.cpp:1
    @@ -431,6 +727,300 @@ catch(...)
         return exception_to_hipblas_status();
     }
     
    +hipblasStatus_t hipblasLtFusedEpilogueCreate(hipblasLtFusedEpilogueDescriptor_t* desc)
    +try
    +{
    +    rocblaslt::Debug::Instance().markerStart("hipblasLtFusedEpilogueCreate");
    +    if(desc == nullptr)
    +    {
    +        rocblaslt::Debug::Instance().markerStop();
    +        return HIPBLAS_STATUS_INVALID_VALUE;
    +    }
    +
    +    *desc = new hipblasLtFusedEpilogueDescriptor();
    +    rocblaslt::Debug::Instance().markerStop();
    +    return HIPBLAS_STATUS_SUCCESS;
    +}
    +catch(...)
    +{
    +    return exception_to_hipblas_status();
    +}
    +
    +hipblasStatus_t hipblasLtFusedEpilogueAdd(hipblasLtFusedEpilogueDescriptor_t desc,
    +                                          hipblasLtFuseableEpilogue_t        epilogue)
    +try
    +{
    +    rocblaslt::Debug::Instance().markerStart("hipblasLtFusedEpilogueAdd");
    +    hipblasStatus_t status = HIPBLAS_STATUS_SUCCESS;
    +
    +    if(desc == nullptr || !fused_epilogue_stage_recognized(epilogue))
    +    {
    +        status = HIPBLAS_STATUS_INVALID_VALUE;
    +    }
    +    else if(fused_epilogue_has_stage(desc, epilogue)
    +            || !fused_epilogue_stage_composes(desc, epilogue))
    +    {
    +        log_error(__func__, "epilogue stage does not compose with the stages already added");
    +        status = HIPBLAS_STATUS_INVALID_VALUE;
    +    }
    +    else
    +    {
    +        desc->stages.push_back(epilogue);
    +    }
    +
    +    rocblaslt::Debug::Instance().markerStop();
    +    return status;
    +}
    +catch(...)
    +{
    +    return exception_to_hipblas_status();
    +}
    +
    +hipblasStatus_t hipblasLtFusedEpilogueSetAttribute(hipblasLtFusedEpilogueDescriptor_t desc,
    +                                                   hipblasLtFusedEpilogueAttribute_t  attr,
    +                                                   const void*                        buf,
    +                                                   size_t                             sizeInBytes)
    +try
    +{
    +    rocblaslt::Debug::Instance().markerStart("hipblasLtFusedEpilogueSetAttribute");
    +    hipblasStatus_t status = HIPBLAS_STATUS_SUCCESS;
    +
    +    if(desc == nullptr || buf == nullptr)
    +    {
    +        rocblaslt::Debug::Instance().markerStop();
    +        return HIPBLAS_STATUS_INVALID_VALUE;
    +    }
    +
    +    switch(attr)
    +    {
    +    case HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT:
    +    {
    +        if(sizeInBytes < sizeof(int64_t))
    +        {
    +            log_error(__func__, "invalid all-to-all extent buf size", sizeInBytes);
    +            status = HIPBLAS_STATUS_INVALID_VALUE;
    +            break;
    +        }
    +        int64_t am = 0;
    +        memcpy(&am, buf, sizeof(am));
    +        if(am <= 0)
    +        {
    +            log_error(__func__, "all-to-all extent must be positive", (int)am);
    +            status = HIPBLAS_STATUS_INVALID_VALUE;
    +            break;
    +        }
    +        desc->a2a_extent     = am;
    +        desc->a2a_extent_set = true;
    +        break;
    +    }
    +    case HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_COMPLETION_MODE:
    +    {
    +        if(sizeInBytes < sizeof(hipblasLtA2ACompletionMode_t))
    +        {
    +            log_error(__func__, "invalid all-to-all completion mode buf size", sizeInBytes);
    +            status = HIPBLAS_STATUS_INVALID_VALUE;
    +            break;
    +        }
    +        hipblasLtA2ACompletionMode_t mode = HIPBLASLT_A2A_COMPLETION_IN_KERNEL;
    +        memcpy(&mode, buf, sizeof(mode));
    +        if(mode != HIPBLASLT_A2A_COMPLETION_IN_KERNEL)
    +        {
    +            log_error(__func__, "unsupported all-to-all completion mode", (int)mode);
    +            status = HIPBLAS_STATUS_INVALID_VALUE;
    +            break;
    +        }
    +        desc->a2a_completion = mode;
    +        break;
    +    }
    +    case HIPBLASLT_FUSED_EPILOGUE_COMM_CHANNEL:
    +    {
    +        if(sizeInBytes < sizeof(uint32_t))
    +        {
    +            log_error(__func__, "invalid comm channel buf size", sizeInBytes);
    +            status = HIPBLAS_STATUS_INVALID_VALUE;
    +            break;
    +        }
    +        // The upper bound is the communicator's nChannels, which lives on the
    +        // library handle and is not in hand here, so it is checked where the
    +        // handle is: before a solution is selected, and again at launch.
    +        memcpy(&desc->comm_channel, buf, sizeof(desc->comm_channel));
    +        break;
    +    }
    +    case HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_RECV_PTRS:
    +    {
    +        if(sizeInBytes == 0 || sizeInBytes % sizeof(void*) != 0
    +           || sizeInBytes / sizeof(void*) > HIPBLASLT_DEVICE_COMM_MAX_WORLD)
    +        {
    +            log_error(__func__, "invalid all-to-all peer-recv array size", sizeInBytes);
    +            status = HIPBLAS_STATUS_INVALID_VALUE;
    +            break;
    +        }
    +        const size_t count = sizeInBytes / sizeof(void*);
    +        desc->a2a_recv_ptrs.assign(count, nullptr);
    +        memcpy(desc->a2a_recv_ptrs.data(), buf, sizeInBytes);
    +        break;
    +    }
    +    case HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_SDMA_QUEUES:
    +    {
    +        if(sizeInBytes == 0 || sizeInBytes % sizeof(hipblasLtSdmaQueue_t) != 0
    +           || sizeInBytes / sizeof(hipblasLtSdmaQueue_t) > HIPBLASLT_DEVICE_COMM_MAX_WORLD)
    +        {
    +            log_error(__func__, "invalid all-to-all SDMA queue array size", sizeInBytes);
    +            status = HIPBLAS_STATUS_INVALID_VALUE;
    +            break;
    +        }
    +        const size_t count = sizeInBytes / sizeof(hipblasLtSdmaQueue_t);
    +        desc->a2a_queues.assign(count, hipblasLtSdmaQueue_t{});
    +        memcpy(desc->a2a_queues.data(), buf, sizeInBytes);
    +        break;
    +    }
    +    default:
    +        log_error(__func__, "invalid fused epilogue attribute", (int)attr);
    +        status = HIPBLAS_STATUS_INVALID_VALUE;
    +        break;
    +    }
    +
    +    rocblaslt::Debug::Instance().markerStop();
    +    return status;
    +}
    +catch(...)
    +{
    +    return exception_to_hipblas_status();
    +}
    +
    +hipblasStatus_t hipblasLtFusedEpilogueDestroy(hipblasLtFusedEpilogueDescriptor_t desc)
    +try
    +{
    +    rocblaslt::Debug::Instance().markerStart("hipblasLtFusedEpilogueDestroy");
    +    delete desc;
    +    rocblaslt::Debug::Instance().markerStop();
    +    return HIPBLAS_STATUS_SUCCESS;
    +}
    +catch(...)
    +{
    +    return exception_to_hipblas_status();
    +}
    +
    +hipblasStatus_t hipblasLtSetDeviceComm(hipblasLtHandle_t              handle,
    +                                       uint32_t                       rank,
    +                                       uint32_t                       world,
    +                                       uint32_t                       nChannels,
    +                                       hipblasLtDeviceCommAllgatherFn allgather,
    +                                       void*                          userData)
    +try
    +{
    +    rocblaslt::Debug::Instance().markerStart("hipblasLtSetDeviceComm");
    +
    +    if(handle == nullptr)
    +    {
    +        rocblaslt::Debug::Instance().markerStop();
    +        return HIPBLAS_STATUS_NOT_INITIALIZED;
    +    }
    +
    +    rocblaslt_handle h = (rocblaslt_handle)handle;
    +
    +    if(world < 1 || world > HIPBLASLT_DEVICE_COMM_MAX_WORLD || rank >= world || nChannels == 0
    +       || allgather == nullptr)
    +    {
    +        log_error(__func__, "invalid communicator arguments; world", (int)world);
    +        rocblaslt::Debug::Instance().markerStop();
    +        return HIPBLAS_STATUS_INVALID_VALUE;
    +    }
    +
    +    // Exactly once per handle, matching arguments or not. That is what makes world
    +    // immutable, and world participates in solution selection.
    +    if(h->device_comm_registered)
    +    {
    +        log_error(__func__, "this handle already carries a communicator");
    +        rocblaslt::Debug::Instance().markerStop();
    +        return HIPBLAS_STATUS_INVALID_VALUE;
    +    }
    +
    +    void*        flags = nullptr;
    +    const size_t bytes = (size_t)nChannels * kDeviceCommFlagChannelSize;
    +    // Fine-grained, because a peer's copy engine updates these lines.
    +    if(hipExtMallocWithFlags(&flags, bytes, hipDeviceMallocFinegrained) != hipSuccess
    +       || flags == nullptr)
    +    {
    +        log_error(__func__, "could not allocate the communicator's flag regions");
    +        rocblaslt::Debug::Instance().markerStop();
    +        return HIPBLAS_STATUS_ALLOC_FAILED;
    +    }
    +    if(hipMemset(flags, 0, bytes) != hipSuccess)
    +    {
    +        static_cast<void>(hipFree(flags));
    +        rocblaslt::Debug::Instance().markerStop();
    +        return HIPBLAS_STATUS_ALLOC_FAILED;
    +    }
    +
    +    DeviceCommExchange mine{};
    +    mine.magic     = kDeviceCommMagic;
    +    mine.rank      = rank;
    +    mine.world     = world;
    +    mine.nChannels = nChannels;
    +    mine.pid       = (uint64_t)getpid();
    +    mine.flags     = flags;
    +    // Only needed by a peer in another process; a failure here is reported when
    +    // such a peer is actually found, not before.
    +    mine.ipcValid = (hipIpcGetMemHandle(&mine.ipc, flags) == hipSuccess) ? 1u : 0u;
    +
    +    std::vector<DeviceCommExchange> all(world);
    +    hipblasStatus_t                 status
    +        = allgather(userData, &mine, all.data(), sizeof(DeviceCommExchange));
    +    if(status != HIPBLAS_STATUS_SUCCESS)
    +    {
    +        static_cast<void>(hipFree(flags));
    +        rocblaslt::Debug::Instance().markerStop();
    +        return status;
    +    }
    +
    +    h->device_comm_flags = flags;
    +
    +    for(uint32_t j = 0; j < world; ++j)
    +    {
    +        const DeviceCommExchange& peer = all[j];
    +        if(peer.magic != kDeviceCommMagic || peer.rank != j || peer.world != world
    +           || peer.nChannels != nChannels || peer.flags == nullptr)
    +        {
    +            log_error(__func__, "ranks disagree about the communicator; rank", (int)j);
    +            release_device_comm(h);
    +            rocblaslt::Debug::Instance().markerStop();
    +            return HIPBLAS_STATUS_INVALID_VALUE;
    +        }
    +
    +        if(j == rank || peer.pid == mine.pid)
    +        {
    +            h->device_comm_peer_flags[j]        = peer.flags;
    +            h->device_comm_peer_flags_mapped[j] = false;
    +            continue;
    +        }

    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

    DDEle DDEle commented on code on Aug 28, 2026 07:27 UTC
    Code Review
    projects/hipblaslt/library/src/amd_detail/rocblaslt/src/include/handle.h:1
    @@ -129,6 +129,24 @@ struct _rocblaslt_handle
         bool                  check_numerics_stop_on_first = false;
         // Sticky bypass for scan_D once any caller observes a NaN.
         std::atomic<bool>     check_numerics_short_circuit{false};
    +
    +    // Device communicator, registered once by hipblasLtSetDeviceComm. Every rank
    +    // registers on its own handle; the W handles form one communicator, of which
    +    // this is the local view. Absent (device_comm_registered == false) unless a
    +    // caller asks for a communicating fused epilogue.
    +    bool     device_comm_registered = false;
    +    uint32_t device_comm_rank       = 0;
    +    uint32_t device_comm_world      = 0;
    +    uint32_t device_comm_channels   = 0;
    +
    +    // Library-owned completion flags: device_comm_channels independent regions on
    +    // this device, never passed in nor readable by the caller. device_comm_flags
    +    // is this device's allocation; device_comm_peer_flags[j] is rank j's region as
    +    // addressed from this process, which for a peer in another process means an
    +    // IPC mapping this handle owns and closes.
    +    void* device_comm_flags                                             = nullptr;
    +    void* device_comm_peer_flags[HIPBLASLT_DEVICE_COMM_MAX_WORLD]        = {};
    +    bool  device_comm_peer_flags_mapped[HIPBLASLT_DEVICE_COMM_MAX_WORLD] = {};

    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).

    DDEle DDEle commented on Aug 28, 2026 07:49 UTC
    Reviewer

    This reads well and the API surface matches what we agreed on. Two comments below. LGTM for other parts.

    yzhang93 yzhang93 commented on code on Aug 28, 2026 16:59 UTC
    Code Review
    projects/hipblaslt/library/src/amd_detail/hipblaslt.cpp:1
    @@ -431,6 +727,300 @@ catch(...)
         return exception_to_hipblas_status();
     }
     
    +hipblasStatus_t hipblasLtFusedEpilogueCreate(hipblasLtFusedEpilogueDescriptor_t* desc)
    +try
    +{
    +    rocblaslt::Debug::Instance().markerStart("hipblasLtFusedEpilogueCreate");
    +    if(desc == nullptr)
    +    {
    +        rocblaslt::Debug::Instance().markerStop();
    +        return HIPBLAS_STATUS_INVALID_VALUE;
    +    }
    +
    +    *desc = new hipblasLtFusedEpilogueDescriptor();
    +    rocblaslt::Debug::Instance().markerStop();
    +    return HIPBLAS_STATUS_SUCCESS;
    +}
    +catch(...)
    +{
    +    return exception_to_hipblas_status();
    +}
    +
    +hipblasStatus_t hipblasLtFusedEpilogueAdd(hipblasLtFusedEpilogueDescriptor_t desc,
    +                                          hipblasLtFuseableEpilogue_t        epilogue)
    +try
    +{
    +    rocblaslt::Debug::Instance().markerStart("hipblasLtFusedEpilogueAdd");
    +    hipblasStatus_t status = HIPBLAS_STATUS_SUCCESS;
    +
    +    if(desc == nullptr || !fused_epilogue_stage_recognized(epilogue))
    +    {
    +        status = HIPBLAS_STATUS_INVALID_VALUE;
    +    }
    +    else if(fused_epilogue_has_stage(desc, epilogue)
    +            || !fused_epilogue_stage_composes(desc, epilogue))
    +    {
    +        log_error(__func__, "epilogue stage does not compose with the stages already added");
    +        status = HIPBLAS_STATUS_INVALID_VALUE;
    +    }
    +    else
    +    {
    +        desc->stages.push_back(epilogue);
    +    }
    +
    +    rocblaslt::Debug::Instance().markerStop();
    +    return status;
    +}
    +catch(...)
    +{
    +    return exception_to_hipblas_status();
    +}
    +
    +hipblasStatus_t hipblasLtFusedEpilogueSetAttribute(hipblasLtFusedEpilogueDescriptor_t desc,
    +                                                   hipblasLtFusedEpilogueAttribute_t  attr,
    +                                                   const void*                        buf,
    +                                                   size_t                             sizeInBytes)
    +try
    +{
    +    rocblaslt::Debug::Instance().markerStart("hipblasLtFusedEpilogueSetAttribute");
    +    hipblasStatus_t status = HIPBLAS_STATUS_SUCCESS;
    +
    +    if(desc == nullptr || buf == nullptr)
    +    {
    +        rocblaslt::Debug::Instance().markerStop();
    +        return HIPBLAS_STATUS_INVALID_VALUE;
    +    }
    +
    +    switch(attr)
    +    {
    +    case HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT:
    +    {
    +        if(sizeInBytes < sizeof(int64_t))
    +        {
    +            log_error(__func__, "invalid all-to-all extent buf size", sizeInBytes);
    +            status = HIPBLAS_STATUS_INVALID_VALUE;
    +            break;
    +        }
    +        int64_t am = 0;
    +        memcpy(&am, buf, sizeof(am));
    +        if(am <= 0)
    +        {
    +            log_error(__func__, "all-to-all extent must be positive", (int)am);
    +            status = HIPBLAS_STATUS_INVALID_VALUE;
    +            break;
    +        }
    +        desc->a2a_extent     = am;
    +        desc->a2a_extent_set = true;
    +        break;
    +    }
    +    case HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_COMPLETION_MODE:
    +    {
    +        if(sizeInBytes < sizeof(hipblasLtA2ACompletionMode_t))
    +        {
    +            log_error(__func__, "invalid all-to-all completion mode buf size", sizeInBytes);
    +            status = HIPBLAS_STATUS_INVALID_VALUE;
    +            break;
    +        }
    +        hipblasLtA2ACompletionMode_t mode = HIPBLASLT_A2A_COMPLETION_IN_KERNEL;
    +        memcpy(&mode, buf, sizeof(mode));
    +        if(mode != HIPBLASLT_A2A_COMPLETION_IN_KERNEL)
    +        {
    +            log_error(__func__, "unsupported all-to-all completion mode", (int)mode);
    +            status = HIPBLAS_STATUS_INVALID_VALUE;
    +            break;
    +        }
    +        desc->a2a_completion = mode;
    +        break;
    +    }
    +    case HIPBLASLT_FUSED_EPILOGUE_COMM_CHANNEL:
    +    {
    +        if(sizeInBytes < sizeof(uint32_t))
    +        {
    +            log_error(__func__, "invalid comm channel buf size", sizeInBytes);
    +            status = HIPBLAS_STATUS_INVALID_VALUE;
    +            break;
    +        }
    +        // The upper bound is the communicator's nChannels, which lives on the
    +        // library handle and is not in hand here, so it is checked where the
    +        // handle is: before a solution is selected, and again at launch.
    +        memcpy(&desc->comm_channel, buf, sizeof(desc->comm_channel));
    +        break;
    +    }
    +    case HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_RECV_PTRS:
    +    {
    +        if(sizeInBytes == 0 || sizeInBytes % sizeof(void*) != 0
    +           || sizeInBytes / sizeof(void*) > HIPBLASLT_DEVICE_COMM_MAX_WORLD)
    +        {
    +            log_error(__func__, "invalid all-to-all peer-recv array size", sizeInBytes);
    +            status = HIPBLAS_STATUS_INVALID_VALUE;
    +            break;
    +        }
    +        const size_t count = sizeInBytes / sizeof(void*);
    +        desc->a2a_recv_ptrs.assign(count, nullptr);
    +        memcpy(desc->a2a_recv_ptrs.data(), buf, sizeInBytes);
    +        break;
    +    }
    +    case HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_SDMA_QUEUES:
    +    {
    +        if(sizeInBytes == 0 || sizeInBytes % sizeof(hipblasLtSdmaQueue_t) != 0
    +           || sizeInBytes / sizeof(hipblasLtSdmaQueue_t) > HIPBLASLT_DEVICE_COMM_MAX_WORLD)
    +        {
    +            log_error(__func__, "invalid all-to-all SDMA queue array size", sizeInBytes);
    +            status = HIPBLAS_STATUS_INVALID_VALUE;
    +            break;
    +        }
    +        const size_t count = sizeInBytes / sizeof(hipblasLtSdmaQueue_t);
    +        desc->a2a_queues.assign(count, hipblasLtSdmaQueue_t{});
    +        memcpy(desc->a2a_queues.data(), buf, sizeInBytes);
    +        break;
    +    }
    +    default:
    +        log_error(__func__, "invalid fused epilogue attribute", (int)attr);
    +        status = HIPBLAS_STATUS_INVALID_VALUE;
    +        break;
    +    }
    +
    +    rocblaslt::Debug::Instance().markerStop();
    +    return status;
    +}
    +catch(...)
    +{
    +    return exception_to_hipblas_status();
    +}
    +
    +hipblasStatus_t hipblasLtFusedEpilogueDestroy(hipblasLtFusedEpilogueDescriptor_t desc)
    +try
    +{
    +    rocblaslt::Debug::Instance().markerStart("hipblasLtFusedEpilogueDestroy");
    +    delete desc;
    +    rocblaslt::Debug::Instance().markerStop();
    +    return HIPBLAS_STATUS_SUCCESS;
    +}
    +catch(...)
    +{
    +    return exception_to_hipblas_status();
    +}
    +
    +hipblasStatus_t hipblasLtSetDeviceComm(hipblasLtHandle_t              handle,
    +                                       uint32_t                       rank,
    +                                       uint32_t                       world,
    +                                       uint32_t                       nChannels,
    +                                       hipblasLtDeviceCommAllgatherFn allgather,
    +                                       void*                          userData)
    +try
    +{
    +    rocblaslt::Debug::Instance().markerStart("hipblasLtSetDeviceComm");
    +
    +    if(handle == nullptr)
    +    {
    +        rocblaslt::Debug::Instance().markerStop();
    +        return HIPBLAS_STATUS_NOT_INITIALIZED;
    +    }
    +
    +    rocblaslt_handle h = (rocblaslt_handle)handle;
    +
    +    if(world < 1 || world > HIPBLASLT_DEVICE_COMM_MAX_WORLD || rank >= world || nChannels == 0
    +       || allgather == nullptr)
    +    {
    +        log_error(__func__, "invalid communicator arguments; world", (int)world);
    +        rocblaslt::Debug::Instance().markerStop();
    +        return HIPBLAS_STATUS_INVALID_VALUE;
    +    }
    +
    +    // Exactly once per handle, matching arguments or not. That is what makes world
    +    // immutable, and world participates in solution selection.
    +    if(h->device_comm_registered)
    +    {
    +        log_error(__func__, "this handle already carries a communicator");
    +        rocblaslt::Debug::Instance().markerStop();
    +        return HIPBLAS_STATUS_INVALID_VALUE;
    +    }
    +
    +    void*        flags = nullptr;
    +    const size_t bytes = (size_t)nChannels * kDeviceCommFlagChannelSize;
    +    // Fine-grained, because a peer's copy engine updates these lines.
    +    if(hipExtMallocWithFlags(&flags, bytes, hipDeviceMallocFinegrained) != hipSuccess
    +       || flags == nullptr)
    +    {
    +        log_error(__func__, "could not allocate the communicator's flag regions");
    +        rocblaslt::Debug::Instance().markerStop();
    +        return HIPBLAS_STATUS_ALLOC_FAILED;
    +    }
    +    if(hipMemset(flags, 0, bytes) != hipSuccess)
    +    {
    +        static_cast<void>(hipFree(flags));
    +        rocblaslt::Debug::Instance().markerStop();
    +        return HIPBLAS_STATUS_ALLOC_FAILED;
    +    }
    +
    +    DeviceCommExchange mine{};
    +    mine.magic     = kDeviceCommMagic;
    +    mine.rank      = rank;
    +    mine.world     = world;
    +    mine.nChannels = nChannels;
    +    mine.pid       = (uint64_t)getpid();
    +    mine.flags     = flags;
    +    // Only needed by a peer in another process; a failure here is reported when
    +    // such a peer is actually found, not before.
    +    mine.ipcValid = (hipIpcGetMemHandle(&mine.ipc, flags) == hipSuccess) ? 1u : 0u;
    +
    +    std::vector<DeviceCommExchange> all(world);
    +    hipblasStatus_t                 status
    +        = allgather(userData, &mine, all.data(), sizeof(DeviceCommExchange));
    +    if(status != HIPBLAS_STATUS_SUCCESS)
    +    {
    +        static_cast<void>(hipFree(flags));
    +        rocblaslt::Debug::Instance().markerStop();
    +        return status;
    +    }
    +
    +    h->device_comm_flags = flags;
    +
    +    for(uint32_t j = 0; j < world; ++j)
    +    {
    +        const DeviceCommExchange& peer = all[j];
    +        if(peer.magic != kDeviceCommMagic || peer.rank != j || peer.world != world
    +           || peer.nChannels != nChannels || peer.flags == nullptr)
    +        {
    +            log_error(__func__, "ranks disagree about the communicator; rank", (int)j);
    +            release_device_comm(h);
    +            rocblaslt::Debug::Instance().markerStop();
    +            return HIPBLAS_STATUS_INVALID_VALUE;
    +        }
    +
    +        if(j == rank || peer.pid == mine.pid)
    +        {
    +            h->device_comm_peer_flags[j]        = peer.flags;
    +            h->device_comm_peer_flags_mapped[j] = false;
    +            continue;
    +        }

    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.

    yzhang93 yzhang93 commented on code on Aug 28, 2026 16:59 UTC
    Code Review
    projects/hipblaslt/library/src/amd_detail/rocblaslt/src/include/handle.h:1
    @@ -129,6 +129,24 @@ struct _rocblaslt_handle
         bool                  check_numerics_stop_on_first = false;
         // Sticky bypass for scan_D once any caller observes a NaN.
         std::atomic<bool>     check_numerics_short_circuit{false};
    +
    +    // Device communicator, registered once by hipblasLtSetDeviceComm. Every rank
    +    // registers on its own handle; the W handles form one communicator, of which
    +    // this is the local view. Absent (device_comm_registered == false) unless a
    +    // caller asks for a communicating fused epilogue.
    +    bool     device_comm_registered = false;
    +    uint32_t device_comm_rank       = 0;
    +    uint32_t device_comm_world      = 0;
    +    uint32_t device_comm_channels   = 0;
    +
    +    // Library-owned completion flags: device_comm_channels independent regions on
    +    // this device, never passed in nor readable by the caller. device_comm_flags
    +    // is this device's allocation; device_comm_peer_flags[j] is rank j's region as
    +    // addressed from this process, which for a peer in another process means an
    +    // IPC mapping this handle owns and closes.
    +    void* device_comm_flags                                             = nullptr;
    +    void* device_comm_peer_flags[HIPBLASLT_DEVICE_COMM_MAX_WORLD]        = {};
    +    bool  device_comm_peer_flags_mapped[HIPBLASLT_DEVICE_COMM_MAX_WORLD] = {};

    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.

    Alex-Vasile Alex-Vasile commented on code on Sep 01, 2026 19:16 UTC
    Code Review
    projects/hipblaslt/library/src/amd_detail/hipblaslt.cpp:1
    @@ -38,6 +38,8 @@
     #include <stdio.h>
     #include <stdlib.h>
     #include <string>
    +#include <unistd.h>
    Alex-Vasile Alex-Vasile commented on code on Sep 01, 2026 21:17 UTC
    Code Review
    projects/hipblaslt/clients/tests/src/fused_a2a_gtest.cpp:1
    @@ -0,0 +1,892 @@
    +// Copyright Advanced Micro Devices, Inc., or its affiliates.
    +// SPDX-License-Identifier: MIT
    +
    +// API-surface tests for the fused GEMM + all-to-all epilogue.
    +//
    +// This covers what the host can decide on its own: the builder's single-stage
    +// family rule, each attribute's accepted range, the completeness check that runs
    +// when the descriptor is attached to a matmul descriptor, communicator
    +// registration, and the shape and layout requirements checked before a solution
    +// is selected. No architecture carries a fused all-to-all kernel yet, so a
    +// well-formed request ends in HIPBLAS_STATUS_NOT_SUPPORTED; the tests assert that
    +// distinction, since an unusable request must be an error while missing
    +// capability must never present as a rejected shape.
    +//
    +// The suite names carry the "pre_checkin" token on purpose: the ctest presets in
    +// clients/tests/test_categories.yaml select by loose substring on a category
    +// token, and a plain gtest suite has none, so it would be invisible to them.
    +
    +#include <gtest/gtest.h>
    +#include <hip/hip_runtime.h>
    +#include <hipblaslt/hipblaslt.h>
    +
    +#include <chrono>
    +#include <condition_variable>
    +#include <cstring>
    +#include <mutex>
    +#include <thread>
    +#include <vector>
    +
    +namespace
    +{
    +    bool gpuAvailable()
    +    {
    +        int deviceCount = 0;
    +        return hipGetDeviceCount(&deviceCount) == hipSuccess && deviceCount > 0;
    +    }
    +
    +    // A single-process allgather: with one rank it is exactly the memcpy the
    +    // design doc names as the single-process case.
    +    hipblasStatus_t memcpyAllgather(void*       userData,
    +                                    const void* sendbuf,
    +                                    void*       recvbuf,
    +                                    size_t      bytesPerRank)
    +    {
    +        (void)userData;
    +        memcpy(recvbuf, sendbuf, bytesPerRank);
    +        return HIPBLAS_STATUS_SUCCESS;
    +    }
    +
    +    hipblasStatus_t failingAllgather(void*       userData,
    +                                     const void* sendbuf,
    +                                     void*       recvbuf,
    +                                     size_t      bytesPerRank)
    +    {
    +        (void)userData;
    +        (void)sendbuf;
    +        (void)recvbuf;
    +        (void)bytesPerRank;
    +        return HIPBLAS_STATUS_INTERNAL_ERROR;
    +    }
    +
    +    // Publishes this rank's payload and leaves the second slot zeroed, which no
    +    // real contribution can ever look like. Stands in for any way the ranks can
    +    // fail to agree about the communicator.
    +    hipblasStatus_t silentPeerAllgather(void*       userData,
    +                                        const void* sendbuf,
    +                                        void*       recvbuf,
    +                                        size_t      bytesPerRank)
    +    {
    +        (void)userData;
    +        memcpy(recvbuf, sendbuf, bytesPerRank);
    +        memset(static_cast<char*>(recvbuf) + bytesPerRank, 0, bytesPerRank);
    +        return HIPBLAS_STATUS_SUCCESS;
    +    }
    +
    +    // Copies this rank's payload into both slots, so the second slot claims to be
    +    // rank 0 where rank 1 belongs.
    +    hipblasStatus_t duplicatingAllgather(void*       userData,
    +                                         const void* sendbuf,
    +                                         void*       recvbuf,
    +                                         size_t      bytesPerRank)
    +    {
    +        (void)userData;
    +        memcpy(recvbuf, sendbuf, bytesPerRank);
    +        memcpy(static_cast<char*>(recvbuf) + bytesPerRank, sendbuf, bytesPerRank);
    +        return HIPBLAS_STATUS_SUCCESS;
    +    }
    +
    +    // A real allgather for ranks that are threads of one process: each publishes
    +    // into its own slot and waits for the rest before reading the whole buffer
    +    // back. Registration cannot return until every peer has contributed, so this
    +    // rendezvous is the only way more than one rank registers in one process. The
    +    // wait is bounded so a rank that never arrives fails the test instead of
    +    // hanging it.
    +    struct Rendezvous
    +    {
    +        std::mutex              mutex;
    +        std::condition_variable arrival;
    +        std::vector<char>       slots;
    +        uint32_t                arrived = 0;
    +        uint32_t                world   = 0;
    +    };
    +
    +    struct RendezvousRank
    +    {
    +        Rendezvous* shared;
    +        uint32_t    rank;
    +    };
    +
    +    hipblasStatus_t
    +        rendezvousAllgather(void* userData, const void* sendbuf, void* recvbuf, size_t bytesPerRank)
    +    {
    +        RendezvousRank& self   = *static_cast<RendezvousRank*>(userData);
    +        Rendezvous&     shared = *self.shared;
    +
    +        std::unique_lock<std::mutex> lock(shared.mutex);
    +        if(shared.slots.empty())
    +            shared.slots.resize(bytesPerRank * shared.world);
    +        memcpy(shared.slots.data() + bytesPerRank * self.rank, sendbuf, bytesPerRank);
    +
    +        if(++shared.arrived == shared.world)
    +        {
    +            shared.arrival.notify_all();
    +        }
    +        else if(!shared.arrival.wait_for(
    +                    lock, std::chrono::seconds(30), [&] { return shared.arrived == shared.world; }))
    +        {
    +            return HIPBLAS_STATUS_INTERNAL_ERROR;
    +        }
    +
    +        memcpy(recvbuf, shared.slots.data(), bytesPerRank * shared.world);
    +        return HIPBLAS_STATUS_SUCCESS;
    +    }
    +
    +    // Four plausible-looking addresses. The library stores a queue's fields
    +    // without interpreting them, so a test only needs them to be non-null.
    +    hipblasLtSdmaQueue_t fakeQueue(uintptr_t base)
    +    {
    +        hipblasLtSdmaQueue_t q{};
    +        q.queueBuf = reinterpret_cast<void*>(base);
    +        q.rptr     = reinterpret_cast<void*>(base + 0x100);
    +        q.wptr     = reinterpret_cast<void*>(base + 0x200);
    +        q.doorbell = reinterpret_cast<void*>(base + 0x300);
    +        return q;
    +    }
    +
    +    /************************************************************************
    +     * Builder: lifecycle, the single-stage family rule, and attributes.
    +     * None of this needs a device.
    +     ***********************************************************************/
    +
    +    class FusedA2ABuilder_pre_checkin : public ::testing::Test
    +    {
    +    protected:
    +        void SetUp() override
    +        {
    +            ASSERT_EQ(hipblasLtFusedEpilogueCreate(&fused), HIPBLAS_STATUS_SUCCESS);
    +            ASSERT_NE(fused, nullptr);
    +        }
    +
    +        void TearDown() override
    +        {
    +            if(fused)
    +                EXPECT_EQ(hipblasLtFusedEpilogueDestroy(fused), HIPBLAS_STATUS_SUCCESS);
    +        }
    +
    +        hipblasStatus_t addA2A()
    +        {
    +            return hipblasLtFusedEpilogueAdd(fused, HIPBLASLT_FUSEABLE_EPILOGUE_A2A_PREFIX);
    +        }
    +
    +        hipblasStatus_t setExtent(int64_t am)
    +        {
    +            return hipblasLtFusedEpilogueSetAttribute(
    +                fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT, &am, sizeof(am));
    +        }
    +
    +        hipblasStatus_t setRecvPtrs(const std::vector<void*>& ptrs)
    +        {
    +            return hipblasLtFusedEpilogueSetAttribute(fused,
    +                                                      HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_RECV_PTRS,
    +                                                      ptrs.data(),
    +                                                      ptrs.size() * sizeof(void*));
    +        }
    +
    +        hipblasStatus_t setQueues(const std::vector<hipblasLtSdmaQueue_t>& queues)
    +        {
    +            return hipblasLtFusedEpilogueSetAttribute(
    +                fused,
    +                HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_SDMA_QUEUES,
    +                queues.data(),
    +                queues.size() * sizeof(hipblasLtSdmaQueue_t));
    +        }
    +
    +        hipblasLtFusedEpilogueDescriptor_t fused = nullptr;
    +    };
    +
    +    TEST(FusedA2ALifecycle_pre_checkin, CreateRejectsNullOut)
    +    {
    +        EXPECT_EQ(hipblasLtFusedEpilogueCreate(nullptr), HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST(FusedA2ALifecycle_pre_checkin, DestroyAcceptsNull)
    +    {
    +        EXPECT_EQ(hipblasLtFusedEpilogueDestroy(nullptr), HIPBLAS_STATUS_SUCCESS);
    +    }
    +
    +    TEST(FusedA2ALifecycle_pre_checkin, AddRejectsNullDescriptor)
    +    {
    +        EXPECT_EQ(hipblasLtFusedEpilogueAdd(nullptr, HIPBLASLT_FUSEABLE_EPILOGUE_A2A_PREFIX),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2ABuilder_pre_checkin, AddAcceptsAllToAll)
    +    {
    +        EXPECT_EQ(addA2A(), HIPBLAS_STATUS_SUCCESS);
    +    }
    +
    +    TEST_F(FusedA2ABuilder_pre_checkin, AddRejectsUnrecognizedStage)
    +    {
    +        EXPECT_EQ(hipblasLtFusedEpilogueAdd(fused, static_cast<hipblasLtFuseableEpilogue_t>(4242)),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    // The collective family holds one stage, so a second all-to-all is rejected
    +    // at the call expressing the mistake rather than at launch.
    +    TEST_F(FusedA2ABuilder_pre_checkin, AddRejectsDuplicateAllToAll)
    +    {
    +        ASSERT_EQ(addA2A(), HIPBLAS_STATUS_SUCCESS);
    +        EXPECT_EQ(addA2A(), HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2ABuilder_pre_checkin, SetAttributeRejectsNullArguments)
    +    {
    +        const int64_t am = 512;
    +        EXPECT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      nullptr, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT, &am, sizeof(am)),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +        EXPECT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT, nullptr, sizeof(am)),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2ABuilder_pre_checkin, SetAttributeRejectsUnknownAttribute)
    +    {
    +        const int64_t value = 1;
    +        EXPECT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused,
    +                      static_cast<hipblasLtFusedEpilogueAttribute_t>(9999),
    +                      &value,
    +                      sizeof(value)),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2ABuilder_pre_checkin, ExtentMustBePositiveAndCorrectlySized)
    +    {
    +        EXPECT_EQ(setExtent(512), HIPBLAS_STATUS_SUCCESS);
    +        EXPECT_EQ(setExtent(0), HIPBLAS_STATUS_INVALID_VALUE);
    +        EXPECT_EQ(setExtent(-8), HIPBLAS_STATUS_INVALID_VALUE);
    +
    +        const int32_t narrow = 512;
    +        EXPECT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT, &narrow, sizeof(narrow)),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2ABuilder_pre_checkin, CompletionModeAcceptsInKernelOnly)
    +    {
    +        hipblasLtA2ACompletionMode_t mode = HIPBLASLT_A2A_COMPLETION_IN_KERNEL;
    +        EXPECT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused,
    +                      HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_COMPLETION_MODE,
    +                      &mode,
    +                      sizeof(mode)),
    +                  HIPBLAS_STATUS_SUCCESS);
    +
    +        // Value 1 is reserved for the deferred mode, which ships with the
    +        // primitive a caller would wait on and not before it.
    +        mode = static_cast<hipblasLtA2ACompletionMode_t>(1);
    +        EXPECT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused,
    +                      HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_COMPLETION_MODE,
    +                      &mode,
    +                      sizeof(mode)),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2ABuilder_pre_checkin, PerRankArraysAreSizedInWholeEntries)
    +    {
    +        EXPECT_EQ(setRecvPtrs({reinterpret_cast<void*>(0x1000)}), HIPBLAS_STATUS_SUCCESS);
    +        EXPECT_EQ(setQueues({fakeQueue(0x2000)}), HIPBLAS_STATUS_SUCCESS);
    +
    +        void* one = reinterpret_cast<void*>(0x1000);
    +        EXPECT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_RECV_PTRS, &one, 0),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +        EXPECT_EQ(hipblasLtFusedEpilogueSetAttribute(fused,
    +                                                     HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_RECV_PTRS,
    +                                                     &one,
    +                                                     sizeof(void*) + 1),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2ABuilder_pre_checkin, PerRankArraysAreBoundedByTheMaximumWorld)
    +    {
    +        const std::vector<void*> tooMany(HIPBLASLT_DEVICE_COMM_MAX_WORLD + 1,
    +                                         reinterpret_cast<void*>(0x1000));
    +        EXPECT_EQ(setRecvPtrs(tooMany), HIPBLAS_STATUS_INVALID_VALUE);
    +
    +        const std::vector<hipblasLtSdmaQueue_t> tooManyQueues(HIPBLASLT_DEVICE_COMM_MAX_WORLD + 1,
    +                                                              fakeQueue(0x2000));
    +        EXPECT_EQ(setQueues(tooManyQueues), HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    /************************************************************************
    +     * Attach: the descriptor stops being a work in progress here, so this is
    +     * where a stage's required parameters must all be present.
    +     ***********************************************************************/
    +
    +    class FusedA2AAttach_pre_checkin : public ::testing::Test
    +    {
    +    protected:
    +        void SetUp() override
    +        {
    +            ASSERT_EQ(hipblasLtMatmulDescCreate(&matmulDesc, HIPBLAS_COMPUTE_32F, HIP_R_32F),
    +                      HIPBLAS_STATUS_SUCCESS);
    +            ASSERT_EQ(hipblasLtFusedEpilogueCreate(&fused), HIPBLAS_STATUS_SUCCESS);
    +            ASSERT_EQ(hipblasLtFusedEpilogueAdd(fused, HIPBLASLT_FUSEABLE_EPILOGUE_A2A_PREFIX),
    +                      HIPBLAS_STATUS_SUCCESS);
    +        }
    +
    +        void TearDown() override
    +        {
    +            if(fused)
    +                EXPECT_EQ(hipblasLtFusedEpilogueDestroy(fused), HIPBLAS_STATUS_SUCCESS);
    +            if(matmulDesc)
    +                EXPECT_EQ(hipblasLtMatmulDescDestroy(matmulDesc), HIPBLAS_STATUS_SUCCESS);
    +        }
    +
    +        // Fills in everything a one-rank all-to-all needs.
    +        void completeForOneRank()
    +        {
    +            const int64_t am = 512;
    +            ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                          fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT, &am, sizeof(am)),
    +                      HIPBLAS_STATUS_SUCCESS);
    +            void* recv = reinterpret_cast<void*>(0x1000);
    +            ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                          fused,
    +                          HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_RECV_PTRS,
    +                          &recv,
    +                          sizeof(recv)),
    +                      HIPBLAS_STATUS_SUCCESS);
    +            hipblasLtSdmaQueue_t queue = fakeQueue(0x2000);
    +            ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                          fused,
    +                          HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_SDMA_QUEUES,
    +                          &queue,
    +                          sizeof(queue)),
    +                      HIPBLAS_STATUS_SUCCESS);
    +        }
    +
    +        hipblasStatus_t attach()
    +        {
    +            return hipblasLtMatmulDescSetAttribute(
    +                matmulDesc, HIPBLASLT_MATMUL_DESC_FUSED_EPILOGUE, &fused, sizeof(fused));
    +        }
    +
    +        hipblasLtMatmulDesc_t              matmulDesc = nullptr;
    +        hipblasLtFusedEpilogueDescriptor_t fused      = nullptr;
    +    };
    +
    +    TEST_F(FusedA2AAttach_pre_checkin, CompleteDescriptorAttaches)
    +    {
    +        completeForOneRank();
    +        EXPECT_EQ(attach(), HIPBLAS_STATUS_SUCCESS);
    +    }
    +
    +    TEST_F(FusedA2AAttach_pre_checkin, AttachRejectsMissingExtent)
    +    {
    +        void* recv = reinterpret_cast<void*>(0x1000);
    +        ASSERT_EQ(
    +            hipblasLtFusedEpilogueSetAttribute(
    +                fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_RECV_PTRS, &recv, sizeof(recv)),
    +            HIPBLAS_STATUS_SUCCESS);
    +        hipblasLtSdmaQueue_t queue = fakeQueue(0x2000);
    +        ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused,
    +                      HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_SDMA_QUEUES,
    +                      &queue,
    +                      sizeof(queue)),
    +                  HIPBLAS_STATUS_SUCCESS);
    +
    +        EXPECT_EQ(attach(), HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2AAttach_pre_checkin, AttachRejectsMissingRecvPointers)
    +    {
    +        const int64_t am = 512;
    +        ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT, &am, sizeof(am)),
    +                  HIPBLAS_STATUS_SUCCESS);
    +        hipblasLtSdmaQueue_t queue = fakeQueue(0x2000);
    +        ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused,
    +                      HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_SDMA_QUEUES,
    +                      &queue,
    +                      sizeof(queue)),
    +                  HIPBLAS_STATUS_SUCCESS);
    +
    +        EXPECT_EQ(attach(), HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2AAttach_pre_checkin, AttachRejectsMissingQueues)
    +    {
    +        const int64_t am = 512;
    +        ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT, &am, sizeof(am)),
    +                  HIPBLAS_STATUS_SUCCESS);
    +        void* recv = reinterpret_cast<void*>(0x1000);
    +        ASSERT_EQ(
    +            hipblasLtFusedEpilogueSetAttribute(
    +                fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_RECV_PTRS, &recv, sizeof(recv)),
    +            HIPBLAS_STATUS_SUCCESS);
    +
    +        EXPECT_EQ(attach(), HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2AAttach_pre_checkin, AttachRejectsNullPeerEntry)
    +    {
    +        completeForOneRank();
    +        void* recv[2] = {reinterpret_cast<void*>(0x1000), nullptr};
    +        ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_RECV_PTRS, recv, sizeof(recv)),
    +                  HIPBLAS_STATUS_SUCCESS);
    +        hipblasLtSdmaQueue_t queues[2] = {fakeQueue(0x2000), fakeQueue(0x3000)};
    +        ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused,
    +                      HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_SDMA_QUEUES,
    +                      queues,
    +                      sizeof(queues)),
    +                  HIPBLAS_STATUS_SUCCESS);
    +
    +        EXPECT_EQ(attach(), HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2AAttach_pre_checkin, AttachRejectsIncompleteQueueEntry)
    +    {
    +        completeForOneRank();
    +        hipblasLtSdmaQueue_t queue = fakeQueue(0x2000);
    +        queue.doorbell             = nullptr;
    +        ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused,
    +                      HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_SDMA_QUEUES,
    +                      &queue,
    +                      sizeof(queue)),
    +                  HIPBLAS_STATUS_SUCCESS);
    +
    +        EXPECT_EQ(attach(), HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2AAttach_pre_checkin, AttachedDescriptorReadsBack)
    +    {
    +        completeForOneRank();
    +        ASSERT_EQ(attach(), HIPBLAS_STATUS_SUCCESS);
    +
    +        hipblasLtFusedEpilogueDescriptor_t readBack = nullptr;
    +        size_t                             written  = 0;
    +        EXPECT_EQ(hipblasLtMatmulDescGetAttribute(matmulDesc,
    +                                                  HIPBLASLT_MATMUL_DESC_FUSED_EPILOGUE,
    +                                                  &readBack,
    +                                                  sizeof(readBack),
    +                                                  &written),
    +                  HIPBLAS_STATUS_SUCCESS);
    +        EXPECT_EQ(written, sizeof(readBack));
    +        EXPECT_EQ(readBack, fused);
    +    }
    +
    +    /************************************************************************
    +     * Communicator registration.
    +     ***********************************************************************/
    +
    +    class FusedA2AComm_pre_checkin : public ::testing::Test
    +    {
    +    protected:
    +        void SetUp() override
    +        {
    +            if(!gpuAvailable())
    +                GTEST_SKIP() << "No GPU available";
    +            ASSERT_EQ(hipblasLtCreate(&handle), HIPBLAS_STATUS_SUCCESS);
    +        }
    +
    +        void TearDown() override
    +        {
    +            if(handle)
    +                EXPECT_EQ(hipblasLtDestroy(handle), HIPBLAS_STATUS_SUCCESS);
    +        }
    +
    +        hipblasLtHandle_t handle = nullptr;
    +    };
    +
    +    TEST_F(FusedA2AComm_pre_checkin, RejectsInvalidRankAndWorld)
    +    {
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 1, 1, 1, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 0, 1, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle,
    +                                         0,
    +                                         HIPBLASLT_DEVICE_COMM_MAX_WORLD + 1,
    +                                         1,
    +                                         memcpyAllgather,
    +                                         nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 1, 0, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 1, 1, nullptr, nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST(FusedA2ACommHandle_pre_checkin, RejectsNullHandle)
    +    {
    +        EXPECT_EQ(hipblasLtSetDeviceComm(nullptr, 0, 1, 1, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_NOT_INITIALIZED);
    +    }
    +
    +    TEST_F(FusedA2AComm_pre_checkin, RegistersOnceAndOnlyOnce)
    +    {
    +        ASSERT_EQ(hipblasLtSetDeviceComm(handle, 0, 1, 1, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_SUCCESS);
    +        // A second call fails whether or not its arguments match, which is what
    +        // makes world immutable.
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 1, 1, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 1, 4, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2AComm_pre_checkin, PropagatesAllgatherFailure)
    +    {
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 1, 1, failingAllgather, nullptr),
    +                  HIPBLAS_STATUS_INTERNAL_ERROR);
    +        // The failed attempt left nothing registered.
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 1, 1, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_SUCCESS);
    +    }
    +
    +    TEST_F(FusedA2AComm_pre_checkin, RejectsRanksThatDisagree)
    +    {
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 2, 1, silentPeerAllgather, nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2AComm_pre_checkin, RejectsMisorderedAllgather)
    +    {
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 2, 1, duplicatingAllgather, nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2AComm_pre_checkin, MultipleChannelsRegister)
    +    {
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 1, 4, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_SUCCESS);
    +    }
    +
    +    // The one path a single process can drive all the way through: two ranks, two
    +    // handles, each finding the other's flag region among the payloads. Where
    +    // there are two devices the ranks take one each, so registration has to make
    +    // the peer's region reachable rather than merely record its address. Both
    +    // handles are then destroyed, which is where the three kinds of entry have to
    +    // be told apart: a rank frees its own region and leaves its peer's alone.
    +    TEST(FusedA2ACommPeers_pre_checkin, TwoRanksInOneProcessRegister)
    +    {
    +        if(!gpuAvailable())
    +            GTEST_SKIP() << "No GPU available";
    +
    +        int deviceCount = 0;
    +        ASSERT_EQ(hipGetDeviceCount(&deviceCount), hipSuccess);
    +
    +        constexpr uint32_t kWorld = 2;
    +
    +        Rendezvous shared;
    +        shared.world = kWorld;
    +
    +        RendezvousRank  args[kWorld] = {{&shared, 0}, {&shared, 1}};
    +        hipblasStatus_t status[kWorld]
    +            = {HIPBLAS_STATUS_NOT_INITIALIZED, HIPBLAS_STATUS_NOT_INITIALIZED};
    +        std::thread ranks[kWorld];
    +
    +        for(uint32_t r = 0; r < kWorld; ++r)
    +        {
    +            ranks[r] = std::thread([&, r] {
    +                if(hipSetDevice((int)r % deviceCount) != hipSuccess)

    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.

    Alex-Vasile Alex-Vasile commented on code on Sep 02, 2026 15:29 UTC
    Code Review
    projects/hipblaslt/clients/tests/src/fused_a2a_gtest.cpp:1
    @@ -513,6 +563,50 @@ namespace
                       HIPBLAS_STATUS_SUCCESS);
         }
     
    +    // The one path a single process can drive all the way through: two ranks, two
    +    // handles, each finding the other's flag region among the payloads. Where
    +    // there are two devices the ranks take one each, so registration has to make
    +    // the peer's region reachable rather than merely record its address. Both
    +    // handles are then destroyed, which is where the three kinds of entry have to
    +    // be told apart: a rank frees its own region and leaves its peer's alone.
    +    TEST(FusedA2ACommPeers_pre_checkin, TwoRanksInOneProcessRegister)
    +    {
    +        if(!gpuAvailable())
    +            GTEST_SKIP() << "No GPU available";
    +
    +        int deviceCount = 0;
    +        ASSERT_EQ(hipGetDeviceCount(&deviceCount), hipSuccess);
    +
    +        constexpr uint32_t kWorld = 2;
    +
    +        Rendezvous shared;
    +        shared.world = kWorld;
    +
    +        RendezvousRank  args[kWorld] = {{&shared, 0}, {&shared, 1}};
    +        hipblasStatus_t status[kWorld]
    +            = {HIPBLAS_STATUS_NOT_INITIALIZED, HIPBLAS_STATUS_NOT_INITIALIZED};
    +        std::thread ranks[kWorld];
    +
    +        for(uint32_t r = 0; r < kWorld; ++r)
    +        {
    +            ranks[r] = std::thread([&, r] {
    +                if(hipSetDevice((int)r % deviceCount) != hipSuccess)
    +                    return;
    +                hipblasLtHandle_t handle = nullptr;
    +                if(hipblasLtCreate(&handle) != HIPBLAS_STATUS_SUCCESS)
    +                    return;
    +                status[r]
    +                    = hipblasLtSetDeviceComm(handle, r, kWorld, 1, rendezvousAllgather, &args[r]);
    +                EXPECT_EQ(hipblasLtDestroy(handle), HIPBLAS_STATUS_SUCCESS);

    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 .

    Alex-Vasile Alex-Vasile commented on code on Sep 02, 2026 16:03 UTC
    Code Review
    projects/hipblaslt/library/include/hipblaslt/hipblaslt.h:1
    @@ -108,6 +108,121 @@ typedef enum {
       HIPBLASLT_EPILOGUE_CLAMP_AUX_BIAS_EXT = 131204, /**<Output GEMM results after applying bias but before applying clamp transform.*/
     } hipblasLtEpilogue_t;
     
    +/*! \ingroup types_module
    + *  \brief Stages that can be selected on a fused epilogue descriptor.
    + *
    + *  \details
    + *  Unlike the flat ``hipblasLtEpilogue_t`` enum, these values name epilogue stages that are
    + *  accumulated into a ``hipblasLtFusedEpilogueDescriptor_t`` via ``hipblasLtFusedEpilogueAdd``
    + *  and attached to a matmul descriptor through ``HIPBLASLT_MATMUL_DESC_FUSED_EPILOGUE``.
    + *
    + *  The fused epilogue API offers several families, each with its own composition rule. Values
    + *  ``0``-``6`` are reserved for the chainable family (residual add, RMSNorm, partial RMSNorm
    + *  stats, RMSNorm scale-apply, AMax, requant) and for the gated linear units, which compose
    + *  by their own rules. All-to-all is the collective family: a single stage that does not
    + *  compose with any other, so adding a companion stage is rejected at ``Add`` time.
    + */
    +typedef enum {
    +  HIPBLASLT_FUSEABLE_EPILOGUE_A2A_PREFIX = 7, /**<Collective family: redistribute a leading run of D's free-0 (feature) positions across the ranks of the registered device communicator, from the GEMM's own store path. Single stage; not chainable. The ``PREFIX`` suffix names the dispatch criterion - the exported region is the positional run ``[0, AM)`` given by ``HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT``.*/
    +} hipblasLtFuseableEpilogue_t;
    +
    +/*! \ingroup types_module
    + *  \brief Attributes settable on a fused epilogue descriptor.
    + *
    + *  \details
    + *  Values ``0``-``11`` are reserved for the chainable family's attributes.
    + */
    +typedef enum {
    +  HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_SDMA_QUEUES = 12, /**<Required by a solution using the SDMA transport. Host array of ``world`` ``hipblasLtSdmaQueue_t`` entries; entry ``j`` is this device's copy-engine queue targeting rank ``j``, with ``j == rank`` the loopback queue. The library copies the entries and never interprets the addresses, so the caller's array need not outlive the call - but the queues themselves must outlive the launch group. Data type: ``const hipblasLtSdmaQueue_t*``.*/
    +  HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_RECV_PTRS = 13, /**<Required. Host array of ``world`` pointers in rank order; entry ``j`` is the address, in this process, of rank ``j``'s receive buffer. The buffer holds ``world * N * (AM / world)`` elements of D's type, laid out ``[source, token, feature]`` with feature contiguous and the unpadded ``N`` as the source stride. Data type: ``void* const*``.*/
    +  HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT = 14, /**<Required. ``AM``, the number of leading free-0 (feature) positions of D that are redistributed; the per-rank shard is ``AM / world``. Must be positive and divide by ``world``. This participates in solution selection, so it has the same standing as M, N, and K: setting it after ``hipblasLtMatmulAlgoGetHeuristic`` invalidates the returned algo. Data type: ``int64_t``.*/
    +  HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_COMPLETION_MODE = 15, /**<Optional. How receive completion is established. ``HIPBLASLT_A2A_COMPLETION_IN_KERNEL`` is the only accepted value in this release, and the default. Data type: ``hipblasLtA2ACompletionMode_t``.*/
    +  HIPBLASLT_FUSED_EPILOGUE_COMM_CHANNEL = 16, /**<Optional, default ``0``. Which of the communicator's ``nChannels`` flag regions this operation uses. Concurrent operations need distinct channels and disjoint queue sets; every rank of one launch group must pass the same channel, which the library cannot verify. Data type: ``uint32_t``.*/
    +} hipblasLtFusedEpilogueAttribute_t;
    +
    +/*! \ingroup types_module
    + *  \brief How a fused all-to-all establishes receive completion.
    + */
    +typedef enum {
    +  HIPBLASLT_A2A_COMPLETION_IN_KERNEL = 0, /**<The kernel does not retire until this rank's receive buffer is fully populated, so ordinary stream semantics cover the collective and the receive buffer is safe to read once this rank's stream is synchronized.*/
    +
    +  /* Value 1 is reserved for a deferred mode, in which the kernel retires before
    +     inbound data lands. It ships together with the primitive a caller would wait
    +     on, not before it. */
    +} hipblasLtA2ACompletionMode_t;
    +
    +/*! \ingroup types_module
    + *  \brief One caller-created copy-engine (SDMA) queue, as four addresses.
    + *
    + *  \details
    + *  Creating a copy-engine queue means allocating its ring and creating the queue against a
    + *  topology node and engine, all of which goes through the kernel-mode thunk. Leaving that to
    + *  the caller is what keeps the thunk out of hipBLASLt's build: the caller reads these four
    + *  values out of the queue it created, and the library stores them and hands them to the kernel
    + *  without interpreting any of them.
    + */
    +typedef struct {
    +  void* queueBuf; /**<Copy-engine ring base.*/
    +  void* rptr;     /**<Hardware read pointer.*/
    +  void* wptr;     /**<Hardware write pointer.*/
    +  void* doorbell; /**<Doorbell.*/
    +} hipblasLtSdmaQueue_t;
    +
    +/*! \ingroup types_module
    + *  \brief Opaque handle representing a fused epilogue.
    + *
    + *  \details
    + *  Use the following functions to manipulate this handle:
    + *
    + *  \ref hipblasLtFusedEpilogueCreate(): To create one instance of the handle.
    + *
    + *  \ref hipblasLtFusedEpilogueAdd(): To select a fused epilogue stage.
    + *
    + *  \ref hipblasLtFusedEpilogueSetAttribute(): To configure that stage's parameters.
    + *
    + *  \ref hipblasLtFusedEpilogueDestroy(): To destroy a previously created handle and release
    + *  the resources.
    + */
    +typedef struct hipblasLtFusedEpilogueDescriptor* hipblasLtFusedEpilogueDescriptor_t;
    +
    +/*! \ingroup types_module
    + *  \brief Largest world size a device communicator supports.
    + *
    + *  \details
    + *  An implementation limit rather than an API one: the kernel's per-peer state is a fixed-size
    + *  array and the drain wait's lane mask also bounds it.
    + */
    +#define HIPBLASLT_DEVICE_COMM_MAX_WORLD 8
    +
    +/*! \ingroup types_module
    + *  \brief Caller-supplied allgather used to register a device communicator.
    + *
    + *  \details
    + *  A true allgather: rank ``r``'s \p sendbuf (\p bytesPerRank bytes) must land at
    + *  ``recvbuf + r * bytesPerRank`` on every rank, and \p recvbuf must be readable on return.
    + *  The payload is opaque; the caller must not interpret or reorder it.
    + *
    + *  This callback is the only capability the caller hands over, and the reason one entry point
    + *  covers both deployment shapes: the library performs no rendezvous of its own. In a single
    + *  process the callback is a memcpy; across processes it is ``MPI_Allgather`` or a
    + *  ``torch.distributed`` store, and nothing else changes.

    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.

    DDEle DDEle approved these changes on Sep 02, 2026 16:07 UTC
    Approved Reviewer

    Everything looks good to me now.

    Alex-Vasile Alex-Vasile commented on code on Sep 02, 2026 16:12 UTC
    Code Review
    projects/hipblaslt/library/src/amd_detail/hipblaslt.cpp:1
    @@ -107,6 +109,283 @@ hipblasStatus_t RocBlasLtStatusToHIPStatus(rocblaslt_status_ status)
         }
     }
     
    +/********************************************************************************
    + * Fused epilogue descriptor.
    + *
    + * Opaque to the caller. Its contents are read only here, in the C-API layer that
    + * knows what the stages mean; rocBLASLt carries it as a forward-declared pointer.
    + *******************************************************************************/
    +struct hipblasLtFusedEpilogueDescriptor
    +{
    +    std::vector<hipblasLtFuseableEpilogue_t> stages;
    +
    +    // HIPBLASLT_FUSEABLE_EPILOGUE_A2A_PREFIX parameters. The per-rank arrays are
    +    // sized by the caller's SetAttribute call; that their length is the
    +    // communicator's world size is checked where the communicator is visible.
    +    int64_t                           a2a_extent     = 0;
    +    bool                              a2a_extent_set = false;
    +    hipblasLtA2ACompletionMode_t      a2a_completion = HIPBLASLT_A2A_COMPLETION_IN_KERNEL;
    +    uint32_t                          comm_channel   = 0;
    +    std::vector<void*>                a2a_recv_ptrs;
    +    std::vector<hipblasLtSdmaQueue_t> a2a_queues;
    +};
    +
    +namespace
    +{
    +    bool fused_epilogue_has_stage(const hipblasLtFusedEpilogueDescriptor* d,
    +                                  hipblasLtFuseableEpilogue_t             e)
    +    {
    +        for(auto s : d->stages)
    +            if(s == e)
    +                return true;
    +        return false;
    +    }
    +
    +    bool fused_epilogue_stage_recognized(hipblasLtFuseableEpilogue_t stage)
    +    {
    +        switch(stage)
    +        {
    +        case HIPBLASLT_FUSEABLE_EPILOGUE_A2A_PREFIX:
    +            return true;
    +        }
    +        return false;
    +    }
    +
    +    // The collective family holds one stage and composes with nothing. Rejecting a
    +    // companion here rather than at launch is deliberate: the caller is asking for
    +    // something the API does not define, so it should learn that at the call that
    +    // expresses the mistake. Legalizing a combination later turns this into
    +    // success, which is the compatible direction.
    +    bool fused_epilogue_stage_composes(const hipblasLtFusedEpilogueDescriptor* desc,
    +                                       hipblasLtFuseableEpilogue_t             stage)
    +    {
    +        if(desc->stages.empty())
    +            return true;
    +        if(stage == HIPBLASLT_FUSEABLE_EPILOGUE_A2A_PREFIX)
    +            return false;
    +        return !fused_epilogue_has_stage(desc, HIPBLASLT_FUSEABLE_EPILOGUE_A2A_PREFIX);
    +    }
    +
    +    // Checked when the descriptor is attached to a matmul descriptor: every stage
    +    // present must have the parameters it cannot run without. World size is not
    +    // known here, so the per-rank arrays are checked for content but not length;
    +    // validate_fused_a2a_launch compares both against it.
    +    hipblasStatus_t validate_fused_epilogue_attach(const hipblasLtFusedEpilogueDescriptor* desc)
    +    {
    +        if(!fused_epilogue_has_stage(desc, HIPBLASLT_FUSEABLE_EPILOGUE_A2A_PREFIX))
    +            return HIPBLAS_STATUS_SUCCESS;
    +
    +        if(!desc->a2a_extent_set || desc->a2a_recv_ptrs.empty() || desc->a2a_queues.empty())
    +        {
    +            log_error(__func__, "all-to-all stage is missing a required attribute");
    +            return HIPBLAS_STATUS_INVALID_VALUE;
    +        }
    +
    +        for(size_t j = 0; j < desc->a2a_recv_ptrs.size(); ++j)
    +        {
    +            if(desc->a2a_recv_ptrs[j] == nullptr)
    +            {
    +                log_error(__func__, "null all-to-all peer-recv pointer for rank", (int)j);
    +                return HIPBLAS_STATUS_INVALID_VALUE;
    +            }
    +        }
    +
    +        for(size_t j = 0; j < desc->a2a_queues.size(); ++j)
    +        {
    +            const hipblasLtSdmaQueue_t& q = desc->a2a_queues[j];
    +            if(q.queueBuf == nullptr || q.rptr == nullptr || q.wptr == nullptr
    +               || q.doorbell == nullptr)
    +            {
    +                log_error(__func__, "incomplete all-to-all SDMA queue for rank", (int)j);
    +                return HIPBLAS_STATUS_INVALID_VALUE;
    +            }
    +        }
    +
    +        return HIPBLAS_STATUS_SUCCESS;
    +    }
    +
    +    // Checked before a solution is selected and again at launch, this being the
    +    // first point where both the communicator and D's layout are in hand.
    +    //
    +    // The requirements that depend on the selected solution's macro tile -
    +    // n_shard % MT0 == 0, MT1 < 2^14, MT0/MT1 in {128, 256}, data-parallel only,
    +    // and no split-K - are enforced by the kernel generator as solution
    +    // rejections, so they become "no usable algo" rather than a return code here.
    +    hipblasStatus_t validate_fused_a2a_launch(rocblaslt_handle                        handle,
    +                                              const hipblasLtFusedEpilogueDescriptor* desc,
    +                                              rocblaslt_matrix_layout                 matD)
    +    {
    +        if(handle == nullptr || matD == nullptr)
    +            return HIPBLAS_STATUS_INVALID_VALUE;
    +
    +        // Registration is optional, but it is not a fallback: an all-to-all stage
    +        // without a communicator is an error, not a silent unfused GEMM.
    +        const uint32_t world = handle->device_comm_world;
    +        if(world == 0)
    +        {
    +            log_error(__func__, "all-to-all stage requires hipblasLtSetDeviceComm on this handle");
    +            return HIPBLAS_STATUS_INVALID_VALUE;
    +        }
    +
    +        if(desc->comm_channel >= handle->device_comm_channels)
    +        {
    +            log_error(__func__, "comm channel out of range", (int)desc->comm_channel);
    +            return HIPBLAS_STATUS_INVALID_VALUE;
    +        }
    +
    +        if(desc->a2a_recv_ptrs.size() != world || desc->a2a_queues.size() != world)
    +        {
    +            log_error(__func__, "all-to-all per-rank arrays do not have world entries");
    +            return HIPBLAS_STATUS_INVALID_VALUE;
    +        }
    +
    +        // The receive-buffer layout has no batch axis.
    +        if(matD->batch_count > 1)
    +        {
    +            log_error(__func__, "all-to-all does not support batched GEMM", matD->batch_count);
    +            return HIPBLAS_STATUS_INVALID_VALUE;
    +        }
    +
    +        const int64_t am = desc->a2a_extent;
    +        if(am % (int64_t)world != 0)
    +        {
    +            log_error(__func__, "all-to-all extent does not divide by world", am);
    +            return HIPBLAS_STATUS_INVALID_VALUE;
    +        }
    +        if(am > (int64_t)matD->m)
    +        {
    +            log_error(__func__, "all-to-all extent exceeds D's free-0 extent", am);
    +            return HIPBLAS_STATUS_INVALID_VALUE;
    +        }
    +
    +        // The copy moves n_shard contiguous elements per token row, so a strided
    +        // feature axis would ship unrelated data.
    +        if(matD->order != HIPBLASLT_ORDER_COL)
    +        {
    +            log_error(__func__, "all-to-all requires a unit free-0 stride on D");
    +            return HIPBLAS_STATUS_INVALID_VALUE;
    +        }
    +
    +        if(matD->type != HIP_R_16BF)
    +        {
    +            log_error(__func__, "all-to-all supports a BF16 D only", (int)matD->type);
    +            return HIPBLAS_STATUS_NOT_SUPPORTED;
    +        }
    +
    +        // Copy widths and pitches are expressed in the descriptor's 16-byte
    +        // addressing granularity and are not rounded, and its extent and pitch
    +        // fields are narrow: 14 bits for an extent, 19 for the source pitch.
    +        constexpr int64_t elemsPer16B = 16 / sizeof(hip_bfloat16);
    +        const int64_t     shard       = am / (int64_t)world;
    +        const int64_t     ldd         = matD->ld;
    +        if(shard % elemsPer16B != 0 || ldd % elemsPer16B != 0)
    +        {
    +            log_error(__func__, "all-to-all shard extent and ldd must be 16-byte multiples");
    +            return HIPBLAS_STATUS_INVALID_VALUE;
    +        }
    +        if(shard / elemsPer16B >= (int64_t{1} << 14) || ldd / elemsPer16B >= (int64_t{1} << 19))
    +        {
    +            log_error(__func__, "all-to-all shard extent or ldd exceeds the copy descriptor");
    +            return HIPBLAS_STATUS_INVALID_VALUE;
    +        }
    +
    +        // The request is well formed; no architecture carries a fused all-to-all
    +        // kernel in this release.
    +        log_error(__func__, "no fused all-to-all implementation for the selected device");
    +        return HIPBLAS_STATUS_NOT_SUPPORTED;
    +    }
    +
    +    // Runs the checks a matmul carrying a fused epilogue owes before it is
    +    // dispatched. A descriptor with no communicating stage passes through.
    +    hipblasStatus_t validate_fused_epilogue_dispatch(hipblasLtHandle_t       handle,
    +                                                     hipblasLtMatmulDesc_t   matmulDesc,
    +                                                     hipblasLtMatrixLayout_t Ddesc)
    +    {
    +        if(matmulDesc == nullptr)
    +            return HIPBLAS_STATUS_SUCCESS;
    +
    +        const hipblasLtFusedEpilogueDescriptor* desc
    +            = ((rocblaslt_matmul_desc)matmulDesc)->fused_epilogue;
    +        if(desc == nullptr
    +           || !fused_epilogue_has_stage(desc, HIPBLASLT_FUSEABLE_EPILOGUE_A2A_PREFIX))
    +            return HIPBLAS_STATUS_SUCCESS;
    +
    +        return validate_fused_a2a_launch(
    +            (rocblaslt_handle)handle, desc, (rocblaslt_matrix_layout)Ddesc);
    +    }
    +
    +    /****************************************************************************
    +     * Device communicator.
    +     ***************************************************************************/
    +
    +    // A channel's flag region: one uint32_t arrival counter per source rank,
    +    // packed into the first line, then the outbound counter on a line of its
    +    // own. Sized by the compile-time maximum world so every offset into a region
    +    // is a constant - 128 bytes while that maximum is 8.
    +    //
    +    // Twinned with FUSED_A2A_LINE_BYTES, FUSED_A2A_OUTBOUND_OFFSET, and
    +    // FUSED_A2A_FLAG_BLOCK_BYTES in the kernel's FusedA2AKernArg.hpp, which is
    +    // what the arrival atomics and the drain barrier index against. A region
    +    // smaller than the kernel's block is memory corruption rather than a wrong
    +    // answer, so the two derivations must stay identical.
    +    constexpr size_t kDeviceCommFlagLine = 64;
    +
    +    constexpr size_t align_device_comm_flag_line(size_t bytes)
    +    {
    +        return (bytes + kDeviceCommFlagLine - 1) / kDeviceCommFlagLine * kDeviceCommFlagLine;
    +    }
    +
    +    constexpr size_t kDeviceCommFlagOutboundOffset
    +        = align_device_comm_flag_line(HIPBLASLT_DEVICE_COMM_MAX_WORLD * sizeof(uint32_t));
    +    constexpr size_t kDeviceCommFlagChannelSize
    +        = align_device_comm_flag_line(kDeviceCommFlagOutboundOffset + sizeof(uint32_t));

    This is independently recreating the size of the flag block, it can get out of sync with what FusedA2AKernArg.hpp does.

    Alex-Vasile Alex-Vasile commented on code on Sep 02, 2026 16:21 UTC
    Code Review
    projects/hipblaslt/clients/tests/src/fused_a2a_gtest.cpp:1
    @@ -0,0 +1,892 @@
    +// Copyright Advanced Micro Devices, Inc., or its affiliates.
    +// SPDX-License-Identifier: MIT
    +
    +// API-surface tests for the fused GEMM + all-to-all epilogue.
    +//
    +// This covers what the host can decide on its own: the builder's single-stage
    +// family rule, each attribute's accepted range, the completeness check that runs
    +// when the descriptor is attached to a matmul descriptor, communicator
    +// registration, and the shape and layout requirements checked before a solution
    +// is selected. No architecture carries a fused all-to-all kernel yet, so a
    +// well-formed request ends in HIPBLAS_STATUS_NOT_SUPPORTED; the tests assert that
    +// distinction, since an unusable request must be an error while missing
    +// capability must never present as a rejected shape.
    +//
    +// The suite names carry the "pre_checkin" token on purpose: the ctest presets in
    +// clients/tests/test_categories.yaml select by loose substring on a category
    +// token, and a plain gtest suite has none, so it would be invisible to them.
    +
    +#include <gtest/gtest.h>
    +#include <hip/hip_runtime.h>
    +#include <hipblaslt/hipblaslt.h>
    +
    +#include <chrono>
    +#include <condition_variable>
    +#include <cstring>
    +#include <mutex>
    +#include <thread>
    +#include <vector>
    +
    +namespace
    +{
    +    bool gpuAvailable()
    +    {
    +        int deviceCount = 0;
    +        return hipGetDeviceCount(&deviceCount) == hipSuccess && deviceCount > 0;
    +    }
    +
    +    // A single-process allgather: with one rank it is exactly the memcpy the
    +    // design doc names as the single-process case.
    +    hipblasStatus_t memcpyAllgather(void*       userData,
    +                                    const void* sendbuf,
    +                                    void*       recvbuf,
    +                                    size_t      bytesPerRank)
    +    {
    +        (void)userData;
    +        memcpy(recvbuf, sendbuf, bytesPerRank);
    +        return HIPBLAS_STATUS_SUCCESS;
    +    }
    +
    +    hipblasStatus_t failingAllgather(void*       userData,
    +                                     const void* sendbuf,
    +                                     void*       recvbuf,
    +                                     size_t      bytesPerRank)
    +    {
    +        (void)userData;
    +        (void)sendbuf;
    +        (void)recvbuf;
    +        (void)bytesPerRank;
    +        return HIPBLAS_STATUS_INTERNAL_ERROR;
    +    }
    +
    +    // Publishes this rank's payload and leaves the second slot zeroed, which no
    +    // real contribution can ever look like. Stands in for any way the ranks can
    +    // fail to agree about the communicator.
    +    hipblasStatus_t silentPeerAllgather(void*       userData,
    +                                        const void* sendbuf,
    +                                        void*       recvbuf,
    +                                        size_t      bytesPerRank)
    +    {
    +        (void)userData;
    +        memcpy(recvbuf, sendbuf, bytesPerRank);
    +        memset(static_cast<char*>(recvbuf) + bytesPerRank, 0, bytesPerRank);
    +        return HIPBLAS_STATUS_SUCCESS;
    +    }
    +
    +    // Copies this rank's payload into both slots, so the second slot claims to be
    +    // rank 0 where rank 1 belongs.
    +    hipblasStatus_t duplicatingAllgather(void*       userData,
    +                                         const void* sendbuf,
    +                                         void*       recvbuf,
    +                                         size_t      bytesPerRank)
    +    {
    +        (void)userData;
    +        memcpy(recvbuf, sendbuf, bytesPerRank);
    +        memcpy(static_cast<char*>(recvbuf) + bytesPerRank, sendbuf, bytesPerRank);
    +        return HIPBLAS_STATUS_SUCCESS;
    +    }
    +
    +    // A real allgather for ranks that are threads of one process: each publishes
    +    // into its own slot and waits for the rest before reading the whole buffer
    +    // back. Registration cannot return until every peer has contributed, so this
    +    // rendezvous is the only way more than one rank registers in one process. The
    +    // wait is bounded so a rank that never arrives fails the test instead of
    +    // hanging it.
    +    struct Rendezvous
    +    {
    +        std::mutex              mutex;
    +        std::condition_variable arrival;
    +        std::vector<char>       slots;
    +        uint32_t                arrived = 0;
    +        uint32_t                world   = 0;
    +    };
    +
    +    struct RendezvousRank
    +    {
    +        Rendezvous* shared;
    +        uint32_t    rank;
    +    };
    +
    +    hipblasStatus_t
    +        rendezvousAllgather(void* userData, const void* sendbuf, void* recvbuf, size_t bytesPerRank)
    +    {
    +        RendezvousRank& self   = *static_cast<RendezvousRank*>(userData);
    +        Rendezvous&     shared = *self.shared;
    +
    +        std::unique_lock<std::mutex> lock(shared.mutex);
    +        if(shared.slots.empty())
    +            shared.slots.resize(bytesPerRank * shared.world);
    +        memcpy(shared.slots.data() + bytesPerRank * self.rank, sendbuf, bytesPerRank);
    +
    +        if(++shared.arrived == shared.world)
    +        {
    +            shared.arrival.notify_all();
    +        }
    +        else if(!shared.arrival.wait_for(
    +                    lock, std::chrono::seconds(30), [&] { return shared.arrived == shared.world; }))
    +        {
    +            return HIPBLAS_STATUS_INTERNAL_ERROR;
    +        }
    +
    +        memcpy(recvbuf, shared.slots.data(), bytesPerRank * shared.world);
    +        return HIPBLAS_STATUS_SUCCESS;
    +    }
    +
    +    // Four plausible-looking addresses. The library stores a queue's fields
    +    // without interpreting them, so a test only needs them to be non-null.
    +    hipblasLtSdmaQueue_t fakeQueue(uintptr_t base)
    +    {
    +        hipblasLtSdmaQueue_t q{};
    +        q.queueBuf = reinterpret_cast<void*>(base);
    +        q.rptr     = reinterpret_cast<void*>(base + 0x100);
    +        q.wptr     = reinterpret_cast<void*>(base + 0x200);
    +        q.doorbell = reinterpret_cast<void*>(base + 0x300);
    +        return q;
    +    }
    +
    +    /************************************************************************
    +     * Builder: lifecycle, the single-stage family rule, and attributes.
    +     * None of this needs a device.
    +     ***********************************************************************/
    +
    +    class FusedA2ABuilder_pre_checkin : public ::testing::Test
    +    {
    +    protected:
    +        void SetUp() override
    +        {
    +            ASSERT_EQ(hipblasLtFusedEpilogueCreate(&fused), HIPBLAS_STATUS_SUCCESS);
    +            ASSERT_NE(fused, nullptr);
    +        }
    +
    +        void TearDown() override
    +        {
    +            if(fused)
    +                EXPECT_EQ(hipblasLtFusedEpilogueDestroy(fused), HIPBLAS_STATUS_SUCCESS);
    +        }
    +
    +        hipblasStatus_t addA2A()
    +        {
    +            return hipblasLtFusedEpilogueAdd(fused, HIPBLASLT_FUSEABLE_EPILOGUE_A2A_PREFIX);
    +        }
    +
    +        hipblasStatus_t setExtent(int64_t am)
    +        {
    +            return hipblasLtFusedEpilogueSetAttribute(
    +                fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT, &am, sizeof(am));
    +        }
    +
    +        hipblasStatus_t setRecvPtrs(const std::vector<void*>& ptrs)
    +        {
    +            return hipblasLtFusedEpilogueSetAttribute(fused,
    +                                                      HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_RECV_PTRS,
    +                                                      ptrs.data(),
    +                                                      ptrs.size() * sizeof(void*));
    +        }
    +
    +        hipblasStatus_t setQueues(const std::vector<hipblasLtSdmaQueue_t>& queues)
    +        {
    +            return hipblasLtFusedEpilogueSetAttribute(
    +                fused,
    +                HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_SDMA_QUEUES,
    +                queues.data(),
    +                queues.size() * sizeof(hipblasLtSdmaQueue_t));
    +        }
    +
    +        hipblasLtFusedEpilogueDescriptor_t fused = nullptr;
    +    };
    +
    +    TEST(FusedA2ALifecycle_pre_checkin, CreateRejectsNullOut)
    +    {
    +        EXPECT_EQ(hipblasLtFusedEpilogueCreate(nullptr), HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST(FusedA2ALifecycle_pre_checkin, DestroyAcceptsNull)
    +    {
    +        EXPECT_EQ(hipblasLtFusedEpilogueDestroy(nullptr), HIPBLAS_STATUS_SUCCESS);
    +    }
    +
    +    TEST(FusedA2ALifecycle_pre_checkin, AddRejectsNullDescriptor)
    +    {
    +        EXPECT_EQ(hipblasLtFusedEpilogueAdd(nullptr, HIPBLASLT_FUSEABLE_EPILOGUE_A2A_PREFIX),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2ABuilder_pre_checkin, AddAcceptsAllToAll)
    +    {
    +        EXPECT_EQ(addA2A(), HIPBLAS_STATUS_SUCCESS);
    +    }
    +
    +    TEST_F(FusedA2ABuilder_pre_checkin, AddRejectsUnrecognizedStage)
    +    {
    +        EXPECT_EQ(hipblasLtFusedEpilogueAdd(fused, static_cast<hipblasLtFuseableEpilogue_t>(4242)),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    // The collective family holds one stage, so a second all-to-all is rejected
    +    // at the call expressing the mistake rather than at launch.
    +    TEST_F(FusedA2ABuilder_pre_checkin, AddRejectsDuplicateAllToAll)
    +    {
    +        ASSERT_EQ(addA2A(), HIPBLAS_STATUS_SUCCESS);
    +        EXPECT_EQ(addA2A(), HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2ABuilder_pre_checkin, SetAttributeRejectsNullArguments)
    +    {
    +        const int64_t am = 512;
    +        EXPECT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      nullptr, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT, &am, sizeof(am)),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +        EXPECT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT, nullptr, sizeof(am)),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2ABuilder_pre_checkin, SetAttributeRejectsUnknownAttribute)
    +    {
    +        const int64_t value = 1;
    +        EXPECT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused,
    +                      static_cast<hipblasLtFusedEpilogueAttribute_t>(9999),
    +                      &value,
    +                      sizeof(value)),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2ABuilder_pre_checkin, ExtentMustBePositiveAndCorrectlySized)
    +    {
    +        EXPECT_EQ(setExtent(512), HIPBLAS_STATUS_SUCCESS);
    +        EXPECT_EQ(setExtent(0), HIPBLAS_STATUS_INVALID_VALUE);
    +        EXPECT_EQ(setExtent(-8), HIPBLAS_STATUS_INVALID_VALUE);
    +
    +        const int32_t narrow = 512;
    +        EXPECT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT, &narrow, sizeof(narrow)),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2ABuilder_pre_checkin, CompletionModeAcceptsInKernelOnly)
    +    {
    +        hipblasLtA2ACompletionMode_t mode = HIPBLASLT_A2A_COMPLETION_IN_KERNEL;
    +        EXPECT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused,
    +                      HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_COMPLETION_MODE,
    +                      &mode,
    +                      sizeof(mode)),
    +                  HIPBLAS_STATUS_SUCCESS);
    +
    +        // Value 1 is reserved for the deferred mode, which ships with the
    +        // primitive a caller would wait on and not before it.
    +        mode = static_cast<hipblasLtA2ACompletionMode_t>(1);
    +        EXPECT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused,
    +                      HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_COMPLETION_MODE,
    +                      &mode,
    +                      sizeof(mode)),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2ABuilder_pre_checkin, PerRankArraysAreSizedInWholeEntries)
    +    {
    +        EXPECT_EQ(setRecvPtrs({reinterpret_cast<void*>(0x1000)}), HIPBLAS_STATUS_SUCCESS);
    +        EXPECT_EQ(setQueues({fakeQueue(0x2000)}), HIPBLAS_STATUS_SUCCESS);
    +
    +        void* one = reinterpret_cast<void*>(0x1000);
    +        EXPECT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_RECV_PTRS, &one, 0),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +        EXPECT_EQ(hipblasLtFusedEpilogueSetAttribute(fused,
    +                                                     HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_RECV_PTRS,
    +                                                     &one,
    +                                                     sizeof(void*) + 1),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2ABuilder_pre_checkin, PerRankArraysAreBoundedByTheMaximumWorld)
    +    {
    +        const std::vector<void*> tooMany(HIPBLASLT_DEVICE_COMM_MAX_WORLD + 1,
    +                                         reinterpret_cast<void*>(0x1000));
    +        EXPECT_EQ(setRecvPtrs(tooMany), HIPBLAS_STATUS_INVALID_VALUE);
    +
    +        const std::vector<hipblasLtSdmaQueue_t> tooManyQueues(HIPBLASLT_DEVICE_COMM_MAX_WORLD + 1,
    +                                                              fakeQueue(0x2000));
    +        EXPECT_EQ(setQueues(tooManyQueues), HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    /************************************************************************
    +     * Attach: the descriptor stops being a work in progress here, so this is
    +     * where a stage's required parameters must all be present.
    +     ***********************************************************************/
    +
    +    class FusedA2AAttach_pre_checkin : public ::testing::Test
    +    {
    +    protected:
    +        void SetUp() override
    +        {
    +            ASSERT_EQ(hipblasLtMatmulDescCreate(&matmulDesc, HIPBLAS_COMPUTE_32F, HIP_R_32F),
    +                      HIPBLAS_STATUS_SUCCESS);
    +            ASSERT_EQ(hipblasLtFusedEpilogueCreate(&fused), HIPBLAS_STATUS_SUCCESS);
    +            ASSERT_EQ(hipblasLtFusedEpilogueAdd(fused, HIPBLASLT_FUSEABLE_EPILOGUE_A2A_PREFIX),
    +                      HIPBLAS_STATUS_SUCCESS);
    +        }
    +
    +        void TearDown() override
    +        {
    +            if(fused)
    +                EXPECT_EQ(hipblasLtFusedEpilogueDestroy(fused), HIPBLAS_STATUS_SUCCESS);
    +            if(matmulDesc)
    +                EXPECT_EQ(hipblasLtMatmulDescDestroy(matmulDesc), HIPBLAS_STATUS_SUCCESS);
    +        }
    +
    +        // Fills in everything a one-rank all-to-all needs.
    +        void completeForOneRank()
    +        {
    +            const int64_t am = 512;
    +            ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                          fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT, &am, sizeof(am)),
    +                      HIPBLAS_STATUS_SUCCESS);
    +            void* recv = reinterpret_cast<void*>(0x1000);
    +            ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                          fused,
    +                          HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_RECV_PTRS,
    +                          &recv,
    +                          sizeof(recv)),
    +                      HIPBLAS_STATUS_SUCCESS);
    +            hipblasLtSdmaQueue_t queue = fakeQueue(0x2000);
    +            ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                          fused,
    +                          HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_SDMA_QUEUES,
    +                          &queue,
    +                          sizeof(queue)),
    +                      HIPBLAS_STATUS_SUCCESS);
    +        }
    +
    +        hipblasStatus_t attach()
    +        {
    +            return hipblasLtMatmulDescSetAttribute(
    +                matmulDesc, HIPBLASLT_MATMUL_DESC_FUSED_EPILOGUE, &fused, sizeof(fused));
    +        }
    +
    +        hipblasLtMatmulDesc_t              matmulDesc = nullptr;
    +        hipblasLtFusedEpilogueDescriptor_t fused      = nullptr;
    +    };
    +
    +    TEST_F(FusedA2AAttach_pre_checkin, CompleteDescriptorAttaches)
    +    {
    +        completeForOneRank();
    +        EXPECT_EQ(attach(), HIPBLAS_STATUS_SUCCESS);
    +    }
    +
    +    TEST_F(FusedA2AAttach_pre_checkin, AttachRejectsMissingExtent)
    +    {
    +        void* recv = reinterpret_cast<void*>(0x1000);
    +        ASSERT_EQ(
    +            hipblasLtFusedEpilogueSetAttribute(
    +                fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_RECV_PTRS, &recv, sizeof(recv)),
    +            HIPBLAS_STATUS_SUCCESS);
    +        hipblasLtSdmaQueue_t queue = fakeQueue(0x2000);
    +        ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused,
    +                      HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_SDMA_QUEUES,
    +                      &queue,
    +                      sizeof(queue)),
    +                  HIPBLAS_STATUS_SUCCESS);
    +
    +        EXPECT_EQ(attach(), HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2AAttach_pre_checkin, AttachRejectsMissingRecvPointers)
    +    {
    +        const int64_t am = 512;
    +        ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT, &am, sizeof(am)),
    +                  HIPBLAS_STATUS_SUCCESS);
    +        hipblasLtSdmaQueue_t queue = fakeQueue(0x2000);
    +        ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused,
    +                      HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_SDMA_QUEUES,
    +                      &queue,
    +                      sizeof(queue)),
    +                  HIPBLAS_STATUS_SUCCESS);
    +
    +        EXPECT_EQ(attach(), HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2AAttach_pre_checkin, AttachRejectsMissingQueues)
    +    {
    +        const int64_t am = 512;
    +        ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT, &am, sizeof(am)),
    +                  HIPBLAS_STATUS_SUCCESS);
    +        void* recv = reinterpret_cast<void*>(0x1000);
    +        ASSERT_EQ(
    +            hipblasLtFusedEpilogueSetAttribute(
    +                fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_RECV_PTRS, &recv, sizeof(recv)),
    +            HIPBLAS_STATUS_SUCCESS);
    +
    +        EXPECT_EQ(attach(), HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2AAttach_pre_checkin, AttachRejectsNullPeerEntry)
    +    {
    +        completeForOneRank();
    +        void* recv[2] = {reinterpret_cast<void*>(0x1000), nullptr};
    +        ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_RECV_PTRS, recv, sizeof(recv)),
    +                  HIPBLAS_STATUS_SUCCESS);
    +        hipblasLtSdmaQueue_t queues[2] = {fakeQueue(0x2000), fakeQueue(0x3000)};
    +        ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused,
    +                      HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_SDMA_QUEUES,
    +                      queues,
    +                      sizeof(queues)),
    +                  HIPBLAS_STATUS_SUCCESS);
    +
    +        EXPECT_EQ(attach(), HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2AAttach_pre_checkin, AttachRejectsIncompleteQueueEntry)
    +    {
    +        completeForOneRank();
    +        hipblasLtSdmaQueue_t queue = fakeQueue(0x2000);
    +        queue.doorbell             = nullptr;
    +        ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused,
    +                      HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_SDMA_QUEUES,
    +                      &queue,
    +                      sizeof(queue)),
    +                  HIPBLAS_STATUS_SUCCESS);
    +
    +        EXPECT_EQ(attach(), HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2AAttach_pre_checkin, AttachedDescriptorReadsBack)
    +    {
    +        completeForOneRank();
    +        ASSERT_EQ(attach(), HIPBLAS_STATUS_SUCCESS);
    +
    +        hipblasLtFusedEpilogueDescriptor_t readBack = nullptr;
    +        size_t                             written  = 0;
    +        EXPECT_EQ(hipblasLtMatmulDescGetAttribute(matmulDesc,
    +                                                  HIPBLASLT_MATMUL_DESC_FUSED_EPILOGUE,
    +                                                  &readBack,
    +                                                  sizeof(readBack),
    +                                                  &written),
    +                  HIPBLAS_STATUS_SUCCESS);
    +        EXPECT_EQ(written, sizeof(readBack));
    +        EXPECT_EQ(readBack, fused);
    +    }
    +
    +    /************************************************************************
    +     * Communicator registration.
    +     ***********************************************************************/
    +
    +    class FusedA2AComm_pre_checkin : public ::testing::Test
    +    {
    +    protected:
    +        void SetUp() override
    +        {
    +            if(!gpuAvailable())
    +                GTEST_SKIP() << "No GPU available";
    +            ASSERT_EQ(hipblasLtCreate(&handle), HIPBLAS_STATUS_SUCCESS);
    +        }
    +
    +        void TearDown() override
    +        {
    +            if(handle)
    +                EXPECT_EQ(hipblasLtDestroy(handle), HIPBLAS_STATUS_SUCCESS);
    +        }
    +
    +        hipblasLtHandle_t handle = nullptr;
    +    };
    +
    +    TEST_F(FusedA2AComm_pre_checkin, RejectsInvalidRankAndWorld)
    +    {
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 1, 1, 1, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 0, 1, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle,
    +                                         0,
    +                                         HIPBLASLT_DEVICE_COMM_MAX_WORLD + 1,
    +                                         1,
    +                                         memcpyAllgather,
    +                                         nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 1, 0, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 1, 1, nullptr, nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST(FusedA2ACommHandle_pre_checkin, RejectsNullHandle)
    +    {
    +        EXPECT_EQ(hipblasLtSetDeviceComm(nullptr, 0, 1, 1, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_NOT_INITIALIZED);
    +    }
    +
    +    TEST_F(FusedA2AComm_pre_checkin, RegistersOnceAndOnlyOnce)
    +    {
    +        ASSERT_EQ(hipblasLtSetDeviceComm(handle, 0, 1, 1, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_SUCCESS);
    +        // A second call fails whether or not its arguments match, which is what
    +        // makes world immutable.
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 1, 1, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 1, 4, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2AComm_pre_checkin, PropagatesAllgatherFailure)
    +    {
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 1, 1, failingAllgather, nullptr),
    +                  HIPBLAS_STATUS_INTERNAL_ERROR);
    +        // The failed attempt left nothing registered.
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 1, 1, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_SUCCESS);
    +    }
    +
    +    TEST_F(FusedA2AComm_pre_checkin, RejectsRanksThatDisagree)
    +    {
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 2, 1, silentPeerAllgather, nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2AComm_pre_checkin, RejectsMisorderedAllgather)
    +    {
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 2, 1, duplicatingAllgather, nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2AComm_pre_checkin, MultipleChannelsRegister)
    +    {
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 1, 4, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_SUCCESS);
    +    }
    +
    +    // The one path a single process can drive all the way through: two ranks, two

    We could also use a multi-process tests if the PR claims that this is supported

    yzhang93 yzhang93 commented on code on Sep 02, 2026 19:40 UTC
    Code Review
    projects/hipblaslt/library/src/amd_detail/hipblaslt.cpp:1
    @@ -38,6 +38,8 @@
     #include <stdio.h>
     #include <stdlib.h>
     #include <string>
    +#include <unistd.h>

    Nice catch. getpid() needs <process.h> on MSVC, so the include is platform-guarded now, matching what utility.cpp and logging.h already do.

    yzhang93 yzhang93 commented on code on Sep 02, 2026 19:40 UTC
    Code Review
    projects/hipblaslt/clients/tests/src/fused_a2a_gtest.cpp:1
    @@ -0,0 +1,892 @@
    +// Copyright Advanced Micro Devices, Inc., or its affiliates.
    +// SPDX-License-Identifier: MIT
    +
    +// API-surface tests for the fused GEMM + all-to-all epilogue.
    +//
    +// This covers what the host can decide on its own: the builder's single-stage
    +// family rule, each attribute's accepted range, the completeness check that runs
    +// when the descriptor is attached to a matmul descriptor, communicator
    +// registration, and the shape and layout requirements checked before a solution
    +// is selected. No architecture carries a fused all-to-all kernel yet, so a
    +// well-formed request ends in HIPBLAS_STATUS_NOT_SUPPORTED; the tests assert that
    +// distinction, since an unusable request must be an error while missing
    +// capability must never present as a rejected shape.
    +//
    +// The suite names carry the "pre_checkin" token on purpose: the ctest presets in
    +// clients/tests/test_categories.yaml select by loose substring on a category
    +// token, and a plain gtest suite has none, so it would be invisible to them.
    +
    +#include <gtest/gtest.h>
    +#include <hip/hip_runtime.h>
    +#include <hipblaslt/hipblaslt.h>
    +
    +#include <chrono>
    +#include <condition_variable>
    +#include <cstring>
    +#include <mutex>
    +#include <thread>
    +#include <vector>
    +
    +namespace
    +{
    +    bool gpuAvailable()
    +    {
    +        int deviceCount = 0;
    +        return hipGetDeviceCount(&deviceCount) == hipSuccess && deviceCount > 0;
    +    }
    +
    +    // A single-process allgather: with one rank it is exactly the memcpy the
    +    // design doc names as the single-process case.
    +    hipblasStatus_t memcpyAllgather(void*       userData,
    +                                    const void* sendbuf,
    +                                    void*       recvbuf,
    +                                    size_t      bytesPerRank)
    +    {
    +        (void)userData;
    +        memcpy(recvbuf, sendbuf, bytesPerRank);
    +        return HIPBLAS_STATUS_SUCCESS;
    +    }
    +
    +    hipblasStatus_t failingAllgather(void*       userData,
    +                                     const void* sendbuf,
    +                                     void*       recvbuf,
    +                                     size_t      bytesPerRank)
    +    {
    +        (void)userData;
    +        (void)sendbuf;
    +        (void)recvbuf;
    +        (void)bytesPerRank;
    +        return HIPBLAS_STATUS_INTERNAL_ERROR;
    +    }
    +
    +    // Publishes this rank's payload and leaves the second slot zeroed, which no
    +    // real contribution can ever look like. Stands in for any way the ranks can
    +    // fail to agree about the communicator.
    +    hipblasStatus_t silentPeerAllgather(void*       userData,
    +                                        const void* sendbuf,
    +                                        void*       recvbuf,
    +                                        size_t      bytesPerRank)
    +    {
    +        (void)userData;
    +        memcpy(recvbuf, sendbuf, bytesPerRank);
    +        memset(static_cast<char*>(recvbuf) + bytesPerRank, 0, bytesPerRank);
    +        return HIPBLAS_STATUS_SUCCESS;
    +    }
    +
    +    // Copies this rank's payload into both slots, so the second slot claims to be
    +    // rank 0 where rank 1 belongs.
    +    hipblasStatus_t duplicatingAllgather(void*       userData,
    +                                         const void* sendbuf,
    +                                         void*       recvbuf,
    +                                         size_t      bytesPerRank)
    +    {
    +        (void)userData;
    +        memcpy(recvbuf, sendbuf, bytesPerRank);
    +        memcpy(static_cast<char*>(recvbuf) + bytesPerRank, sendbuf, bytesPerRank);
    +        return HIPBLAS_STATUS_SUCCESS;
    +    }
    +
    +    // A real allgather for ranks that are threads of one process: each publishes
    +    // into its own slot and waits for the rest before reading the whole buffer
    +    // back. Registration cannot return until every peer has contributed, so this
    +    // rendezvous is the only way more than one rank registers in one process. The
    +    // wait is bounded so a rank that never arrives fails the test instead of
    +    // hanging it.
    +    struct Rendezvous
    +    {
    +        std::mutex              mutex;
    +        std::condition_variable arrival;
    +        std::vector<char>       slots;
    +        uint32_t                arrived = 0;
    +        uint32_t                world   = 0;
    +    };
    +
    +    struct RendezvousRank
    +    {
    +        Rendezvous* shared;
    +        uint32_t    rank;
    +    };
    +
    +    hipblasStatus_t
    +        rendezvousAllgather(void* userData, const void* sendbuf, void* recvbuf, size_t bytesPerRank)
    +    {
    +        RendezvousRank& self   = *static_cast<RendezvousRank*>(userData);
    +        Rendezvous&     shared = *self.shared;
    +
    +        std::unique_lock<std::mutex> lock(shared.mutex);
    +        if(shared.slots.empty())
    +            shared.slots.resize(bytesPerRank * shared.world);
    +        memcpy(shared.slots.data() + bytesPerRank * self.rank, sendbuf, bytesPerRank);
    +
    +        if(++shared.arrived == shared.world)
    +        {
    +            shared.arrival.notify_all();
    +        }
    +        else if(!shared.arrival.wait_for(
    +                    lock, std::chrono::seconds(30), [&] { return shared.arrived == shared.world; }))
    +        {
    +            return HIPBLAS_STATUS_INTERNAL_ERROR;
    +        }
    +
    +        memcpy(recvbuf, shared.slots.data(), bytesPerRank * shared.world);
    +        return HIPBLAS_STATUS_SUCCESS;
    +    }
    +
    +    // Four plausible-looking addresses. The library stores a queue's fields
    +    // without interpreting them, so a test only needs them to be non-null.
    +    hipblasLtSdmaQueue_t fakeQueue(uintptr_t base)
    +    {
    +        hipblasLtSdmaQueue_t q{};
    +        q.queueBuf = reinterpret_cast<void*>(base);
    +        q.rptr     = reinterpret_cast<void*>(base + 0x100);
    +        q.wptr     = reinterpret_cast<void*>(base + 0x200);
    +        q.doorbell = reinterpret_cast<void*>(base + 0x300);
    +        return q;
    +    }
    +
    +    /************************************************************************
    +     * Builder: lifecycle, the single-stage family rule, and attributes.
    +     * None of this needs a device.
    +     ***********************************************************************/
    +
    +    class FusedA2ABuilder_pre_checkin : public ::testing::Test
    +    {
    +    protected:
    +        void SetUp() override
    +        {
    +            ASSERT_EQ(hipblasLtFusedEpilogueCreate(&fused), HIPBLAS_STATUS_SUCCESS);
    +            ASSERT_NE(fused, nullptr);
    +        }
    +
    +        void TearDown() override
    +        {
    +            if(fused)
    +                EXPECT_EQ(hipblasLtFusedEpilogueDestroy(fused), HIPBLAS_STATUS_SUCCESS);
    +        }
    +
    +        hipblasStatus_t addA2A()
    +        {
    +            return hipblasLtFusedEpilogueAdd(fused, HIPBLASLT_FUSEABLE_EPILOGUE_A2A_PREFIX);
    +        }
    +
    +        hipblasStatus_t setExtent(int64_t am)
    +        {
    +            return hipblasLtFusedEpilogueSetAttribute(
    +                fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT, &am, sizeof(am));
    +        }
    +
    +        hipblasStatus_t setRecvPtrs(const std::vector<void*>& ptrs)
    +        {
    +            return hipblasLtFusedEpilogueSetAttribute(fused,
    +                                                      HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_RECV_PTRS,
    +                                                      ptrs.data(),
    +                                                      ptrs.size() * sizeof(void*));
    +        }
    +
    +        hipblasStatus_t setQueues(const std::vector<hipblasLtSdmaQueue_t>& queues)
    +        {
    +            return hipblasLtFusedEpilogueSetAttribute(
    +                fused,
    +                HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_SDMA_QUEUES,
    +                queues.data(),
    +                queues.size() * sizeof(hipblasLtSdmaQueue_t));
    +        }
    +
    +        hipblasLtFusedEpilogueDescriptor_t fused = nullptr;
    +    };
    +
    +    TEST(FusedA2ALifecycle_pre_checkin, CreateRejectsNullOut)
    +    {
    +        EXPECT_EQ(hipblasLtFusedEpilogueCreate(nullptr), HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST(FusedA2ALifecycle_pre_checkin, DestroyAcceptsNull)
    +    {
    +        EXPECT_EQ(hipblasLtFusedEpilogueDestroy(nullptr), HIPBLAS_STATUS_SUCCESS);
    +    }
    +
    +    TEST(FusedA2ALifecycle_pre_checkin, AddRejectsNullDescriptor)
    +    {
    +        EXPECT_EQ(hipblasLtFusedEpilogueAdd(nullptr, HIPBLASLT_FUSEABLE_EPILOGUE_A2A_PREFIX),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2ABuilder_pre_checkin, AddAcceptsAllToAll)
    +    {
    +        EXPECT_EQ(addA2A(), HIPBLAS_STATUS_SUCCESS);
    +    }
    +
    +    TEST_F(FusedA2ABuilder_pre_checkin, AddRejectsUnrecognizedStage)
    +    {
    +        EXPECT_EQ(hipblasLtFusedEpilogueAdd(fused, static_cast<hipblasLtFuseableEpilogue_t>(4242)),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    // The collective family holds one stage, so a second all-to-all is rejected
    +    // at the call expressing the mistake rather than at launch.
    +    TEST_F(FusedA2ABuilder_pre_checkin, AddRejectsDuplicateAllToAll)
    +    {
    +        ASSERT_EQ(addA2A(), HIPBLAS_STATUS_SUCCESS);
    +        EXPECT_EQ(addA2A(), HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2ABuilder_pre_checkin, SetAttributeRejectsNullArguments)
    +    {
    +        const int64_t am = 512;
    +        EXPECT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      nullptr, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT, &am, sizeof(am)),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +        EXPECT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT, nullptr, sizeof(am)),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2ABuilder_pre_checkin, SetAttributeRejectsUnknownAttribute)
    +    {
    +        const int64_t value = 1;
    +        EXPECT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused,
    +                      static_cast<hipblasLtFusedEpilogueAttribute_t>(9999),
    +                      &value,
    +                      sizeof(value)),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2ABuilder_pre_checkin, ExtentMustBePositiveAndCorrectlySized)
    +    {
    +        EXPECT_EQ(setExtent(512), HIPBLAS_STATUS_SUCCESS);
    +        EXPECT_EQ(setExtent(0), HIPBLAS_STATUS_INVALID_VALUE);
    +        EXPECT_EQ(setExtent(-8), HIPBLAS_STATUS_INVALID_VALUE);
    +
    +        const int32_t narrow = 512;
    +        EXPECT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT, &narrow, sizeof(narrow)),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2ABuilder_pre_checkin, CompletionModeAcceptsInKernelOnly)
    +    {
    +        hipblasLtA2ACompletionMode_t mode = HIPBLASLT_A2A_COMPLETION_IN_KERNEL;
    +        EXPECT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused,
    +                      HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_COMPLETION_MODE,
    +                      &mode,
    +                      sizeof(mode)),
    +                  HIPBLAS_STATUS_SUCCESS);
    +
    +        // Value 1 is reserved for the deferred mode, which ships with the
    +        // primitive a caller would wait on and not before it.
    +        mode = static_cast<hipblasLtA2ACompletionMode_t>(1);
    +        EXPECT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused,
    +                      HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_COMPLETION_MODE,
    +                      &mode,
    +                      sizeof(mode)),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2ABuilder_pre_checkin, PerRankArraysAreSizedInWholeEntries)
    +    {
    +        EXPECT_EQ(setRecvPtrs({reinterpret_cast<void*>(0x1000)}), HIPBLAS_STATUS_SUCCESS);
    +        EXPECT_EQ(setQueues({fakeQueue(0x2000)}), HIPBLAS_STATUS_SUCCESS);
    +
    +        void* one = reinterpret_cast<void*>(0x1000);
    +        EXPECT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_RECV_PTRS, &one, 0),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +        EXPECT_EQ(hipblasLtFusedEpilogueSetAttribute(fused,
    +                                                     HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_RECV_PTRS,
    +                                                     &one,
    +                                                     sizeof(void*) + 1),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2ABuilder_pre_checkin, PerRankArraysAreBoundedByTheMaximumWorld)
    +    {
    +        const std::vector<void*> tooMany(HIPBLASLT_DEVICE_COMM_MAX_WORLD + 1,
    +                                         reinterpret_cast<void*>(0x1000));
    +        EXPECT_EQ(setRecvPtrs(tooMany), HIPBLAS_STATUS_INVALID_VALUE);
    +
    +        const std::vector<hipblasLtSdmaQueue_t> tooManyQueues(HIPBLASLT_DEVICE_COMM_MAX_WORLD + 1,
    +                                                              fakeQueue(0x2000));
    +        EXPECT_EQ(setQueues(tooManyQueues), HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    /************************************************************************
    +     * Attach: the descriptor stops being a work in progress here, so this is
    +     * where a stage's required parameters must all be present.
    +     ***********************************************************************/
    +
    +    class FusedA2AAttach_pre_checkin : public ::testing::Test
    +    {
    +    protected:
    +        void SetUp() override
    +        {
    +            ASSERT_EQ(hipblasLtMatmulDescCreate(&matmulDesc, HIPBLAS_COMPUTE_32F, HIP_R_32F),
    +                      HIPBLAS_STATUS_SUCCESS);
    +            ASSERT_EQ(hipblasLtFusedEpilogueCreate(&fused), HIPBLAS_STATUS_SUCCESS);
    +            ASSERT_EQ(hipblasLtFusedEpilogueAdd(fused, HIPBLASLT_FUSEABLE_EPILOGUE_A2A_PREFIX),
    +                      HIPBLAS_STATUS_SUCCESS);
    +        }
    +
    +        void TearDown() override
    +        {
    +            if(fused)
    +                EXPECT_EQ(hipblasLtFusedEpilogueDestroy(fused), HIPBLAS_STATUS_SUCCESS);
    +            if(matmulDesc)
    +                EXPECT_EQ(hipblasLtMatmulDescDestroy(matmulDesc), HIPBLAS_STATUS_SUCCESS);
    +        }
    +
    +        // Fills in everything a one-rank all-to-all needs.
    +        void completeForOneRank()
    +        {
    +            const int64_t am = 512;
    +            ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                          fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT, &am, sizeof(am)),
    +                      HIPBLAS_STATUS_SUCCESS);
    +            void* recv = reinterpret_cast<void*>(0x1000);
    +            ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                          fused,
    +                          HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_RECV_PTRS,
    +                          &recv,
    +                          sizeof(recv)),
    +                      HIPBLAS_STATUS_SUCCESS);
    +            hipblasLtSdmaQueue_t queue = fakeQueue(0x2000);
    +            ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                          fused,
    +                          HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_SDMA_QUEUES,
    +                          &queue,
    +                          sizeof(queue)),
    +                      HIPBLAS_STATUS_SUCCESS);
    +        }
    +
    +        hipblasStatus_t attach()
    +        {
    +            return hipblasLtMatmulDescSetAttribute(
    +                matmulDesc, HIPBLASLT_MATMUL_DESC_FUSED_EPILOGUE, &fused, sizeof(fused));
    +        }
    +
    +        hipblasLtMatmulDesc_t              matmulDesc = nullptr;
    +        hipblasLtFusedEpilogueDescriptor_t fused      = nullptr;
    +    };
    +
    +    TEST_F(FusedA2AAttach_pre_checkin, CompleteDescriptorAttaches)
    +    {
    +        completeForOneRank();
    +        EXPECT_EQ(attach(), HIPBLAS_STATUS_SUCCESS);
    +    }
    +
    +    TEST_F(FusedA2AAttach_pre_checkin, AttachRejectsMissingExtent)
    +    {
    +        void* recv = reinterpret_cast<void*>(0x1000);
    +        ASSERT_EQ(
    +            hipblasLtFusedEpilogueSetAttribute(
    +                fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_RECV_PTRS, &recv, sizeof(recv)),
    +            HIPBLAS_STATUS_SUCCESS);
    +        hipblasLtSdmaQueue_t queue = fakeQueue(0x2000);
    +        ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused,
    +                      HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_SDMA_QUEUES,
    +                      &queue,
    +                      sizeof(queue)),
    +                  HIPBLAS_STATUS_SUCCESS);
    +
    +        EXPECT_EQ(attach(), HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2AAttach_pre_checkin, AttachRejectsMissingRecvPointers)
    +    {
    +        const int64_t am = 512;
    +        ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT, &am, sizeof(am)),
    +                  HIPBLAS_STATUS_SUCCESS);
    +        hipblasLtSdmaQueue_t queue = fakeQueue(0x2000);
    +        ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused,
    +                      HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_SDMA_QUEUES,
    +                      &queue,
    +                      sizeof(queue)),
    +                  HIPBLAS_STATUS_SUCCESS);
    +
    +        EXPECT_EQ(attach(), HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2AAttach_pre_checkin, AttachRejectsMissingQueues)
    +    {
    +        const int64_t am = 512;
    +        ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT, &am, sizeof(am)),
    +                  HIPBLAS_STATUS_SUCCESS);
    +        void* recv = reinterpret_cast<void*>(0x1000);
    +        ASSERT_EQ(
    +            hipblasLtFusedEpilogueSetAttribute(
    +                fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_RECV_PTRS, &recv, sizeof(recv)),
    +            HIPBLAS_STATUS_SUCCESS);
    +
    +        EXPECT_EQ(attach(), HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2AAttach_pre_checkin, AttachRejectsNullPeerEntry)
    +    {
    +        completeForOneRank();
    +        void* recv[2] = {reinterpret_cast<void*>(0x1000), nullptr};
    +        ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_RECV_PTRS, recv, sizeof(recv)),
    +                  HIPBLAS_STATUS_SUCCESS);
    +        hipblasLtSdmaQueue_t queues[2] = {fakeQueue(0x2000), fakeQueue(0x3000)};
    +        ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused,
    +                      HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_SDMA_QUEUES,
    +                      queues,
    +                      sizeof(queues)),
    +                  HIPBLAS_STATUS_SUCCESS);
    +
    +        EXPECT_EQ(attach(), HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2AAttach_pre_checkin, AttachRejectsIncompleteQueueEntry)
    +    {
    +        completeForOneRank();
    +        hipblasLtSdmaQueue_t queue = fakeQueue(0x2000);
    +        queue.doorbell             = nullptr;
    +        ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused,
    +                      HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_SDMA_QUEUES,
    +                      &queue,
    +                      sizeof(queue)),
    +                  HIPBLAS_STATUS_SUCCESS);
    +
    +        EXPECT_EQ(attach(), HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2AAttach_pre_checkin, AttachedDescriptorReadsBack)
    +    {
    +        completeForOneRank();
    +        ASSERT_EQ(attach(), HIPBLAS_STATUS_SUCCESS);
    +
    +        hipblasLtFusedEpilogueDescriptor_t readBack = nullptr;
    +        size_t                             written  = 0;
    +        EXPECT_EQ(hipblasLtMatmulDescGetAttribute(matmulDesc,
    +                                                  HIPBLASLT_MATMUL_DESC_FUSED_EPILOGUE,
    +                                                  &readBack,
    +                                                  sizeof(readBack),
    +                                                  &written),
    +                  HIPBLAS_STATUS_SUCCESS);
    +        EXPECT_EQ(written, sizeof(readBack));
    +        EXPECT_EQ(readBack, fused);
    +    }
    +
    +    /************************************************************************
    +     * Communicator registration.
    +     ***********************************************************************/
    +
    +    class FusedA2AComm_pre_checkin : public ::testing::Test
    +    {
    +    protected:
    +        void SetUp() override
    +        {
    +            if(!gpuAvailable())
    +                GTEST_SKIP() << "No GPU available";
    +            ASSERT_EQ(hipblasLtCreate(&handle), HIPBLAS_STATUS_SUCCESS);
    +        }
    +
    +        void TearDown() override
    +        {
    +            if(handle)
    +                EXPECT_EQ(hipblasLtDestroy(handle), HIPBLAS_STATUS_SUCCESS);
    +        }
    +
    +        hipblasLtHandle_t handle = nullptr;
    +    };
    +
    +    TEST_F(FusedA2AComm_pre_checkin, RejectsInvalidRankAndWorld)
    +    {
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 1, 1, 1, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 0, 1, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle,
    +                                         0,
    +                                         HIPBLASLT_DEVICE_COMM_MAX_WORLD + 1,
    +                                         1,
    +                                         memcpyAllgather,
    +                                         nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 1, 0, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 1, 1, nullptr, nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST(FusedA2ACommHandle_pre_checkin, RejectsNullHandle)
    +    {
    +        EXPECT_EQ(hipblasLtSetDeviceComm(nullptr, 0, 1, 1, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_NOT_INITIALIZED);
    +    }
    +
    +    TEST_F(FusedA2AComm_pre_checkin, RegistersOnceAndOnlyOnce)
    +    {
    +        ASSERT_EQ(hipblasLtSetDeviceComm(handle, 0, 1, 1, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_SUCCESS);
    +        // A second call fails whether or not its arguments match, which is what
    +        // makes world immutable.
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 1, 1, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 1, 4, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2AComm_pre_checkin, PropagatesAllgatherFailure)
    +    {
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 1, 1, failingAllgather, nullptr),
    +                  HIPBLAS_STATUS_INTERNAL_ERROR);
    +        // The failed attempt left nothing registered.
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 1, 1, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_SUCCESS);
    +    }
    +
    +    TEST_F(FusedA2AComm_pre_checkin, RejectsRanksThatDisagree)
    +    {
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 2, 1, silentPeerAllgather, nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2AComm_pre_checkin, RejectsMisorderedAllgather)
    +    {
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 2, 1, duplicatingAllgather, nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2AComm_pre_checkin, MultipleChannelsRegister)
    +    {
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 1, 4, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_SUCCESS);
    +    }
    +
    +    // The one path a single process can drive all the way through: two ranks, two
    +    // handles, each finding the other's flag region among the payloads. Where
    +    // there are two devices the ranks take one each, so registration has to make
    +    // the peer's region reachable rather than merely record its address. Both
    +    // handles are then destroyed, which is where the three kinds of entry have to
    +    // be told apart: a rank frees its own region and leaves its peer's alone.
    +    TEST(FusedA2ACommPeers_pre_checkin, TwoRanksInOneProcessRegister)
    +    {
    +        if(!gpuAvailable())
    +            GTEST_SKIP() << "No GPU available";
    +
    +        int deviceCount = 0;
    +        ASSERT_EQ(hipGetDeviceCount(&deviceCount), hipSuccess);
    +
    +        constexpr uint32_t kWorld = 2;
    +
    +        Rendezvous shared;
    +        shared.world = kWorld;
    +
    +        RendezvousRank  args[kWorld] = {{&shared, 0}, {&shared, 1}};
    +        hipblasStatus_t status[kWorld]
    +            = {HIPBLAS_STATUS_NOT_INITIALIZED, HIPBLAS_STATUS_NOT_INITIALIZED};
    +        std::thread ranks[kWorld];
    +
    +        for(uint32_t r = 0; r < kWorld; ++r)
    +        {
    +            ranks[r] = std::thread([&, r] {
    +                if(hipSetDevice((int)r % deviceCount) != hipSuccess)

    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.

    yzhang93 yzhang93 commented on code on Sep 02, 2026 19:40 UTC
    Code Review
    projects/hipblaslt/clients/tests/src/fused_a2a_gtest.cpp:1
    @@ -513,6 +563,50 @@ namespace
                       HIPBLAS_STATUS_SUCCESS);
         }
     
    +    // The one path a single process can drive all the way through: two ranks, two
    +    // handles, each finding the other's flag region among the payloads. Where
    +    // there are two devices the ranks take one each, so registration has to make
    +    // the peer's region reachable rather than merely record its address. Both
    +    // handles are then destroyed, which is where the three kinds of entry have to
    +    // be told apart: a rank frees its own region and leaves its peer's alone.
    +    TEST(FusedA2ACommPeers_pre_checkin, TwoRanksInOneProcessRegister)
    +    {
    +        if(!gpuAvailable())
    +            GTEST_SKIP() << "No GPU available";
    +
    +        int deviceCount = 0;
    +        ASSERT_EQ(hipGetDeviceCount(&deviceCount), hipSuccess);
    +
    +        constexpr uint32_t kWorld = 2;
    +
    +        Rendezvous shared;
    +        shared.world = kWorld;
    +
    +        RendezvousRank  args[kWorld] = {{&shared, 0}, {&shared, 1}};
    +        hipblasStatus_t status[kWorld]
    +            = {HIPBLAS_STATUS_NOT_INITIALIZED, HIPBLAS_STATUS_NOT_INITIALIZED};
    +        std::thread ranks[kWorld];
    +
    +        for(uint32_t r = 0; r < kWorld; ++r)
    +        {
    +            ranks[r] = std::thread([&, r] {
    +                if(hipSetDevice((int)r % deviceCount) != hipSuccess)
    +                    return;
    +                hipblasLtHandle_t handle = nullptr;
    +                if(hipblasLtCreate(&handle) != HIPBLAS_STATUS_SUCCESS)
    +                    return;
    +                status[r]
    +                    = hipblasLtSetDeviceComm(handle, r, kWorld, 1, rendezvousAllgather, &args[r]);
    +                EXPECT_EQ(hipblasLtDestroy(handle), HIPBLAS_STATUS_SUCCESS);

    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.

    yzhang93 yzhang93 commented on code on Sep 02, 2026 19:40 UTC
    Code Review
    projects/hipblaslt/library/include/hipblaslt/hipblaslt.h:1
    @@ -108,6 +108,121 @@ typedef enum {
       HIPBLASLT_EPILOGUE_CLAMP_AUX_BIAS_EXT = 131204, /**<Output GEMM results after applying bias but before applying clamp transform.*/
     } hipblasLtEpilogue_t;
     
    +/*! \ingroup types_module
    + *  \brief Stages that can be selected on a fused epilogue descriptor.
    + *
    + *  \details
    + *  Unlike the flat ``hipblasLtEpilogue_t`` enum, these values name epilogue stages that are
    + *  accumulated into a ``hipblasLtFusedEpilogueDescriptor_t`` via ``hipblasLtFusedEpilogueAdd``
    + *  and attached to a matmul descriptor through ``HIPBLASLT_MATMUL_DESC_FUSED_EPILOGUE``.
    + *
    + *  The fused epilogue API offers several families, each with its own composition rule. Values
    + *  ``0``-``6`` are reserved for the chainable family (residual add, RMSNorm, partial RMSNorm
    + *  stats, RMSNorm scale-apply, AMax, requant) and for the gated linear units, which compose
    + *  by their own rules. All-to-all is the collective family: a single stage that does not
    + *  compose with any other, so adding a companion stage is rejected at ``Add`` time.
    + */
    +typedef enum {
    +  HIPBLASLT_FUSEABLE_EPILOGUE_A2A_PREFIX = 7, /**<Collective family: redistribute a leading run of D's free-0 (feature) positions across the ranks of the registered device communicator, from the GEMM's own store path. Single stage; not chainable. The ``PREFIX`` suffix names the dispatch criterion - the exported region is the positional run ``[0, AM)`` given by ``HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT``.*/
    +} hipblasLtFuseableEpilogue_t;
    +
    +/*! \ingroup types_module
    + *  \brief Attributes settable on a fused epilogue descriptor.
    + *
    + *  \details
    + *  Values ``0``-``11`` are reserved for the chainable family's attributes.
    + */
    +typedef enum {
    +  HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_SDMA_QUEUES = 12, /**<Required by a solution using the SDMA transport. Host array of ``world`` ``hipblasLtSdmaQueue_t`` entries; entry ``j`` is this device's copy-engine queue targeting rank ``j``, with ``j == rank`` the loopback queue. The library copies the entries and never interprets the addresses, so the caller's array need not outlive the call - but the queues themselves must outlive the launch group. Data type: ``const hipblasLtSdmaQueue_t*``.*/
    +  HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_RECV_PTRS = 13, /**<Required. Host array of ``world`` pointers in rank order; entry ``j`` is the address, in this process, of rank ``j``'s receive buffer. The buffer holds ``world * N * (AM / world)`` elements of D's type, laid out ``[source, token, feature]`` with feature contiguous and the unpadded ``N`` as the source stride. Data type: ``void* const*``.*/
    +  HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT = 14, /**<Required. ``AM``, the number of leading free-0 (feature) positions of D that are redistributed; the per-rank shard is ``AM / world``. Must be positive and divide by ``world``. This participates in solution selection, so it has the same standing as M, N, and K: setting it after ``hipblasLtMatmulAlgoGetHeuristic`` invalidates the returned algo. Data type: ``int64_t``.*/
    +  HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_COMPLETION_MODE = 15, /**<Optional. How receive completion is established. ``HIPBLASLT_A2A_COMPLETION_IN_KERNEL`` is the only accepted value in this release, and the default. Data type: ``hipblasLtA2ACompletionMode_t``.*/
    +  HIPBLASLT_FUSED_EPILOGUE_COMM_CHANNEL = 16, /**<Optional, default ``0``. Which of the communicator's ``nChannels`` flag regions this operation uses. Concurrent operations need distinct channels and disjoint queue sets; every rank of one launch group must pass the same channel, which the library cannot verify. Data type: ``uint32_t``.*/
    +} hipblasLtFusedEpilogueAttribute_t;
    +
    +/*! \ingroup types_module
    + *  \brief How a fused all-to-all establishes receive completion.
    + */
    +typedef enum {
    +  HIPBLASLT_A2A_COMPLETION_IN_KERNEL = 0, /**<The kernel does not retire until this rank's receive buffer is fully populated, so ordinary stream semantics cover the collective and the receive buffer is safe to read once this rank's stream is synchronized.*/
    +
    +  /* Value 1 is reserved for a deferred mode, in which the kernel retires before
    +     inbound data lands. It ships together with the primitive a caller would wait
    +     on, not before it. */
    +} hipblasLtA2ACompletionMode_t;
    +
    +/*! \ingroup types_module
    + *  \brief One caller-created copy-engine (SDMA) queue, as four addresses.
    + *
    + *  \details
    + *  Creating a copy-engine queue means allocating its ring and creating the queue against a
    + *  topology node and engine, all of which goes through the kernel-mode thunk. Leaving that to
    + *  the caller is what keeps the thunk out of hipBLASLt's build: the caller reads these four
    + *  values out of the queue it created, and the library stores them and hands them to the kernel
    + *  without interpreting any of them.
    + */
    +typedef struct {
    +  void* queueBuf; /**<Copy-engine ring base.*/
    +  void* rptr;     /**<Hardware read pointer.*/
    +  void* wptr;     /**<Hardware write pointer.*/
    +  void* doorbell; /**<Doorbell.*/
    +} hipblasLtSdmaQueue_t;
    +
    +/*! \ingroup types_module
    + *  \brief Opaque handle representing a fused epilogue.
    + *
    + *  \details
    + *  Use the following functions to manipulate this handle:
    + *
    + *  \ref hipblasLtFusedEpilogueCreate(): To create one instance of the handle.
    + *
    + *  \ref hipblasLtFusedEpilogueAdd(): To select a fused epilogue stage.
    + *
    + *  \ref hipblasLtFusedEpilogueSetAttribute(): To configure that stage's parameters.
    + *
    + *  \ref hipblasLtFusedEpilogueDestroy(): To destroy a previously created handle and release
    + *  the resources.
    + */
    +typedef struct hipblasLtFusedEpilogueDescriptor* hipblasLtFusedEpilogueDescriptor_t;
    +
    +/*! \ingroup types_module
    + *  \brief Largest world size a device communicator supports.
    + *
    + *  \details
    + *  An implementation limit rather than an API one: the kernel's per-peer state is a fixed-size
    + *  array and the drain wait's lane mask also bounds it.
    + */
    +#define HIPBLASLT_DEVICE_COMM_MAX_WORLD 8
    +
    +/*! \ingroup types_module
    + *  \brief Caller-supplied allgather used to register a device communicator.
    + *
    + *  \details
    + *  A true allgather: rank ``r``'s \p sendbuf (\p bytesPerRank bytes) must land at
    + *  ``recvbuf + r * bytesPerRank`` on every rank, and \p recvbuf must be readable on return.
    + *  The payload is opaque; the caller must not interpret or reorder it.
    + *
    + *  This callback is the only capability the caller hands over, and the reason one entry point
    + *  covers both deployment shapes: the library performs no rendezvous of its own. In a single
    + *  process the callback is a memcpy; across processes it is ``MPI_Allgather`` or a
    + *  ``torch.distributed`` store, and nothing else changes.

    Memcpy is the world == 1 case only. You're right that the sentence read as if it covered every single-process world. Reworded.

    yzhang93 yzhang93 commented on code on Sep 02, 2026 19:40 UTC
    Code Review
    projects/hipblaslt/library/src/amd_detail/hipblaslt.cpp:1
    @@ -107,6 +109,283 @@ hipblasStatus_t RocBlasLtStatusToHIPStatus(rocblaslt_status_ status)
         }
     }
     
    +/********************************************************************************
    + * Fused epilogue descriptor.
    + *
    + * Opaque to the caller. Its contents are read only here, in the C-API layer that
    + * knows what the stages mean; rocBLASLt carries it as a forward-declared pointer.
    + *******************************************************************************/
    +struct hipblasLtFusedEpilogueDescriptor
    +{
    +    std::vector<hipblasLtFuseableEpilogue_t> stages;
    +
    +    // HIPBLASLT_FUSEABLE_EPILOGUE_A2A_PREFIX parameters. The per-rank arrays are
    +    // sized by the caller's SetAttribute call; that their length is the
    +    // communicator's world size is checked where the communicator is visible.
    +    int64_t                           a2a_extent     = 0;
    +    bool                              a2a_extent_set = false;
    +    hipblasLtA2ACompletionMode_t      a2a_completion = HIPBLASLT_A2A_COMPLETION_IN_KERNEL;
    +    uint32_t                          comm_channel   = 0;
    +    std::vector<void*>                a2a_recv_ptrs;
    +    std::vector<hipblasLtSdmaQueue_t> a2a_queues;
    +};
    +
    +namespace
    +{
    +    bool fused_epilogue_has_stage(const hipblasLtFusedEpilogueDescriptor* d,
    +                                  hipblasLtFuseableEpilogue_t             e)
    +    {
    +        for(auto s : d->stages)
    +            if(s == e)
    +                return true;
    +        return false;
    +    }
    +
    +    bool fused_epilogue_stage_recognized(hipblasLtFuseableEpilogue_t stage)
    +    {
    +        switch(stage)
    +        {
    +        case HIPBLASLT_FUSEABLE_EPILOGUE_A2A_PREFIX:
    +            return true;
    +        }
    +        return false;
    +    }
    +
    +    // The collective family holds one stage and composes with nothing. Rejecting a
    +    // companion here rather than at launch is deliberate: the caller is asking for
    +    // something the API does not define, so it should learn that at the call that
    +    // expresses the mistake. Legalizing a combination later turns this into
    +    // success, which is the compatible direction.
    +    bool fused_epilogue_stage_composes(const hipblasLtFusedEpilogueDescriptor* desc,
    +                                       hipblasLtFuseableEpilogue_t             stage)
    +    {
    +        if(desc->stages.empty())
    +            return true;
    +        if(stage == HIPBLASLT_FUSEABLE_EPILOGUE_A2A_PREFIX)
    +            return false;
    +        return !fused_epilogue_has_stage(desc, HIPBLASLT_FUSEABLE_EPILOGUE_A2A_PREFIX);
    +    }
    +
    +    // Checked when the descriptor is attached to a matmul descriptor: every stage
    +    // present must have the parameters it cannot run without. World size is not
    +    // known here, so the per-rank arrays are checked for content but not length;
    +    // validate_fused_a2a_launch compares both against it.
    +    hipblasStatus_t validate_fused_epilogue_attach(const hipblasLtFusedEpilogueDescriptor* desc)
    +    {
    +        if(!fused_epilogue_has_stage(desc, HIPBLASLT_FUSEABLE_EPILOGUE_A2A_PREFIX))
    +            return HIPBLAS_STATUS_SUCCESS;
    +
    +        if(!desc->a2a_extent_set || desc->a2a_recv_ptrs.empty() || desc->a2a_queues.empty())
    +        {
    +            log_error(__func__, "all-to-all stage is missing a required attribute");
    +            return HIPBLAS_STATUS_INVALID_VALUE;
    +        }
    +
    +        for(size_t j = 0; j < desc->a2a_recv_ptrs.size(); ++j)
    +        {
    +            if(desc->a2a_recv_ptrs[j] == nullptr)
    +            {
    +                log_error(__func__, "null all-to-all peer-recv pointer for rank", (int)j);
    +                return HIPBLAS_STATUS_INVALID_VALUE;
    +            }
    +        }
    +
    +        for(size_t j = 0; j < desc->a2a_queues.size(); ++j)
    +        {
    +            const hipblasLtSdmaQueue_t& q = desc->a2a_queues[j];
    +            if(q.queueBuf == nullptr || q.rptr == nullptr || q.wptr == nullptr
    +               || q.doorbell == nullptr)
    +            {
    +                log_error(__func__, "incomplete all-to-all SDMA queue for rank", (int)j);
    +                return HIPBLAS_STATUS_INVALID_VALUE;
    +            }
    +        }
    +
    +        return HIPBLAS_STATUS_SUCCESS;
    +    }
    +
    +    // Checked before a solution is selected and again at launch, this being the
    +    // first point where both the communicator and D's layout are in hand.
    +    //
    +    // The requirements that depend on the selected solution's macro tile -
    +    // n_shard % MT0 == 0, MT1 < 2^14, MT0/MT1 in {128, 256}, data-parallel only,
    +    // and no split-K - are enforced by the kernel generator as solution
    +    // rejections, so they become "no usable algo" rather than a return code here.
    +    hipblasStatus_t validate_fused_a2a_launch(rocblaslt_handle                        handle,
    +                                              const hipblasLtFusedEpilogueDescriptor* desc,
    +                                              rocblaslt_matrix_layout                 matD)
    +    {
    +        if(handle == nullptr || matD == nullptr)
    +            return HIPBLAS_STATUS_INVALID_VALUE;
    +
    +        // Registration is optional, but it is not a fallback: an all-to-all stage
    +        // without a communicator is an error, not a silent unfused GEMM.
    +        const uint32_t world = handle->device_comm_world;
    +        if(world == 0)
    +        {
    +            log_error(__func__, "all-to-all stage requires hipblasLtSetDeviceComm on this handle");
    +            return HIPBLAS_STATUS_INVALID_VALUE;
    +        }
    +
    +        if(desc->comm_channel >= handle->device_comm_channels)
    +        {
    +            log_error(__func__, "comm channel out of range", (int)desc->comm_channel);
    +            return HIPBLAS_STATUS_INVALID_VALUE;
    +        }
    +
    +        if(desc->a2a_recv_ptrs.size() != world || desc->a2a_queues.size() != world)
    +        {
    +            log_error(__func__, "all-to-all per-rank arrays do not have world entries");
    +            return HIPBLAS_STATUS_INVALID_VALUE;
    +        }
    +
    +        // The receive-buffer layout has no batch axis.
    +        if(matD->batch_count > 1)
    +        {
    +            log_error(__func__, "all-to-all does not support batched GEMM", matD->batch_count);
    +            return HIPBLAS_STATUS_INVALID_VALUE;
    +        }
    +
    +        const int64_t am = desc->a2a_extent;
    +        if(am % (int64_t)world != 0)
    +        {
    +            log_error(__func__, "all-to-all extent does not divide by world", am);
    +            return HIPBLAS_STATUS_INVALID_VALUE;
    +        }
    +        if(am > (int64_t)matD->m)
    +        {
    +            log_error(__func__, "all-to-all extent exceeds D's free-0 extent", am);
    +            return HIPBLAS_STATUS_INVALID_VALUE;
    +        }
    +
    +        // The copy moves n_shard contiguous elements per token row, so a strided
    +        // feature axis would ship unrelated data.
    +        if(matD->order != HIPBLASLT_ORDER_COL)
    +        {
    +            log_error(__func__, "all-to-all requires a unit free-0 stride on D");
    +            return HIPBLAS_STATUS_INVALID_VALUE;
    +        }
    +
    +        if(matD->type != HIP_R_16BF)
    +        {
    +            log_error(__func__, "all-to-all supports a BF16 D only", (int)matD->type);
    +            return HIPBLAS_STATUS_NOT_SUPPORTED;
    +        }
    +
    +        // Copy widths and pitches are expressed in the descriptor's 16-byte
    +        // addressing granularity and are not rounded, and its extent and pitch
    +        // fields are narrow: 14 bits for an extent, 19 for the source pitch.
    +        constexpr int64_t elemsPer16B = 16 / sizeof(hip_bfloat16);
    +        const int64_t     shard       = am / (int64_t)world;
    +        const int64_t     ldd         = matD->ld;
    +        if(shard % elemsPer16B != 0 || ldd % elemsPer16B != 0)
    +        {
    +            log_error(__func__, "all-to-all shard extent and ldd must be 16-byte multiples");
    +            return HIPBLAS_STATUS_INVALID_VALUE;
    +        }
    +        if(shard / elemsPer16B >= (int64_t{1} << 14) || ldd / elemsPer16B >= (int64_t{1} << 19))
    +        {
    +            log_error(__func__, "all-to-all shard extent or ldd exceeds the copy descriptor");
    +            return HIPBLAS_STATUS_INVALID_VALUE;
    +        }
    +
    +        // The request is well formed; no architecture carries a fused all-to-all
    +        // kernel in this release.
    +        log_error(__func__, "no fused all-to-all implementation for the selected device");
    +        return HIPBLAS_STATUS_NOT_SUPPORTED;
    +    }
    +
    +    // Runs the checks a matmul carrying a fused epilogue owes before it is
    +    // dispatched. A descriptor with no communicating stage passes through.
    +    hipblasStatus_t validate_fused_epilogue_dispatch(hipblasLtHandle_t       handle,
    +                                                     hipblasLtMatmulDesc_t   matmulDesc,
    +                                                     hipblasLtMatrixLayout_t Ddesc)
    +    {
    +        if(matmulDesc == nullptr)
    +            return HIPBLAS_STATUS_SUCCESS;
    +
    +        const hipblasLtFusedEpilogueDescriptor* desc
    +            = ((rocblaslt_matmul_desc)matmulDesc)->fused_epilogue;
    +        if(desc == nullptr
    +           || !fused_epilogue_has_stage(desc, HIPBLASLT_FUSEABLE_EPILOGUE_A2A_PREFIX))
    +            return HIPBLAS_STATUS_SUCCESS;
    +
    +        return validate_fused_a2a_launch(
    +            (rocblaslt_handle)handle, desc, (rocblaslt_matrix_layout)Ddesc);
    +    }
    +
    +    /****************************************************************************
    +     * Device communicator.
    +     ***************************************************************************/
    +
    +    // A channel's flag region: one uint32_t arrival counter per source rank,
    +    // packed into the first line, then the outbound counter on a line of its
    +    // own. Sized by the compile-time maximum world so every offset into a region
    +    // is a constant - 128 bytes while that maximum is 8.
    +    //
    +    // Twinned with FUSED_A2A_LINE_BYTES, FUSED_A2A_OUTBOUND_OFFSET, and
    +    // FUSED_A2A_FLAG_BLOCK_BYTES in the kernel's FusedA2AKernArg.hpp, which is
    +    // what the arrival atomics and the drain barrier index against. A region
    +    // smaller than the kernel's block is memory corruption rather than a wrong
    +    // answer, so the two derivations must stay identical.
    +    constexpr size_t kDeviceCommFlagLine = 64;
    +
    +    constexpr size_t align_device_comm_flag_line(size_t bytes)
    +    {
    +        return (bytes + kDeviceCommFlagLine - 1) / kDeviceCommFlagLine * kDeviceCommFlagLine;
    +    }
    +
    +    constexpr size_t kDeviceCommFlagOutboundOffset
    +        = align_device_comm_flag_line(HIPBLASLT_DEVICE_COMM_MAX_WORLD * sizeof(uint32_t));
    +    constexpr size_t kDeviceCommFlagChannelSize
    +        = align_device_comm_flag_line(kDeviceCommFlagOutboundOffset + sizeof(uint32_t));

    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.

    yzhang93 yzhang93 commented on code on Sep 04, 2026 17:29 UTC
    Code Review
    projects/hipblaslt/clients/tests/src/fused_a2a_gtest.cpp:1
    @@ -0,0 +1,892 @@
    +// Copyright Advanced Micro Devices, Inc., or its affiliates.
    +// SPDX-License-Identifier: MIT
    +
    +// API-surface tests for the fused GEMM + all-to-all epilogue.
    +//
    +// This covers what the host can decide on its own: the builder's single-stage
    +// family rule, each attribute's accepted range, the completeness check that runs
    +// when the descriptor is attached to a matmul descriptor, communicator
    +// registration, and the shape and layout requirements checked before a solution
    +// is selected. No architecture carries a fused all-to-all kernel yet, so a
    +// well-formed request ends in HIPBLAS_STATUS_NOT_SUPPORTED; the tests assert that
    +// distinction, since an unusable request must be an error while missing
    +// capability must never present as a rejected shape.
    +//
    +// The suite names carry the "pre_checkin" token on purpose: the ctest presets in
    +// clients/tests/test_categories.yaml select by loose substring on a category
    +// token, and a plain gtest suite has none, so it would be invisible to them.
    +
    +#include <gtest/gtest.h>
    +#include <hip/hip_runtime.h>
    +#include <hipblaslt/hipblaslt.h>
    +
    +#include <chrono>
    +#include <condition_variable>
    +#include <cstring>
    +#include <mutex>
    +#include <thread>
    +#include <vector>
    +
    +namespace
    +{
    +    bool gpuAvailable()
    +    {
    +        int deviceCount = 0;
    +        return hipGetDeviceCount(&deviceCount) == hipSuccess && deviceCount > 0;
    +    }
    +
    +    // A single-process allgather: with one rank it is exactly the memcpy the
    +    // design doc names as the single-process case.
    +    hipblasStatus_t memcpyAllgather(void*       userData,
    +                                    const void* sendbuf,
    +                                    void*       recvbuf,
    +                                    size_t      bytesPerRank)
    +    {
    +        (void)userData;
    +        memcpy(recvbuf, sendbuf, bytesPerRank);
    +        return HIPBLAS_STATUS_SUCCESS;
    +    }
    +
    +    hipblasStatus_t failingAllgather(void*       userData,
    +                                     const void* sendbuf,
    +                                     void*       recvbuf,
    +                                     size_t      bytesPerRank)
    +    {
    +        (void)userData;
    +        (void)sendbuf;
    +        (void)recvbuf;
    +        (void)bytesPerRank;
    +        return HIPBLAS_STATUS_INTERNAL_ERROR;
    +    }
    +
    +    // Publishes this rank's payload and leaves the second slot zeroed, which no
    +    // real contribution can ever look like. Stands in for any way the ranks can
    +    // fail to agree about the communicator.
    +    hipblasStatus_t silentPeerAllgather(void*       userData,
    +                                        const void* sendbuf,
    +                                        void*       recvbuf,
    +                                        size_t      bytesPerRank)
    +    {
    +        (void)userData;
    +        memcpy(recvbuf, sendbuf, bytesPerRank);
    +        memset(static_cast<char*>(recvbuf) + bytesPerRank, 0, bytesPerRank);
    +        return HIPBLAS_STATUS_SUCCESS;
    +    }
    +
    +    // Copies this rank's payload into both slots, so the second slot claims to be
    +    // rank 0 where rank 1 belongs.
    +    hipblasStatus_t duplicatingAllgather(void*       userData,
    +                                         const void* sendbuf,
    +                                         void*       recvbuf,
    +                                         size_t      bytesPerRank)
    +    {
    +        (void)userData;
    +        memcpy(recvbuf, sendbuf, bytesPerRank);
    +        memcpy(static_cast<char*>(recvbuf) + bytesPerRank, sendbuf, bytesPerRank);
    +        return HIPBLAS_STATUS_SUCCESS;
    +    }
    +
    +    // A real allgather for ranks that are threads of one process: each publishes
    +    // into its own slot and waits for the rest before reading the whole buffer
    +    // back. Registration cannot return until every peer has contributed, so this
    +    // rendezvous is the only way more than one rank registers in one process. The
    +    // wait is bounded so a rank that never arrives fails the test instead of
    +    // hanging it.
    +    struct Rendezvous
    +    {
    +        std::mutex              mutex;
    +        std::condition_variable arrival;
    +        std::vector<char>       slots;
    +        uint32_t                arrived = 0;
    +        uint32_t                world   = 0;
    +    };
    +
    +    struct RendezvousRank
    +    {
    +        Rendezvous* shared;
    +        uint32_t    rank;
    +    };
    +
    +    hipblasStatus_t
    +        rendezvousAllgather(void* userData, const void* sendbuf, void* recvbuf, size_t bytesPerRank)
    +    {
    +        RendezvousRank& self   = *static_cast<RendezvousRank*>(userData);
    +        Rendezvous&     shared = *self.shared;
    +
    +        std::unique_lock<std::mutex> lock(shared.mutex);
    +        if(shared.slots.empty())
    +            shared.slots.resize(bytesPerRank * shared.world);
    +        memcpy(shared.slots.data() + bytesPerRank * self.rank, sendbuf, bytesPerRank);
    +
    +        if(++shared.arrived == shared.world)
    +        {
    +            shared.arrival.notify_all();
    +        }
    +        else if(!shared.arrival.wait_for(
    +                    lock, std::chrono::seconds(30), [&] { return shared.arrived == shared.world; }))
    +        {
    +            return HIPBLAS_STATUS_INTERNAL_ERROR;
    +        }
    +
    +        memcpy(recvbuf, shared.slots.data(), bytesPerRank * shared.world);
    +        return HIPBLAS_STATUS_SUCCESS;
    +    }
    +
    +    // Four plausible-looking addresses. The library stores a queue's fields
    +    // without interpreting them, so a test only needs them to be non-null.
    +    hipblasLtSdmaQueue_t fakeQueue(uintptr_t base)
    +    {
    +        hipblasLtSdmaQueue_t q{};
    +        q.queueBuf = reinterpret_cast<void*>(base);
    +        q.rptr     = reinterpret_cast<void*>(base + 0x100);
    +        q.wptr     = reinterpret_cast<void*>(base + 0x200);
    +        q.doorbell = reinterpret_cast<void*>(base + 0x300);
    +        return q;
    +    }
    +
    +    /************************************************************************
    +     * Builder: lifecycle, the single-stage family rule, and attributes.
    +     * None of this needs a device.
    +     ***********************************************************************/
    +
    +    class FusedA2ABuilder_pre_checkin : public ::testing::Test
    +    {
    +    protected:
    +        void SetUp() override
    +        {
    +            ASSERT_EQ(hipblasLtFusedEpilogueCreate(&fused), HIPBLAS_STATUS_SUCCESS);
    +            ASSERT_NE(fused, nullptr);
    +        }
    +
    +        void TearDown() override
    +        {
    +            if(fused)
    +                EXPECT_EQ(hipblasLtFusedEpilogueDestroy(fused), HIPBLAS_STATUS_SUCCESS);
    +        }
    +
    +        hipblasStatus_t addA2A()
    +        {
    +            return hipblasLtFusedEpilogueAdd(fused, HIPBLASLT_FUSEABLE_EPILOGUE_A2A_PREFIX);
    +        }
    +
    +        hipblasStatus_t setExtent(int64_t am)
    +        {
    +            return hipblasLtFusedEpilogueSetAttribute(
    +                fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT, &am, sizeof(am));
    +        }
    +
    +        hipblasStatus_t setRecvPtrs(const std::vector<void*>& ptrs)
    +        {
    +            return hipblasLtFusedEpilogueSetAttribute(fused,
    +                                                      HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_RECV_PTRS,
    +                                                      ptrs.data(),
    +                                                      ptrs.size() * sizeof(void*));
    +        }
    +
    +        hipblasStatus_t setQueues(const std::vector<hipblasLtSdmaQueue_t>& queues)
    +        {
    +            return hipblasLtFusedEpilogueSetAttribute(
    +                fused,
    +                HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_SDMA_QUEUES,
    +                queues.data(),
    +                queues.size() * sizeof(hipblasLtSdmaQueue_t));
    +        }
    +
    +        hipblasLtFusedEpilogueDescriptor_t fused = nullptr;
    +    };
    +
    +    TEST(FusedA2ALifecycle_pre_checkin, CreateRejectsNullOut)
    +    {
    +        EXPECT_EQ(hipblasLtFusedEpilogueCreate(nullptr), HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST(FusedA2ALifecycle_pre_checkin, DestroyAcceptsNull)
    +    {
    +        EXPECT_EQ(hipblasLtFusedEpilogueDestroy(nullptr), HIPBLAS_STATUS_SUCCESS);
    +    }
    +
    +    TEST(FusedA2ALifecycle_pre_checkin, AddRejectsNullDescriptor)
    +    {
    +        EXPECT_EQ(hipblasLtFusedEpilogueAdd(nullptr, HIPBLASLT_FUSEABLE_EPILOGUE_A2A_PREFIX),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2ABuilder_pre_checkin, AddAcceptsAllToAll)
    +    {
    +        EXPECT_EQ(addA2A(), HIPBLAS_STATUS_SUCCESS);
    +    }
    +
    +    TEST_F(FusedA2ABuilder_pre_checkin, AddRejectsUnrecognizedStage)
    +    {
    +        EXPECT_EQ(hipblasLtFusedEpilogueAdd(fused, static_cast<hipblasLtFuseableEpilogue_t>(4242)),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    // The collective family holds one stage, so a second all-to-all is rejected
    +    // at the call expressing the mistake rather than at launch.
    +    TEST_F(FusedA2ABuilder_pre_checkin, AddRejectsDuplicateAllToAll)
    +    {
    +        ASSERT_EQ(addA2A(), HIPBLAS_STATUS_SUCCESS);
    +        EXPECT_EQ(addA2A(), HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2ABuilder_pre_checkin, SetAttributeRejectsNullArguments)
    +    {
    +        const int64_t am = 512;
    +        EXPECT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      nullptr, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT, &am, sizeof(am)),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +        EXPECT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT, nullptr, sizeof(am)),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2ABuilder_pre_checkin, SetAttributeRejectsUnknownAttribute)
    +    {
    +        const int64_t value = 1;
    +        EXPECT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused,
    +                      static_cast<hipblasLtFusedEpilogueAttribute_t>(9999),
    +                      &value,
    +                      sizeof(value)),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2ABuilder_pre_checkin, ExtentMustBePositiveAndCorrectlySized)
    +    {
    +        EXPECT_EQ(setExtent(512), HIPBLAS_STATUS_SUCCESS);
    +        EXPECT_EQ(setExtent(0), HIPBLAS_STATUS_INVALID_VALUE);
    +        EXPECT_EQ(setExtent(-8), HIPBLAS_STATUS_INVALID_VALUE);
    +
    +        const int32_t narrow = 512;
    +        EXPECT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT, &narrow, sizeof(narrow)),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2ABuilder_pre_checkin, CompletionModeAcceptsInKernelOnly)
    +    {
    +        hipblasLtA2ACompletionMode_t mode = HIPBLASLT_A2A_COMPLETION_IN_KERNEL;
    +        EXPECT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused,
    +                      HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_COMPLETION_MODE,
    +                      &mode,
    +                      sizeof(mode)),
    +                  HIPBLAS_STATUS_SUCCESS);
    +
    +        // Value 1 is reserved for the deferred mode, which ships with the
    +        // primitive a caller would wait on and not before it.
    +        mode = static_cast<hipblasLtA2ACompletionMode_t>(1);
    +        EXPECT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused,
    +                      HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_COMPLETION_MODE,
    +                      &mode,
    +                      sizeof(mode)),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2ABuilder_pre_checkin, PerRankArraysAreSizedInWholeEntries)
    +    {
    +        EXPECT_EQ(setRecvPtrs({reinterpret_cast<void*>(0x1000)}), HIPBLAS_STATUS_SUCCESS);
    +        EXPECT_EQ(setQueues({fakeQueue(0x2000)}), HIPBLAS_STATUS_SUCCESS);
    +
    +        void* one = reinterpret_cast<void*>(0x1000);
    +        EXPECT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_RECV_PTRS, &one, 0),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +        EXPECT_EQ(hipblasLtFusedEpilogueSetAttribute(fused,
    +                                                     HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_RECV_PTRS,
    +                                                     &one,
    +                                                     sizeof(void*) + 1),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2ABuilder_pre_checkin, PerRankArraysAreBoundedByTheMaximumWorld)
    +    {
    +        const std::vector<void*> tooMany(HIPBLASLT_DEVICE_COMM_MAX_WORLD + 1,
    +                                         reinterpret_cast<void*>(0x1000));
    +        EXPECT_EQ(setRecvPtrs(tooMany), HIPBLAS_STATUS_INVALID_VALUE);
    +
    +        const std::vector<hipblasLtSdmaQueue_t> tooManyQueues(HIPBLASLT_DEVICE_COMM_MAX_WORLD + 1,
    +                                                              fakeQueue(0x2000));
    +        EXPECT_EQ(setQueues(tooManyQueues), HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    /************************************************************************
    +     * Attach: the descriptor stops being a work in progress here, so this is
    +     * where a stage's required parameters must all be present.
    +     ***********************************************************************/
    +
    +    class FusedA2AAttach_pre_checkin : public ::testing::Test
    +    {
    +    protected:
    +        void SetUp() override
    +        {
    +            ASSERT_EQ(hipblasLtMatmulDescCreate(&matmulDesc, HIPBLAS_COMPUTE_32F, HIP_R_32F),
    +                      HIPBLAS_STATUS_SUCCESS);
    +            ASSERT_EQ(hipblasLtFusedEpilogueCreate(&fused), HIPBLAS_STATUS_SUCCESS);
    +            ASSERT_EQ(hipblasLtFusedEpilogueAdd(fused, HIPBLASLT_FUSEABLE_EPILOGUE_A2A_PREFIX),
    +                      HIPBLAS_STATUS_SUCCESS);
    +        }
    +
    +        void TearDown() override
    +        {
    +            if(fused)
    +                EXPECT_EQ(hipblasLtFusedEpilogueDestroy(fused), HIPBLAS_STATUS_SUCCESS);
    +            if(matmulDesc)
    +                EXPECT_EQ(hipblasLtMatmulDescDestroy(matmulDesc), HIPBLAS_STATUS_SUCCESS);
    +        }
    +
    +        // Fills in everything a one-rank all-to-all needs.
    +        void completeForOneRank()
    +        {
    +            const int64_t am = 512;
    +            ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                          fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT, &am, sizeof(am)),
    +                      HIPBLAS_STATUS_SUCCESS);
    +            void* recv = reinterpret_cast<void*>(0x1000);
    +            ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                          fused,
    +                          HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_RECV_PTRS,
    +                          &recv,
    +                          sizeof(recv)),
    +                      HIPBLAS_STATUS_SUCCESS);
    +            hipblasLtSdmaQueue_t queue = fakeQueue(0x2000);
    +            ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                          fused,
    +                          HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_SDMA_QUEUES,
    +                          &queue,
    +                          sizeof(queue)),
    +                      HIPBLAS_STATUS_SUCCESS);
    +        }
    +
    +        hipblasStatus_t attach()
    +        {
    +            return hipblasLtMatmulDescSetAttribute(
    +                matmulDesc, HIPBLASLT_MATMUL_DESC_FUSED_EPILOGUE, &fused, sizeof(fused));
    +        }
    +
    +        hipblasLtMatmulDesc_t              matmulDesc = nullptr;
    +        hipblasLtFusedEpilogueDescriptor_t fused      = nullptr;
    +    };
    +
    +    TEST_F(FusedA2AAttach_pre_checkin, CompleteDescriptorAttaches)
    +    {
    +        completeForOneRank();
    +        EXPECT_EQ(attach(), HIPBLAS_STATUS_SUCCESS);
    +    }
    +
    +    TEST_F(FusedA2AAttach_pre_checkin, AttachRejectsMissingExtent)
    +    {
    +        void* recv = reinterpret_cast<void*>(0x1000);
    +        ASSERT_EQ(
    +            hipblasLtFusedEpilogueSetAttribute(
    +                fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_RECV_PTRS, &recv, sizeof(recv)),
    +            HIPBLAS_STATUS_SUCCESS);
    +        hipblasLtSdmaQueue_t queue = fakeQueue(0x2000);
    +        ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused,
    +                      HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_SDMA_QUEUES,
    +                      &queue,
    +                      sizeof(queue)),
    +                  HIPBLAS_STATUS_SUCCESS);
    +
    +        EXPECT_EQ(attach(), HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2AAttach_pre_checkin, AttachRejectsMissingRecvPointers)
    +    {
    +        const int64_t am = 512;
    +        ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT, &am, sizeof(am)),
    +                  HIPBLAS_STATUS_SUCCESS);
    +        hipblasLtSdmaQueue_t queue = fakeQueue(0x2000);
    +        ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused,
    +                      HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_SDMA_QUEUES,
    +                      &queue,
    +                      sizeof(queue)),
    +                  HIPBLAS_STATUS_SUCCESS);
    +
    +        EXPECT_EQ(attach(), HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2AAttach_pre_checkin, AttachRejectsMissingQueues)
    +    {
    +        const int64_t am = 512;
    +        ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_EXTENT, &am, sizeof(am)),
    +                  HIPBLAS_STATUS_SUCCESS);
    +        void* recv = reinterpret_cast<void*>(0x1000);
    +        ASSERT_EQ(
    +            hipblasLtFusedEpilogueSetAttribute(
    +                fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_RECV_PTRS, &recv, sizeof(recv)),
    +            HIPBLAS_STATUS_SUCCESS);
    +
    +        EXPECT_EQ(attach(), HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2AAttach_pre_checkin, AttachRejectsNullPeerEntry)
    +    {
    +        completeForOneRank();
    +        void* recv[2] = {reinterpret_cast<void*>(0x1000), nullptr};
    +        ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused, HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_RECV_PTRS, recv, sizeof(recv)),
    +                  HIPBLAS_STATUS_SUCCESS);
    +        hipblasLtSdmaQueue_t queues[2] = {fakeQueue(0x2000), fakeQueue(0x3000)};
    +        ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused,
    +                      HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_SDMA_QUEUES,
    +                      queues,
    +                      sizeof(queues)),
    +                  HIPBLAS_STATUS_SUCCESS);
    +
    +        EXPECT_EQ(attach(), HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2AAttach_pre_checkin, AttachRejectsIncompleteQueueEntry)
    +    {
    +        completeForOneRank();
    +        hipblasLtSdmaQueue_t queue = fakeQueue(0x2000);
    +        queue.doorbell             = nullptr;
    +        ASSERT_EQ(hipblasLtFusedEpilogueSetAttribute(
    +                      fused,
    +                      HIPBLASLT_FUSED_EPILOGUE_A2A_PREFIX_SDMA_QUEUES,
    +                      &queue,
    +                      sizeof(queue)),
    +                  HIPBLAS_STATUS_SUCCESS);
    +
    +        EXPECT_EQ(attach(), HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2AAttach_pre_checkin, AttachedDescriptorReadsBack)
    +    {
    +        completeForOneRank();
    +        ASSERT_EQ(attach(), HIPBLAS_STATUS_SUCCESS);
    +
    +        hipblasLtFusedEpilogueDescriptor_t readBack = nullptr;
    +        size_t                             written  = 0;
    +        EXPECT_EQ(hipblasLtMatmulDescGetAttribute(matmulDesc,
    +                                                  HIPBLASLT_MATMUL_DESC_FUSED_EPILOGUE,
    +                                                  &readBack,
    +                                                  sizeof(readBack),
    +                                                  &written),
    +                  HIPBLAS_STATUS_SUCCESS);
    +        EXPECT_EQ(written, sizeof(readBack));
    +        EXPECT_EQ(readBack, fused);
    +    }
    +
    +    /************************************************************************
    +     * Communicator registration.
    +     ***********************************************************************/
    +
    +    class FusedA2AComm_pre_checkin : public ::testing::Test
    +    {
    +    protected:
    +        void SetUp() override
    +        {
    +            if(!gpuAvailable())
    +                GTEST_SKIP() << "No GPU available";
    +            ASSERT_EQ(hipblasLtCreate(&handle), HIPBLAS_STATUS_SUCCESS);
    +        }
    +
    +        void TearDown() override
    +        {
    +            if(handle)
    +                EXPECT_EQ(hipblasLtDestroy(handle), HIPBLAS_STATUS_SUCCESS);
    +        }
    +
    +        hipblasLtHandle_t handle = nullptr;
    +    };
    +
    +    TEST_F(FusedA2AComm_pre_checkin, RejectsInvalidRankAndWorld)
    +    {
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 1, 1, 1, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 0, 1, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle,
    +                                         0,
    +                                         HIPBLASLT_DEVICE_COMM_MAX_WORLD + 1,
    +                                         1,
    +                                         memcpyAllgather,
    +                                         nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 1, 0, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 1, 1, nullptr, nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST(FusedA2ACommHandle_pre_checkin, RejectsNullHandle)
    +    {
    +        EXPECT_EQ(hipblasLtSetDeviceComm(nullptr, 0, 1, 1, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_NOT_INITIALIZED);
    +    }
    +
    +    TEST_F(FusedA2AComm_pre_checkin, RegistersOnceAndOnlyOnce)
    +    {
    +        ASSERT_EQ(hipblasLtSetDeviceComm(handle, 0, 1, 1, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_SUCCESS);
    +        // A second call fails whether or not its arguments match, which is what
    +        // makes world immutable.
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 1, 1, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 1, 4, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2AComm_pre_checkin, PropagatesAllgatherFailure)
    +    {
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 1, 1, failingAllgather, nullptr),
    +                  HIPBLAS_STATUS_INTERNAL_ERROR);
    +        // The failed attempt left nothing registered.
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 1, 1, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_SUCCESS);
    +    }
    +
    +    TEST_F(FusedA2AComm_pre_checkin, RejectsRanksThatDisagree)
    +    {
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 2, 1, silentPeerAllgather, nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2AComm_pre_checkin, RejectsMisorderedAllgather)
    +    {
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 2, 1, duplicatingAllgather, nullptr),
    +                  HIPBLAS_STATUS_INVALID_VALUE);
    +    }
    +
    +    TEST_F(FusedA2AComm_pre_checkin, MultipleChannelsRegister)
    +    {
    +        EXPECT_EQ(hipblasLtSetDeviceComm(handle, 0, 1, 4, memcpyAllgather, nullptr),
    +                  HIPBLAS_STATUS_SUCCESS);
    +    }
    +
    +    // The one path a single process can drive all the way through: two ranks, two

    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.

    newling newling approved these changes on Sep 09, 2026 17:34 UTC
    Approved Reviewer

    Approved these changes.

    randyh62 randyh62 approved these changes on Sep 09, 2026 19:37 UTC
    Approved Reviewer

    Approved these changes.

    davidd-amd davidd-amd commented on code on Sep 10, 2026 16:25 UTC
    Code Review
    projects/hipblaslt/clients/tests/src/fused_a2a_gtest.cpp:1
    @@ -0,0 +1,959 @@
    +// Copyright Advanced Micro Devices, Inc., or its affiliates.
    +// SPDX-License-Identifier: MIT
    +
    +// API-surface tests for the fused GEMM + all-to-all epilogue.
    +//
    +// This covers what the host can decide on its own: the builder's single-stage
    +// family rule, each attribute's accepted range, the completeness check that runs
    +// when the descriptor is attached to a matmul descriptor, communicator
    +// registration, and the shape and layout requirements checked before a solution
    +// is selected. No architecture carries a fused all-to-all kernel yet, so a
    +// well-formed request ends in HIPBLAS_STATUS_NOT_SUPPORTED; the tests assert that
    +// distinction, since an unusable request must be an error while missing
    +// capability must never present as a rejected shape.
    +//
    +// The suite names carry the "pre_checkin" token on purpose: the ctest presets in
    +// clients/tests/test_categories.yaml select by loose substring on a category
    +// token, and a plain gtest suite has none, so it would be invisible to them.
    +// One suite carries "multi_gpu" instead, which is the category that file gives a
    +// two-device host; it skips rather than degrading to one device.

    Would this be more appropriate for documentation?

    davidd-amd davidd-amd commented on code on Sep 10, 2026 16:27 UTC
    Code Review
    projects/hipblaslt/clients/tests/src/fused_a2a_gtest.cpp:1
    @@ -0,0 +1,959 @@
    +// Copyright Advanced Micro Devices, Inc., or its affiliates.
    +// SPDX-License-Identifier: MIT
    +
    +// API-surface tests for the fused GEMM + all-to-all epilogue.
    +//
    +// This covers what the host can decide on its own: the builder's single-stage
    +// family rule, each attribute's accepted range, the completeness check that runs
    +// when the descriptor is attached to a matmul descriptor, communicator
    +// registration, and the shape and layout requirements checked before a solution
    +// is selected. No architecture carries a fused all-to-all kernel yet, so a
    +// well-formed request ends in HIPBLAS_STATUS_NOT_SUPPORTED; the tests assert that
    +// distinction, since an unusable request must be an error while missing
    +// capability must never present as a rejected shape.
    +//
    +// The suite names carry the "pre_checkin" token on purpose: the ctest presets in
    +// clients/tests/test_categories.yaml select by loose substring on a category
    +// token, and a plain gtest suite has none, so it would be invisible to them.
    +// One suite carries "multi_gpu" instead, which is the category that file gives a
    +// two-device host; it skips rather than degrading to one device.
    +
    +#include <gtest/gtest.h>
    +#include <hip/hip_runtime.h>
    +#include <hipblaslt/hipblaslt.h>
    +
    +#include <chrono>
    +#include <condition_variable>
    +#include <cstring>
    +#include <mutex>
    +#include <thread>
    +#include <vector>
    +
    +namespace
    +{
    +    bool gpuAvailable()
    +    {
    +        int deviceCount = 0;
    +        return hipGetDeviceCount(&deviceCount) == hipSuccess && deviceCount > 0;
    +    }
    +
    +    // A single-process allgather: with one rank it is exactly the memcpy the
    +    // design doc names as the single-process case.
    +    hipblasStatus_t memcpyAllgather(void*       userData,
    +                                    const void* sendbuf,
    +                                    void*       recvbuf,
    +                                    size_t      bytesPerRank)
    +    {
    +        (void)userData;
    +        memcpy(recvbuf, sendbuf, bytesPerRank);
    +        return HIPBLAS_STATUS_SUCCESS;
    +    }
    +
    +    hipblasStatus_t failingAllgather(void*       userData,
    +                                     const void* sendbuf,
    +                                     void*       recvbuf,
    +                                     size_t      bytesPerRank)
    +    {
    +        (void)userData;
    +        (void)sendbuf;
    +        (void)recvbuf;
    +        (void)bytesPerRank;
    +        return HIPBLAS_STATUS_INTERNAL_ERROR;
    +    }
    +
    +    // Publishes this rank's payload and leaves the second slot zeroed, which no
    +    // real contribution can ever look like. Stands in for any way the ranks can
    +    // fail to agree about the communicator.
    +    hipblasStatus_t silentPeerAllgather(void*       userData,
    +                                        const void* sendbuf,
    +                                        void*       recvbuf,
    +                                        size_t      bytesPerRank)
    +    {
    +        (void)userData;
    +        memcpy(recvbuf, sendbuf, bytesPerRank);
    +        memset(static_cast<char*>(recvbuf) + bytesPerRank, 0, bytesPerRank);
    +        return HIPBLAS_STATUS_SUCCESS;
    +    }
    +
    +    // Copies this rank's payload into both slots, so the second slot claims to be
    +    // rank 0 where rank 1 belongs.
    +    hipblasStatus_t duplicatingAllgather(void*       userData,
    +                                         const void* sendbuf,
    +                                         void*       recvbuf,
    +                                         size_t      bytesPerRank)
    +    {
    +        (void)userData;
    +        memcpy(recvbuf, sendbuf, bytesPerRank);
    +        memcpy(static_cast<char*>(recvbuf) + bytesPerRank, sendbuf, bytesPerRank);
    +        return HIPBLAS_STATUS_SUCCESS;
    +    }
    +
    +    // A real allgather for ranks that are threads of one process: each publishes
    +    // into its own slot and waits for the rest before reading the whole buffer
    +    // back. Registration cannot return until every peer has contributed, so this
    +    // rendezvous is the only way more than one rank registers in one process. The
    +    // wait is bounded so a rank that never arrives fails the test instead of
    +    // hanging it.

    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.

    davidd-amd davidd-amd commented on code on Sep 10, 2026 16:48 UTC
    Code Review
    projects/hipblaslt/clients/tests/src/fused_a2a_gtest.cpp:1
    @@ -0,0 +1,959 @@
    +// Copyright Advanced Micro Devices, Inc., or its affiliates.
    +// SPDX-License-Identifier: MIT
    +
    +// API-surface tests for the fused GEMM + all-to-all epilogue.
    +//
    +// This covers what the host can decide on its own: the builder's single-stage
    +// family rule, each attribute's accepted range, the completeness check that runs
    +// when the descriptor is attached to a matmul descriptor, communicator
    +// registration, and the shape and layout requirements checked before a solution
    +// is selected. No architecture carries a fused all-to-all kernel yet, so a
    +// well-formed request ends in HIPBLAS_STATUS_NOT_SUPPORTED; the tests assert that
    +// distinction, since an unusable request must be an error while missing
    +// capability must never present as a rejected shape.
    +//
    +// The suite names carry the "pre_checkin" token on purpose: the ctest presets in
    +// clients/tests/test_categories.yaml select by loose substring on a category
    +// token, and a plain gtest suite has none, so it would be invisible to them.
    +// One suite carries "multi_gpu" instead, which is the category that file gives a
    +// two-device host; it skips rather than degrading to one device.
    +
    +#include <gtest/gtest.h>
    +#include <hip/hip_runtime.h>
    +#include <hipblaslt/hipblaslt.h>
    +
    +#include <chrono>
    +#include <condition_variable>
    +#include <cstring>
    +#include <mutex>
    +#include <thread>
    +#include <vector>
    +
    +namespace
    +{
    +    bool gpuAvailable()
    +    {
    +        int deviceCount = 0;
    +        return hipGetDeviceCount(&deviceCount) == hipSuccess && deviceCount > 0;
    +    }
    +
    +    // A single-process allgather: with one rank it is exactly the memcpy the
    +    // design doc names as the single-process case.
    +    hipblasStatus_t memcpyAllgather(void*       userData,
    +                                    const void* sendbuf,
    +                                    void*       recvbuf,
    +                                    size_t      bytesPerRank)
    +    {
    +        (void)userData;
    +        memcpy(recvbuf, sendbuf, bytesPerRank);
    +        return HIPBLAS_STATUS_SUCCESS;
    +    }
    +
    +    hipblasStatus_t failingAllgather(void*       userData,
    +                                     const void* sendbuf,
    +                                     void*       recvbuf,
    +                                     size_t      bytesPerRank)
    +    {
    +        (void)userData;
    +        (void)sendbuf;
    +        (void)recvbuf;
    +        (void)bytesPerRank;

    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.

    davidd-amd davidd-amd commented on Sep 10, 2026 17:09 UTC
    Contributor

    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.

    yzhang93 yzhang93 commented on code on Sep 10, 2026 18:49 UTC
    Code Review
    projects/hipblaslt/clients/tests/src/fused_a2a_gtest.cpp:1
    @@ -0,0 +1,959 @@
    +// Copyright Advanced Micro Devices, Inc., or its affiliates.
    +// SPDX-License-Identifier: MIT
    +
    +// API-surface tests for the fused GEMM + all-to-all epilogue.
    +//
    +// This covers what the host can decide on its own: the builder's single-stage
    +// family rule, each attribute's accepted range, the completeness check that runs
    +// when the descriptor is attached to a matmul descriptor, communicator
    +// registration, and the shape and layout requirements checked before a solution
    +// is selected. No architecture carries a fused all-to-all kernel yet, so a
    +// well-formed request ends in HIPBLAS_STATUS_NOT_SUPPORTED; the tests assert that
    +// distinction, since an unusable request must be an error while missing
    +// capability must never present as a rejected shape.
    +//
    +// The suite names carry the "pre_checkin" token on purpose: the ctest presets in
    +// clients/tests/test_categories.yaml select by loose substring on a category
    +// token, and a plain gtest suite has none, so it would be invisible to them.
    +// One suite carries "multi_gpu" instead, which is the category that file gives a
    +// two-device host; it skips rather than degrading to one device.

    Trimmed the comments.

    yzhang93 yzhang93 commented on code on Sep 10, 2026 18:49 UTC
    Code Review
    projects/hipblaslt/clients/tests/src/fused_a2a_gtest.cpp:1
    @@ -0,0 +1,959 @@
    +// Copyright Advanced Micro Devices, Inc., or its affiliates.
    +// SPDX-License-Identifier: MIT
    +
    +// API-surface tests for the fused GEMM + all-to-all epilogue.
    +//
    +// This covers what the host can decide on its own: the builder's single-stage
    +// family rule, each attribute's accepted range, the completeness check that runs
    +// when the descriptor is attached to a matmul descriptor, communicator
    +// registration, and the shape and layout requirements checked before a solution
    +// is selected. No architecture carries a fused all-to-all kernel yet, so a
    +// well-formed request ends in HIPBLAS_STATUS_NOT_SUPPORTED; the tests assert that
    +// distinction, since an unusable request must be an error while missing
    +// capability must never present as a rejected shape.
    +//
    +// The suite names carry the "pre_checkin" token on purpose: the ctest presets in
    +// clients/tests/test_categories.yaml select by loose substring on a category
    +// token, and a plain gtest suite has none, so it would be invisible to them.
    +// One suite carries "multi_gpu" instead, which is the category that file gives a
    +// two-device host; it skips rather than degrading to one device.
    +
    +#include <gtest/gtest.h>
    +#include <hip/hip_runtime.h>
    +#include <hipblaslt/hipblaslt.h>
    +
    +#include <chrono>
    +#include <condition_variable>
    +#include <cstring>
    +#include <mutex>
    +#include <thread>
    +#include <vector>
    +
    +namespace
    +{
    +    bool gpuAvailable()
    +    {
    +        int deviceCount = 0;
    +        return hipGetDeviceCount(&deviceCount) == hipSuccess && deviceCount > 0;
    +    }
    +
    +    // A single-process allgather: with one rank it is exactly the memcpy the
    +    // design doc names as the single-process case.
    +    hipblasStatus_t memcpyAllgather(void*       userData,
    +                                    const void* sendbuf,
    +                                    void*       recvbuf,
    +                                    size_t      bytesPerRank)
    +    {
    +        (void)userData;
    +        memcpy(recvbuf, sendbuf, bytesPerRank);
    +        return HIPBLAS_STATUS_SUCCESS;
    +    }
    +
    +    hipblasStatus_t failingAllgather(void*       userData,
    +                                     const void* sendbuf,
    +                                     void*       recvbuf,
    +                                     size_t      bytesPerRank)
    +    {
    +        (void)userData;
    +        (void)sendbuf;
    +        (void)recvbuf;
    +        (void)bytesPerRank;
    +        return HIPBLAS_STATUS_INTERNAL_ERROR;
    +    }
    +
    +    // Publishes this rank's payload and leaves the second slot zeroed, which no
    +    // real contribution can ever look like. Stands in for any way the ranks can
    +    // fail to agree about the communicator.
    +    hipblasStatus_t silentPeerAllgather(void*       userData,
    +                                        const void* sendbuf,
    +                                        void*       recvbuf,
    +                                        size_t      bytesPerRank)
    +    {
    +        (void)userData;
    +        memcpy(recvbuf, sendbuf, bytesPerRank);
    +        memset(static_cast<char*>(recvbuf) + bytesPerRank, 0, bytesPerRank);
    +        return HIPBLAS_STATUS_SUCCESS;
    +    }
    +
    +    // Copies this rank's payload into both slots, so the second slot claims to be
    +    // rank 0 where rank 1 belongs.
    +    hipblasStatus_t duplicatingAllgather(void*       userData,
    +                                         const void* sendbuf,
    +                                         void*       recvbuf,
    +                                         size_t      bytesPerRank)
    +    {
    +        (void)userData;
    +        memcpy(recvbuf, sendbuf, bytesPerRank);
    +        memcpy(static_cast<char*>(recvbuf) + bytesPerRank, sendbuf, bytesPerRank);
    +        return HIPBLAS_STATUS_SUCCESS;
    +    }
    +
    +    // A real allgather for ranks that are threads of one process: each publishes
    +    // into its own slot and waits for the rest before reading the whole buffer
    +    // back. Registration cannot return until every peer has contributed, so this
    +    // rendezvous is the only way more than one rank registers in one process. The
    +    // wait is bounded so a rank that never arrives fails the test instead of
    +    // hanging it.

    Good point. Trimmed this one and the other helper comments.

    yzhang93 yzhang93 commented on code on Sep 10, 2026 18:49 UTC
    Code Review
    projects/hipblaslt/clients/tests/src/fused_a2a_gtest.cpp:1
    @@ -0,0 +1,959 @@
    +// Copyright Advanced Micro Devices, Inc., or its affiliates.
    +// SPDX-License-Identifier: MIT
    +
    +// API-surface tests for the fused GEMM + all-to-all epilogue.
    +//
    +// This covers what the host can decide on its own: the builder's single-stage
    +// family rule, each attribute's accepted range, the completeness check that runs
    +// when the descriptor is attached to a matmul descriptor, communicator
    +// registration, and the shape and layout requirements checked before a solution
    +// is selected. No architecture carries a fused all-to-all kernel yet, so a
    +// well-formed request ends in HIPBLAS_STATUS_NOT_SUPPORTED; the tests assert that
    +// distinction, since an unusable request must be an error while missing
    +// capability must never present as a rejected shape.
    +//
    +// The suite names carry the "pre_checkin" token on purpose: the ctest presets in
    +// clients/tests/test_categories.yaml select by loose substring on a category
    +// token, and a plain gtest suite has none, so it would be invisible to them.
    +// One suite carries "multi_gpu" instead, which is the category that file gives a
    +// two-device host; it skips rather than degrading to one device.
    +
    +#include <gtest/gtest.h>
    +#include <hip/hip_runtime.h>
    +#include <hipblaslt/hipblaslt.h>
    +
    +#include <chrono>
    +#include <condition_variable>
    +#include <cstring>
    +#include <mutex>
    +#include <thread>
    +#include <vector>
    +
    +namespace
    +{
    +    bool gpuAvailable()
    +    {
    +        int deviceCount = 0;
    +        return hipGetDeviceCount(&deviceCount) == hipSuccess && deviceCount > 0;
    +    }
    +
    +    // A single-process allgather: with one rank it is exactly the memcpy the
    +    // design doc names as the single-process case.
    +    hipblasStatus_t memcpyAllgather(void*       userData,
    +                                    const void* sendbuf,
    +                                    void*       recvbuf,
    +                                    size_t      bytesPerRank)
    +    {
    +        (void)userData;
    +        memcpy(recvbuf, sendbuf, bytesPerRank);
    +        return HIPBLAS_STATUS_SUCCESS;
    +    }
    +
    +    hipblasStatus_t failingAllgather(void*       userData,
    +                                     const void* sendbuf,
    +                                     void*       recvbuf,
    +                                     size_t      bytesPerRank)
    +    {
    +        (void)userData;
    +        (void)sendbuf;
    +        (void)recvbuf;
    +        (void)bytesPerRank;

    Good catch. Applied your suggestion, and did the same for the unused argument in memcpyAllgather, silentPeerAllgather and duplicatingAllgather.

    davidd-amd davidd-amd commented on Sep 11, 2026 16:00 UTC
    Contributor

    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.

    davidd-amd davidd-amd commented on Sep 14, 2026 18:09 UTC
    Contributor

    @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
    

    davidd-amd davidd-amd approved these changes on Sep 14, 2026 18:10 UTC
    Approved Reviewer

    Approved these changes.

    assistant-librarian[bot] assistant-librarian[bot] commented on Sep 17, 2026 19:13 UTC
    Bot

    <!-- therock-bump-breadcrumb -->

    TheRock Submodule Bump Activity


    _Newest first_

  • 2026-09-17 — Included in TheRock via ROCm/TheRock#8289. <!-- event-id: d584e98b90541285bc5c85bc2a315d41b45843c2_rocm-libraries_False --> <!-- event-time: 2026-09-17T19:00:01+00:00 -->
  • Reviewers
    Assignees
    yzhang93 yzhang93
    Labels
    risk: low confidence: 87.9% 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: 71.5% (HIGH) · Higher = larger blast radius
    71.5%
    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: 87.9% · Lower = rushed or shallow review
    87.9%
    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: 8.6% · Safe to merge
    8.6%