Skip to content

[HIP] fea: impl gfx1250 lamport ar+rms - #7499

Merged
junhaha666 merged 6 commits into
mainfrom
gfx1250_lamport_ar_rms
Nov 11, 2026
Merged

junhaha666 merged 6 commits into
mainfrom
gfx1250_lamport_ar_rms

Conversation

@TennyWang1223

Copy link
Copy Markdown
Contributor

Summary

Add a Lamport one-shot fused all-reduce + residual add + RMSNorm kernel for gfx1250. fused_allreduce_rmsnorm now uses it on TP2 up to 16 MiB and on TP4 up to 8 MiB. Above that size, and for TP6/TP8, the routing is unchanged.

Motivation

On gfx1250, inputs ≤ 4 MiB currently go through LL all-reduce followed by a separate rmsnorm2d_fwd_with_add, which is two kernels. Inputs above 4 MiB go to ar_rmsnorm_gfx1250, which pays for a barrier and a copy-in. The Lamport kernel does the whole thing in one kernel with no barrier and no copy-in: each rank pushes its data straight into the peers' inboxes, and the readers poll for a 0xffff sentinel. That makes it 1.3–2.1x faster than the current route in the decode / small-prefill range.

Changes

  • Kernel (custom_all_reduce_gfx1250.cuh): there are two layouts. In row mode one block handles one row. In cluster mode one workgroup cluster handles one row, and partial sums are combined through a cluster barrier. The inbox is triple-buffered and tracks rounds with a counter per wave.
  • CUDA graph fix: HIP stream capture drops the clusterDim of hipLaunchKernelEx. After capture, the kernel puts it back on the captured node with hipGraphKernelNodeSetAttribute. Without this, a graph runs the kernel with no cluster sync and the RMSNorm comes out wrong.
  • Ops: lamport_ar_rms_buffer_size / init_lamport_ar_rms / fused_allreduce_rmsnorm_lamport, all in module_custom_all_reduce_gfx1250.
  • Python:
    • CustomAllreduce._init_lamport_ar_rms sets up one IPC inbox per communicator. It uses cached memory and takes 96 MiB per rank on both TP2 and TP4.
    • should_lamport_ar_rms decides from shape, dtype and size only, so every rank picks the same path.
    • The dispatch sits in CudaCommunicator.fused_allreduce_rmsnorm, after the opt-in Gluon branch, so AITER_GLUON_FUSED_AR still takes precedence.
  • Env: AITER_CUSTOM_AR_LAMPORT_RMS_MAX_SIZE overrides the size cap. Setting it to 0 turns the path off.
  • Constraints: bf16/fp16 only, contiguous tensors, hidden a multiple of 256 and ≤ 8192.

Performance (if applicable)

4x gfx1250 (256 CU), ROCm 10.1, IPC transport, CUDA graph (10 calls × 20 replays, median per rank, slowest rank reported).
Before = old production route: ≤ 4 MiB → LL AR + rmsnorm2d_fwd_with_add, > 4 MiB → ar_rmsnorm_gfx1250. After = this PR.

TL;DR: TP2 1.26–2.14x, TP4 1.33–1.83x, bf16 and fp16 alike. Inputs above the cap (TP4 > 8 MiB) keep the old route.

bf16

Hardware Workload/configuration Before (us) After (us) Change
gfx1250 TP2, hidden 2048, M=1 (4 KiB) 9.3 6.6 1.41x
gfx1250 TP2, hidden 2048, M=4 (16 KiB) 10.0 7.1 1.41x
gfx1250 TP2, hidden 2048, M=16 (64 KiB) 10.1 7.2 1.40x
gfx1250 TP2, hidden 2048, M=64 (0.25 MiB) 10.5 7.8 1.34x
gfx1250 TP2, hidden 2048, M=128 (0.5 MiB) 11.1 8.0 1.40x
gfx1250 TP2, hidden 2048, M=256 (1 MiB) 11.9 8.5 1.39x
gfx1250 TP2, hidden 2048, M=512 (2 MiB) 17.3 10.1 1.71x
gfx1250 TP2, hidden 2048, M=1024 (4 MiB) 26.7 12.6 2.12x
gfx1250 TP2, hidden 4096, M=1 (8 KiB) 9.5 7.4 1.29x
gfx1250 TP2, hidden 4096, M=4 (32 KiB) 10.2 7.8 1.32x
gfx1250 TP2, hidden 4096, M=16 (0.12 MiB) 10.4 7.9 1.32x
gfx1250 TP2, hidden 4096, M=64 (0.5 MiB) 11.0 8.2 1.33x
gfx1250 TP2, hidden 4096, M=128 (1 MiB) 12.1 8.6 1.41x
gfx1250 TP2, hidden 4096, M=256 (2 MiB) 17.2 10.2 1.69x
gfx1250 TP2, hidden 4096, M=512 (4 MiB) 26.4 12.7 2.08x
gfx1250 TP2, hidden 4096, M=1024 (8 MiB) 34.6 17.6 1.97x
gfx1250 TP2, hidden 7168, M=1 (14 KiB) 10.8 8.2 1.33x
gfx1250 TP2, hidden 7168, M=4 (56 KiB) 10.8 8.6 1.26x
gfx1250 TP2, hidden 7168, M=16 (0.22 MiB) 11.3 8.7 1.29x
gfx1250 TP2, hidden 7168, M=64 (0.88 MiB) 12.3 9.5 1.30x
gfx1250 TP2, hidden 7168, M=128 (1.75 MiB) 17.3 11.0 1.57x
gfx1250 TP2, hidden 7168, M=256 (3.5 MiB) 26.0 13.3 1.95x
gfx1250 TP2, hidden 7168, M=512 (7 MiB) 30.2 16.7 1.81x
gfx1250 TP2, hidden 7168, M=1024 (14 MiB) 39.7 30.9 1.28x
gfx1250 TP2, hidden 8192, M=1 (16 KiB) 11.1 8.3 1.34x
gfx1250 TP2, hidden 8192, M=4 (64 KiB) 10.9 8.6 1.27x
gfx1250 TP2, hidden 8192, M=16 (0.25 MiB) 11.4 8.7 1.30x
gfx1250 TP2, hidden 8192, M=64 (1 MiB) 12.8 9.2 1.40x
gfx1250 TP2, hidden 8192, M=128 (2 MiB) 17.9 11.1 1.61x
gfx1250 TP2, hidden 8192, M=256 (4 MiB) 26.9 14.1 1.91x
gfx1250 TP2, hidden 8192, M=512 (8 MiB) 32.5 18.1 1.80x
gfx1250 TP2, hidden 8192, M=1024 (16 MiB) 44.3 33.2 1.33x
gfx1250 TP4, hidden 2048, M=1 (4 KiB) 9.9 7.0 1.42x
gfx1250 TP4, hidden 2048, M=4 (16 KiB) 10.7 7.2 1.48x
gfx1250 TP4, hidden 2048, M=16 (64 KiB) 11.0 7.8 1.42x
gfx1250 TP4, hidden 2048, M=64 (0.25 MiB) 12.0 8.2 1.47x
gfx1250 TP4, hidden 2048, M=128 (0.5 MiB) 13.1 8.8 1.48x
gfx1250 TP4, hidden 2048, M=256 (1 MiB) 15.5 10.0 1.55x
gfx1250 TP4, hidden 2048, M=512 (2 MiB) 22.7 15.0 1.51x
gfx1250 TP4, hidden 2048, M=1024 (4 MiB) 37.7 21.1 1.79x
gfx1250 TP4, hidden 4096, M=1 (8 KiB) 10.6 7.7 1.38x
gfx1250 TP4, hidden 4096, M=4 (32 KiB) 10.9 8.0 1.37x
gfx1250 TP4, hidden 4096, M=16 (0.12 MiB) 11.3 8.4 1.34x
gfx1250 TP4, hidden 4096, M=64 (0.5 MiB) 13.2 9.0 1.47x
gfx1250 TP4, hidden 4096, M=128 (1 MiB) 15.5 10.3 1.50x
gfx1250 TP4, hidden 4096, M=256 (2 MiB) 22.9 14.5 1.58x
gfx1250 TP4, hidden 4096, M=512 (4 MiB) 37.6 20.5 1.83x
gfx1250 TP4, hidden 4096, M=1024 (8 MiB) 45.2 33.9 1.33x
gfx1250 TP4, hidden 7168, M=1 (14 KiB) 11.8 8.5 1.38x
gfx1250 TP4, hidden 7168, M=4 (56 KiB) 11.8 8.8 1.33x
gfx1250 TP4, hidden 7168, M=16 (0.22 MiB) 12.4 9.2 1.35x
gfx1250 TP4, hidden 7168, M=64 (0.88 MiB) 15.8 10.8 1.46x
gfx1250 TP4, hidden 7168, M=128 (1.75 MiB) 22.8 15.5 1.47x
gfx1250 TP4, hidden 7168, M=256 (3.5 MiB) 35.4 20.0 1.77x
gfx1250 TP4, hidden 7168, M=512 (7 MiB) 41.7 30.3 1.38x
gfx1250 TP4, hidden 7168, M=1024 (14 MiB) 62.4 62.4 above cap, unchanged
gfx1250 TP4, hidden 8192, M=1 (16 KiB) 11.6 8.6 1.35x
gfx1250 TP4, hidden 8192, M=4 (64 KiB) 11.9 8.7 1.36x
gfx1250 TP4, hidden 8192, M=16 (0.25 MiB) 12.5 9.2 1.36x
gfx1250 TP4, hidden 8192, M=64 (1 MiB) 16.3 10.8 1.51x
gfx1250 TP4, hidden 8192, M=128 (2 MiB) 23.3 16.4 1.42x
gfx1250 TP4, hidden 8192, M=256 (4 MiB) 38.0 21.6 1.76x
gfx1250 TP4, hidden 8192, M=512 (8 MiB) 45.5 33.8 1.35x
gfx1250 TP4, hidden 8192, M=1024 (16 MiB) 66.3 66.3 above cap, unchanged
fp16 (all measured points)
Hardware Workload/configuration Before (us) After (us) Change
gfx1250 TP2, hidden 2048, M=1 (4 KiB) 8.7 6.6 1.31x
gfx1250 TP2, hidden 2048, M=16 (64 KiB) 10.1 7.3 1.39x
gfx1250 TP2, hidden 2048, M=256 (1 MiB) 12.0 8.2 1.46x
gfx1250 TP2, hidden 2048, M=1024 (4 MiB) 26.5 12.4 2.14x
gfx1250 TP2, hidden 4096, M=1 (8 KiB) 9.4 7.3 1.29x
gfx1250 TP2, hidden 4096, M=16 (0.12 MiB) 10.4 7.8 1.32x
gfx1250 TP2, hidden 4096, M=256 (2 MiB) 17.1 10.1 1.69x
gfx1250 TP2, hidden 4096, M=1024 (8 MiB) 34.4 18.0 1.91x
gfx1250 TP2, hidden 7168, M=1 (14 KiB) 10.8 8.1 1.34x
gfx1250 TP2, hidden 7168, M=16 (0.22 MiB) 11.3 8.6 1.31x
gfx1250 TP2, hidden 7168, M=256 (3.5 MiB) 26.0 12.8 2.03x
gfx1250 TP2, hidden 7168, M=1024 (14 MiB) 39.8 30.5 1.30x
gfx1250 TP2, hidden 8192, M=1 (16 KiB) 10.9 8.2 1.33x
gfx1250 TP2, hidden 8192, M=16 (0.25 MiB) 11.3 8.6 1.32x
gfx1250 TP2, hidden 8192, M=256 (4 MiB) 27.1 14.0 1.94x
gfx1250 TP2, hidden 8192, M=1024 (16 MiB) 44.4 32.8 1.35x
gfx1250 TP4, hidden 2048, M=1 (4 KiB) 9.9 7.1 1.40x
gfx1250 TP4, hidden 2048, M=16 (64 KiB) 10.8 7.7 1.41x
gfx1250 TP4, hidden 2048, M=256 (1 MiB) 15.4 10.1 1.52x
gfx1250 TP4, hidden 2048, M=1024 (4 MiB) 37.3 21.1 1.77x
gfx1250 TP4, hidden 4096, M=1 (8 KiB) 10.4 7.5 1.38x
gfx1250 TP4, hidden 4096, M=16 (0.12 MiB) 11.3 8.4 1.35x
gfx1250 TP4, hidden 4096, M=256 (2 MiB) 22.6 14.5 1.56x
gfx1250 TP4, hidden 4096, M=1024 (8 MiB) 44.5 32.5 1.37x
gfx1250 TP4, hidden 7168, M=1 (14 KiB) 11.6 8.2 1.42x
gfx1250 TP4, hidden 7168, M=16 (0.22 MiB) 12.3 9.0 1.36x
gfx1250 TP4, hidden 7168, M=256 (3.5 MiB) 35.2 20.1 1.75x
gfx1250 TP4, hidden 7168, M=1024 (14 MiB) 61.4 61.4 above cap, unchanged
gfx1250 TP4, hidden 8192, M=1 (16 KiB) 11.5 8.3 1.39x
gfx1250 TP4, hidden 8192, M=16 (0.25 MiB) 12.6 9.1 1.39x
gfx1250 TP4, hidden 8192, M=256 (4 MiB) 37.7 21.6 1.75x
gfx1250 TP4, hidden 8192, M=1024 (16 MiB) 66.1 66.1 above cap, unchanged

