Repository navigation
[HIP] perf(custom_ar): gfx1250 DCP merge: all-to-all and LSE combine in one LL kernel - #7801
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
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 |
|
Read the whole diff (646 lines) plus the LL machinery it reuses ( Before merge
Should fix |
…in one LL kernel Under decode context parallelism (DCP) every rank attends all H query heads over its own KV shard, then each rank needs its H / n heads' partials from every rank merged by their LSE. ATOM does that with a Triton pack kernel, an RCCL all_to_all_single (with a copy-in) and a Triton combine kernel. On gfx1250 RCCL's all-to-all is slow at these sizes: Kimi-K3 TP8+DCP8 decode at 54 tokens spends 40 us a full-attention layer in that path, 30 us of it in ddaAllToAllFabric. Above 4 MiB (more than 168 tokens) RCCL leaves its DDA path for one that takes 220-500 us and cannot be captured in a CUDA graph. dcp_merge_ll_gfx1250 does the exchange and the merge in one launch over the LL scratch, with its epochs, banks and slot stride (it interleaves with the LL all-reduce and all-gather): - a (b, h) row of 128 bf16 travels as 32 LL lines of 8 bytes plus one LSE line; rank s writes its rows for rank r into slot s of rank r's scratch; - sender and merger waves are separate: a sender wave loads its rows first and then issues their remote stores; a merger wave polls every peer's lines of one output row in one batch, reads its own shard's row from o, and combines as ATOM's Triton combine does (non-finite LSE counts as -inf, fp32, rounded to bf16 once). API: CustomAllreduce.should_custom_dcp_merge / custom_dcp_merge, CudaCommunicator.dcp_lse_merge and GroupCoordinator.dcp_lse_merge, which return None for inputs the kernel does not take (gfx1250 only, o [B, H, 128] bf16, lse [B, H] fp32, B * H / n rows within the LL slot: up to 1323 tokens at TP8 with 96 heads). It reads o and lse in place: no registered buffer, and the same inside and outside CUDA graph capture. Test: op_tests/multigpu_tests/test_dcp_merge.py (fp32 reference with empty and NaN rows, owned_counts and return_lse; graph replays; calls interleaved with LL all-reduces and all-gathers). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…he review's tests - should_custom_dcp_merge no longer reads o.data_ptr(): a caller picks between this kernel and a collective of its own from the answer, so it must not differ across ranks. It depends on shapes, dtypes and strides alone; the C++ entry still rejects an o whose rows are not 8-byte aligned. GroupCoordinator.dcp_lse_merge states that contract, and points at the gfx950 mailbox merge (aiter.ops.flydsl.dcp_mailbox.dcp_lse_combine). - The kernel comment states the epoch assumption it shares with ar_ll / ag_ll: every block of a launch resident at once, and no LL kernel of the same communicator on another stream at the same time. - test_dcp_merge.py adds strided o / lse, B = 0 followed by a regular call, owned_counts that change between graph replays, and a late rank in every interleaved round. Co-Authored-By: Claude Opus 5.5 <[email protected]>
036fe1f to
9eb751c
Compare
- cp_lse_a2a calls cp_group.dcp_lse_merge (ROCm/aiter#7801's GroupCoordinator.dcp_lse_merge) directly instead of probing for it. The group returns None for inputs it does not take, and pack / all-to-all / combine runs. - Not under decode TBO (--enable-tbo all): the kernel shares the custom all-reduce's LL scratch and epochs, which two micro-batches on two streams could interleave. - The comment states that both paths are collectives, so the choice must be the same on every rank. The docstring names aiter's method (this module's dcp_lse_merge is a different function), says the LSE may be any float dtype, and says the fused-quant combine never asks the group. - Tests: the group declining (its None reaches pack / all-to-all / combine, whose result comes back), and the fused-quant combine and decode TBO never asking it, with all_to_all_single as a local permute. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks, re-read at
Still missing:
|
|
Thanks @yitingw1. Rebased onto main 1. Rebase, and the tests at this head.
2. Numbers for this kernel.
3. Rank-invariant gate.
4. Test gaps.
5. The epoch assumption is stated at the kernel and in 6. Two entry points. |
|
Review routing reminder: @TennyWang1223 is the primary reviewer for the communication/all-reduce scope on this PR. @zufayu is backup/co-review. Please route the next technical review/action to Tenny; CI status remains a separate merge gate. |
…fly_rms #7801 set _dcp_merge_max_rows at the end of __init__, after _init_fly_oneshot(). #5670 merged four minutes earlier and changed the same region. The squash merge of #7801 (03f9f37) placed the hunk at the end of _init_fly_rms instead. _init_fly_rms returns early when the FlyDSL fused AR + RMSNorm engine does not build. The engine builds only with AITER_FLY_AR=1 on gfx942 or gfx950. Thus: - On gfx1250 the attribute is never set, so should_custom_dcp_merge always returns False and the gfx1250 DCP merge cannot run. - The rank-agreement test builds a CustomAllreduce with __new__, then calls _init_fly_rms. That call now reads _is_gfx1250, which the stand-in does not set. test_matching_ranks_build[fused] fails with AttributeError on main. Move the assignment and its comment back to __init__, after _init_fly_rms(). Also require "not self.disabled". The cross-node symm_mem failure path disables the communicator and returns before it sets self._ptr, so the gfx1250 call would raise on it. Revert the test change of the previous commit. The test file is now identical to main. MI308X (gfx942), TP2: - test_flydsl_allreduce_rank_agreement.py: 28 passed (main: 1 failed, 27 passed). - A real CustomAllreduce has _dcp_merge_max_rows == 0 with AITER_FLY_AR unset and with AITER_FLY_AR=1. On main the attribute is missing when the variable is unset.
…fly_rms (#8117) * [FlyDSL] [Test] test_flydsl_allreduce_rank_agreement: set _is_gfx1250 on the __new__-built CustomAllreduce test_matching_ranks_build[fused] builds a CustomAllreduce with __new__ and sets by hand the attributes that _init_fly_rms reads. Since #7801, _init_fly_rms also reads self._is_gfx1250 after the engine is built, to size the gfx1250 DCP merge. __init__ sets this attribute on every instance, but the stand-in did not. Thus both ranks raised AttributeError and the case failed on main. Set it to False. The stand-in host is gfx950 (ARCH), and the FlyDSL fused backend builds only on gfx942 and gfx950. With True, which is the module value on a gfx1250 runner, _init_fly_rms calls dcp_merge_max_rows_gfx1250(self._ptr), and the stand-in has no _ptr. MI308X (gfx942), main b9e08da: the file gives 1 failed, 27 passed before this change, and 28 passed after it. * custom_all_reduce: set _dcp_merge_max_rows in __init__, not in _init_fly_rms #7801 set _dcp_merge_max_rows at the end of __init__, after _init_fly_oneshot(). #5670 merged four minutes earlier and changed the same region. The squash merge of #7801 (03f9f37) placed the hunk at the end of _init_fly_rms instead. _init_fly_rms returns early when the FlyDSL fused AR + RMSNorm engine does not build. The engine builds only with AITER_FLY_AR=1 on gfx942 or gfx950. Thus: - On gfx1250 the attribute is never set, so should_custom_dcp_merge always returns False and the gfx1250 DCP merge cannot run. - The rank-agreement test builds a CustomAllreduce with __new__, then calls _init_fly_rms. That call now reads _is_gfx1250, which the stand-in does not set. test_matching_ranks_build[fused] fails with AttributeError on main. Move the assignment and its comment back to __init__, after _init_fly_rms(). Also require "not self.disabled". The cross-node symm_mem failure path disables the communicator and returns before it sets self._ptr, so the gfx1250 call would raise on it. Revert the test change of the previous commit. The test file is now identical to main. MI308X (gfx942), TP2: - test_flydsl_allreduce_rank_agreement.py: 28 passed (main: 1 failed, 27 passed). - A real CustomAllreduce has _dcp_merge_max_rows == 0 with AITER_FLY_AR unset and with AITER_FLY_AR=1. On main the attribute is missing when the variable is unset. --------- Co-authored-by: TennyWang1223 <[email protected]>
Under decode context parallelism (DCP) every rank attends all H query heads over its own KV shard, then each rank needs its H / n heads' partials from every rank merged by their LSE. ATOM does that with a Triton pack kernel, an RCCL all_to_all_single (with a copy-in) and a Triton combine kernel. On gfx1250 RCCL's all-to-all is slow at these sizes: Kimi-K3 TP8+DCP8 decode at 54 tokens spends 40 us a full-attention layer in that path, 30 us of it in ddaAllToAllFabric. Above 4 MiB (more than 168 tokens) RCCL leaves its DDA path for one that takes 220-500 us and cannot be captured in a CUDA graph.
dcp_merge_ll_gfx1250 does the exchange and the merge in one launch over the LL scratch, with its epochs, banks and slot stride (it interleaves with the LL all-reduce and all-gather):
API: CustomAllreduce.should_custom_dcp_merge / custom_dcp_merge, CudaCommunicator.dcp_lse_merge and GroupCoordinator.dcp_lse_merge, which return None for inputs the kernel does not take (gfx1250 only, o [B, H, 128] bf16, lse [B, H] fp32, B * H / n rows within the LL slot: up to 1323 tokens at TP8 with 96 heads). It reads o and lse in place: no registered buffer, and the same inside and outside CUDA graph capture.
Test: op_tests/multigpu_tests/test_dcp_merge.py (fp32 reference with empty and NaN rows, owned_counts and return_lse; graph replays; calls interleaved with LL all-reduces and all-gathers).