Skip to content

[FlyDSL] route sequence-parallel reduce-scatter / all-gather to INT4 by payload size - #7819

Open
eppaneamd wants to merge 12 commits into
eppaneamd/flydsl-quickreduce-sp-rs-agfrom
eppaneamd/aiter-sp-router
Open

eppaneamd wants to merge 12 commits into
eppaneamd/flydsl-quickreduce-sp-rs-agfrom
eppaneamd/aiter-sp-router

Conversation

@eppaneamd

@eppaneamd eppaneamd commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Stacked on #7444 (base branch eppaneamd/flydsl-quickreduce-sp-rs-ag, so the diff shows only the router's own changes, not #7444's).

A sequence-parallel layer reduce-scatters a bf16 [T, H] activation over a tensor-parallel group and all-gathers it back. Its caller already has an exact collective for both (an IPC kernel, RCCL).

This PR adds SequenceParallelCollectives. Inside a size window for the platform it runs #7444's INT4 single-phase kernels. Outside it, it returns None, meaning "not served here, continue with the exact collective".

Why in AITER: the review of vllm-project/vllm#65628 asked for routing to the best kernel configuration in AITER instead of new arguments in vLLM. That PR is being reworked to ask this router and to carry no flag or environment variable of its own for it.

What changes

  • aiter/dist/device_communicators/sp_collectives.py (new)
    • create_sp_collectives(quick) takes the FlyQuickAllReduce the caller already has. It is a collective: every rank calls it, outside graph capture.
      • The ranks vote on their windows as plain data ((min, max) or None, so a rank without FlyDSL never unpickles a Window), then compile the single-phase kernels with compile_sp.
      • It returns None on every rank if FlyDSL is unavailable, a rank has no window for its platform, the windows differ, or the kernels cannot run.
    • reduce_scatter(inp) and all_gather(inp) return a tensor, or None for another dtype or rank, T not divisible by the group size (reduce-scatter), a payload outside the window, or a padded tensor of 4 GiB or more.
    • The router pads each rank's block with zero rows to a whole number of tiles (hidden 2560: a multiple of 16, 8 or 4 rows at TP 2, 4 or 8), copies a misaligned or non-contiguous input, and returns the result unpadded. The caller owns none of this.
  • aiter/ops/flydsl/allreduce_policy.py: SP_INT4_WINDOWS, keyed (arch, link, world_size), next to the other tuned decisions. One row: gfx950, xGMI, TP2, from 8 MiB. No row means no INT4 there. There is no environment override.
  • aiter/ops/flydsl/kernels/comm/README.md: documents the router.
  • Not changed: FlyQuickAllReduce, the all-reduce policy rows, and communicator_cuda.py (a rung there would apply INT4 to every aiter.dist group and caller).

How a call is decided:

  • The window counts the bytes of the full tensor (the reduce-scatter input, the all-gather output), not the padding. A block of a few rows is therefore never served because its padding fills whole tiles. The 4 GiB limit of the kernels applies to the padded bytes.
  • The decision depends on shape, dtype, window and platform only, so every rank of a group decides alike. A rank on the exact path while a peer runs INT4 would leave the peer polling for it.

Tests

  • tests/test_sp_collectives.py (CPU, 60 cases against a stand-in engine)
    • Hand-derived padding units and window boundaries, including the exact-8-MiB shape and the sent-versus-padded cases at H = 2560 and 2568.
    • Zero padding rows, the alignment copy, the 4 GiB cap counted on the padded bytes (H = 2561), the factory's vote (plain data) and failure paths.
    • Runs in the repo's CI once the PR targets main.
  • op_tests/multigpu_tests/test_flydsl_sp_collectives.py (GPU)
    • TP2 through the factory, which must return a router exactly on gfx950 / xGMI / TP2 and None elsewhere. Also payloads below the window and CUDA graph replay.
    • TP4 over an engine with a window that admits every size.
    • Both build their engines on the uncached inbox, which the single-phase kernels require (auto is the fine-grained inbox at TP4 and TP8 over PCIe).
    • Both check accuracy against the exact result (NMSE, and checkAllclose with the [FlyDSL] FlyQuickAllReduce: reduce-scatter and all-gather modes for sequence parallelism #7444 test's tolerances and mismatch bound), bit identity with the engine on a test-padded input, and zero padding rows. A world size named with --tp that cannot run is an error, not a skip.
    • After the checks, a @benchmark sweep (run_perftest with CUDA events, a markdown summary) times the router, the engine on a test-padded input and RCCL, for both modes on every shape, and checks each output with checkAllclose. Times are reported, not asserted. Numbers below.
  • Mutants: 20 (18 of sp_collectives.py, 2 of allreduce_policy.py), each failing a CPU test that names its decision.
    • sp_collectives.py, by decision:
      • window: counted on padded bytes, < for <=, absent row compiling, the factory returning None where the table has a row;
      • vote: none, after a local return, the window itself as the vote;
      • size: no 4 GiB cap, the cap on sent bytes;
      • padding: no zero fill, no alignment copy, wrong unit, padding before the rows, result not unpadded, wrong rows;
      • checks: dtype unchecked, divisibility unchecked, swallowed compile error.
    • allreduce_policy.py: the window read from AITER_FLY_AR_MESH_MIN_BYTES, the table row removed.
    • Seven of the 19 earlier ones also failed the GPU test (run on 98a6d468d, not rerun on the follow-up). Three (wrong rows, padding before the rows, result not unpadded) were run against the GPU test with the checkAllclose checks: each fails, with the checkAllclose message among its failures (NMSE and the engine comparison fail on the same shapes).
  • Runs (gfx950, FlyDSL 0.5.0): CPU 60 passed. GPU: TP2 and TP4 passed, with the timed sweep, and the three mutants above fail. The router code is the same in all of them.

Timed sweep (microseconds per call; MI355X gfx950, FlyDSL 0.5.0, one run, other jobs were leased on the node; "engine" is the engine on an input padded in the test, so it has neither the router's padding copy nor the copy of its result back to the unpadded shape; RS reduce-scatter, AG all-gather):

tokens x hidden TP RS router RS engine RS RCCL AG router AG engine AG RCCL
1640 x 2560 2 65.6 50.5 126.7 68.8 50.0 121.7
4096 x 2560 2 89.0 85.3 258.3 87.3 84.8 245.6
3302 x 2568 2 101.8 85.5 216.0 107.5 86.2 206.5
40 x 2560 4 43.7 29.0 40.5 46.1 27.5 39.9
2044 x 2568 4 59.6 43.5 98.0 67.2 42.6 95.7
4096 x 2560 4 63.5 58.3 150.8 62.1 60.0 152.0
  • At the three TP2 shapes the router is 1.8 to 2.9 times faster than RCCL.
  • Where no padding is needed (4096 x 2560) the router does no padding or unpadding copy and takes 3 to 9 % more than the engine (not broken down further). Where the shape is padded it takes 19 to 67 % more, a difference that includes the padding copy and the copy back to the unpadded shape.
  • TP4 40 x 2560 (0.2 MB) is the one shape where RCCL is faster than the router. TP4 has no window row, so production would not route it; the test's window admits every size only to time it.
  • Every checkAllclose mismatch fraction is 0 except one: in the TP4 4096 x 2560 reduce-scatter, the router and the engine each have 3.8e-7, which is one element of the 2,621,440 per rank. The bound is 0.5.

Used in a served model

With this router and the vllm-project/vllm#65628 rework (Qwen3.8-Flash-Next-Quark-MXFP4, TP2, --enable-hc-sp, VLLM_ROCM_QUICK_REDUCE_QUANTIZATION=INT4; two arms that differ only by this router):

  • An 8,192-token step runs 193 INT4 kernels (192 launches of the layer's four SP sites over 48 layers, plus 1 all-reduce) against 1 without the router. GPU busy per large step: 180.1 ms against 236.2 ms. Decode steps (below the window) run the same kernels as without it.
  • Output throughput: +25 to +30 % at the prefill-heavy cells.
  • GSM8K 5-shot pooled over four rounds (5,276 paired questions): -0.34 point strict (95 % CI [-0.75, +0.07]) and -0.32 flexible ([-0.72, +0.08]). The lower limits were checked against a bound of -1.0 point fixed beforehand. Needle: 40/40 at all depths.
  • INT4 served a minority of steps in that eval, so the accuracy numbers bound the loss at that exposure.
  • Setup, tables and exposure are in the description of the [ROCm][Perf][Qwen4Exp] AITER routes the INT4 sequence-parallel collectives of the --enable-hc-sp layers by payload size vllm-project/vllm#65628 rework.
  • Those runs used this PR's earlier commit bd54a9dee over an earlier head of [FlyDSL] FlyQuickAllReduce: reduce-scatter and all-gather modes for sequence parallelism #7444. The final commit has the same router code, docstrings, import lines and a policy comment aside (TILE_BYTES is 32,768 in both; the op test compares it with the engine's tile).
  • The CPU tests and the GPU tests (TP2, TP4, three mutants) ran on the final router code; the other GPU mutants on the router commit.

Limits

  • The window is measured at hidden 2560 on gfx950 TP2 only. Below 8 MiB the INT4 crossover has not been swept and the accuracy has not been signed off, so the row stays where it was checked. Other TP sizes and gfx942 have no row.
  • For hidden sizes with a large row unit the padding can inflate the moved bytes: at H = 2561 (unit 8192 rows) a payload at the 8 MiB floor moves about 10 times its size. The window is keyed by (arch, link, world_size), not by hidden size.
  • The import guard (except Exception, as in quick_all_reduce.py) turns the router off without a log line for any import problem, not only a missing FlyDSL.
  • An allocation failure on one rank between the two votes of the factory would leave its peers in compile_sp's vote until the process group times out.
  • The repository's workflows filter on branches: [main], so this stacked PR gets no CI until it is retargeted to main after [FlyDSL] FlyQuickAllReduce: reduce-scatter and all-gather modes for sequence parallelism #7444 merges. The evidence above comes from our own CPU and GPU runs.

🤖 Generated with Claude Code

…by payload size

The single-phase reduce-scatter and all-gather of `FlyQuickAllReduce` need the
full tensor to be a whole number of 32 KiB tiles, an aligned contiguous input
and zero padding rows. A sequence-parallel caller that also has an exact
collective (an IPC kernel, RCCL) should not own those rules or the payload
policy: it asks, and where AITER does not serve the call it continues with its
own collective.

- `aiter/dist/device_communicators/sp_collectives.py`:
  `SequenceParallelCollectives(quick, window)` with `reduce_scatter(inp)` and
  `all_gather(inp)`. Each returns the result for a bf16 2-D input whose full
  tensor (the reduce-scatter input, the all-gather output) is inside the window
  (reduce-scatter also needs `T` divisible by the group size) and whose padded
  tensor is under the 4 GiB limit of the kernels, and None otherwise: the
  caller's exact path. The router pads each rank's block with zero rows to a
  whole number of tiles, copies a misaligned or non-contiguous input, and
  returns the unpadded result; the padding does not count towards the window,
  so a block of a few rows is never served because its padding fills whole
  tiles. Whether a call is served depends on shape, dtype, window and platform
  only, so every rank decides alike. `create_sp_collectives(quick)` is a
  collective: the ranks compare their windows, then it builds the router, or
  returns None on every rank when FlyDSL is unavailable, a rank has no window,
  the windows differ or `compile_sp` fails.
- `allreduce_policy.py`: `SP_INT4_WINDOWS` and `sp_int4_window`, one `Window`
  per `(arch, link, world_size)`. The only row is gfx950 / xGMI / TP2 from
  8 MiB of full tensor, the lower bound checked end to end. There is no
  environment override.
- Tests: `tests/test_sp_collectives.py` (58 CPU cases against a stand-in
  engine: hand-derived padding units and window boundaries, zero padding rows,
  alignment copy, the 4 GiB cap on the padded bytes, the factory's vote and
  failure paths, the window ignoring `AITER_FLY_AR_MESH_{MIN,MAX}_BYTES`) and
  `op_tests/multigpu_tests/test_flydsl_sp_collectives.py` (TP2 through the
  factory, which must return a router exactly on gfx950 / xGMI / TP2 and None
  elsewhere; TP4 over an engine with a window that admits every size. Accuracy
  against the exact result, bit identity with the engine on a test-padded input
  and zero padding rows at both; payloads below the window, including a block
  whose padding fills whole tiles, and graph replay at TP2).
- `kernels/comm/README.md` describes the router.

No change to `FlyQuickAllReduce`, `communicator_cuda.py` or the all-reduce
policy rows.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Signed-off-by: Rony Leppänen <[email protected]>

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

The availability vote can fail when a rank lacks a compatible FlyDSL installation because deserializing a peer’s Window retries the optional import, while the TP4 test setup and required correctness and performance coverage also need fixes.

2 open issues
What changed in this PR

Adds a sequence-parallel router over #7444’s INT4 reduce-scatter and all-gather kernels, allowing callers to retain exact collectives outside the supported payload window.

Changes:

  • Adds collective initialization, payload routing, alignment copies, and per-rank padding and unpadding.
  • Enables gfx950/xGMI/TP2 payloads from 8 MiB through a centralized policy table.
  • Adds CPU routing tests, multi-GPU correctness and graph-replay tests, and router documentation.
File Description
tests/​test_sp_collectives.py Tests routing boundaries, padding, alignment, and factory failure paths.
op_tests/​multigpu_tests/​test_flydsl_sp_collectives.py Checks TP2/TP4 correctness, engine equivalence, and graph replay.
aiter/​ops/​flydsl/​kernels/​comm/​README.md Documents router behavior, policy, and tests.
aiter/​ops/​flydsl/​allreduce_policy.py Defines the sequence-parallel INT4 payload window.
aiter/​dist/​device_communicators/​sp_collectives.py Implements collective setup, routing, and tensor preparation.

Review effort: Balanced

…gines on the uncached inbox

create_sp_collectives gathered each rank's Window with all_gather_object. A peer
unpickles it, which imports aiter.ops.flydsl, and that import raises on a rank whose
flydsl is missing or older than 0.5.0: the rank raised from the vote while its peers
returned None. The vote is now (min, max) or None. On a package with the real router,
policy and flydsl import guard and two CPU ranks, one without flydsl, that rank raised
ModuleNotFoundError from all_gather_object before and returns None now. The new test
fails on the previous code: the vote must not name an aiter class.

The multi-GPU test built its engines with inbox_memory="auto", which is the fine-grained
inbox at TP4 and TP8 on a host whose GPUs are linked by PCIe, and _sp_engine() refuses
that. The engines are now built on the uncached inbox, which auto resolves to on xGMI
and at TP2.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@eppaneamd

Copy link
Copy Markdown
Contributor Author

On the review summary's point that the availability vote can fail on a rank without a compatible FlyDSL: valid, and it reproduces. all_gather_object unpickles every peer's Window, which imports aiter.ops.flydsl, and that import raises when flydsl is missing or older than 0.5.0. With two CPU ranks, one of them without flydsl, that rank raised ModuleNotFoundError from the vote while its peer returned None. Fixed in a4a53b8e7: the vote is (min, max) or None, so both ranks return None. A new test fails on the previous code (the vote must not name an aiter class), and the 20 router mutants (one new, vote = window) each still fail a CPU test. The reproduction ran on a package with the real router, policy and flydsl import guard, not on full aiter, because the node image's aiter is older than this branch.

…a timed sweep of the router, the engine and RCCL

The aiter-op-test standard asks an op test for checkAllclose and a run_perftest sweep with
a markdown summary, as the #7444 test does.

Both modes now also run checkAllclose against the exact fp32 result with the #7444 test's
tolerances and mismatch bound. NMSE and bit identity with the engine stay the strict
checks, as there.

After the checks, a sweep over the shapes of the two configurations (a @benchmark
function, run_perftest with CUDA events, a markdown table) times the router, the engine on
an input padded in the test (no padding copy, no copy of the result back to the unpadded
shape) and the exact collective (RCCL), and checks every output against the exact result.
Times are reported, not asserted. A world size whose factory returned None has no router
and is not timed. The engine and router setup is shared by the checks and the sweep.

The comm README's paragraph on the test mentions the sweep.

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

@johannes-graner johannes-graner 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.

Reviewed at head 0a0abe41.

The router shape looks right to me: it returns None and the consumer keeps its exact path, and the size policy lives in aiter as the vLLM review asked. Locally, the CPU suite passes (60 tests at 0a0abe41). The TP2 op test passed on gfx950 with xGMI at 98a6d468, and I measured router overhead with a TP2 timing probe at the same head. I have not run the GPU tests at 0a0abe41. Below are the items I would like to see addressed before merge:

  1. Factory vote can diverge across ranks
  2. Padding copies the whole tensor
  3. SP_INT4_WINDOWS key validation
  4. Import of TILE_BYTES breaks silently after rebase
  5. GPU test gives no per-case values

Design questions

  • The all-reduce FlyDSL path is gated by AITER_FLY_AR=1, the INT4 regime, and per-window byte overrides. The router reads none of these, so the only off switch is the consumer's: in vllm#65628, dropping the INT4 env also drops the INT4 all-reduces. Is a consumer-only gate the intent? Would a disable-only variable in aiter, voted through the factory with the rest of the plan, fit, so an operator can turn the pair off without a vLLM change?
  • vllm#65628 adds QuickAllReduce.sp_collectives() over its own engine, while aiter's QuickAllReduce already holds the same mesh engine and runs the plan vote at init. Is an aiter-side accessor planned, so the dist path and vLLM share one gate and one build point? Until then, could the README name aiter.dist.device_communicators.sp_collectives.create_sp_collectives as the supported entry point? A consumer that turns an ImportError into "no router" would otherwise lose the feature silently after a rename.
  • The policy comment says 8 MiB is where accuracy was signed off, and that the crossover below it was not swept. The new sweep covers 1640x2560 (just above 8 MiB), 3302x2568 and 4096x2560 at TP2. In those rows the router is 1.8 to 2.9 times faster than RCCL. There is no point below 8 MiB, no graph replay and no IPC baseline. Could you add RS-only and AG-only timings below 8 MiB, with graph replay, against the exact path vLLM falls back to? RS and AG share one threshold, and once vllm#67010 lands the exact reduce-scatter becomes aiter's IPC kernel. I would like to know whether 8 MiB is at, above or below the crossover for each. If it is above, a note in the policy comment naming the baseline would help the next retune.

Lower importance

  • FlyDSL availability (nit, lower importance): the comment at line 40 names the wrong cases. FlyDSL is required on Linux and optional only on Windows and Triton-only installs. The version-check ImportError is caught by the guard at line 48, so the decline is silent. Ask for that failure to be logged, as in item 1.
  • Floor comment (nit, lower importance): a sentence beside SP_INT4_WINDOWS on why the SP floor (8 MiB) differs from the all-reduce mesh floor (512 KiB) would help. The SP floor is where the end-to-end accuracy check was signed off (the 1 MiB gate lost accuracy in #7444), and the engine's min_bytes does not apply to the single-phase modes, so this window is their only floor.
  • Wording (nit, lower importance): "another dtype or rank" in the reduce_scatter and all_gather docstrings and in the README reads as process rank. "not a 2-D tensor" avoids that. The GPU test docstring refers to "the 7444 test's bound" (line 18) and "the 7444 test's tolerances" (line 31); naming NMSE_MAX from test_flydsl_quick_reduce_scatter_all_gather.py survives the merge.
  • CI runtime (nit, lower importance): the sweep adds six spawn pools to a file that the multi-GPU CI job runs in full. Gating the sweep behind a flag, or adding the file to the skip list, would keep the job's runtime unchanged.
  • Pool timeout (nit, lower importance): a regression that makes ranks disagree would wait the default 3600 s. A timeout= of a few minutes in _run_pool would keep a hang cheap in multi-GPU CI.
  • Redundant CPU cases (nit, lower importance): test_tile_is_32_kib is implied by the hand-derived block_row_unit values. In test_reduce_scatter_window, the 1000-row, 16384-row and 2040-row cases repeat a neighbour on the same side of the bound. Dropping them keeps every distinct rule covered.

if padded == rows:
src = _aligned(inp)
else:
src = inp.new_zeros((w, padded, hidden))

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.

Item 2: padding copies the whole tensor (category: performance) Performance note: measured on TP2, gfx950 with xGMI, H=2560, eager, single runs, reduce-scatter latency in µs, router against the engine on a pre-padded input: T=1640 (832 rows per rank after padding) 44.3 vs 31.7 (RCCL 108.3); T=8190 152.6 vs 120.8; T=16382 280.9 vs 231.9; aligned T=8192 122.9 vs 120.9. All-gather is similar at T=1640 (44.5 vs 31.4). Padded shapes cost +12.6 to +54.1 µs (21–43 % of engine time). Aligned shapes cost at most 4.3 µs. Your sweep shows the same direction: the PR text gives +19 to +67 % for padded shapes and +3 to +9 % for aligned ones. The overhead grows with tensor size rather than with padding rows: one padding row at T=8190 costs +31.8 µs (inferred from these rows, consistent with the full-buffer zero fill and copy-in, plus the unpad copy-out for all-gather). Could the router zero only the padding rows, copying the real rows into a new_empty buffer? The copy itself may be part of the cost (inferred, not measured separately). The window counts unpadded bytes, so padding can move more bytes than the window priced. At the H=2560 floor the moved/sent ratio is about 1.015 (computed from block_row_unit); at H=2880 it is 1.053 with a 128-row unit, and at H=2561 it is 10x at the floor. A ratio guard such as moved <= 2 * sent in _padded_rows would keep the window close to what was measured, without affecting the real models.

Contiguity question: does vLLM ever pass a non-contiguous or misaligned input? _aligned (62-66) clones in that case, but only on the no-padding path, since the padded path copies anyway. If vLLM never does, the clone is a cold path and a fallback is enough. Torch allocations are 512 B aligned, so only sliced views would reach the clone, and each would pay one full-tensor copy.

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.

Still open as far as I can see: new_zeros at lines 115 and 136 zero-fills and copies the whole tensor, and _padded_rows has no limit on how much padding a shape can carry. Could the router copy only the tail rows (allocate with new_empty and zero just the padding rows), or bound the ratio (for example moved <= 2 * sent) and fall back to the standard path past it?

# gfx950 / xGMI / TP2 [8 MiB, inf) -- the lower bound the INT4 path was
# checked against end to end (GSM8K) on MI355X TP2. Below it the INT4
# crossover has not been swept and the accuracy has not been signed off.
SP_INT4_WINDOWS: dict[tuple[str, str, int], Window] = {

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.

Item 3: SP_INT4_WINDOWS key validation (category: correctness) FamilyPolicy.__post_init__ checks arch, link and world size. SP_INT4_WINDOWS is a plain dict, and sp_int4_window returns any key it holds, so a row for PCIe TP4 or an unsupported arch is accepted. The only symptom would be a logged warning when compile_sp fails on the node. Could the dict get the same checks (arch in SUPPORTED_ARCHS, link in LINKS, world size in SUPPORTED_WORLDS), plus a test that each key has a MESH_ST_LADDER rung with super_tile=1 that resolves an uncached inbox? A later row for an unserved platform would then fail in CI.

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.

SP_INT4_WINDOWS is still a bare dict. Could its keys be validated at import time, with the same arch, link and world-size checks that FamilyPolicy.__post_init__ applies, so a typo fails loudly instead of silently disabling INT4?

MAX_PAYLOAD_BYTES,
PAYLOAD_ALIGN_BYTES,
)
from aiter.ops.flydsl.kernels.comm.allreduce_shared import TILE_BYTES

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.

Item 4: import of TILE_BYTES breaks silently after rebase (category: correctness, medium) TILE_BYTES is imported from aiter.ops.flydsl.kernels.comm.allreduce_shared. #5670, merged to main on 2026-11-17, renamed that module to transport.py, where TILE_BYTES now lives. This head predates the rename, so the import works here. Once the base is rebased onto main, the import raises ImportError. The guard at 48-49 swallows it, fly_policy becomes None, and the router is off on every rank with no log. This is inferred from the code and main's tree, not run. Could the router take the tile size from the engine (_sp_engine().tile_bytes, which the GPU test already compares), and could the guard log the failure?

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.

The logging change helps, but line 50 still imports TILE_BYTES from allreduce_shared, which main no longer has after #5670 (TILE_BYTES is in transport.py now). After a rebase the import fails, the router is off on every rank, and the log says "FlyDSL cannot be imported" although FlyDSL is fine. Could you fix the import in the rebase, and log which import actually failed?

fails += _failures(ranks, tp=tp, factory=factory)
if not ranks[0]["factory_none"]:
served.append(tp)
print(

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.

Item 5: GPU test gives no per-case values (category: tests, low importance) The asserted checkAllclose and the timed sweep are in place. The sweep runs run_perftest for the router, the engine on a test-padded input, and RCCL, and logs a markdown table. The success path still prints only the shape count and "all checks passed" (lines 492-495, 508), so a CI log has no NMSE or engine-equal result per case. The table has us, TFLOPS, TB/s and err columns and no NMSE, padded-row, engine-equal or served column. A per-case row with those values would show what each case checked. The sweep is eager with an event sync per iteration and has no graph replay (see design question 3).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 80fc2c5: main() now prints one line per checked shape and mode (rs/ag) before the shape count. Each line shows served, the worst NMSE and checkAllclose err across ranks, engine_equal, input_unchanged and, for all-gather, ranks_equal; the padded-row check has no separate value because the NMSE and engine_equal results cover it.

# and ``max`` exclusive, as above. A missing row disables them. There is no
# environment override.
#
# gfx950 / xGMI / TP2 [8 MiB, inf) -- the lower bound the INT4 path was

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.

Nit: floor comment (nit, lower importance) A sentence beside SP_INT4_WINDOWS on why the SP floor (8 MiB) differs from the all-reduce mesh floor (512 KiB) would help. The SP floor is where the end-to-end accuracy check was signed off (the 1 MiB gate lost accuracy in #7444), and the engine's min_bytes does not apply to the single-phase modes, so this window is their only floor.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 520e628: the comment above SP_INT4_WINDOWS now says this is the single-phase modes' only floor, unlike the 512 KiB mesh all-reduce floor, and that a gate of about 1 MiB lost about half a GSM8K point in #7444.

"""The block of the element-wise sum over ranks that this rank owns,
``[T / world_size, H]``, from this rank's bf16 ``[T, H]`` partial; the
rows ``[rank * T/W, (rank + 1) * T/W)`` of the sum. ``None`` when not
served: another dtype or rank, ``T`` not divisible by the group size,

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.

Nit: wording (nit, lower importance) "another dtype or rank" reads as process rank in a collective module. "not a 2-D tensor" avoids that. The same phrase appears in all_gather (line 118) and in the README (line 86). The GPU test docstring refers to "the 7444 test's bound" (line 18) and "the 7444 test's tolerances" (line 31); naming NMSE_MAX from test_flydsl_quick_reduce_scatter_all_gather.py survives the merge.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in a125042: "another dtype or rank" now reads "another dtype, not a 2-D tensor" in the reduce_scatter and all_gather docstrings, and the README says "for a tensor that is not a 2-D tensor". The GPU test docstring no longer says "the 7444 test". It names NMSE_MAX, the checkAllclose tolerances and the CLOSE_ERR_RATIO mismatch bound of test_flydsl_quick_reduce_scatter_all_gather.py.


@benchmark()
def test_sp_router(tokens, hidden, tp):
ranks = _run_pool(tp, _bench_rank, tokens=tokens, hidden=hidden, factory=tp == 2)

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.

Nit: CI runtime (nit, lower importance) The sweep adds six spawn pools (_bench_rank), each of which rebuilds a FlyQuickAllReduce. .github/scripts/aiter_test.sh runs every op_tests/multigpu_tests/*.py under timeout 60m (glob at line 25, run at line 98), and this file is not on its skip list (lines 42-58). I have not timed this file in CI. Could the sweep be gated behind a flag, or the file added to the skip list?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not changed: aiter's op-test standard (.claude/skills/aiter-op-test/SKILL.md, rules 6 and 8) makes the timed sweep and its summary table part of every op test and rules out behaviour-toggle flags, and the skip list would drop the checks from CI as well. The file has not been timed in CI.

served = [] # the world sizes with a router here, which the sweep times
for tp in tps:
factory = tp == 2
ranks = _run_pool(tp, _run_rank, factory=factory)

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.

Nit: pool timeout (nit, lower importance) If a regression makes the ranks disagree, _run_pool(tp, _run_rank, ...) waits the default 3600 s. The sweep pools at line 448 have no timeout= either. A timeout= of a few minutes would keep a hang cheap in multi-GPU CI.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 33f046a: both _run_pool calls in main() and test_sp_router now pass timeout=_POOL_TIMEOUT_S (600 s).

Comment thread tests/test_sp_collectives.py Outdated
(1634, 2560, False), # its padded payload, 8,519,680 B, is above 8 MiB
(1633, 2560, False), # odd: no equal blocks
(16385, 2560, False), # odd, and its floor would be inside the window
(1000, 2560, False),

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.

Nit: redundant CPU cases (nit, lower importance) The 1000-row case (170) repeats a neighbour on the same side of the bound, as do the 16384-row (171) and 2040-row (174) cases in test_reduce_scatter_window. test_tile_is_32_kib (120) is implied by the hand-derived block_row_unit values. Dropping these keeps every distinct rule covered.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 8bcf952: removed the 1000-row case and the 16384-row and 2040-row cases from test_reduce_scatter_window, and removed test_tile_is_32_kib. Each removed case sat on the same side of the bound as a case that stays, and the tile size is already fixed by the block_row_unit values.

@aiter-bot

aiter-bot commented Nov 18, 2026 •

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision 182148d2b2ef · 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 behavior would each changed op test fail on before this PR, and why is that coverage not already provided by an existing canonical test?
  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_flydsl_sp_collectives.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.

eppaneamd and others added 8 commits November 18, 2026 21:43
The success path printed only the shape count. Print one line per
shape and mode with served, worst NMSE and checkAllclose err over the
ranks, engine equality, input unchanged and, for all-gather, equality
across ranks.

Signed-off-by: Rony Leppänen <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The import guard swallowed every exception, so an old or missing
FlyDSL turned the router off silently. Keep the exception and log it
as a warning in create_sp_collectives. Correct the comment: FlyDSL is
required on Linux, optional on Windows and Triton-only installs.

Signed-off-by: Rony Leppänen <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Note that the 8 MiB floor is the only floor for the single-phase modes,
since the engine's min_bytes does not apply to them, and that a gate of
about 1 MiB lost about half a GSM8K point in #7444.

Signed-off-by: Rony Leppänen <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
"Rank" read as process rank in a collective module, so the docstrings
and the README now say "not a 2-D tensor". The GPU test docstring
names NMSE_MAX, the checkAllclose tolerances and CLOSE_ERR_RATIO of
test_flydsl_quick_reduce_scatter_all_gather.py instead of "the 7444
test", which will mean nothing after the merge.

Signed-off-by: Rony Leppänen <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Ranks that disagree leave their peers polling, and _run_pool then waits
its default 3600 s. Pass a 600 s timeout from the main sweep and the
benchmark pools.

Signed-off-by: Rony Leppänen <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Remove window cases that repeat a neighbour on the same side of the
bound (1000, 16384 and 2040 rows) and test_tile_is_32_kib, which the
block_row_unit values already imply.

Signed-off-by: Rony Leppänen <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
detect_arch, the window lookup and the probe tensors now run in one try
before the vote. The vote is {"min", "max"} of the window, or a string
naming why this rank declines (FlyDSL import failure, no window, setup
failure), logged once on that rank. Disagreements are logged by the
helper. The tests stub get_world_size and use string/dict peer votes.

Signed-off-by: Rony Leppänen <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The vote goes through all_ranks_agree_on_plan, so sp_collectives no longer
calls torch.distributed itself (ruff F401). The tests' peers fixture now
patches it through flydsl_utils, which makes the calls.

Signed-off-by: Rony Leppänen <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

@johannes-graner johannes-graner 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.

Thanks for the fixes. I checked the vote fix and the six nit fixes against the code, and they hold. I also ran the multi-GPU test at 182148d2 on gfx950 (FlyDSL 0.5.3): TP2 and TP4 pass, and every case is served by INT4 with err 0 and NMSE about 6.5e-3. That matters because your earlier runs predate the vote and logging commits. The CPU suite passes (56 tests).

On the sweep flag: agreed, the op-test convention forbids behaviour-toggle flags, so I withdraw that nit.

Test gap: no CPU test pins the vote fix. Narrowing except Exception so that a setup error escapes before the vote (the original hang) still leaves all 56 tests passing, and so does removing the decline logging. Could you add CPU cases where detect_arch, the tensor allocation or quick.link raises, asserting exactly one vote and a logged reason?

Question on the vote: after it, the code relies on "compile_sp raises on every rank when any rank cannot run the kernels". What guarantees that? If one rank can fail locally while the others enter a collective, they hang. Does compile_sp end in a collective that every rank reaches, for example?

The PR description is stale: it says 60 CPU tests (56 now), describes the old (min, max) vote, still has the "dtype or rank" wording, and still lists two Limits bullets that these commits fixed (the silent import-guard decline and the allocation failure between votes).

Minor, all optional:

  • The 600 s pool timeout includes the first JIT build, so a cold CI cache could fail it spuriously.
  • _case_lines raises IndexError if ranks disagree on the row count, which would mask the real failure.
  • The peers fixture hardcodes world size 2, including for the TP4 and TP8 window cases.

Three design questions from the first review are still unanswered: an aiter-side off switch beyond the consumer gate, the entry point (QuickAllReduce.sp_collectives()), and the INT4 window against the crossover below 8 MiB (graph replay, IPC baseline). Are they deferred to follow-ups? That is fine, I would just like it on record.

Reviewed at head 182148d2.


import torch

from aiter.dist.device_communicators.flydsl_utils import all_ranks_agree_on_plan

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.

all_ranks_agree_on_plan is imported from flydsl_utils outside the guard. #5670 deleted flydsl_utils.py from main, and the function is in flydsl_backends.py now. After the rebase this line raises when the module is imported, instead of the router declining, so the CPU tests fail at collection and a consumer that feature-detects with ImportError loses the router. Could you fix it in the same rebase as the TILE_BYTES import?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants