Skip to content

[FlyDSL] [CI] fused all-reduce + Gemma RMSNorm: exact bf16 pull schedule (TP4 gfx950, H=6144) - #8574

Merged
TennyWang1223 merged 8 commits into
ROCm:mainfrom
ganyi1996ppo:pr-ar-pull
Nov 27, 2026
Merged

TennyWang1223 merged 8 commits into
ROCm:mainfrom
ganyi1996ppo:pr-ar-pull

Conversation

@ganyi1996ppo

@ganyi1996ppo ganyi1996ppo commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

At a glance

  • Change: adds "pull" as a third algorithm of quick_allreduce.ALGORITHMS: an exact (bf16, unquantized) fused all-reduce + residual add + Gemma RMSNorm that reads the ranks' CUDA-graph-registered inputs in place (TP4, gfx950, hidden 6144; rows 1..1024 since head 033c9381f, was 1..640).
  • What changes: a pull schedule (one-shot with read acks for 1-11 rows, one-row two-stage pull for 12-287, streamed pull with weight hoist for 288-640) that reads peers' registered buffers directly; the arithmetic matches amd-kernels' reference (bit-exact, 0 mismatches of 5.66e9 elements). Which part of the schedule gives the gain was not ablated (see the open points below).
  • How much (MI355X gfx950, TP4, graphs of 64 calls, ABAB, max over ranks, through tensor_model_parallel_fused_allreduce_rmsnorm(gemma_norm=True) vs the current aiter path): M=8 8.25-8.49 -> 6.34-6.44 us, M=32 13.4 -> 8.6, M=128 24.3-24.7 -> 18.6-18.7, M=384 56.7-56.8 -> 48.0-48.3 us.
  • End to end: not measured.
  • Stack order: independent; no ATOM change needed (ATOM's capture already enters aiter graph_capture()).
  • Policy table (head 033c9381f): the payload window and the kernel tiers now come from allreduce_policy (FamilyPolicy.pull, FUSED_PULL_LADDER / the pull entry of fused_allreduce_ladders.json, AITER_FLY_AR_FUSED_PULL_{MIN,MAX}_BYTES, digest vote); see the section below. AITER_FLY_AR_PULL remains a kill switch only.
  • Open design points: no ablation of which part of the schedule gives the gain (the forced-kernel table below compares the kernels with each other, not with the old path's parts); the pull engine is still graph-capture only and a separate backend class.

What

Adds "pull" as a third entry of quick_allreduce.ALGORITHMS: an exact (bf16, unquantized) fused all-reduce + residual add + Gemma RMSNorm that reads the ranks' CUDA-graph-registered inputs in place. The host keeps one interface: FlyQuickAllReduceRMSNorm(algorithm="pull").allreduce_rmsnorm(..., gemma_norm=True); tensor_model_parallel_fused_allreduce_rmsnorm(gemma_norm=True) picks it inside graph captures, so every model that uses the fused op benefits (no ATOM change needed: ATOM's capture already enters aiter graph_capture() -> CustomAllreduce.capture()).

Scope (PR1): TP4, gfx950, hidden 6144, rows 1..640 (decode tiers): one-shot with read acks (1-11), one-row two-stage pull (12-287), streamed pull R2/R4 with weight hoist (288-640). Everything else (other widths/TP/arch, rows > 640, calls outside a registered capture) falls through to the existing paths unchanged. Follow-ups, not here: rows 641+ (batch pull / lossless coded), MXFP8 emit, MoE slots4, unregistered (eager) path.

Design

  • ALGORITHMS["pull"]: new _Algorithm.registered=True, no ladders/super-tiles, rs_codecs=ag_codecs=("bf16",) (identity wire format, so _resolve_codecs and the codec checks need no special case; int4/5/6/fp16 on pull raise, bf16 on mesh/ring raises; plain FlyQuickAllReduce(algorithm="pull") raises: fused-only).
  • FlyQuickAllReduceRMSNorm delegates to PullAllReduceRMSNorm (own IPC flag buffer + address table of registered inputs; capture() exchanges handles at capture end).
  • Dispatch: CudaCommunicator.fused_allreduce_rmsnorm tries it first for gemma_norm calls; AITER_FLY_AR_PULL=1/0 forces on/off, unset follows AITER_FLY_AR=1. Off/neutral otherwise.
  • Algorithm, flag protocols, tier thresholds and arithmetic are ported from amd-kernels (norm/gemma_add_rmsnorm_h6144/allreduce_add_rmsnorm), credited in file headers; no amd_kernels import. Legacy buffer_ops like the sibling mesh/ring kernels; raw atomics/inline asm/DPP justified in the kernel header.

Verification (MI355X, TP4, 034 GPUs 0-3)

  • Bit-exactness vs amd-kernels' own registered AR+norm, rows 1..384 + 385/400/480/481/500/640, 3 graph replays on fresh data each (incl. denormal/zero entries): residual_out and out 0 mismatches of 5.66e9 elements; through tensor_model_parallel_fused_allreduce_rmsnorm(gemma_norm=True) in aiter graph_capture() (input produced inside the capture): 0 / 0 of 1.19e8.
  • Latency, graphs of 64 calls, 21 rounds, median, max over ranks, ABAB; aiter pull / amd-kernels over 3 repeats and 19 row counts: 0.97-1.012 (M=8: 6.26/6.28/6.47 vs 6.45/6.38/6.44 us; M=32 8.60 vs 8.65; M=128 18.75 vs 18.69; M=384 47.93 vs 47.94; M=640 78.7 vs 78.3).
  • Through the interface vs current aiter path (AITER_FLY_AR_PULL=0, same graphs): M=8 8.25-8.49 -> 6.34-6.44 us, M=32 13.4 -> 8.6, M=128 24.3-24.7 -> 18.6-18.7, M=384 56.7-56.8 -> 48.0-48.3 us.
  • Tests: op_tests/flydsl_tests/test_flydsl_quick_allreduce_codec.py (175 passed), new TP4 op_tests/multigpu_tests/test_flydsl_pull_allreduce_rmsnorm.py (every tier edge, fp32 two-stage reference: residual exact, out <= 1 bf16 ulp). Note CI does not scan these two directories (multigpu needs the label); run manually.
  • Numerics: residual equals AITER's two-stage fp32 rank sum except a rare fp32 summation-order difference (none observed here); norm follows gemma_add_rmsnorm (Triton tl.sum order).

Policy-table update (head 033c9381f, commits 6aa02d0e1 + 033c9381f)

What changed. The hard-coded gate (rows 1..640, hidden 6144, tier edges in pull_allreduce_rmsnorm.py) is gone; routing comes from the table:

  • Level 1: FamilyPolicy.pull (a payload Window) in FUSED_FAMILY_POLICIES; gfx950 / xGMI / TP4 = rows 1..1024 of 6144 bf16 (Window(0, 12300 KiB)); no other platform has one. Override: AITER_FLY_AR_FUSED_PULL_{MIN,MAX}_BYTES (MAX=0 switches it off; ignored where there is no pull ladder, like the other families). The plain tables are unchanged.
  • Level 2: per-width pull ladder (FusedPullRung: min_bytes, kernel = oneshot / pull (wave) / stream (rows_per_wg, hoist)) in fused_allreduce_ladders.json, no default ladder (a width without an entry is not served); the file loader validates it (pull is an optional platform key, schema version unchanged).
  • The engine (PullAllReduceRMSNorm) takes the window and the ladders, has no thresholds of its own, and refuses a ladder that reaches the one-row kernels above 640 rows (they hang: every workgroup must be resident; 768 rows timed out). FlyDSLPullAllReduceRMSNorm resolves the fused policy, votes on a digest of window + ladders (so ranks with different env / ladder files decline together) and builds it. AITER_FLY_AR_PULL stays tri-state: 0 kills, 1 builds without AITER_FLY_AR, unset follows AITER_FLY_AR=1.
  • New AITER_AR_ROUTE_TRACE=<path> counts which backend served each fused all-reduce call (rows, width, captured or eager), per rank.

Measured (MI355X, TP4, hidden 6144 Gemma, through the interface in graph_capture, graphs of 64 calls, 21 ABAB rounds, median, max over ranks; op_tests/multigpu_tests/bench_fused_ar_rms_gemma.py, full tables in docs/flydsl_pull_ar_m31.md). Every one of 431 cells: residual_out bit-exact against the fp32 two-stage reference, out within 1 bf16 ulp. us per call, interface (pull) / aiter without pull / custom fused 2-stage / unfused all-reduce + rmsnorm2d_fwd_with_add:

rows pull (interface) without pull custom 2-stage unfused
8 6.49 8.45 8.53 8.09
32 8.79 13.93 11.44 10.96
128 19.23 26.68 26.58 23.08
256 33.82 41.81 41.77 38.18
384 49.22 58.66 58.53 54.24
512 64.09 73.89 73.91 69.06
640 79.71 89.74 89.60 85.28
768 95.62 105.85 105.52 101.74
1024 127.41 138.26 137.93 130.22

The pull path is the fastest exact candidate at every one of the 20 row counts 1..1024 (2.2% to 29% ahead of the best other one). The FlyDSL one-shot / quick-reduce fused ops decline gemma_norm, so they cannot serve this call. Kernel fit (each pull kernel forced on every row): streamed 2 rows per workgroup from 257 rows (1-4% ahead of the one-row kernels from there on), 4 rows per workgroup from 513 (1.4-2.3% ahead of 2 rows from 528 on); the edges inside run-to-run noise (one-shot vs pull at 11-16, block vs wave hand-offs at 36-37 and 96-97) keep the PR's tiers. Window beyond 640: the streamed R4 kernel at 641-1024 rows is 6.3-6.5% (768-896 rows) and 2.2-3.3% (960-1024) ahead of the unfused pair, three repeats each (table in docs/flydsl_pull_ar_m31.md).

Not faster, not routed to: the custom fused kernel (custom_fused_ar_rms, 1- and 2-stage) is never the fastest candidate for Gemma at hidden 6144 here: the unfused pair is 2.5-15% faster than the best of the two at every row count of the table above, 3.6-5% at 2048-4096 rows (graph 252.9 vs 263.7 us at 2048, 493.5 vs 512.9 at 4096; eager 264.7 vs 275.2, 511.2 vs 537.2). Rows above 1024 and eager calls still go to the custom fused kernel in this PR (a separate routing decision, not changed here).

Runtime evidence (real MiniMax-M3.1 TP4 server, public FsW stack with this tree's aiter, AITER_FLY_AR_PULL=1 as in the recipe). Route trace (per rank, ranks agree): all 120 fused all-reduce + Gemma RMSNorm calls per forward (2 per layer + the final norm) of every captured decode graph (batch 1..64 x (k+1=8) = 8..512 rows) and every prefill token graph (256 / 512 / 1024 rows) are pull: rows 8 one-shot, 16-32 and 112-256 pull block, 40-96 pull wave, 320-512 stream R2, 1024 stream R4. Only the warm-up calls before each capture and one eager 1146-row prefill step (above the window) went to custom_fused_ar_rms_2stage. Sequence-parallel prefill (4096+ tokens) uses no all-reduce. A graph records its calls once, so the trace shows the kernels the replayed graphs contain, not replay counts.

Tests. 296 CPU policy tests pass in the p1 container with GPUs hidden (window / ladder resolution for the M3.1 rows, env overrides, digest changes with window or rungs, loader rejects, engine refuses a hanging ladder, route trace); the TP4 test_flydsl_pull_allreduce_rmsnorm.py now covers 19 row counts to 1024 and declines 1025: PASSED (head tree).

Not done: no end-to-end A/B of the server with and without pull at c8..c64 (the kernel-level numbers above are graph replays; the route trace shows the kernels are reached); no ablation of which part of the pull schedule gives the gain.

Size / review

~1.9k added lines (kernels 0.87k, engine 0.44k, rest glue/tests/README) in two commits (kernels+engine+algorithm entry; dispatch). A split below 1000 lines has no self-consistent intermediate state, so it is one PR.
Review: repo review-pr rules applied by hand to the diff (size, env knob HK9 -> tri-state kill switch, test prints, arch via get_gfx_runtime); GPU validation run manually as above.

Review-fix update (head d0299ccb6)

  • accepts() declines CPU / other-GPU optional outputs and overlapping out / residual_out (same buffer or intersecting byte spans), and residual_in.stride(0) >= 2**31; FlyQuickAllReduceRMSNorm.accepts forwards out / residual_out.
  • The registered branch forwards the caller's stream.
  • The row-offset products are Int64 (fx.Int64(rw) * (fx.Int64(i32_sr) * fx.Int64(2)) at the three sites).
  • The process-wide launcher factories are keyed by device index.
  • The TP4 test prints a graph-replay table (50 replays per tier edge).

Re-verified on gfx950 TP4 (4 GPUs, overlay with this PR head's python tree on an older aiter image): test_flydsl_pull_allreduce_rmsnorm.py PASSED (all 15 tier-edge row counts x 3 replays, the new accepts() assertions for CPU, other-GPU, same-buffer and overlapping destinations, disjoint destinations accepted). Graph replay us (rank 0, 50 replays): rows 1: 15.7, 8: 14.8, 12: 12.0, 37: 14.2, 96: 20.8, 256: 38.3, 288: 42.4, 384: 54.4, 480: 64.1, 640: 83.9. Not tested on GPU: the stride >= 2**31 decline (needs an 8 GiB storage) and the Int64 widening beyond "no regression" (test strides are small), two engines on two devices in one process.

Reproduce (TP4): python3 op_tests/multigpu_tests/test_flydsl_pull_allreduce_rmsnorm.py; CI does not scan these directories for this test (multi-GPU needs the label), so it is run manually.

PR Self-Review

Reviewed revision

033c9381f (earlier revision d0299ccb6; the policy-table update is in the section above, reviewed by hand against the repo review rules: dispatch gates, rank-agreement vote, hang guard, tests that fail on revert, black + ruff clean)

Behavior and intent

Adds an exact bf16 pull schedule for the fused all-reduce + Gemma RMSNorm of the TP4 decode tiers on gfx950. The existing fused path is about 1.2-1.6x slower at the same shapes (numbers above).

Validation and unverified scope

Commands, hardware and results are in the Verification and review-fix sections (gfx950 MI355X, TP4): bit-exactness vs amd-kernels' own registered AR + norm over rows 1..384 and 385 / 400 / 480 / 481 / 500 / 640, latency ABAB over 19 row counts (pull / amd-kernels 0.97-1.012), test_flydsl_quick_allreduce_codec.py 175 passed, the new TP4 test. Not verified: any ablation of why it is faster; the interface-unification question above; end-to-end effect; rows > 640, other TP, other widths and eager (unregistered) calls fall through to the existing paths unchanged and are not covered by this PR.

PR-specific question

What behavior would each changed op test fail on before this PR, and why is that coverage not already provided by an existing canonical test?

On main algorithm="pull" does not exist (the codec test asserts it raises where it must, the TP4 test needs the new engine), and no existing test runs a registered-capture fused AR + Gemma norm at the tier edges.

Changed op tests

  • op_tests/flydsl_tests/test_flydsl_quick_allreduce_codec.py: extended with the pull entry of ALGORITHMS: its codecs are bf16 only (int4/5/6/fp16 on pull raise, bf16 on mesh/ring raises, plain FlyQuickAllReduce(algorithm="pull") raises). It is the canonical codec-resolution test, so the cases belong here.
  • op_tests/multigpu_tests/test_flydsl_pull_allreduce_rmsnorm.py: new TP4 test: every tier edge against an fp32 two-stage reference (residual exact, out within 1 bf16 ulp), 3 graph replays on fresh data each, the accepts() declines (CPU, other-GPU, same-buffer, overlapping destinations) and a graph-replay timing table. It is not redundant: no existing multi-GPU test captures a registered fused AR + Gemma norm.

Review-fix update (head 707f7a7b1)

  • accepts() generalizes the overlap check: a destination (out, residual_out) is now declined
    against every source (inp, residual_in, weight) too, not only against the other destination,
    unless it is the exact same tensor (identical data_ptr/shape/stride -- the one case with no
    cross-row hazard). Found by Copilot: a contiguous residual_out shifted one row from
    residual_in (or inp shifted from out, or out landing on weight's storage) passed every
    existing check.
  • CustomAllreduce.capture() only enters fly_pull.capture() when self._register_for_capturing
    is True (the rank-agreed _agree_capture_path() decision): previously pull always registered its
    captured inputs, even when every rank had just agreed to use copy-in (expandable_segments
    active, or the host opted out via enable_register_for_capturing=False, e.g. ATOM's PIECEWISE
    graphs) -- found by a human P2 review (not reproduced in our environment; fix is a direct read of
    the flag _agree_capture_path() already computes).
  • bench_fused_ar_rms_gemma.py's forced single-rung engines used an unbounded window, so
    _check_ladder() measured each one-rung ladder against the physical max_rows=1024 instead of
    its own kernel's cap (oneshot 16, pull 640): the documented --rows 8 64 512 command raised
    ValueError at setup before running anything. Bounded each forced engine's window to its kernel's
    cap; also gated main() on 4 visible GPUs + gfx950, and added the script to
    .github/scripts/aiter_test.sh's skip_tests (no assertions, should not run as a CI test).
  • New TP4 test test_pull_allreduce_rmsnorm_back_to_back_tp4: many pull calls of mixed row counts
    (crossing tier edges both ways) inside one captured graph, replayed 3x on fresh inputs, every
    output checked -- the gap the P2 review found in the one-call-per-graph test above (that test
    still only exercises the engine directly, not the CudaCommunicator.fused_allreduce_rmsnorm -> CustomAllreduce.capture() -> pull dispatch route; bench_fused_ar_rms_gemma.py exercises that
    route but asserts nothing).

Re-verified on gfx950 TP4 (MI355X, node 034 GPUs 0-3): test_pull_allreduce_rmsnorm_tp4 and
test_pull_allreduce_rmsnorm_back_to_back_tp4 both PASS; bench_fused_ar_rms_gemma.py --rows 8 64 512 --rounds 2 --ncall 4 completes for every tier (previously aborted at setup for pf_oneshot /
pf_pull_* before the window fix). Not re-tested: the capture-path gating fix itself (expandable_segments
is off in this environment, as the reviewer also noted for theirs), and the pull-vs-other-backends
registration in a shared perf/correctness harness (left as a follow-up / open question, not a code fix).

🤖 Generated with Claude Code

ganyi1996ppo and others added 2 commits November 24, 2026 07:31
…TP4 gfx950, hidden 6144)

Adds "pull" as the third entry of quick_allreduce.ALGORITHMS. It is fused-only
and moves bf16 rows in place (identity codec "bf16", no ladder), so the host
keeps one interface: FlyQuickAllReduceRMSNorm(algorithm="pull").
allreduce_rmsnorm(gemma_norm=True) delegates to PullAllReduceRMSNorm, which
registers the CUDA-graph inputs of the ranks (capture()) and launches one of
three kernels by rows: one-shot with read acks (1-11), one-row two-stage pull
(12-287), streamed pull (288-640).

Algorithm, flag protocols, tier thresholds and arithmetic are ported from
amd-kernels (norm/gemma_add_rmsnorm_h6144/allreduce_add_rmsnorm), credited in
the file headers; no amd_kernels import.

Co-Authored-By: Claude <[email protected]>
…side graph captures

CudaCommunicator.fused_allreduce_rmsnorm tries the pull schedule first for
gemma_norm calls recorded in a graph capture; CustomAllreduce.capture()
(entered by graph_capture()) registers the captured inputs. Calls outside a
registered capture, other widths/row counts and other archs fall through to
the existing paths unchanged. AITER_FLY_AR_PULL=1/0 forces it on/off; unset it
follows AITER_FLY_AR=1.

Co-Authored-By: Claude <[email protected]>
@ganyi1996ppo
ganyi1996ppo requested review from a team and a balanced review from Copilot November 24, 2026 13:32
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

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

Extended tests (opt-in via labels):

Label Tests
ci:mi300x Run Aiter standard tests on MI300X in PRs; main branch always runs them
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 Radeon R9700 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 8574 --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.

Reviews:
A reviewer is usually assigned within one working day after the PR is ready for review (see Code Review Process). If nobody has responded for about a week, mention the area contact listed in CONTACTS.md. Want to help review? See REVIEWERS.md.

@aiter-bot

aiter-bot commented Nov 24, 2026 •

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision 707f7a7b1392 · 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. What permissions and untrusted-input boundary does this CI change have, and can fork PR code or text reach a privileged execution path?
  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 — Reviewed revision must contain at least the first 7 characters of the current head SHA
  • FAIL — changed op test not explained in Changed op tests: op_tests/flydsl_tests/test_flydsl_allreduce_policy.py
  • FAIL — changed op test not explained in Changed op tests: op_tests/multigpu_tests/bench_fused_ar_rms_gemma.py
  • FAIL — changed op test not explained in Changed op tests: op_tests/test_ar_route_trace.py

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

@ganyi1996ppo

Copy link
Copy Markdown
Contributor Author

Re-verified on the rebased head (62cb8de + this PR, MI355X TP4, 034 GPUs 4-7): AITER_FLY_AR_PULL=1, tensor_model_parallel_fused_allreduce_rmsnorm(gemma_norm=True) inside aiter graph_capture() (input produced inside the capture), rows 1, 8, 11, 12, 40, 96, 128, 287, 288, 384, 480, 640 (all three tiers), 3 replays each, vs amd-kernels: residual_out 0 and out 0 mismatches of 175,104,000 elements.

🤖 Generated with Claude Code

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved critical defects can trigger unsupported HIP IPC exports when registration is disabled and allow GPU writes to CPU or wrong-device output memory.

4 open issues
What changed in this PR

Adds an unquantized bf16 “pull” schedule to AITER’s fused all-reduce, residual-add, and Gemma RMSNorm path. It targets registered graph captures on four gfx950 GPUs, hidden size 6144, and 1–640 rows, with existing backends retained as fallbacks.

Changes:

  • Adds three row-tiered pull kernels and an engine for input registration and IPC management.
  • Integrates pull into the existing host interface, communicator dispatch, capture lifecycle, and environment controls.
  • Adds codec checks, multi-GPU numerical tests, and documentation.
File Description
op_tests/​multigpu_tests/​test_flydsl_pull_allreduce_rmsnorm.py Tests captured pull execution and numerical results across tier boundaries.
op_tests/​flydsl_tests/​test_flydsl_quick_allreduce_codec.py Tests pull’s bf16-only codec and fused-only restrictions.
aiter/​ops/​flydsl/​quick_allreduce.py Adds the pull algorithm and delegates registered execution.
aiter/​ops/​flydsl/​pull_allreduce_rmsnorm.py Implements registration, validation, tier selection, and launches.
aiter/​ops/​flydsl/​kernels/​comm/​README.md Documents pull’s scope, arithmetic, and controls.
aiter/​ops/​flydsl/​kernels/​comm/​quick_allreduce_pull.py Implements one-shot, two-stage, and streamed pull kernels.
aiter/​ops/​flydsl/​allreduce_policy.py Declares pull’s identity bf16 wire format.
aiter/​dist/​device_communicators/​flydsl_backends.py Adds collective backend setup and enablement controls.
aiter/​dist/​device_communicators/​custom_all_reduce.py Connects pull setup, capture registration, and cleanup.
aiter/​dist/​device_communicators/​communicator_cuda.py Routes eligible Gemma calls to pull before existing backends.

Review effort: Balanced

Comment thread aiter/ops/flydsl/quick_allreduce.py Resolved
Copilot AI balanced review requested due to automatic review settings November 24, 2026 13:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved critical defects in output validation, device-bound launcher caching, stream forwarding, and stride arithmetic can cause invalid GPU writes, broken execution ordering, or incorrect results.

6 open issues

Review effort: Balanced

…erlap checks on outputs, forward stream, per-device launchers; test additions

Co-Authored-By: Claude <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 26, 2026 01:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Unresolved critical issues can trigger unsupported IPC exports, leave peer ranks blocked when an export fails, and corrupt results when overlapping tensors are accepted.

2 open issues
2 previously missed issues

In code that hasn't changed since last review

High severity Handle export failures collectively and clear pending inputs

aiter/​ops/​flydsl/​pull_allreduce_rmsnorm.py:268

If an input export fails on one rank, that rank exits before the metadata broadcast while its peers enter the collective and wait until timeout; an input allocated earlier under expandable segments can trigger this even after the allocator setting is disabled. The pending input entries also remain because registration runs outside capture()'s exception handler. Exchange export success on every rank before broadcasting metadata, and discard pending entries on all ranks when export fails.

High severity Reject unsafe overlapping input and output views

aiter/​ops/​flydsl/​pull_allreduce_rmsnorm.py:338

At 12 rows, inp=a[:12] and out=a[1:13] pass accepts(), allowing one workgroup to overwrite the next row before its reducer reads it. Shifted overlaps with residual_in and outputs overlapping the shared weight are also accepted and can corrupt values that other workgroups still need. Check both destinations against every read operand across all tiers, allowing only proven row-preserving aliases, and add shifted-view regression cases.

4 resolved since last review

Review effort: Balanced

@zufayu

zufayu commented Nov 26, 2026

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 23 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 #8574 — [FlyDSL] fused all-reduce + Gemma RMSNorm: exact bf16 pull schedule (TP4 gfx950, H=6144)

Review (advisory): ⚠️ NEEDS WORK
Validation (deterministic): NOT RUN — auto-validation disabled (REVIEW_AUTO_VALIDATE=0), and the triaged target (op_tests/multigpu_tests/test_flydsl_pull_allreduce_rmsnorm.py) needs 4 gfx950 GPUs while this box is gfx942, so the run would skip the changed path here anyway; the PR's own MI355X TP4 evidence (bit-exact residual, ≤1 bf16 ulp out, every tier edge, 3 replays on fresh data) is self-reported and was not re-run.
Perf (advisory): NOT RUN — the target ships no benchmark entry point the perf stage can drive, and the PR adds the pull path itself so base has no counterpart to time; the PR's own A/B numbers (same graphs, AITER_FLY_AR_PULL=0 vs 1, MI355X TP4: M=8 8.25-8.49 → 6.34-6.44 us, M=32 13.4 → 8.6, M=128 24.3-24.7 → 18.6-18.7, M=384 56.7-56.8 → 48.0-48.3 us) were not re-run on this box.
Size: 1971 lines / 10 files — over the review bar
Design (advisory): SPLIT — the natural seams are the PR's own two commits: (a) the schedule itself (quick_allreduce_pull.py + pull_allreduce_rmsnorm.py + the ALGORITHMS entry + PULL_CODECS + the tests — self-consistent, nothing dispatches to it yet), (b) the serving wiring (communicator_cuda.py dispatch + custom_all_reduce.py capture/close + flydsl_backends.py); the underlying decision — reading the ranks' graph-captured inputs in place through an IPC address table instead of copying through an inbox, which forces the capture-registration coupling, the fused-only restriction and the row tiers — rides in (a).
Human: recommend vpietila-amd review whether the registered-inputs pull contract is right for the serving path in PR #8574 — in-place IPC reads of graph-captured inputs with generation-tagged flag protocols (vs extending the existing one-shot/mesh engines), and whether its failure modes (a single-rank export failure blocking peers in the capture-end broadcast; two graphs sharing a row count racing the per-row counts on concurrent streams) are acceptable in production.

⚠️ [verified] The only timing evidence for the PR's claimed 1.3-1.6x decode-latency gain is the PR's own self-reported numbers; the repo ships no benchmark entry point for the pull schedule (the TP4 test prints a replay-timing table but is not a harness the perf stage can drive, and base has no pull path to compare against), so nothing outside the PR has re-run the measurement and a future regression in the tier thresholds would be invisible to CI. Author must add the pull candidate to a runnable benchmark harness (e.g. the shared comm benchmark) so the gain and the tier crossovers are reproducible on a gfx950 box.

📝 [verified] The two test files this PR adds land where no CI job of this PR will run them: op_tests/flydsl_tests/test_flydsl_quick_allreduce_codec.py sits in a subdirectory the standard job never collects (find op_tests -maxdepth 1 in .github/scripts/aiter_test.sh) and op_tests/multigpu_tests/test_flydsl_pull_allreduce_rmsnorm.py needs the ci:multi-gpu label (aiter-test.yaml), which this PR does not carry — the PR description discloses this ("run manually"), so the codec contract and the TP4 numerics have no automated regression guard on future PRs. Author should add the ci:multi-gpu label to this PR (and consider placing the codec tests where the standard job collects them).

2 finding(s) posted inline, on the lines they are about:

  • aiter/ops/flydsl/pull_allreduce_rmsnorm.py:351-376 — register_graph_buffers (aiter/ops/flydsl/pull_allreduce_rmsnorm.py:351-376) exports the captured inputs…
  • aiter/ops/flydsl/pull_allreduce_rmsnorm.py:267-321 — accepts (aiter/ops/flydsl/pull_allreduce_rmsnorm.py:267-321) checks out/residual_out against the input…

@ganyi1996ppo

Copy link
Copy Markdown
Contributor Author

Status of the bot reviews (Copilot 6040221997, 6040369447, 6067381291; aiter-bot 6067947363), head d0299cc:

  • Copilot inline items 4680810802, 4680810866, 4680810936, 4680930413, 4680930527: fixed in d0299cc, see the thread replies. 4680811023 (shared benchmark harness): partly addressed (graph-replay timing table added), the harness registration is decision pending.
  • Copilot 6067381291 "previously missed" items (collective export-failure handling and clearing pending inputs; overlapping inp/out/residual_in views): same as the two aiter-bot inline findings; acknowledged, tracked, fix not pushed yet.
  • aiter-bot 6067947363: size/SPLIT note and ci:multi-gpu label: acknowledged, decision pending (maintainer/author; labels are not changed by this task). Perf-harness request: acknowledged, decision pending. Self-reported numbers: reproduction commands are in the description.

aiter-bot Self-Review, queue and CI Guide comments: the PR Self-Review section in the description covers the current head and the bot refreshes its comment on its own; nothing further to answer there.

ganyi1996ppo and others added 2 commits November 26, 2026 00:36
…adder come from the fused policy tables

The pull schedule no longer gates itself on hard-coded rows (1..640) and tier
edges. Its payload window is the new `pull` field of the fused FamilyPolicy row
(gfx950 / xGMI / TP4: rows 1..1024 of 6144 bf16), moved by
AITER_FLY_AR_FUSED_PULL_{MIN,MAX}_BYTES like the other families, and its kernels
are the rungs of a per-width `pull` ladder in fused_allreduce_ladders.json
(FusedPullRung). A width without a ladder is not served. The engine refuses a
ladder that reaches the one-row kernels above the rows they are known to survive
(they hang when their grid cannot be resident). AITER_FLY_AR_PULL stays as a
kill switch only; the ranks vote on a digest of the window and the ladders.

Refit on the measured M3.1 shapes (MI355X TP4, graph replay, ABAB, max over
ranks, docs/flydsl_pull_ar_m31.md): the streamed kernel at 2 rows per workgroup
from 257 rows and at 4 rows per workgroup from 513, and the window extended to
1024 rows (3-6% ahead of the unfused pair, 7-8% ahead of the custom fused kernel
at 768-1024 rows; residual bit-exact, out within 1 ulp in every cell).

Co-Authored-By: Claude <[email protected]>
….1 pull measurement harness

AITER_AR_ROUTE_TRACE=<path> counts, per rank, which backend served each fused
all-reduce(+quant) call by rows and width (captures count once per recorded
call site). bench_fused_ar_rms_gemma.py times and checks every backend that can
serve the Gemma hidden-6144 call (interface, interface without pull, custom
fused 1-/2-stage, unfused, each pull kernel forced) in graph replay;
docs/flydsl_pull_ar_m31.md holds the measured table behind the pull ladder.

Co-Authored-By: Claude <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 26, 2026 06:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved critical issues can export unsupported allocations during capture and corrupt results through overlapping buffers, while benchmark setup and post-teardown rank tracing also remain defective.

4 open issues
1 resolved since last review

Review effort: Balanced

@TennyWang1223

Copy link
Copy Markdown
Contributor

Review: changes requested

Thanks for the PR. The kernel-side protocol looks solid. I checked count/flag epochs when the row count changes between calls, reduced-slot reuse, that a rank's input is not reused before peers finish reading it, the one-shot ACK table bound, Int64 offsets, and that accepts() decides the same way on every rank. I found no issues there. Two problems in the host integration and test coverage should be fixed before merge, plus one CI nit.

1. Pull registration bypasses CustomAllreduce's capture-registration gate [verified code path; crash inferred]

CustomAllreduce registers captured inputs in place only when that is safe. Otherwise it falls back to copy-in. There are two cases where it falls back:

The pull engine ignores both. custom_all_reduce.py:2252 always enters fly_pull.capture(), and PullAllReduceRMSNorm.accepts() / register_graph_buffers() always export the captured inputs.

Please: make pull follow the rank-agreed capture-time decision, declining when _expandable_segments_enabled() at capture() entry (voted like _agree_capture_path). Either honor enable_register_for_capturing = False, or document why the in-kernel read acks make the PIECEWISE hazard a non-issue for pull.

2. No asserting test for back-to-back calls or the real dispatch path [verified]

test_flydsl_pull_allreduce_rmsnorm.py records one call per graph and runs synchronize() + barrier() before every replay. So these are never asserted:

  • epoch/flag progression and reduced-slot reuse across consecutive calls in one graph
  • tier switches (oneshot / pull / stream) inside one graph
  • the route CudaCommunicator.fused_allreduce_rmsnorm → CustomAllreduce.capture() → pull

bench_fused_ar_rms_gemma.py does run 64 back-to-back calls, but it checks only the last call and asserts nothing.

Please: add a TP4 test that captures, inside graph_capture(), many back-to-back tensor_model_parallel_fused_allreduce_rmsnorm(gemma_norm=True) calls. Use distinct inputs/outputs per call and mixed row counts across tiers (e.g. 8, 64, 8, 300, 600, 64), and check every output against the fp32 reference.

3. Benchmark runs as a test in multi-GPU CI [verified]

aiter_test.sh runs every .py under op_tests/multigpu_tests/ that is not in skip_tests, so the main-branch Multi-GPU job (MI350X) will run bench_fused_ar_rms_gemma.py as a test. It has no assertions, so it can't fail on wrong results and only adds runtime.

Please: add op_tests/multigpu_tests/bench_fused_ar_rms_gemma.py to skip_tests in .github/scripts/aiter_test.sh, as is done for flydsl_allreduce_bench.py.

…the agreed capture path, fix bench forced-engine windows

Review round on ROCm#8574 (3 new Copilot inline comments + a human P2 review):

- PullAllReduceRMSNorm.accepts(): the existing out/residual_out overlap check did not cover a
  destination overlapping a source (inp, residual_in, weight). A contiguous residual_out shifted
  one row from residual_in, an inp shifted one row from out, or an out landing on weight's storage
  all passed every existing check. Added a general destination-vs-source (and destination-vs-
  destination) overlap check, with the exact-same-tensor case (identical data_ptr/shape/stride)
  exempted as the one proven-safe in-place mapping.
- CustomAllreduce.capture(): fly_pull.capture() was entered unconditionally, so the pull schedule
  registered (IPC-exported) its captured inputs even when _agree_capture_path() had just decided
  every rank must use copy-in (PyTorch expandable_segments active, or the host opted out via
  enable_register_for_capturing=False, e.g. ATOM's PIECEWISE graphs). Gated fly_pull.capture() on
  self._register_for_capturing, so pull declines every call in that capture exactly like the
  registered custom-allreduce path does, instead of registering unexportable pointers.
- bench_fused_ar_rms_gemma.py: the forced single-rung pull engines were built with an unbounded
  window, so _check_ladder() measured each one-rung ladder against the physical max_rows (1024)
  cap rather than its own kernel's known-good cap (oneshot 16, pull 640): the documented
  `--rows 8 64 512` command raised ValueError at setup before running anything. Bound each forced
  engine's window to (cap+1)*ROW_BYTES. Also gated main() on 4 visible GPUs and gfx950 (graceful
  skip instead of a crash on other hardware), and added the script to aiter_test.sh's skip_tests
  (it has no assertions, so it should not run as a multi-GPU CI test).
- test_flydsl_pull_allreduce_rmsnorm.py: new assertions for the three overlap gaps above, an
  exact-alias accept (rows=64, pull tier -- rows=8/oneshot declines any inp/out overlap including
  exact, by design, so is not a valid case for this check), and a new TP4 test
  (test_pull_allreduce_rmsnorm_back_to_back_tp4) that captures many back-to-back calls of mixed
  row counts (crossing tier edges both ways) in one graph and checks every output after replay --
  the gap the P2 human review found in the existing one-call-per-graph test.

Verified on TP4 (MI355X, gfx950, node 034 GPUs 0-3): test_pull_allreduce_rmsnorm_tp4 and
test_pull_allreduce_rmsnorm_back_to_back_tp4 both pass; bench_fused_ar_rms_gemma.py --rows 8 64
512 --rounds 2 --ncall 4 completes for all tiers (previously aborted at setup for pf_oneshot/
pf_pull_* before this fix).

Not fixed from the P2 review (needs a design decision, not a code fix): adding a test through the
real dispatch route (CudaCommunicator.fused_allreduce_rmsnorm -> CustomAllreduce.capture() ->
pull) with assertions -- bench_fused_ar_rms_gemma.py exercises that route but asserts nothing;
the new back-to-back test above goes through the engine directly, like the existing TP4 test.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 26, 2026 09:13
@github-actions github-actions Bot changed the title [FlyDSL] fused all-reduce + Gemma RMSNorm: exact bf16 pull schedule (TP4 gfx950, H=6144) [FlyDSL] [CI] fused all-reduce + Gemma RMSNorm: exact bf16 pull schedule (TP4 gfx950, H=6144) Nov 26, 2026
@github-actions github-actions Bot added the CI label Nov 26, 2026
@ganyi1996ppo

Copy link
Copy Markdown
Contributor Author

@TennyWang1223 thanks for the review. All three fixed in 707f7a7:

  1. Pull registration bypassing CustomAllreduce's capture-registration gate: real bug, fixed as you suggested. CustomAllreduce.capture() (aiter/dist/device_communicators/custom_all_reduce.py) now only enters fly_pull.capture() when self._register_for_capturing is True -- the same rank-agreed _agree_capture_path() decision the registered custom-allreduce path already follows. When expandable_segments is active or the host opted out (enable_register_for_capturing=False), pull now declines every call in that capture (its own accepts() already requires self._capturing, which this no longer sets) instead of registering an unexportable pointer. I did not reproduce the capture failure itself (expandable_segments is off in our environment, as you noted for yours too), but the fix is a direct, minimal read of the flag _agree_capture_path() already computes.

  2. No asserting test for back-to-back calls: added test_pull_allreduce_rmsnorm_back_to_back_tp4 in test_flydsl_pull_allreduce_rmsnorm.py -- one captured graph of 8 calls at mixed row counts (8, 64, 8, 300, 600, 64, 11, 12, crossing the oneshot/pull/stream tier edges both ways), replayed 3x on fresh inputs, every output checked against the fp32 reference. Passes on TP4 (MI355X gfx950, node 034 GPUs 0-3). This goes through the engine directly (PullAllReduceRMSNorm.allreduce_rmsnorm), like the existing TP4 test above it -- it does not add coverage of the CudaCommunicator.fused_allreduce_rmsnorm -> CustomAllreduce.capture() -> pull dispatch route itself; bench_fused_ar_rms_gemma.py exercises that route but asserts nothing (see 3). Registering the pull candidate in a shared correctness/perf harness against the other backends is a larger change I'm leaving for a follow-up / your call.

  3. Benchmark running as a test in multi-GPU CI: added op_tests/multigpu_tests/bench_fused_ar_rms_gemma.py to skip_tests in .github/scripts/aiter_test.sh, next to flydsl_allreduce_bench.py.

While verifying 3 I found the documented python3 op_tests/multigpu_tests/bench_fused_ar_rms_gemma.py --rows 8 64 512 command actually aborted at setup (unrelated to your review): the forced single-rung engines used an unbounded window, so _check_ladder() measured each one-rung ladder against the physical max_rows=1024 cap instead of its own kernel's cap (16 for oneshot, 640 for pull), raising ValueError before running anything. Fixed in the same commit (bounded window per rung) and added a 4-GPU gate + gfx950 gate to main() so it skips cleanly off that hardware. Verified: the documented command now completes for every tier.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Critical findings involving collective deadlocks, incorrect-device IPC mappings, and benchmark hangs require human assessment beyond the published review.

1 open issue
3 resolved since last review

Review effort: Balanced

@TennyWang1223 TennyWang1223 added the ci:multi-gpu Trigger multi-GPU op tests on PR label Nov 26, 2026
@TennyWang1223
TennyWang1223 merged commit a3ecc89 into ROCm:main Nov 27, 2026
149 of 155 checks passed
vpietila-amd added a commit that referenced this pull request Dec 1, 2026
Resolves the conflicts with #7093 (kernel-arg peers, device-memory
colours, magic-number codec rounding, gfx950/xGMI block-64 mesh rung)
and #8574 (fused-only "pull" schedule):

* mesh/ring take main's peer0..peer7 kernel arguments and
  device_colors; the Lamport mesh code uses main's self_inbox.
* The hier kernel moves to peer0..peer7 too, to match the host's
  shared launch arguments.
* "hier" and "pull" coexist in ALGORITHMS, _TWO_SHOT_CODECS and
  FamilyPolicy; both test blocks are kept.
* The gfx950/xGMI MESH_ST_LADDER keeps this branch's Lamport rungs in
  place of #7093's block-64 flag rungs.

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

Labels

ci:multi-gpu Trigger multi-GPU op tests on PR CI FlyDSL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants