feat(tensilelite): add the A2A+GEMM shard-loop kernel (FusedA2A: A2AGemm) #14168
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.52) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #14168"
general
weight: 0.35
yzhang93
Motivation
hipBLASLt already fuses an all-to-all after the GEMM (
FusedA2A: GemmA2A: compute, then scatter D over xGMI). The mirror case has no implementation: a GEMM whose B operand arrives by all-to-all, where each of theWranks holds oneK/Wshard of every token block and the GEMM cannot start a shard until that shard lands. Run unfused, the collective is fully exposed. This PR addsFusedA2A: A2AGemm, which walks theWshards in an outer loop and overlaps each round's compute with the next round's transfer.The two modes are the two ends of one all-to-all edge: the producer's feature dimension is the consumer's K dimension, so a GemmA2A output buffer is layout-identical to an A2AGemm input.
JIRA ID : ROCM-27524
Technical Details
FusedA2Akey with valuesDisabled(default),GemmA2AandA2AGemmreplaces theFusedGemmA2Abool, and aFusedA2AEqualpredicate on every solution keeps a problem matching kernels of its own mode. The predicate's serialized name moves with it, so a device library built before this change fails to load: hipBLASLt reportsCould not load <path>,TENSILE_DB=0x1000prints the cause, and the device library has to be rebuilt.Kholds the wholeW k_localreduction and one shard round coversK/W. Each round's transition, skipped after the last round, rebinds the A/B descriptors, resets the LDS pointers and, unless A and B are both DirectToLds, syncs the work-group. B is the rank's pre-gather input and the kernel only reads it: round 0 reads the rank's own block of B, and the peers' shards are gathered by in-kernel SDMA packets intoa2aBuf, which later rounds read.A2ASubRounds(S, one of 1, 2 or 4; default 1) splits each peer's arrival into S independently flagged pieces, so a round's compute waits on1/Sof a peer's shard instead of all of it. The shard loop then runs1 + (W-1) Srounds rather thanW, the rank's own round never being split, andA2AGemmShaperequiresKto be a multiple ofW DepthU S.[W][N][K/W]with blockdbound for rankd, under a dense[N, K]descriptor, so the caller passesldb == K(W * k_local), whichA2AGemmShapechecks;ContractionSolutiondivides B's strides byworld, so the kernel walks each segment with row stridek_local. The gathered segments land ina2aBuf(theA2A_BUFslot), which has the same layout. The per-peer kernarg slotrecvPtris renamedbufPtr: GemmA2A fills it with each rank's receive buffer, A2AGemm with each peer's B and, for its own rank, itsa2aBuf. The publicRECV_PTRSattribute keeps its name.A2AGemmShapealso requiresa2aExtent == K(setA2ABufsizesa2aBuffrom it) and the strided batch mode (the pointer-array branch would read the gathered buffer as a pointer array), and the client refuses--batch-mode=1for A2AGemm. Both modes requireMacroTile0/1in {128, 256}. A2AGemm solutions requireBufferLoad, a bf16 B, and, withA2ASubRounds > 1, aDepthUwhose B bytes are a multiple of 128. The A2AGemm batch election needs each batch's feature-tile-0 work-group to be dispatched before the batches it places fill every free slot, so A2AGemm also rejects negativeWorkGroupMapping,WorkGroupMappingXCC != 1and anySpaceFillingAlgo, and the host rejects an A2AGemm launch whose runtime mapping (e.g. fromTENSILE_FIXED_WGM) breaks the same rule or whosea2aBufis not 128-byte aligned. A batch is the whole token blocks whose work-groups add up to aboutcomputeUnitCount; its size affects only how early the next wave's copies are placed, not forward progress. A2AGemm takesAssertSummationElementMultiple1 or DepthU and sets it to DepthU, so its kernels have no tail loop.A2AGemmShapealso rejects K = 0.FusedNumCu, which only A2AGemm reads, grows the segment's scalar tail from 16 to 20 bytes for every fused mode;appendFusedSegmentthrows when there is no CU count or when the rank is outside the world.GemmA2Atag instead ofFusedA2A, as A2AGemm names carryA2AGemm, so the shipped gfx950 logic file becomesgfx950_Cijk_Alik_Bljk_BBS_BH_GemmA2A_UserArgs.yaml(its kernel names, solution names andBaseNamemove with it).--fused-a2a-sdma-rotatedefaults to -1 for both modes and is rejected without--fused-a2a. It moves each remote peer's SDMA queue along the even xGMI engines 2, 4, ..., 14 from KFD's recommendation: A2AGemm pulls B from its peers, and with KFD's engines two concurrent pull queues can sit on the two engines of one xGMI port group, which slows both. GemmA2A pushes and showed no measurable change, so both modes share one queue setup. The loopback queue uses engine 0. A nonzero rotation requires the node to report 14 xGMI SDMA engines, and every remote peer queue must use an even engine in 2..14 at any rotation, because on GC 9.4.3, 9.4.4 and 9.5.0 a doorbell rung from a shader for a queue on an odd engine reaches the previous engine.A2AGemmShapekeeps every segment 128-byte aligned. That is a property of the current read order, not a construction-level guarantee: changing the shard loop's read order, or allowing a B type other than bf16, requires revisiting it.A2ASubRoundsjoins the parameter registry andtest_a2a_gemm_loop_char.ambris a new codegen golden. Only A2AGemm names carryAASR<n>; GemmA2A's golden moves only with its new name tag.FusedGemmA2A: falseare left as they are;Problem.pyraises only on a truthy value, so they load unchanged.Test Plan
The TensileLite Python unit suite and the host gtests, including the new
FusedA2AProblem_testandFusedA2AKernArg_test. On an 8-GPU gfx950 host, thea2a_gemm_loopcomm config at world 2, 4 and 8 withA2ASubRounds1, 2 and 4, covering an oddk_local/DepthUtrip, anNspanning several batches, aDirectToLds 0group and token counts that do not fill a macro tile, and the existingfused_a2aconfig as a GemmA2A regression; world 1 runs locally from a temporary copy of the configs. The comm configs run three enqueues per sync on rotated buffer slots and validate the later launches. CI runs these comm configs on two gfx950 GPUs, which covers world 2, so world 4 and 8 are a local gate. Emitted assembly is compared for the changes expected to be codegen-neutral.Test Result
The unit suite and the gtests pass and everything builds clean. On 8 GPUs every comm row reports
validation: PASSED, at each world and in both modes, including the launches on rotated slots, and world 1 passes from the temporary copy;fused_a2a.yaml(GemmA2A) passes at world 2, 4 and 8, and its timing showed no measurable change under the -1 rotate default. Hardware validation covers gfx950 only. Emitted A2AGemm assembly is byte-identical across thea2aExtentchange and, once kernel name lines are excluded, across theAASRnaming change. Deliberately broken clients each fail validation: remote peer entries pointing ata2aBuf, the peer table shifted by one rank, and the poison written into B fail D validation at world 2, 4 and 8, and an input corrupted only in the rotated slots fails in both modes. The per-round write-pointer reset, the barrier and the ASEM change show no measurable time change at world 4 (M = 3072 and 8192). Not covered:interleaveA2AGemmReferencesis reached only through the multi-GPU comm run.At the production shape, A2AGemm is about 1.4–1.9× faster than an unfused torch all-to-all followed by a matmul at world 2, 4 and 8, and hides about 60–85% of the all-to-all time at world 4 and 8 relative to the same GEMM without communication (35–50% at world 2, where the all-to-all alone takes longer than the GEMM). GemmA2A shows no regression against develop.
Submission Checklist