← Back to Pull requests

perf(tensilelite): group A2AGemm token blocks by contiguous runs and pick the group count per shape #16608

Open
unknown opened this pull request with 376 lines diff across 4 files
View on GitHub
unknown unknown commented on Nov 24, 2026 02:29 UTC
Author

JIRA ID : ROCM-27524

Motivation

A2AGemm is the TensileLite GEMM kernel that gathers matrix B's K slices from the other GPUs while it multiplies (#14168, #15352). With W GPUs, W−1 SDMA copy queues deliver the slices, and each token block (a set of output rows) reads them in a rotated order so the queues serve different blocks at once. Blocks with the same order form a peer group and read the same part of matrix A at the same time, so they can share it in the L2 cache. The groups interleaved the blocks across each batch, which spread a group's reads of A, and the number of groups was fixed by a formula even though the best count differs by shape.

Stacked on #16606. It also carries the commit of #16607, whose SGPR-hazard scanner the A2AGemm test uses.

Technical Details

  • Peer groups are contiguous runs of blocks inside each batch, and their sizes differ by at most one block. By default a batch of count blocks now forms ceil(count / ceil(count / (W−1))) groups instead of min(W−1, count), so 8 blocks at W = 8 form 4 groups of 2 instead of 7. The SDMA enqueuer issues one ATOMIC packet per non-empty group.

  • A new solution parameter, A2APeerGroups (0–7, valid only with A2AGemm), caps the number of groups: 0 uses the default above and k ≥ 1 uses at most k groups. A non-zero value adds AAPG<k> to the kernel name, so existing kernel names do not change.

  • The enqueuer read two SGPRs immediately after v_readfirstlane wrote them, which gfx950 does not allow. Both reads now follow two unrelated scalar instructions, at no extra cost.

  • The gfx950 A2AGemm logic gains three solutions and four rows, and production world 8 with N = 4096 moves to A2APeerGroups 3. A non-zero A2APeerGroups was kept only where it won every one of 10 interleaved timing rounds.

  • Four saved test results change for the new parameter and the new test group. adr/0039-record-a2apeergroups-parameter.md records them for the bulk-snapshot check.
  • Test Plan

    comm/gfx950/a2a_gemm_loop.yaml adds batch sizes that stress the grouping and an A2APeerGroups 1/2/7 group. test_a2a_gemm_loop_char.py runs the emitted group arithmetic on worlds 2 to 8 and batches of 1 to 70 blocks, and checks every kernel for SGPR hazards. On MI355X the A2AGemm comm config was also run before and after the enqueuer fix on integer inputs from a fixed seed, using a test client that prints a hash of every output.

    Test Result

    All 12,796 outputs of a2a_gemm_loop.yaml are bitwise identical before and after the enqueuer fix, and a repeated run gives the same bits. The unit suite shows only the failures that develop shows in the same environment. On 8 MI355X GPUs, the comm configs pass with full validation at every world from 2 to 8, the hipBLASLt fused tests pass, and hipblaslt-bench-a2a --verify passes and selects the solution in the logic for each shape.

    Submission Checklist

  • Look over the contributing guidelines at https://github.com/ROCm/TheRock/blob/main/GOVERNANCE.md#pull-requests.
  • Diff: 376 lines (+282 / -94) across 4 files Reviewer: yzhang93 Review duration: 10570m
    All Vouch review confidence checks passed
    Residual risk 0.38 = Change Risk (0.66) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.66 · 376 lines diff across 4 files
    0.66
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    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.355
    Shallow Review Depth shallow_review_depth
    0.344
    Sensitive Paths sensitive_paths
    0.066
    Real PR Conversation Timeline
    1 comments
    "Review active on #16608"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 43.0% reviewed sensitive_module
    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: 66.1% (HIGH) · Higher = larger blast radius
    66.1%
    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: 43.0% · Lower = rushed or shallow review
    43.0%
    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: 37.7% · Moderate risk
    37.7%