vs Gluon (opt-in AITER_GLUON_FUSED_AR=1)

Gluon only covers TP4, bf16, power-of-2 hidden and ≤ 8 MiB. It is still opt-in and, when enabled, still takes precedence over Lamport. E2E models run a single fixed hidden, so whether to turn it on can be decided per model.

hidden (TP4, bf16) Gluon (us) Lamport (us) Faster
2048, M 1–1024 5.7–20.6 7.3–21.3 Gluon, by 4–26%
4096, M 1–128 (≤ 1 MiB) 10.2–13.4 7.9–10.8 Lamport 1.24–1.29x
4096, M 256–1024 (2–8 MiB) 15.4–34.9 15.5–33.5 tie
7168 n/a (needs power-of-2 hidden) 8.5–30.3 Lamport
8192, M 1–512 30.7–48.7 8.8–33.9 Lamport 1.4–3.5x

Testing

  • Unit tests added or updated
  • Performance benchmarks run
  • Tested on MI250X — not affected: gfx1250 only
  • Tested on MI300X — not affected: gfx1250 only

Documentation

  • Docstrings updated
  • User guide updated
  • Performance guide updated
  • No documentation change is needed, with the reason stated below

This is an internal routing change. The only new user-facing knob is the env var, and it is documented in the docstring of _resolve_lamport_ar_rms_max_size.

Dependencies

  • No new third-party dependencies added
  • New dependencies are listed and justified below

Breaking Changes

None. Note that on gfx1250 with TP2/TP4, each rank now allocates an extra 96 MiB IPC inbox at init. Set AITER_CUSTOM_AR_LAMPORT_RMS_MAX_SIZE=0 to opt out.

PR Self-Review

Reviewed revision

719d23e

Behavior and intent

On gfx1250 TP2/TP4, fused AR + RMSNorm calls up to the size cap now go through a single Lamport kernel instead of LL AR + RMSNorm or the barrier fused kernel. The output is bit-identical to ar_rmsnorm_gfx1250. Larger inputs, TP6/TP8, other archs, and the opt-in Gluon path behave as before.

Validation and unverified scope

Command: python op_tests/multigpu_tests/test_fused_ar_rms_lamport.py -d bf16 fp16 (defaults: TP 2 and 4, M 1–1024, hidden 2048/4096/7168/8192)

  • Bit-exact against ar_rmsnorm_gfx1250 for every case under the cap, in both bf16 and fp16.
  • Mixed sequence of 44 calls per TP on the shared inbox: hidden and M change from call to call, the 0xffff sentinel is injected, and CUDA graph replays are mixed in with fresh input on every replay. Max bitdiff 0.
  • The Gluon comparison comes from the 2026-11-03 boundary sweep (3-run median, pre-final kernel). In that run the Lamport numbers were within about 0.3 us of the final run (e.g. TP4 h2048 M=1: 7.26 vs 7.03 us). I did not re-measure it against the final kernel.
  • Unverified: TP6/TP8 (off by default; gfx1250 machines go up to TP4), and end-to-end model runs.

