Repository navigation
Conversation
…sequence parallelism Add reduce_scatter(inp, out), all_gather(inp, out) and compile_sp(full, shard) to QuickAllReduceInt4. They run one phase of the INT4 all-reduce on its own, on its codec (group-16 signed E4M3 scales, 1152 B per 2048 bf16), IPC inbox and colored flags, and leave each rank a contiguous row block: the kernel maps the all-reduce's per-tile atom ownership to contiguous shards by an address transpose. Both modes are super_tile=1 only; every partial, a rank's own included, goes through the codec, so a row's value does not depend on which rank owns it. A single phase has no second-phase guard against inbox reuse, so both modes send through the all-gather slots and start each round with a `ready` flag (the reduce-scatter phase's release flag, no payload). The all-reduce is unchanged (ISA and output hash identical); the host helpers it shares were split (_check_tensors) or routed through _variant. Add op_tests/multigpu_tests/test_flydsl_quick_reduce_scatter_all_gather.py: placement and accuracy against fp32 references on normal, heavy-tailed and all-zero inputs, owner independence, sentinel and guard buffers, alternating back-to-back launches with a delayed rank, and refusal of malformed tensors. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Rony Leppänen <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
NOT READY FOR HUMAN REVIEWPR Self-ReviewRevision Author self-review accepted. Readiness report: Author answers
Show the author's self-review answersBehavior and intentValidation and unverified scopePR-specific questionChanged op testsPR state
Copilot findings
Code and op-test hygiene
Required CI
Shadow mode reports what would block but keeps the status successful. Set |
There was a problem hiding this comment.
🟡 Changes recommended
Regression coverage is missing for multi-rank CUDA graph capture/replay and delayed-rank transitions between allreduce and the new modes, leaving shared-state advancement and inbox reuse unverified.
2 open issues
What changed in this PR
Adds standalone INT4 reduce-scatter and all-gather to QuickAllReduceInt4, providing row-contiguous shards for sequence parallelism while retaining the existing all-reduce path.
Changes:
- Adds single-phase kernel modes with contiguous shard addressing and inbox-reuse synchronization.
- Exposes
reduce_scatter,all_gather, andcompile_sp, with payload validation. - Adds multi-GPU correctness checks, delayed-rank stress tests, and timing sweeps.
| File | Description |
|---|---|
op_tests/multigpu_tests/test_flydsl_quick_reduce_scatter_all_gather.py |
Tests accuracy, shard placement, synchronization, and malformed-input rejection. |
aiter/ops/flydsl/quick_allreduce_int4.py |
Adds public methods, validation, and cached mode-specific launchers. |
aiter/ops/flydsl/kernels/quick_allreduce_int4.py |
Implements standalone collective modes and their synchronization protocol. |
Review effort: Balanced
Conflict resolution only. Upstream #5461 moved the FlyDSL INT4 quick all-reduce kernel to kernels/comm/ and rewrote the host class, so this takes main's host file and accepts the deletion of kernels/quick_allreduce_int4.py. The reduce-scatter / all-gather modes are not on the tree after this commit (the new op test does not run here); the next commit ports them onto main's mesh kernel. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ydsl-quickreduce-sp-rs-ag
…odes onto the #5461 mesh kernel Re-apply the sequence-parallel modes of this PR on the kernel and host that #5461 rewrote (per-rank binaries, peers-only publish/wait, runtime n_blocks, inbox memory modes, engines keyed by (super_tile, block)) and on the E5M2 group scale of #7258. Kernel (kernels/comm/quick_allreduce_int4.py): make_quick_allreduce_int4_kernel takes mode="ar" | "rs" | "ag". "rs" and "ag" run one phase of the INT4 mesh on its own, for super_tile=1, the 8-atom tile and no fused norm. Rank d owns a contiguous block of N / world_size bytes; the tile machinery is unchanged and only the HBM address of an atom moves, through a full / shard layout local to the mesh kernel (_sp_payload_io) with the runtime n_blocks stride. Both modes send through the all-gather slots and start every round with a payload-free `ready` flag, since a single phase has no second-phase guard against inbox reuse. Unlike the all-reduce, which adds its own share from registers, "rs" quantizes this rank's own partial through the codec and accumulates every rank in rank order with the same dequant, so a row's value does not depend on which rank owns it. The JIT symbol gets an `_rs` / `_ag` suffix and the single-phase builds pin waves_per_eu to the plain kernel's residency. Host (quick_allreduce_int4.py): reduce_scatter(inp, out), all_gather(inp, out) and compile_sp(full, shard). They run on the super_tile=1 engine at the default block (shared inbox and colors) and raise for the ring, an inbox other than "uncached", or a ladder without that engine. There is no min_bytes floor. compile_sp now loads both builds with preload_launcher like preload: it checks the shapes, launches nothing and overwrites nothing, and takes no stream. A single-phase launch under CUDA graph capture raises unless its build is loaded. check_tensors is split out of check_payload (same behaviour and signature) for the pair check. README documents the modes. The op test imports from kernels.comm and builds its engine from a one-rung ladder instead of super_tile / grid_cap. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Rony Leppänen <[email protected]>
…rleave and unsupported engines Close two gaps in the op test of this PR and cover the refusals of the host. Graph: after compile_sp (which launches nothing and leaves its tensors alone), capture reduce_scatter and all_gather into one CUDA graph with torch.cuda.graph and the all-rank capture vote of the rmsnorm test, then replay it with new inputs written in place. Every replay must equal an eager run of the same inputs bit for bit and stay within NMSE_MAX of a fresh fp32 reference. A capture on an engine that has not loaded its builds must be refused with a message that names compile_sp. Interleave: all-reduce, reduce-scatter and all-gather alternate on one engine with no sync between them, each call with its own input, in a cycle that contains every ordered transition between the three modes (asserted when the cycle is built), with each rank slowed in turn by fp32 matmuls on a side stream. Every output must equal the isolated result of its call bit for bit. It runs on a one-rung ST=1 engine at grid cap 64 (several tiles per block) and on the shipping ladder, where one all-reduce size is kept for each binary the ladder picks. Refusals: reduce_scatter, all_gather and compile_sp raise on an engine built with the ring or with a fine-grained inbox. The rank setup and the spawn pool are shared by the existing and the new workers. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Rony Leppänen <[email protected]>
…ero for all-zero inputs The test required the outputs for all-zero inputs to be bitwise +0.0. On the current codec they come out as -0.0 (int16 bit pattern -32768 at TP2, TP4 and TP8), which compares equal to zero but is not +0.0. Check that every output element equals zero (NaN and stray values still fail), and put the observed int16 bit patterns in the failure message. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Rony Leppänen <[email protected]>
…e accumulation order shows in the result With the normal and heavy-tailed fills the reduce-scatter result barely depends on the order in which the ranks' packets are accumulated: a dequantized product is exact in fp16 and a sum of terms of similar magnitude rarely rounds, so a kernel that accumulates a rank's own packet first (owner-dependent order) can pass the owner-independence check, which is the property the single-phase modes exist to guarantee. Add a fill in which rank r's partial is 4**(r % 4) times as large (up to 64x, far below the fp16 maximum), whose sums round, so a row's value depends on its owner whenever the accumulation order does. With two ranks the sum has two terms and a single rounding, so the order cannot show at TP2. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Rony Leppänen <[email protected]>
…sp-rs-ag No conflicts; main's new commit touches only op_tests/op_benchmarks/triton/bench_sage.py. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…he 4 GiB window; fix two stale comments reduce_scatter and all_gather raise before any launch when the full tensor is larger than the 4 GiB buffer window, as the all-reduce does; nothing exercised that check. Add one oversized, uninitialized pair to the refusal cases (whole tiles, tp times the shard, one step past MAX_PAYLOAD_BYTES): every other check passes on it, so only the window check can refuse it. Also: the test's expected-NMSE comment named the E4M3 group scale (the codec has the E5M2 scale since #7258), the ranged-fill comment said a sum of similar magnitudes is exact (it rarely rounds), and a host comment named a method that does not exist (sp_launch for _sp_launcher). Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Rony Leppänen <[email protected]>
johannes-graner
left a comment
There was a problem hiding this comment.
Reviewed at head 30f37d9.
On gfx950 at TP2, the new test passed at 1024x2560 and 8192x2560 with RS/AG NMSE about 6.50e-3, matching the PR. TP4/TP8 and gfx942 were not run here. The existing all-reduce regression tests (test_flydsl_quick_allreduce_int4.py --tp 2 -a mesh and test_flydsl_quick_allreduce_int4_rmsnorm.py --tp 2) also pass at this head, including cross-rank bit identity and the skewed-rank dispatch agreement.
Must fix: the graph accuracy check in the new test can accept NaN output, SP kernel co-residency needs a verified resource check, and SP launches need an in-library all-rank readiness check. The accuracy question on the same-layout GSM8K comparison below also needs settling before this is enabled for serving.
Accuracy: the same-layout comparison (B vs C) loses 1.14 strict-match points with the INT4 SP collectives, past the PR's own 1.0-point bound, and the 23/8 split on the questions where B and C disagree is unlikely under no effect (p=0.011). One run per configuration can't tell a fluke from a regression. Could you check this more closely before landing: repeat the B/C pair with additional seeds or sampling, or on a second benchmark, and if the gap holds, run an ablation that keeps the own share exact in RS (diagnostic only, not a proposed fix) to see whether self-quantization drives it? Until that is settled, please keep INT4 SP opt-in on the consumer side.
…, keep the start method Review of #7444 (op test): - Graph replay: the NMSE of every replay and mode is kept and tested on its own. The worker accumulated them with max(), and max(0.0, nan, nan) is 0.0, so a graph that replayed NaN passed (the replay also compares bitwise against an eager run, which writes the same NaN). A NaN now fails. - Interleave: every comparison is against the isolated outputs, so a kernel that wrote the same NaN in both runs passed. The isolated outputs are now checked finite. - --tp: it only chose the timed sweep (default 2); the validity and the graph / interleave checks ran at every size that fit the visible GPUs. It now names the world sizes of all three, through select_world_sizes as in test_flydsl_quick_allreduce_int4.py. Without it every size the visible GPUs can run is run, so the timed sweep covers TP2/4/8 where it covered TP2; a size that is named but cannot run is an error, and so is an empty selection (a host with fewer than 2 GPUs used to skip everything with a warning and exit 0). - The module no longer sets the process-wide start method at import; _run_pool uses a spawn context. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Rony Leppänen <[email protected]>
…idency check; state the stream-ordering contract Review of #7444 (host): - compile_sp is now a collective preflight, and the single-phase launches need one to have passed: an eager reduce_scatter / all_gather on an engine that has not passed runs it with its own tensors (which makes that first call a collective: every rank makes it, in the same mode and with the same sizes), and a call under CUDA graph capture is refused, naming compile_sp. Each rank catches what raises locally (the engine and codec rules, the tensors, both builds, the residency check) and the ranks vote through the group on whether any rank failed, together with the call kind and the full and shard sizes, which are all that can differ between ranks that get this far (the world size is the group's, the grid the minimum over the ranks, and the single-phase builds take the INT4 codec only). If a rank failed or the kinds or sizes differ, every rank raises: the failing rank its own exception, the others a RuntimeError naming it, and the engine is not ready. Before, a rank that failed validation or the compile while a peer launched could leave that peer polling its flags, and locally valid but unequal sizes could give different block counts, as the review points out. A ready engine takes no collective on a launch. The capture refusal used to depend on the build not being loaded and now depends on the preflight not having passed. - Residency: both builds of the engine are checked, as part of the preflight, with ceil(grid / CUs) <= max_blocks_per_cu() of the compiled artifact (the kernels are persistent and spin on peers' flags, so a block that is not resident deadlocks the launch), and the call fails where the limit is not met. Nothing is clamped. - The class, allreduce, reduce_scatter, all_gather and compile_sp docstrings and the README state that launches and graph replays of every mode on one communicator run in one serialized device order (they share colors and inbox slots; independent streams need an event dependency), and that later shapes must agree across ranks. Tests (op test): a preflight pool in which rank 1 differs from the others (valid but unequal sizes after a ready compile_sp, invalid tensors through compile_sp and through the first eager call, reduce-scatter against all-gather as the first calls): every rank raises and the engine is not ready, and after the size mismatch a capture is refused; an agreeing retry passes, calls the residency check for both builds at the engine's grid and CU count and is correct; ready launches vote no more. The residency comparison is also run against stub artifacts before any rank is spawned. The zero-tensor helper of the refusal cases is shared with the new pool. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Rony Leppänen <[email protected]>
…; test local build and residency failures Host (quick_allreduce_int4.py, kernels/comm/README.md): - the single-phase preflight refuses a CUDA graph capture itself, so compile_sp inside a capture is refused before any vote (it loads modules, which a capture cannot); before, only the lazy first call in _run_sp checked. The message still names compile_sp, and a refused capture leaves the engine's readiness as it was. - the vote's fingerprint drops the shard size, which the full size fixes (_check_sp_payload enforces full == world_size * shard); a mismatch is now reported as kind / full_bytes only. - docstrings and README: launches share inbox slots and colors per engine (the single-phase modes and the all-reduce sizes the ladder gives the same super_tile=1 engine), one serialized order for all launches stays the rule; the exception types differ between ranks after a failed preflight; a failed repeat compile_sp revokes an earlier pass; later shapes are checked on their own rank, the address-dependent checks included. Op test: - a build or a residency failure on rank 1 alone must be raised by every rank (two new preflight cases; a stub makes any launch after a failed preflight an error instead of a persistent kernel); - the residency check is shown to run on the reduce-scatter build and then the all-gather build, and the CU count in use is compared with the device's; - the residency stub covers every artifact in either order and a second CU count, and a RuntimeError of another kind is not a refusal; - the reference outputs of the back-to-back launches must be finite, and the number of graph replay NMSE values is checked, so a loop that did not run fails; - compile_sp inside a capture, on a ready engine, is refused and the engine stays ready; - the refusal cases also run on a ready engine, where the check of each launch (not the preflight's copy of it) refuses. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Rony Leppänen <[email protected]>
…l check; pin compile_sp-under-capture to no vote and no load Follow-up to the review of the previous commit. Op test: - every refusal check (the malformed-tensor cases, on a not-ready and on a ready engine, and the engines the modes cannot run on) runs with a stub that raises at any launch, as the preflight cases already did, so a refusal that regresses fails as an assertion instead of launching a persistent kernel on invalid tensors; - compile_sp inside a capture, on a ready engine, is now shown to refuse before any vote and any module load (neither all_gather_object nor preload_launcher is called), not only to raise a message that names compile_sp and keep the engine ready; - a peer's failed capture is reported once; the healthy ranks no longer add "missing replay values" and "not refused" lines; - the module docstring lists the new coverage, the worker docstring no longer says that no case launches (the retry and the steady-state calls do), a comment on the back-to-back references is corrected, and the non-finite count is one helper. Docs (no behaviour change): the all-reduce, the fused RMSNorm and the single-phase modes share inbox slots and colors per engine, now said in the class docstring, the _sp_engine and reduce_scatter docstrings and the README. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Rony Leppänen <[email protected]>
|
On the accuracy request in the review body (reviewed head Repeated with three new pairs; the rule, the bound and the analysis were fixed before the first run. Setup as the pair in the description: Qwen3.8-Flash-Next MXFP4, TP2, GSM8K 5-shot, 1,319 questions, temperature 0, same seed; INT4 = Shipped 8 MiB gate, INT4 minus exact in points (pooled = per-question paired difference, mean over the rounds, SE over the 1,319 questions because the rounds reuse them):
The bound was -1.0 point on the lower CI limit of both filters: no loss beyond the bound. Code these runs used: the kernel file is byte-identical to the current head's; the host file was Run-to-run spread, same configuration: exact arm, thirteen runs, strict 95.60-96.82 (range 1.21 points, 0.76 without the earliest run); INT4 arm, four runs, 96.13-96.66. A one-point difference between two runs of one configuration is within what is seen, so one pair cannot settle the question, which is why a pooled CI is given. The earlier single pair in the description (-1.14) had an RCCL exact arm and an earlier tree; this spread does not explain it. Exposure at 8 MiB: a separate run with step statistics on (INT4 arm, lm-eval only) shows 104 of 6,243 engine steps (1.7 %) above 2,048 tokens, certainly above the gate, and 762 (12 %) between 1,024 and 2,048, which may or may not be; the rest are far below it. The pairs above exercise INT4 on a minority of steps and bound the loss for that exposure only. Upper bound, gate lowered to about 1 MiB (
Not claimed: a mechanism, other benchmarks or models, TP4 / TP8, gfx942, gates other than the two tested (8 MiB, and 1 MiB as the upper bound), MTP. |
|
Pushed
|
|
On the accuracy request: the repeat pairs at the 8 MiB gate (pooled CI inside the bound) and the default-off opt-in in vllm#65628 are enough for me to land this, with no further ablation or second benchmark needed here. The 1 MiB result stays a caveat for anyone lowering the gate. |
Docs only; the code is unchanged (the module's AST with docstrings stripped is identical to the parent's). - the class docstring gets one paragraph of call rules for every method that takes stream: stream=None is the current PyTorch stream of the device; a call only enqueues work, so its tensors must stay allocated until that work has finished (for a captured call, until the graph's last replay), out is not valid and inp must not be modified before then, and a tensor of another stream needs an event dependency; inp and out are checked by check_tensors (torch tensors, bf16, this rank's CUDA device, contiguous, 16-byte aligned), must not overlap, and are sized by check_payload (all-reduce, fused RMSNorm) or _check_sp_payload (single-phase modes); - reduce_scatter names the INT4 codec among the engine requirements (the single-phase build refuses the fp16 wire codec) and points to the class docstring for the ordering rule and the call rules; all_gather points there and inherits the engine and codec rules of reduce_scatter; - one over-long line in the reduce_scatter docstring is rewrapped. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Rony Leppänen <[email protected]>
…kreduce-sp-rs-ag No conflicts: main (9c119bb) and this branch changed disjoint files. The tree differs from origin/main in the five files of this PR only, with the same diffstat as the branch against its previous merge base (1859 insertions, 12 deletions). Main pins flydsl>=0.5.0 (aiter/ops/flydsl/__init__.py), so this head needs FlyDSL 0.5.0 or newer. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Rony Leppänen <[email protected]>
…on a patched copy of the kernel A section of the op test (TP2 only) runs the single-phase modes with one rank delayed at a fixed point of the kernel, so that a defect in the slot-reuse handshake shows as a wrong output instead of depending on timing: - _slow_reader_source() makes one exact-text edit of the kernel source: rank 1 sleeps (40 x s_sleep(127), the unrolled hook of the earlier stall control) between its data wait and its reads in the single-phase loop. The anchor must occur exactly once, so a kernel edit that moves or repeats it fails the test with the count instead of testing nothing. No factory parameter is added: the copy is loaded from a temporary file under another module name and replaces the host's make_quick_allreduce_int4_kernel for the life of the engine, with its own FlyDSL cache directory; after compile_sp the test requires that directory to hold the compiled kernels (skipped when FlyDSL's disk cache is off), so a build that did not use it fails. - Two spawn pools run the same work: P with the shipped kernel and S with the copy. Each rank computes the isolated outputs of two inputs, then launches 256 reduce-scatters and 256 all-gathers back to back on the one-rung cap-64 engine, alternating the inputs, each into its own output buffer, with one sync at the end. Asserted: no launch differs from the isolated output of its input (P and S), S's isolated outputs equal P's (sha256), and a stalled launch is at least 50 us slower than an unpatched one, so a hook that stops stalling fails instead of passing. - _run_pool() takes a timeout; the section passes 600 s and min(FLYDSL_QR_TIMEOUT, that) applies, so a hang in this section ends in minutes instead of at the 3600 s default. The other pools are unchanged. - main() runs the section first, through _check_slow_reader(), which does nothing unless TP2 is among the selected world sizes (--tp names what runs); the module docstring lists it. First, because the other phases can hang on a missing handshake: with it removed from reduce-scatter in the production kernel the whole file did not finish in 240 s or 600 s (a stack dump showed its first phase, the validity pools), where the section ends the file in 17 s with the wrong outputs. Authoring runs (MI355X, FlyDSL 0.5.0, TP2), not part of the test: unpatched 17-20 us per launch, stalled 287-291 us, no mismatch in either pool. With the slot-reuse handshake removed from the production kernel, one mode at a time, the mutated mode shows 255 of 256 wrong launches on rank 1 in 17 of 18 runs on the cap-64 engine (the 18th, all-gather, ended at the pool timeout) and in 2 of 2 on the shipping ladder, while the same trees without the stall show 0 of 256. Through main() the same defect fails the whole file with the section's message (one run per mode). A hook with 0 sleeps fails the stall check, a different reference input fails the digest comparison, and a build that skips its own cache directory fails the cache check. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Rony Leppänen <[email protected]>
…nous, shorter pointers Docs only (the host file's AST with docstrings stripped is identical to the parent's). Follow-up to the call-rules paragraph of the earlier docstring commit: - that commit said a call "only enqueues work"; the first eager reduce_scatter / all_gather (compile_sp preflight) and the first allreduce_rmsnorm at a new width also compile, load kernels or run a collective before they enqueue. The paragraph now says the call returns once its work is enqueued on the stream, which holds for every call, and the method docstrings keep their first-call rules; - reduce_scatter and all_gather point to the class docstring's call rules without listing what is in them again. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Rony Leppänen <[email protected]>
johannes-graner
left a comment
There was a problem hiding this comment.
Nice, thanks for the fixes!
…kreduce-sp-rs-ag main renamed quick_allreduce_int4 to quick_allreduce (QuickAllReduceInt4 to FlyQuickAllReduce, the kernel module to quick_allreduce_mesh) and moved MAX_PAYLOAD_BYTES, SUPPORTED_BLOCKS and QUANT_MIN_PAYLOAD_BYTES to allreduce_policy (#5555). Conflicts: the module docstring and the factory name of quick_allreduce_mesh.py, and the import block, the class header and a docstring of quick_allreduce.py. The single-phase modes keep their code; their renamed references follow in the next commit. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Rony Leppänen <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
The capture guard checks the current device and stream rather than the engine’s effective targets, allowing cold calls on capturing streams to enter module loading and collective voting instead of being refused.
1 open issue
2 resolved since last review
Review effort: Balanced
| which a CUDA graph capture cannot do, so it is refused there before any | ||
| vote; every rank must be outside a capture. | ||
| """ | ||
| if torch.cuda.is_current_stream_capturing(): |
…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]>
|
No correctness issues found. This can be approved once CI passes. |
…kreduce-sp-rs-ag Brings in #7804, which makes the attention A2A op reserve the MX Q-scale slack that the mha_v4 query-tile gather requires. Without it, op_tests/multigpu_tests/test_attention_a2a.py fails in the 8-GPU job. No conflicts. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Rony Leppänen <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
The capture guard checks the caller’s current device and stream rather than the engine’s actual launch context, allowing capture to go undetected and unsafe kernel loading and collective voting to proceed.
Review effort: Balanced
zufayu
left a comment
There was a problem hiding this comment.
AITER SOP code review on current head 1748d5d:
Verified blocker: the capture guard in quick_allreduce.py checks the caller's current device/current stream, not the engine device and the effective launch stream. If the engine is on another device, or RS/AG is given an explicit capturing stream, this path can still perform JIT/module loading and the cross-rank vote during capture, which can invalidate capture or hang ranks.
Primary reviewer: @TennyWang1223 (communication/all-reduce owner).
Author action: bind capture detection to self._device_index and the actual effective launch stream, add coverage for explicit-stream and cross-device cases, then rerun fresh multi-GPU CI. The current Aiter Gate is red; the new target passed but the overall multi-GPU job timed out, so both code and CI gates remain open.
TennyWang1223
left a comment
There was a problem hiding this comment.
Blocked on:
(1) rebase onto main after #5670 (mesh kernel/host refactor — please re-port the SP path and re-validate TP2/4/8);
(2) the open capture-guard thread (check capture on self._device_index + effective stream, with tests);
(3) the new test takes ~22 min in the 8-GPU job (TP8 ≈17 min) and pushes it past the 120-min timeout — please trim the default CI run. hgemm / capture_registration failures are unrelated.
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]>
…l prefill The INT4 reduce-scatter of ROCm/aiter#7444 (open) is not in any AITER release yet. These are its files at 3c77ea12e, verbatim except for the package-relative import lines (see `MANIFEST.tsv`), as served in the tested image. Remove this commit when SGLang's AITER pin carries sgl-project#7444. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Under pure TP each rank repeats the per-token work of a DeepSeek-V4.1 layer for all prefill rows. On gfx950 this work runs in the Mega-mHC seams, the HIP radix backend's projections and the MXFP8 MoE-input quant, which sgl-project#47888 (gfx942) does not cover. With `SGLANG_DSV4_TOKEN_PARALLEL_PREFILL=1` (and `SGLANG_DSV4_TOKEN_PARALLEL_DSPARK=1` under DSpark capture) eager extend chunks keep 1/tp of the rows per rank in layers before the bounded-replay tail. - New `deepseek_common/amd/deepseek_v4_token_parallel.py`: row layout, exact gathers, INT4 reduce-scatter (ROCm/aiter#7444), eligibility checks - Hooks in `deepseek_v4.py` and the AITER MoE runner (pre-quantized MXFP8 input) - CPU test of the layout and the collectives on 4 gloo ranks Co-Authored-By: Claude Opus 5.5 <[email protected]>

Summary
Adds
reduce_scatter(inp, out),all_gather(inp, out)andcompile_sp(full, shard)toFlyQuickAllReduce.reduce_scatterandall_gathereach run one phase of the INT4 all-reduce on its own and leave row-contiguous shards, the layout sequence parallelism needs.reduce_scatter:inpis this rank's bf16[T, H]partial;outis its block[rank * T/W, (rank + 1) * T/W)of the sum.all_gather:inpis this rank's[T/W, H]block;outis the[T, H]concatenation in rank order.compile_sp(full, shard)is a collective preflight: every rank calls it with the same sizes before CUDA graph capture.group(all_gather_object) on success, call kind and full size. Any failure or disagreement makes every rank raise and leaves the engine not ready.compile_spand that first call are refused under CUDA graph capture.Main (
6efb333ad) was merged on 2026-11-11. #5555 renamedQuickAllReduceInt4toFlyQuickAllReduce,quick_allreduce_int4.pytoquick_allreduce.py(host) andkernels/comm/quick_allreduce_mesh.py(kernel), and moved the payload constants intoallreduce_policy.py. Against main the PR is still the same five files.Motivation
Why the existing INT4 kernels do not cover sequence parallelism:
atoms/Watoms of every tile, so it cannot produce the row-contiguous shards sequence parallelism needs.csrc/kernels/quick_reduce_scatter.cu) is HIP and requires four ranks.What it is for: vllm-project/vllm#65628 uses these methods, through the router in #7819, for the sequence-parallel (SP) collectives of a TP2 model on MI355X. With bf16 RCCL collectives the SP layout was slower than the default layout in every end-to-end measurement made so far. The INT4 collectives are the candidate fix, and that PR reports the end-to-end results.
Changes
kernels/comm/quick_allreduce_mesh.py)modeargument of the mesh kernel factory:MODE_AR(default, unchanged),MODE_RSandMODE_AG. The single-phase modes takesuper_tile=1, the 8-atom tile, INT4, divisor 1 and no fused norm.downs a contiguous block of rows rather than a slice of every tile. The tile machinery is unchanged; only the HBM address of an atom moves (_sp_payload_io).readyflag. It is published after the tile's loads and awaited before the first payload store.waves_per_euis pinned as for the fused-norm builds, and the JIT symbol gets an_rs/_agsuffix._own_packets) and accumulates in rank order. With the exact add, a row's value would depend on the rank that owns it.quick_allreduce.py,allreduce_host_shared.py)reduce_scatter,all_gather,compile_spand the helpers_sp_engine,_sp_launcher,_check_sp_payload,_sp_preflight,_check_sp_residency,_run_sp.check_tensorsis split out ofcheck_payload, whose behaviour and signature are unchanged (_launch_artifactsis imported from it for the residency check).stream;reduce_scatterandall_gatherpoint to it. README: a paragraph oncompile_spand the serialized launch order, and a test line.T % world_size == 0(the host checks byte sizes only).world_sizetimes the shard, a non-empty whole number of 32 KiB tiles (T % 32 == 0at hidden 2560), within the 4 GiB window, and the tensors do not overlap.super_tile=1engine) share its colors and inbox slots, so work on other streams needs an event dependency.super_tile=1engine at block 256 (the host raises otherwise). Nomin_bytesfloor applies to these methods.max_blocks_per_cu()and fails unlessceil(grid / CUs)fits. It does not clamp the grid (whether clamping is safe for the per-block colors is not verified; with the shipped grids the check does not fire on gfx950).5eccc0c7b(FlyDSL 0.4.1; the kernel andallreduce_host_shared.pybyte for byte):super_tile1 and 8 (24), fused norm at hidden 4096super_tile1 and 8 (24), the latency build (12) and the wide tile at hidden 6144 (8), at world size 2 / 4 / 8, first and last rank, gfx950 and gfx942.test_flydsl_quick_allreduce_int4.pyand..._rmsnorm.py, TP2, GPU) gave the same result on main and on this tree: 487 non-timing table cells compared, 0 differences.test_flydsl_quick_allreduce.py --tp 2passes.Performance
µs per call (lower is better), bf16, hidden 2560, CUDA-graph replay, MI355X. The modes are new, so "Before" is RCCL. The INT4 modes are lossy. These timings predate the merge of main and were not repeated on the merged head.
Method:
vllm/vllm-openai-rocmnightlydd4e40142a32(amd-aiter 0.1.27, torch 2.13.0+rocm10.0.0, RCCL 2.30.4), FlyDSL 0.4.1 over the image's 0.4.0,aiter/ops/flydslreplaced by this tree's (301 files md5-checked). The kernel andallreduce_host_shared.pyare3c77ea12e's byte for byte; the host file is30f37d948's up to one comment line, so the timings predatecompile_sp.meta::comms::dda*Ipckernels, and in graph timing PyNccl is 0.975 to 1.000 (RS) and 0.986 to 0.995 (AG) of torch.distributed.(2.0x)means this PR is 2.0 times as fast).-means no number: HIP INT4 exists only for TP4 reduce-scatter, and aiter declines IPC at 16384 rows (the 80 MiB tensor is above its 64 MiB limit).Columns (RS = reduce-scatter, AG = all-gather):
reduce_scatter_tensor/all_gather_into_tensorthrough torch.distributed (TP8: PyNccl, above), bf16, exact. After: this PR (INT4). Speedup: Before divided by After (2.8x means 2.8 times as fast).all_to_all_singleand a dequantizing sum.qr_reduce_scatter, a HIP C++ kernel where this PR's are FlyDSL. It quantizes to 4-bit integers with a different codec (one fp16 scale per 32 values, NMSE 7.4e-3 against 6.5e-3 here), and exists for reduce-scatter on four ranks only.Also measured:
super_tile=8from 4096 rows).Testing
Documentation
Dependencies
This PR adds no requirement; the head merges main, which requires FlyDSL >= 0.5.0 (
aiter/ops/flydsl/__init__.py).Breaking Changes
None.
PR Self-Review
Reviewed revision
1748d5d5617933f88214f09f3aa2b82a30062db5Behavior and intent
New methods only: no existing call, default or output changes (
check_payloadkeeps its behaviour and signature, and the all-reduce ISA was byte-identical to main's before the merge, see Changes). Sequence-parallel layouts get INT4 collectives with row-contiguous shards, which the all-reduce kernel's per-tile ownership could not produce.One behaviour differs from the all-reduce on purpose: the reduce-scatter quantizes the rank's own partial, where the all-reduce adds its own share exactly, so that a row's value does not depend on its owner. Taking the exact add instead is local to
_own_packetsand_reduce_scattered_sp; the owner-independence check would then no longer hold for reduce-scatter.Validation and unverified scope
All runs on MI355X (gfx950), hidden 2560, bf16, in
vllm/vllm-openai-rocmnightlydd4e40142a32(amd-aiter 0.1.27, torch 2.13.0+rocm10.0.0, RCCL 2.30.4), with this tree'saiter/ops/flydsland fouraiter/distfiles over the image's, md5-checked against the commit in every job. FlyDSL 0.4.1 (therequirements.txtpin) over the image's 0.4.0 for the pre-merge rows. FlyDSL 0.5.0 (PyPI wheel), agit archivesnapshot and 8 to 13 md5-checked files per job for the others: the only runs under 0.5.0.30f37d948,3c77ea12eand584df31bdare pre-merge; the head0fd0532e2is584df31bdplus the merge of main6efb333adand an adaptation commit.30f37d948python3 op_tests/multigpu_tests/test_flydsl_quick_reduce_scatter_all_gather.py --tp 2 4 8 -s 8192,2560on 8 GPUs, from a copy outside the repo so thatimport aiterresolves to the overlay30f37d9483c77ea12etest_flydsl_quick_allreduce_int4.py --tp 2 -a mesh--tp 254 s,--tp 461 s,--tp 887 s (preflight pool included); the upstream test passes; TP2 and TP4 repeated on a second gfx950 node pass (62 s, 64 s), same correctness columns584df31bd, 0.5.05bbeb2589, whose kernel and host code are the head's); the op test, whole file, fresh cachemax_blocks_per_cu()works in 36 of 36 builds, limits equal the 0.4.1 ones (TP2 4 against a need of 2, TP4 5 against 4, TP8 5 to 6 against 2), the residency check passes at every probed grid and raises one block per CU above the limit (36 of 36 each). Op test: TP2 rc 0 in 74 s, TP4 rc 0 in 62 s, correctness columns equal to the 0.4.1 runs digit for digit (rs NMSE 0.00650243 at TP2, 0.00650306 at TP4)584df31bd, 0.5.03c77ea12e) and 0.5.0 (the head), one lease0fd0532e2(head), 0.5.0test_flydsl_quick_allreduce.py --tp 2Traceback,Error,failorskipline in any of the logsor codec != "int4"check removed from the overlay'squick_allreduce_mesh.py; op test--tp 2_check_unsupported_enginesfails witha launch was reachedTiming note: in two earlier whole-file TP4 runs three of the four timed values (174.8, 174.7 and 225.6 us; the fourth was 96.0 us) were far above the 0.4.1 ones while another job of mine was running on the node. Four later runs with no other job of mine running gave 90.8 to 91.8 us, and two runs on the merged tree gave 90.9 to 91.3 us. The cause of the slow runs is not shown.
End-to-end accuracy through the INT4 hook of vllm-project/vllm#65628 (Qwen3.8-Flash-Next MXFP4, TP2, GSM8K 5-shot, 1,319 questions, strict match unless noted). The first three rows ran the first version of that hook (
--enable-hc-sp-quick-reduceagainst--enable-hc-sp-aiter-ipc), whose flags no longer exist, on the host file of30f37d948(no collective preflight or residency check). The last row is the reworked PR, which reaches these kernels through #7819.VLLM_ROCM_QUICK_REDUCE_MIN_SIZE_BYTES_MB=1, which also lowers the gate of the server's INT4 all-reduces): an upper bound, six pairsbd54a9deeover an earlier head of this PROne served-model round on a tree with the host code of
3c77ea12e(ad1808d27) starts through the real hook, serves GSM8K and passes the needle check (strict INT4 95.83, exact 96.21). Not claimed: a mechanism, other benchmarks or models, TP4 / TP8, gfx942, MTP.Unverified:
ci:multi-gpulabel.finegrainedinbox (the host refuses these modes there), TP8 on any node but that one, hidden sizes other than 2560, and a fresh install of this tree (the runs used the overlay above). Under FlyDSL 0.5.0 TP8 runs only in the multi-GPU CI job.5eccc0c7bunder FlyDSL 0.4.1 and not repeated on the merged tree. The performance table was not re-timed after the merge.quick_allreduce_int4.pypaths that [FlyDSL] QuickAllReduce INT5/INT6 and all-reduce cleanup #5555 renamed, so they need a rebase in either order. Not trial-merged here.PR-specific question
Before this PR the three methods do not exist, so the new test stops at its first call with
AttributeError. Against mutants of the kernel (TP2 on another node, each run once, on an earlier commit of this branch whose kernel file is identical to the current one):readywait removed from either modeFLYDSL_QR_TIMEOUT(120 s here, default 3600 s), cause not determinedHost-side mutants (TP2 on a gfx950 pair; the CPU runs on
ad1808d27):_sp_preflight/_run_spover a stubbed engine) fail their harness. Seven variants of the residency comparison fail its CPU stub test.Delayed-rank coverage, each test run alone at TP2 on
5d4a4c149(an earlier commit with the current kernel file) against three mutants (thereadywait removed from either mode, the colour not stored back):super_tile=1enginereadyremoved, one mode at a time, the stalled rank's output of that mode is wrong in 255 of 256 launches in 17 of 18 runs on the cap-64 engine (the 18th, all-gather, hung until the pool timeout, cause not determined) and in 2 of 2 on the shipping ladder. The same trees without the stall give 0 of 256, and the other mode stays cleanmain()the whole file fails each of the two mutants in 16 to 17 s with the section's message. The section runs first: before it did, the whole file on the reduce-scatter mutant did not finish in 240 s or 600 s and never reached it (stopped in its first phase, the validity pools).The all-reduce tests cannot cover the new methods:
test_flydsl_quick_allreduce.pyshares the codec but not the shard ownership, thereadyhandshake or the output layout.Changed op tests
op_tests/multigpu_tests/test_flydsl_quick_reduce_scatter_all_gather.pyis new and covers the two modes only:compile_sp, and refusal to capture before it.finegrained, INT5 mesh).compile_spand through the first eager call, a build and a residency failure on one rank, reduce-scatter against all-gather as first calls,compile_spinside a capture, an agreeing retry, and no vote on a ready engine. A stub makes any launch after a failed preflight an error. A CPU stub test covers the residency comparison.main()):make_quick_allreduce_mesh_kernel, with its own FlyDSL cache directory that must hold the compiled kernels afterwards;Harness:
--tpis honored throughselect_world_sizes, as in the sibling test: the no-argument run covers TP2 / 4 / 8 where the GPUs exist, and a named size that cannot run is an error.multiprocessing.get_context("spawn"), with no import-timeset_start_method._run_pooltakes atimeout; these pools end after 600 s (the shorter of that andFLYDSL_QR_TIMEOUTapplies).main()on an unsupported arch like its siblingtest_flydsl_quick_allreduce.py, but reads the arch withget_gfx_runtime()(the live GPU) where the sibling and.github/instructions/aiter-ops-flydsl.instructions.mduseget_gfx(). That followsGPU_ARCHS(the last entry when several are listed) and can differ from the GPU the spawned workers run on.🤖 Generated with Claude Code