Repository navigation
[HIP] perf: gfx1250 LL all-gather lines carry 12 bytes and one flag - #7555
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
881b50e to
b79fd1c
Compare
… one flag ag_ll_gfx1250 sent the all-reduce's LL lines, 8 bytes of payload and two flags in 16 bytes, so a rank pushed 2 x (ngpus - 1) x its input. A line is one 16-byte store and one 16-byte load, so a single flag in word 3 guards it, and words 0-2 now carry 12 bytes: 1.33 x on the wire. The kernel keeps its name, the LL epoch, banks and slot stride, the routing (use_ll_ag) and the in-place read. Each thread takes one 12-byte unit and loads before its remote stores: 256-thread blocks while kMaxBlocks of them cover the message, then 512-thread blocks, then two units a thread. Before, the 512-block cap left threads a second round, one fabric round trip, from 1 MiB a rank. MI455X, rows of 288 two-byte elements (the Kimi-K3 DCP prefill prefix-KV gather), device time of back-to-back calls, rounds interleaved with the old kernel: TP8 across two trays: 0.52 MB a rank 15.3 -> 12.1 us, 1.18 MB 31.9 -> 20.2 us, 2.36 MB 49.4 -> 28.8 us, 4.19 MB 78.4 -> 54.1 us. TP4 in one tray: 0.52 MB 10.0 -> 8.6 us, 1.18 MB 16.6 -> 11.4 us, 4.19 MB 36.6 -> 24.0 us. test_allgather.py adds the K3 DCP shapes (2048, 288) and (896, 288). Co-Authored-By: Claude Opus 5.5 <[email protected]>
b79fd1c to
267ee3a
Compare
WAITING ON AUTHORPR Self-ReviewRevision Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision. Questions to answer in the PR description
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
… one flag (#7555) ag_ll_gfx1250 sent the all-reduce's LL lines, 8 bytes of payload and two flags in 16 bytes, so a rank pushed 2 x (ngpus - 1) x its input. A line is one 16-byte store and one 16-byte load, so a single flag in word 3 guards it, and words 0-2 now carry 12 bytes: 1.33 x on the wire. The kernel keeps its name, the LL epoch, banks and slot stride, the routing (use_ll_ag) and the in-place read. Each thread takes one 12-byte unit and loads before its remote stores: 256-thread blocks while kMaxBlocks of them cover the message, then 512-thread blocks, then two units a thread. Before, the 512-block cap left threads a second round, one fabric round trip, from 1 MiB a rank. MI455X, rows of 288 two-byte elements (the Kimi-K3 DCP prefill prefix-KV gather), device time of back-to-back calls, rounds interleaved with the old kernel: TP8 across two trays: 0.52 MB a rank 15.3 -> 12.1 us, 1.18 MB 31.9 -> 20.2 us, 2.36 MB 49.4 -> 28.8 us, 4.19 MB 78.4 -> 54.1 us. TP4 in one tray: 0.52 MB 10.0 -> 8.6 us, 1.18 MB 16.6 -> 11.4 us, 4.19 MB 36.6 -> 24.0 us. test_allgather.py adds the K3 DCP shapes (2048, 288) and (896, 288). Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: TennyWang1223 <[email protected]> (cherry picked from commit 882bd62)
On gfx1250, an all-gather of up to 4 MiB a rank runs
ag_ll_gfx1250. That kernel sends the all-reduce's LL lines: each 16-byte line carries 8 bytes of payload and two 4-byte flags. So a rank puts twice its input on the wire for every peer.This hits Kimi-K3 TP8 + DCP8 prefill directly. Every MLA layer all-gathers the cached prefix's FP8 KV in chunks; a 16,384-token chunk is 2048 rows of 576 bytes a rank (1.18 MB). Across two MI455X trays that all-gather takes 31.9 µs.
This PR changes the kernel's lines to 12 bytes of payload and one flag, and each thread now moves one 12-byte unit. The same all-gather now takes 20.2 µs (1.58×). From 0.07 to 4.19 MB a rank the kernel is 1.21–1.72× faster at TP8 across two trays, and 1.09–1.62× at TP4 in one tray.
Approach
ll_store_b128) and read with a single 16-byte load (ll_load_b128). The existing LL kernels rely on the same single-transaction property.d_ll_block_flags_). It therefore interleaves withar_ll_gfx1250: a line written by another LL kernel carries an older epoch in word 3, so it is never mistaken for a fresh one.kMaxBlocksof them cover the message, then 512-thread blocks, then two units a thread abovekMaxBlocks× 512 units (3 MiB).use_ll_ag(up tokLLArMaxBytes) decides by shape alone, so every rank takes the same protocol.ll_ag_reads_in_place), the scratch size and the Python side.use_ll_agand its callers are untouched and this PR does not overlap [HIP] perf(custom_ar): gfx1250 LL two-shot all-reduce for 1 MiB+ messages #7432 textually. Its template parameters change from<T, ngpus, ALIGNED>to<ngpus, U, ALIGNED>, so a trace still tells the two versions apart.Op-level speedup
MI455X, rows of 288 two-byte elements (the K3 DCP prefix-KV rows). Device µs per call of 50 back-to-back calls on the slowest rank, median of 7 rounds (TP8) or 5 rounds (TP4). The rounds interleave the old and the new kernel in one process. Every call's output is bit-exact on every rank.
TP8 across two trays (4 + 4 GPUs, UALink):
Bold rows are the K3 DCP prefill chunks of 7168, 15360 and 16384 tokens.
TP4 in one tray:
Dev record
ncclAllGather(RCCL 2.30.7, MNNVL) takes 34.2 / 56.0 / 104.5 µs at 0.52 / 1.18 / 4.19 MB a rank. That is 1.3–2.2 × the old LL kernel's time and 1.9–2.9 × the new kernel's.global_wbof the L2 per wave, and an acquire load aglobal_invper poll.ag_ll_gfx1250andallgather_ll.custom_all_gathercosts about 13 µs of host time a call, more than the kernel itself below 0.5 MB a rank. The device times above are measured with the GPU held behind a spin while the host queues the calls.ar_ll_gfx1250) still send 8-byte lines.naive_unroll4when numel is a multiple of 1024 packs. At TP8 that kernel is latency-bound: 65–72 µs from 0.3 to 3.5 MB a rank, against 22–35 µs fornaive_vec. It runs only above 4 MiB or with LL off.Named result
Kimi-K3 TP8 + DCP8 across two MI455X trays: the prefill prefix-KV all-gather of a 16,384-token chunk (2048 rows of 576 bytes a rank) drops from 31.9 to 20.2 µs a call (−37%). Each prefill MLA layer runs two or three of these (2048 / 2048 / 896 rows in a c32 MLPerf Endpoints agentic trace).
Gates
op_tests/multigpu_tests/test_allgather.pyat TP4: all 40 cases err 0.rank_offset, the byte-wise build), last-dim rows of 8 bytes ((12, 4), a unit spanning rows) and the new K3 DCP shapes(2048, 288)and(896, 288).op_tests/multigpu_tests/test_custom_allreduce.pyat TP4 passes, including the gfx1250 LL mixed-size regression, where LL all-reduces share the scratch and epochs.Evidence: how the numbers were taken
rocm/fw-bringup:gfx1250-atom-k3-20261105;AITER_CUSTOM_AR_USE_SYMM_MEM=1(the symm_mem / mori transport the K3 server uses across trays).CustomAllreduce.custom_all_gather(x, 0)asCudaCommunicator.all_gathercalls it, withxan fp16 tensor of [rows, 288].