PR-specific question

Changed op tests

op_tests/multigpu_tests/test_fused_ar_rms_lamport.py (new): checks Lamport correctness (bit-exact against the barrier fused kernel, a mixed sequence on the shared inbox, and graph replay with fresh input) and times it against the production route, car_fused, car_ar+norm and rccl+norm. The existing tests do not cover this kernel or its inbox round and sentinel protocol.

@TennyWang1223
TennyWang1223 requested a review from a team November 5, 2026 06:57
@github-actions github-actions Bot changed the title fea: impl gfx1250 lamport ar+rms [HIP] fea: impl gfx1250 lamport ar+rms Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the gfx1201 ROCm runner
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 7499 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

@github-actions github-actions Bot added the HIP label Nov 5, 2026
@aiter-bot

aiter-bot commented Nov 5, 2026 •

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision 88848d96802f · mode shadow

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

  1. What behavior does this PR change, and why is the existing behavior insufficient?
  2. What did you validate, and what remains unverified? Include commands, hardware/configuration and results.
  3. Which architecture, dtype and shape boundaries select the changed kernel path, and what invariant prevents unsupported inputs from reaching it?
  4. For every changed op_tests/ file, what behavior does it cover and why is it not redundant? Write None if no op test changed.

Edit the PR Self-Review section in the PR description. Include the current revision SHA; this comment refreshes automatically.

Missing or invalid answers

  • FAIL — missing ### Reviewed revision in the PR description
  • FAIL — missing ### Behavior and intent in the PR description
  • FAIL — missing ### Validation and unverified scope in the PR description
  • FAIL — missing ### PR-specific question in the PR description
  • FAIL — missing ### Changed op tests in the PR description
  • FAIL — Reviewed revision must contain at least the first 7 characters of the current head SHA
  • FAIL — Behavior and intent has no substantive answer
  • FAIL — Validation and unverified scope has no substantive answer
  • FAIL — PR-specific question has no substantive answer
  • FAIL — changed op test not explained in Changed op tests: op_tests/multigpu_tests/test_ar_add_lamport.py
  • FAIL — changed op test not explained in Changed op tests: op_tests/multigpu_tests/test_fused_ar_rms_lamport.py
  • FAIL — Changed op tests must explain why each changed op test is necessary and non-redundant

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

Resolve the conflict in csrc/include/custom_all_reduce_gfx1250.cuh: both
sides added new CustomAllreduce members after allreduce_ll(). Keep both,
the Lamport fused AR + RMSNorm entry points (init_lamport_ar_rms,
fused_allreduce_rmsnorm_lamport) followed by the LL all-gather ones from
#7265 (use_ll_ag, ll_ag_reads_in_place, allgather_ll), each closing its
own brace.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@zufayu
zufayu self-requested a review November 6, 2026 00:53
@zufayu zufayu self-assigned this Nov 6, 2026
zufayu
zufayu previously approved these changes Nov 6, 2026
@zufayu

zufayu commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

ci failed

Resolve the conflict with the gfx9 lamport allreduce (#7452) in
CustomAllreduce init: gfx1250 sets up the lamport AR + RMSNorm inbox,
other archs the lamport allreduce. Add TODOs on both inits for when each
arch gets the other lamport op.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
It forced the lamport AR + RMSNorm cluster block size from the env and
was only meant for tuning; cluster_threads now always uses its heuristic.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@TennyWang1223
TennyWang1223 requested a review from zufayu November 6, 2026 02:20
TennyWang1223 and others added 2 commits November 6, 2026 08:17
The module is prebuilt for every CI arch (gfx942/gfx950 on ROCm 7.2.4),
where the cluster barrier, the cluster memory scope and the cluster
launch attribute do not exist. Compile the cluster kernel out on the
device side unless the target is gfx1250 with cluster support, and on
the host side detect hipLaunchAttributeValue::clusterDim so every call
takes the block-a-row path when the HIP headers lack cluster launch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…reduce_add)

DeepSeek-V4.1 TP decode adds the shared-expert output into the routed MoE
output right before the TP all-reduce of every MoE layer. The sum over
ranks of each rank's x + y now runs as one Lamport one-shot kernel on
gfx1250: each rank adds its pair in fp32 and rounds to the dtype before
sending, so the result has the bits of all-reducing the materialized sum,
the same on every rank.

The kernel shares the AR + RMSNorm inbox, round counters and size cap
(TP2 16 MiB, TP4 8 MiB), so it takes no extra memory. Its kernel arguments
are scalars and pointers only, the inboxes one by one: the module preloads
kernel arguments into SGPRs up to the first aggregate, and a LamportPeers
argument left the rest to serial s_loads before the first remote store,
about 1 us of a decode-size call.

Entry points follow #7488, which ROCm/ATOM#3020 calls:
tensor_model_parallel_all_reduce_add -> GroupCoordinator.all_reduce_add ->
the all_reduce_add_ custom op (its fake follows the add-then-reduce
fallback) -> CudaCommunicator.all_reduce_add, which takes the Lamport
kernel where it fits and all_reduce(x + y) otherwise.

4x gfx1250, TP4, bf16 [M, 5120], 43 calls per HIP graph, slowest rank, us:

     M   this   #7488 Gluon fused   add + RCCL
     1   5.18        5.35              10.7
     8   5.61        6.08              10.3
    48   6.58        7.48              12.2
    96   7.81        9.68              14.3
   288   14.4        17.3              25.0
   409   17.8        22.3              27.0

test_ar_add_lamport.py: bit-exact against the rank-order fp32 reference
at TP2/TP4, bf16 and fp16, and a mixed sequence on the shared inbox (the
add between AR + RMSNorm calls, partial last waves, injected 0xffff,
fallback and broadcast calls against the fake, HIP graph replays with
fresh inputs).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@TennyWang1223

Copy link
Copy Markdown
Contributor Author

Lamport all-reduce of x + y (tensor_model_parallel_all_reduce_add)

DeepSeek-V4.1 TP decode adds the shared-expert output into the routed MoE output right before the TP all-reduce on every MoE layer. This adds a gfx1250 Lamport one-shot kernel for all_reduce(x + y) as a HIP replacement for the Gluon version in #7488.

Performance

4x gfx1250, TP4, bf16 [M, 5120], 43 calls per HIP graph, slowest rank (us):

M This PR #7488 (Gluon fused) add + RCCL
1 5.18 5.35 10.7
8 5.61 6.08 10.3
48 6.58 7.48 12.2
96 7.81 9.68 14.3
288 14.4 17.3 25.0
409 17.8 22.3 27.0

At the cap, TP4 8 MiB is 30.5 us (RCCL 33.2) and TP2 16 MiB is 29.1 us (custom AR 64.7).

Testing

op_tests/multigpu_tests/test_ar_add_lamport.py:

  • Bit-exact against the rank-order fp32 reference at TP2/TP4, bf16 and fp16.
  • Mixed sequence on the shared inbox, 0 bit difference: the add interleaved with AR + RMSNorm, partial last waves, injected 0xffff, fallback and broadcast calls
    checked against the fake, and HIP graph replays with fresh inputs.

@junhaha666
junhaha666 merged commit 06b7fd3 into main Nov 11, 2026
@junhaha666
junhaha666 deleted the gfx1250_lamport_ar_rms branch November 11, 2026 03:38
zejunchen-zejun added a commit that referenced this pull request Nov 11, 2026
Conflicts with #7499 (gfx1250 Lamport AR + RMSNorm), both additive: the
plain all-reduce cutoff table and the Lamport size table in
custom_all_reduce.py, and the two-shot tables and the Lamport inbox member in
CustomAllreduce. Both kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Boss2002n Boss2002n mentioned this pull request Nov 12, 2026
5 of 10 tasks
lirui927 pushed a commit that referenced this pull request Nov 16, 2026
* fea: impl gfx1250 lamport ar+rms

Signed-off-by: TennyWang1223 <[email protected]>

* Remove the DBG_LAMPORT_BS measurement hook

It forced the lamport AR + RMSNorm cluster block size from the env and
was only meant for tuning; cluster_threads now always uses its heuristic.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Guard the lamport cluster path for non-gfx1250 archs and older ROCm

The module is prebuilt for every CI arch (gfx942/gfx950 on ROCm 7.2.4),
where the cluster barrier, the cluster memory scope and the cluster
launch attribute do not exist. Compile the cluster kernel out on the
device side unless the target is gfx1250 with cluster support, and on
the host side detect hipLaunchAttributeValue::clusterDim so every call
takes the block-a-row path when the HIP headers lack cluster launch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Add a gfx1250 Lamport all-reduce of x + y (tensor_model_parallel_all_reduce_add)

DeepSeek-V4.1 TP decode adds the shared-expert output into the routed MoE
output right before the TP all-reduce of every MoE layer. The sum over
ranks of each rank's x + y now runs as one Lamport one-shot kernel on
gfx1250: each rank adds its pair in fp32 and rounds to the dtype before
sending, so the result has the bits of all-reducing the materialized sum,
the same on every rank.

The kernel shares the AR + RMSNorm inbox, round counters and size cap
(TP2 16 MiB, TP4 8 MiB), so it takes no extra memory. Its kernel arguments
are scalars and pointers only, the inboxes one by one: the module preloads
kernel arguments into SGPRs up to the first aggregate, and a LamportPeers
argument left the rest to serial s_loads before the first remote store,
about 1 us of a decode-size call.

Entry points follow #7488, which ROCm/ATOM#3020 calls:
tensor_model_parallel_all_reduce_add -> GroupCoordinator.all_reduce_add ->
the all_reduce_add_ custom op (its fake follows the add-then-reduce
fallback) -> CudaCommunicator.all_reduce_add, which takes the Lamport
kernel where it fits and all_reduce(x + y) otherwise.

4x gfx1250, TP4, bf16 [M, 5120], 43 calls per HIP graph, slowest rank, us:

     M   this   #7488 Gluon fused   add + RCCL
     1   5.18        5.35              10.7
     8   5.61        6.08              10.3
    48   6.58        7.48              12.2
    96   7.81        9.68              14.3
   288   14.4        17.3              25.0
   409   17.8        22.3              27.0

test_ar_add_lamport.py: bit-exact against the rank-order fp32 reference
at TP2/TP4, bf16 and fp16, and a mixed sequence on the shared inbox (the
add between AR + RMSNorm calls, partial last waves, injected 0xffff,
fallback and broadcast calls against the fake, HIP graph replays with
fresh inputs).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Signed-off-by: TennyWang1223 <[email protected]>
Co-authored-by: TennyWang1223 <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 06b7fd3)
XiaobingSuper added a commit that referenced this pull request Nov 30, 2026
…ute up to hidden 2048 where Lamport runs

With the Gluon all-reduce on (TP4), fused_allreduce_rmsnorm took the Gluon
power-of-2 AR + RMSNorm (all_reduce_rmsnorm_quant, #6974) for every
power-of-2 hidden up to 8 MiB, ahead of the Gluon per-token kernel and the
Lamport one-shot, which came later (#7499). At hidden 4096 / 8192 it took
1.02-1.63x / 1.45-4.85x the time of those routes (4x MI455X, TP4, CUDA
graphs, 1 row to the 8 MiB cap); at 1024 / 2048 it stays the faster route.

Where the Lamport one-shot can take the call, the power-of-2 route now stops
at hidden 2048 (_GLUON_AR_MAX_HIDDEN_WITH_LAMPORT) and larger hidden sizes
take the routes after it: the Gluon per-token kernel up to 128 rows, then
Lamport. Their bf16 output bits differ from the power-of-2 kernel's in the
last place (another reduction order).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants