Skip to content

[HIP] fea: impl lamport allreduce on gfx9 - #7452

Merged
zufayu merged 3 commits into
mainfrom
lamport_ar_gfx9
Nov 5, 2026
Merged

zufayu merged 3 commits into
mainfrom
lamport_ar_gfx9

Conversation

@TennyWang1223

@TennyWang1223 TennyWang1223 commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds a Lamport (barrier-free) all-reduce path to the gfx9 custom all-reduce, for bf16/fp16 on gfx942 and gfx950. It replaces origin_custom_ar (LL / LL128 / 1-stage / 2-stage) for small and medium messages:

TP lamport_ar_1shot_ws (1shot) lamport_ar_2shot_ws (2shot) origin_custom_ar (unchanged)
2 ≤ 128 KB 128 KB – 2 MB > 2 MB
4 / 8 ≤ 64 KB 64 KB – 1 MB > 1 MB
  • Speedup inside these ranges, CUDA graph, registered input: gfx942 1.02–1.47x, gfx950 1.00–1.53x. No regression on either arch.
  • Memory: +16 / 20 / 28 MB of uncached IPC memory per rank at TP2 / 4 / 8.
  • On by default. AITER_CUSTOM_AR_DISABLE_LAMPORT=1 restores the original dispatch. gfx1250 is not affected.

Motivation

  • Every origin_custom_ar kernel synchronizes ranks through the Signal barrier before it touches peer buffers, and 2-stage pays this twice. For decode-sized messages this handshake is a large part of the time.
  • The copy-in path (eager mode, expandable_segments) also pays a memcpy into the registered pool before each all-reduce.
  • Lamport removes both. Each rank pushes its data straight into its peers' inboxes and polls only its own. The inbox starts as the 0xffff sentinel (NaN), so the data itself signals arrival: no barrier. Three inbox buffers rotate per block, so no reset is needed between calls.

Changes

  • Kernels (csrc/include/custom_all_reduce.cuh): lamport_ar_1shot_ws and lamport_ar_2shot_ws. Wave64, 2-byte dtypes only. _ws = wave split: a block is ngpus waves, and wave w talks only to rank (rank + w) % ngpus.
    • Sums run in fp32 in rank order and round once, so every rank produces the same bits.
  • Dispatch (CustomAllreduce::lamportKernel): the ranges in the table above. They are bounded by gfx950, see Performance.
    • Kept on origin_custom_ar: fp32, the fp16 open_fp8_quant branch, use_new=False, and two-shot sizes that are not a multiple of 16 * tp bytes.
  • Copy-in skip (csrc/kernels/custom_all_reduce.cu): all_reduce() skips the memcpy into the registered pool for messages Lamport takes. An input that is not 16B aligned is still copied in, and still runs the same Lamport kernel.
  • Python (aiter/dist/device_communicators/custom_all_reduce.py): _initLamport allocates the inbox buffer and fills it with the sentinel. The on/off verdict is AND-ed across ranks.
  • New ops: lamportBufferSize, initLamport, lamportKernel (which kernel the dispatch picks), lamportAllReduce (forces one kernel, for tests and tuning).

Performance (if applicable)

Method: test_custom_allreduce_lamport.py, bf16, H = 7168 / 8192, CUDA graph, registered input. Time = median of 20 replays of a 10-call graph / 10, slowest rank. Before = origin_custom_ar (AITER_CUSTOM_AR_DISABLE_LAMPORT=1). After = what the default dispatch runs. Speedup = before / after.

Key numbers, inside the Lamport ranges:

TP2 TP4 TP8
gfx942 1.02–1.23x 1.04–1.46x 1.13–1.47x
gfx950 1.03–1.23x 1.00–1.39x 1.02–1.53x

On the copy-in path the gain is larger, because Lamport also skips the memcpy (gfx950: 1.13–1.85x). Those numbers are left out of the tables.

Why the caps are 2 MB / 1 MB / 1 MB: they are the largest sizes where Lamport is not slower on gfx950. Above them, on gfx950, the original dispatch is as fast or faster (two-shot vs origin: TP2 0.96–0.99x, TP4 0.98–1.01x, TP8 0.90–1.00x, measured up to 64 MB). One set of caps serves both archs.

Cost on gfx942: gfx942 does not regress above the caps, but it gives up a gain there. At TP4 / TP8 for 1.75–2 MB, a forced two-shot is still 1.21–1.42x faster than origin_custom_ar (e.g. TP8 2 MB: 19.1 µs vs 27.2 µs; forced kernel, measured on d0b868b). Per-arch caps could recover this in a follow-up.

Both tables were measured before the caps were added. Inside the caps the kernels are unchanged. Rows marked origin are past the caps and now run the original dispatch, so After = Before.

MI308X (gfx942)

TP Message (m × n) Kernel Before: origin_custom_ar (µs) After (µs) Speedup
2 14 KB (1 × 7168) 1shot 5.9 5.4 1.11x
2 28 KB (2 × 7168) 1shot 6.6 6.0 1.09x
2 56 KB (4 × 7168) 1shot 7.7 6.6 1.16x
2 112 KB (8 × 7168) 1shot 9.6 8.0 1.21x
2 224 KB (16 × 7168) 2shot 12.1 10.8 1.12x
2 448 KB (32 × 7168) 2shot 16.8 15.7 1.07x
2 896 KB (64 × 7168) 2shot 27.2 25.8 1.05x
2 1.75 MB (128 × 7168) 2shot 47.5 44.3 1.07x
2 3.5 MB (256 × 7168) origin 86.2 = before 1.00x
2 16 KB (1 × 8192) 1shot 5.9 5.5 1.08x
2 32 KB (2 × 8192) 1shot 6.3 6.2 1.02x
2 64 KB (4 × 8192) 1shot 8.1 6.8 1.19x
2 128 KB (8 × 8192) 1shot 10.2 8.3 1.23x
2 256 KB (16 × 8192) 2shot 12.3 10.8 1.14x
2 512 KB (32 × 8192) 2shot 18.3 16.9 1.08x
2 1 MB (64 × 8192) 2shot 31.1 27.9 1.12x
2 2 MB (128 × 8192) 2shot 52.9 49.6 1.07x
2 4 MB (256 × 8192) origin 97.3 = before 1.00x
4 14 KB (1 × 7168) 1shot 6.5 5.6 1.15x
4 28 KB (2 × 7168) 1shot 7.0 6.5 1.08x
4 56 KB (4 × 7168) 1shot 8.7 7.5 1.16x
4 112 KB (8 × 7168) 2shot 11.5 7.8 1.46x
4 224 KB (16 × 7168) 2shot 10.1 9.8 1.04x
4 448 KB (32 × 7168) 2shot 15.0 12.4 1.20x
4 896 KB (64 × 7168) 2shot 22.0 17.0 1.29x
4 1.75 MB (128 × 7168) origin 32.4 = before 1.00x
4 3.5 MB (256 × 7168) origin 56.5 = before 1.00x
4 16 KB (1 × 8192) 1shot 6.2 5.8 1.06x
4 32 KB (2 × 8192) 1shot 7.3 6.6 1.10x
4 64 KB (4 × 8192) 1shot 9.7 6.9 1.40x
4 128 KB (8 × 8192) 2shot 12.0 8.8 1.35x
4 256 KB (16 × 8192) 2shot 11.5 10.0 1.15x
4 512 KB (32 × 8192) 2shot 15.8 11.7 1.35x
4 1 MB (64 × 8192) 2shot 23.5 18.9 1.25x
4 2 MB (128 × 8192) origin 36.6 = before 1.00x
4 4 MB (256 × 8192) origin 62.3 = before 1.00x
8 14 KB (1 × 7168) 1shot 7.5 5.9 1.26x
8 28 KB (2 × 7168) 1shot 9.3 7.0 1.33x
8 56 KB (4 × 7168) 1shot 12.0 8.3 1.45x
8 112 KB (8 × 7168) 2shot 10.5 9.2 1.15x
8 224 KB (16 × 7168) 2shot 11.5 10.0 1.15x
8 448 KB (32 × 7168) 2shot 14.5 12.3 1.18x
8 896 KB (64 × 7168) 2shot 19.8 14.4 1.38x
8 1.75 MB (128 × 7168) origin 24.1 = before 1.00x
8 3.5 MB (256 × 7168) origin 37.4 = before 1.00x
8 16 KB (1 × 8192) 1shot 7.6 6.0 1.26x
8 32 KB (2 × 8192) 1shot 9.7 7.1 1.36x
8 64 KB (4 × 8192) 1shot 12.7 8.6 1.47x
8 128 KB (8 × 8192) 2shot 10.7 9.4 1.13x
8 256 KB (16 × 8192) 2shot 11.9 10.4 1.14x
8 512 KB (32 × 8192) 2shot 15.4 12.9 1.19x
8 1 MB (64 × 8192) 2shot 18.5 14.9 1.24x
8 2 MB (128 × 8192) origin 27.1 = before 1.00x
8 4 MB (256 × 8192) origin 42.4 = before 1.00x

MI350X (gfx950)

TP Message (m × n) Kernel Before: origin_custom_ar (µs) After (µs) Speedup
2 14 KB (1 × 7168) 1shot 4.6 4.5 1.03x
2 28 KB (2 × 7168) 1shot 5.0 4.7 1.08x
2 56 KB (4 × 7168) 1shot 6.0 5.1 1.18x
2 112 KB (8 × 7168) 1shot 7.4 6.0 1.23x
2 224 KB (16 × 7168) 2shot 9.3 8.2 1.13x
2 448 KB (32 × 7168) 2shot 13.7 12.4 1.11x
2 896 KB (64 × 7168) 2shot 22.1 19.9 1.11x
2 1.75 MB (128 × 7168) 2shot 37.1 35.8 1.04x
2 3.5 MB (256 × 7168) origin 66.9 = before 1.00x
2 16 KB (1 × 8192) 1shot 4.8 4.5 1.06x
2 32 KB (2 × 8192) 1shot 5.2 4.7 1.10x
2 64 KB (4 × 8192) 1shot 6.3 5.2 1.20x
2 128 KB (8 × 8192) 1shot 7.6 6.3 1.21x
2 256 KB (16 × 8192) 2shot 9.9 8.8 1.13x
2 512 KB (32 × 8192) 2shot 14.8 13.4 1.11x
2 1 MB (64 × 8192) 2shot 24.2 22.2 1.09x
2 2 MB (128 × 8192) 2shot 41.7 40.2 1.04x
2 4 MB (256 × 8192) origin 75.5 = before 1.00x
4 14 KB (1 × 7168) 1shot 5.0 4.7 1.04x
4 28 KB (2 × 7168) 1shot 5.4 4.9 1.11x
4 56 KB (4 × 7168) 1shot 6.6 5.4 1.23x
4 112 KB (8 × 7168) 2shot 8.6 6.4 1.33x
4 224 KB (16 × 7168) 2shot 7.6 7.2 1.05x
4 448 KB (32 × 7168) 2shot 9.2 8.9 1.03x
4 896 KB (64 × 7168) 2shot 13.0 12.5 1.04x
4 1.75 MB (128 × 7168) origin 20.7 = before 1.00x
4 3.5 MB (256 × 7168) origin 36.9 = before 1.00x
4 16 KB (1 × 8192) 1shot 5.0 4.8 1.05x
4 32 KB (2 × 8192) 1shot 5.6 5.0 1.13x
4 64 KB (4 × 8192) 1shot 7.7 5.5 1.39x
4 128 KB (8 × 8192) 2shot 8.9 6.5 1.37x
4 256 KB (16 × 8192) 2shot 7.7 7.5 1.03x
4 512 KB (32 × 8192) 2shot 9.7 9.5 1.03x
4 1 MB (64 × 8192) 2shot 13.8 13.7 1.00x
4 2 MB (128 × 8192) origin 23.7 = before 1.00x
4 4 MB (256 × 8192) origin 41.6 = before 1.00x
8 14 KB (1 × 7168) 1shot 6.3 5.0 1.26x
8 28 KB (2 × 7168) 1shot 6.9 5.2 1.34x
8 56 KB (4 × 7168) 1shot 8.7 5.9 1.49x
8 112 KB (8 × 7168) 2shot 7.8 6.9 1.13x
8 224 KB (16 × 7168) 2shot 8.0 7.2 1.11x
8 448 KB (32 × 7168) 2shot 8.7 8.3 1.05x
8 896 KB (64 × 7168) 2shot 11.4 10.4 1.10x
8 1.75 MB (128 × 7168) origin 14.8 = before 1.00x
8 3.5 MB (256 × 7168) origin 22.8 = before 1.00x
8 16 KB (1 × 8192) 1shot 6.4 5.0 1.28x
8 32 KB (2 × 8192) 1shot 7.2 5.2 1.37x
8 64 KB (4 × 8192) 1shot 9.3 6.1 1.53x
8 128 KB (8 × 8192) 2shot 7.8 7.0 1.13x
8 256 KB (16 × 8192) 2shot 8.1 7.3 1.10x
8 512 KB (32 × 8192) 2shot 8.9 8.6 1.03x
8 1 MB (64 × 8192) 2shot 11.6 11.4 1.02x
8 2 MB (128 × 8192) origin 16.7 = before 1.00x
8 4 MB (256 × 8192) origin 25.4 = before 1.00x

Testing

  • Unit tests added or updated
  • Performance benchmarks run
  • Tested on MI250X
  • Tested on MI300X (MI308X, gfx942; MI350X gfx950 perf sweep)

Documentation

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

No guide in the repo lists the custom all-reduce env vars or kernels. The switch, the size ranges and the buffer size are documented next to the code (_DISABLE_LAMPORT_ENV, _initLamport, CustomAllreduce::lamportKernel).

Dependencies

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

Breaking Changes

None in the API. Behavior changes on gfx942 / gfx950 only:

  • bf16/fp16 all-reduces up to 2 MB (TP2) / 1 MB (TP4, TP8) run the Lamport kernels. Results are an fp32 rank-order sum with one rounding, bitwise identical on every rank.
  • +16 / 20 / 28 MB of uncached device memory per rank (TP2 / 4 / 8).
  • To restore the old behavior, set AITER_CUSTOM_AR_DISABLE_LAMPORT=1 on every rank.

PR Self-Review

Reviewed revision

d0b868b

Behavior and intent

  • What changes: on gfx942/gfx950, tensor_model_parallel_all_reduce / CustomAllreduce.all_reduce for bf16/fp16 messages inside the ranges above runs lamport_ar_1shot_ws / lamport_ar_2shot_ws instead of origin_custom_ar. Copy-in calls skip the memcpy for those messages.
  • Why: origin_custom_ar pays a cross-rank Signal handshake (twice for 2-stage). Lamport replaces it with data-as-signal inboxes: 1.00–1.53x faster across both archs inside the ranges.
  • Unchanged: fp32, fp8 quant, use_new=False, messages above the caps, all_gather / reduce_scatter / all fused ops (AR + RMSNorm, AR + residual), and gfx1250.

Validation and unverified scope

Hardware: 8 × MI308X (gfx942), xGMI. Commands (with this repo on PYTHONPATH):

python3 op_tests/multigpu_tests/test_custom_allreduce_lamport.py                    # default sweep, up to 4 MB
python3 op_tests/multigpu_tests/test_custom_allreduce_lamport.py -m 1 2 4 8 16 32 64 128 256 512 1024 2048 4096  # up to 64 MB
python3 op_tests/multigpu_tests/test_custom_allreduce.py -d {bf16,fp16} -m {graph,eager}
python3 op_tests/multigpu_tests/test_custom_allreduce_fp8.py
python3 op_tests/multigpu_tests/test_custom_allreduce_rank_order.py
AITER_CUSTOM_AR_DISABLE_LAMPORT=1 python3 op_tests/multigpu_tests/test_custom_allreduce.py -d bf16 -m {graph,eager}

Results on d0b868b (gfx942):

  • Lamport sweep: TP2/4/8 × H 7168/8192, 14 KB – 64 MB (156 cases) and the default 4 MB sweep (108 cases), both capture paths. Every Lamport and forced-kernel result matches the fp32 rank-order reference bit for bit, and the injected 0xffff sentinel comes out as NaN without a hang. The resize check and the unaligned-input check report 0 errors.
  • Dispatch: Lamport is picked exactly inside the caps. Past them the time equals origin_custom_ar (0.98–1.03x, noise).
  • Regression: all pass. Lamport on: test_custom_allreduce.py bf16 / fp16 × graph / eager, test_custom_allreduce_fp8.py, test_custom_allreduce_rank_order.py (no failed ranks). Lamport off: test_custom_allreduce.py bf16 graph / eager.

Unverified:

  • gfx950 on this revision. The MI350X numbers above were measured before the caps and before the inbox shrink. Inside the caps the kernels are the same; past them it is the original dispatch. A re-run on MI350X is still to do.
  • test_custom_allreduce_capture_registration.py and test_custom_allreduce_graph_buffer_reuse.py: fail in setup with torch 2.8 (no torch._C._accelerator_setAllocatorSettings), before any all-reduce. Need a newer torch.
  • End-to-end model runs: not done. The fused AR + residual / AR + RMSNorm thresholds were not re-tuned.
  • MI250X: not applicable (gfx90a has no Lamport path).

PR-specific question

Which arch, dtype and shape select the Lamport path, and what keeps other inputs out:

  • Arch / group: gfx942 or gfx950, world size 2/4/8, env switch not set. All are checked in _initLamport and AND-ed across ranks. Otherwise initLamport never runs, lamport_ stays null, and lamportKernel returns none.
  • Dtype: 2-byte only. lamportDispatch requires elem_size == 2 and use_new. allreduce<T> checks under if constexpr (sizeof(T) == 2). The fp16 fp8-quant branch leaves _all_reduce before allreduce<T>.
  • Shape: one-shot if bytes ≤ 128 KB (TP2) / 64 KB (TP4, TP8). Two-shot if bytes ≤ 2 MB / 1 MB and a multiple of 16 * tp. Anything else runs origin_custom_ar. allreduce<T> already requires whole 16B packs.
  • Invariants:
    • The pick depends only on numel and world size, so every rank runs the same kernel. Input alignment only decides the copy-in, not the kernel.
    • The dispatch caps never exceed the inbox capacity (std::min with twoShotMaxBytes()).
    • runOneShot / runTwoShot throw on anything past capacity rather than overrun the inbox.

Changed op tests

  • op_tests/multigpu_tests/test_custom_allreduce_lamport.py (new). Runs each TP as two process groups, Lamport on and off.
    • Times the production call in CUDA graphs on both capture paths.
    • Forces each Lamport kernel at every size it fits, to tune the 1shot/2shot/origin boundaries.
    • Checks bitwise rank-order sums and the 0xffff sentinel.
    • Covers inbox re-arm across resizes and mixed-alignment copy-in.
  • Not redundant: test_custom_allreduce.py checks origin_custom_ar against a tolerance. It cannot force a kernel, compare Lamport on/off in one run, or catch a missed re-arm (stale data that is still numerically close).

🤖 Generated with Claude Code

@TennyWang1223
TennyWang1223 requested a review from a team November 4, 2026 10:32
@github-actions

github-actions Bot commented Nov 4, 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 7452 --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 changed the title fea: impl lamport allreduce on gfx9 [HIP] fea: impl lamport allreduce on gfx9 Nov 4, 2026
@github-actions github-actions Bot added the HIP label Nov 4, 2026
@aiter-bot

aiter-bot commented Nov 4, 2026 •

Copy link
Copy Markdown

READY FOR HUMAN REVIEW

PR Self-Review

Revision d0b868b47a1d · mode shadow

Author self-review accepted. Readiness report:

Author answers

  • PASS — current-SHA answers are present and structurally specific
Show the author's self-review answers

Behavior and intent

- **What changes:** on gfx942/gfx950, `tensor_model_parallel_all_reduce` / `CustomAllreduce.all_reduce` for bf16/fp16 messages inside the ranges above runs `lamport_ar_1shot_ws` / `lamport_ar_2shot_ws` instead of `origin_custom_ar`. Copy-in calls skip the memcpy for those messages.
- **Why:** `origin_custom_ar` pays a cross-rank `Signal` handshake (twice for 2-stage). Lamport replaces it with data-as-signal inboxes: 1.00–1.53x faster across both archs inside the ranges.
- **Unchanged:** fp32, fp8 quant, `use_new=False`, messages above the caps, all_gather / reduce_scatter / all fused ops (AR + RMSNorm, AR + residual), and gfx1250.

Validation and unverified scope

Hardware: 8 × MI308X (gfx942), xGMI. Commands (with this repo on `PYTHONPATH`):

```bash
python3 op_tests/multigpu_tests/test_custom_allreduce_lamport.py                    # default sweep, up to 4 MB
python3 op_tests/multigpu_tests/test_custom_allreduce_lamport.py -m 1 2 4 8 16 32 64 128 256 512 1024 2048 4096  # up to 64 MB
python3 op_tests/multigpu_tests/test_custom_allreduce.py -d {bf16,fp16} -m {graph,eager}
python3 op_tests/multigpu_tests/test_custom_allreduce_fp8.py
python3 op_tests/multigpu_tests/test_custom_allreduce_rank_order.py
AITER_CUSTOM_AR_DISABLE_LAMPORT=1 python3 op_tests/multigpu_tests/test_custom_allreduce.py -d bf16 -m {graph,eager}
```

Results on d0b868b47 (gfx942):

- **Lamport sweep:** TP2/4/8 × H 7168/8192, 14 KB – 64 MB (156 cases) and the default 4 MB sweep (108 cases), both capture paths. Every Lamport and forced-kernel result matches the fp32 rank-order reference bit for bit, and the injected 0xffff sentinel comes out as NaN without a hang. The resize check and the unaligned-input check report 0 errors.
- **Dispatch:** Lamport is picked exactly inside the caps. Past them the time equals `origin_custom_ar` (0.98–1.03x, noise).
- **Regression:** all pass. Lamport on: `test_custom_allreduce.py` bf16 / fp16 × graph / eager, `test_custom_allreduce_fp8.py`, `test_custom_allreduce_rank_order.py` (no failed ranks). Lamport off: `test_custom_allreduce.py` bf16 graph / eager.

Unverified:

- **gfx950 on this revision.** The MI350X numbers above were measured before the caps and before the inbox shrink. Inside the caps the kernels are the same; past them it is the original dispatch. A re-run on MI350X is still to do.
- **`test_custom_allreduce_capture_registration.py` and `test_custom_allreduce_graph_buffer_reuse.py`:** fail in setup with torch 2.8 (no `torch._C._accelerator_setAllocatorSettings`), before any all-reduce. Need a newer torch.
- **End-to-end model runs:** not done. The fused AR + residual / AR + RMSNorm thresholds were not re-tuned.
- **MI250X:** not applicable (gfx90a has no Lamport path).

PR-specific question

Which arch, dtype and shape select the Lamport path, and what keeps other inputs out:

- **Arch / group:** gfx942 or gfx950, world size 2/4/8, env switch not set. All are checked in `_initLamport` and AND-ed across ranks. Otherwise `initLamport` never runs, `lamport_` stays null, and `lamportKernel` returns `none`.
- **Dtype:** 2-byte only. `lamportDispatch` requires `elem_size == 2` and `use_new`. `allreduce<T>` checks under `if constexpr (sizeof(T) == 2)`. The fp16 fp8-quant branch leaves `_all_reduce` before `allreduce<T>`.
- **Shape:** one-shot if bytes ≤ 128 KB (TP2) / 64 KB (TP4, TP8). Two-shot if bytes ≤ 2 MB / 1 MB and a multiple of `16 * tp`. Anything else runs `origin_custom_ar`. `allreduce<T>` already requires whole 16B packs.
- **Invariants:**
  - The pick depends only on numel and world size, so every rank runs the same kernel. Input alignment only decides the copy-in, not the kernel.
  - The dispatch caps never exceed the inbox capacity (`std::min` with `twoShotMaxBytes()`).
  - `runOneShot` / `runTwoShot` throw on anything past capacity rather than overrun the inbox.

Changed op tests

- `op_tests/multigpu_tests/test_custom_allreduce_lamport.py` (new). Runs each TP as two process groups, Lamport on and off.
  - Times the production call in CUDA graphs on both capture paths.
  - Forces each Lamport kernel at every size it fits, to tune the 1shot/2shot/origin boundaries.
  - Checks bitwise rank-order sums and the 0xffff sentinel.
  - Covers inbox re-arm across resizes and mixed-alignment copy-in.
- **Not redundant:** `test_custom_allreduce.py` checks `origin_custom_ar` against a tolerance. It cannot force a kernel, compare Lamport on/off in one run, or catch a missed re-arm (stale data that is still numerically close).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply
  • ADVISORY — Copilot did not review the current head SHA

Code and op-test hygiene

  • PASS — no committed artifact or conflict marker detected

Required CI

  • PASS — Black: passed
  • PASS — Ruff: passed
  • PASS — Repository dependency: passed
  • PASS — Aiter Test Gate: passed

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

- test_custom_allreduce_lamport.py: call endswith once with a tuple
  (ruff 0.16.0 PIE810)
- black-format test_custom_allreduce_lamport.py and the lamportAllReduce
  signature in aiter/ops/custom_all_reduce.py

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: TennyWang1223 <[email protected]>
- lamportKernel: two-shot up to 2MB at TP2, 1MB at TP4/TP8 (was 64MB).
  On MI350X (gfx950) the original dispatch is as fast or faster above
  these sizes (TP8 down to 0.90x); one set of caps keeps gfx942 and
  gfx950 free of regressions. gfx942 gives up its 1.01-1.27x two-shot
  gain above the caps.
- kLamportTwoShotMaxBytes 64MB -> 2MB: lamport IPC buffer per rank
  TP2/4/8 387.75/391.5/399MB -> 15.75/19.5/27MB.
- test_custom_allreduce_lamport.py: forced two-shot up to 2MB, default
  sweep up to 4MB (one size past the largest two-shot per n), resize
  check positions within the new two-shot capacity.

Verified on MI308X (gfx942): full lamport sweep (156 cases, bitwise),
test_custom_allreduce.py bf16 graph/eager. Not yet re-run on gfx950.

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

Copy link
Copy Markdown
Contributor

@aiter-bot review

@aiter-bot

Copy link
Copy Markdown

aiter-bot — queued behind 1 review(s); expect to start in about 50 min. The box reviews one PR at a time.

@aiter-bot aiter-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ROCm/aiter PR #7452 — [HIP] fea: impl lamport allreduce on gfx9

Review (advisory): ⚠️ NEEDS WORK
Validation (deterministic): NOT RUN — REVIEW_AUTO_VALIDATE=0 (auto-validation disabled) and no GPU access on this review box (permission denied to /dev/kfd, torch sees 0 devices), so the multi-GPU target op_tests/multigpu_tests/test_custom_allreduce_lamport.py could not be run; environment gap, not a PR defect
Perf (advisory): NOT RUN — no usable GPU on this review box (the harness needs 2–8 ranks); environment gap, not a PR defect — the PR's own base-vs-head tables (origin via AITER_CUSTOM_AR_DISABLE_LAMPORT=1 vs the default dispatch, 20-replay medians of a 10-call graph, slowest rank, both archs, both capture paths) are the author's runs, unverified here

⚠️ [verified] The lamport path is on by default on gfx950 (_LAMPORT_GFX = ("gfx942", "gfx950") in aiter/dist/device_communicators/custom_all_reduce.py), but per the PR's own unverified list the exact head revision was never run on gfx950 — the MI350X tables predate the dispatch caps and the inbox shrink — so an arch-specific lamport defect would hang every TP rank on MI350X with no test having ever executed there. Author must re-run test_custom_allreduce_lamport.py on gfx950 at this head (or drop gfx950 from _LAMPORT_GFX until that run exists) before merge.

⚠️ [verified] The only test of the new path runs solely under the opt-in ci:multi-gpu label (for PRs, aiter-test.yaml gates the multigpu job on that label and aiter_test.sh's standard job scans only op_tests/ and tests/ at maxdepth 1), and PR #7452 carries just the HIP label — so this default-on change to the collective every TP model uses would merge with zero CI execution. Author must add the ci:multi-gpu label so the 8-GPU job actually runs op_tests/multigpu_tests/test_custom_allreduce_lamport.py.

📝 [verified] The PR states the fused AR + residual / AR + RMSNorm crossovers (_AR_RESIDUAL_MAX_BYTES, should_fuse_ar_rms in aiter/dist/device_communicators/custom_all_reduce.py) were not re-tuned, and since the PR's own tables claim plain all-reduce is up to ~1.5x faster inside the lamport caps, some fused-vs-plain decisions may now sit on the wrong side of the crossover. Reviewer should ask whether the threshold re-tune is tracked as a follow-up.

📝 [verified] kLamportMaxPacks = 512 * 80 in csrc/include/custom_all_reduce.cuh (the 640KB one-shot inbox) states its purpose — the forced-kernel tuning ceiling — but not where 512*80 itself comes from, so a future resize of the one-shot range has no stated basis to start from. Reviewer should ask for the derivation next to the constant.

@zufayu
zufayu merged commit 3bd3851 into main Nov 5, 2026
@zufayu
zufayu deleted the lamport_ar_gfx9 branch November 5, 2026 09:03
TennyWang1223 added a commit that referenced this pull request Nov 6, 2026
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]>
cpersson-amd added a commit to cpersson-amd/aiter that referenced this pull request Nov 6, 2026
Resolve the custom_all_reduce.cu conflict (keep main's useFp8Quant and
lamportSkipsCopyIn helpers) and adapt the dispatch to the lamport path
of ROCm#7452, which runs ahead of every other path and has no addend input:

- allreduce: with an addend, lamport reduces the staged sum unless the
  fused LL / LL128 add is faster (fused_add_beats_lamport). On gfx950
  that is TP2 up to the fused caps, TP4 up to 48 KB, TP8 up to 24 KB;
  elsewhere lamport, as for a separate add.
- runs_one_shot / uses_1stage_ar: ask lamportDispatch first (lamport
  one-shot counts as one-shot, two-shot does not).
- test_custom_allreduce_add.py: cover the 24 / 48 KB cutovers and the
  lamport one-shot / two-shot boundaries (59 sizes).
josh-schell-amd added a commit to josh-schell-amd/vllm that referenced this pull request Nov 9, 2026
…gments test

AITER v0.1.29 (ROCm/aiter#7452) enables lamport all-reduce by default on
gfx942/gfx950. For 2-byte messages up to 2 MiB at TP2 it reads the input
in place and skips the copy-in to the registered buffer. The test's
(128, 8192) bf16 input is exactly 2 MiB, so the unguarded capture records
no memcpy and `capture_allreduce(unguarded) == 1` fails, although results
are correct. A 4 MiB message stays above every lamport limit, so it still
exercises the staging copy that the test guards.

Verified on MI355 with the build vllm-project#15798 image: the original test
fails with lamport on and passes with AITER_CUSTOM_AR_DISABLE_LAMPORT=1;
the updated test passes with lamport on and off; the full file passes
(6 passed).

Co-Authored-By: Claude <[email protected]>
Signed-off-by: josh schell <[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.

5 participants