You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ulysses sequence parallelism needs an all-to-all that turns per-rank sequence slices of all heads into the full sequence for a subset of heads. The xDiT reference path uses RCCL all_to_all_single, host-side permutes and a separate quantize step.
This PR adds a FlyDSL op, AttentionA2AIntraNodeOp, that does the input hop on the device. Each rank writes its slice into every peer's MoRI symmetric-memory buffers, optionally applying a Q/K Hadamard rotation and quantizing on the way, in the layout MHA V4 reads. Only the input hop is covered; RMSNorm, RoPE and the reverse all-to-all are out of scope.
Technical Details
Interface. Input is bf16 [1, S_local, H, 128] per role (Q, K, V), submitted with submit_role(role, input, stream=None). Token s of rank r lands at global token r * S_local + s.
Packed return: flat uint8 payloads plus scales, logically [1, S, H_local, ...], in MHA V4 layouts.
BF16 return: three flat bf16 tensors, viewable as [1, H_local, S, 128].
Codecs.e4m3, e4m3_pc, int8, mxfp4, mxfp6, mxfp6_p, mxfp8; Q/K and V codecs are chosen independently. e4m3_pc and mxfp6_p are V-only and packed-only; mxfp6_p needs V_FOR_FP6_P. Scales are E8M0 for MX codecs and FP32 descales for E4M3 and INT8. The class docstring has the per-codec scale table.
Constraints. Packed return needs S_local % 32 == 0 for every V codec except e4m3_pc. Dense MXFP4/MXFP6 K/V consumers need S_full % 128 == 0. Q/K + V pairings are not restricted to those MHA V4 supports; choosing a supported pairing is the caller's responsibility.
Config check. Optional group= constructor argument: ranks compare configurations over that group before allocation and raise ValueError on every rank on mismatch.
Synchronization. Q, K and V launches are ordered on the stream, with no grid barrier or CU-residency requirement. Cross-rank buffer reuse uses a per-call epoch and alternating receive-buffer sets; a consumer on another stream must be joined with an event before the next submission that reuses its buffer set.
Shared helpers.build_p2p_table (new communication_ops_host_utils.py) and wave_uniform_i64 (communication_ops_utils.py) are shared with the existing FlyDSL dispatch/combine op, which now imports them.
The test is added to the multi-GPU skip list in .github/scripts/aiter_test.sh; the CI image does not include MoRI.
Test Plan
op_tests/multigpu_tests/test_attention_a2a.py (needs MoRI and ENABLE_CK=0) compares every recipe against a reference, byte-exact for packed payloads and scales. An MHA V4 consumer check verifies bitwise equality of fused output against canonical MHA V4 on the gathered inputs, then checks codec quality against BF16. Cases include %64 controls, %32 FP6-P sequences, a non-multiple-of-32 e4m3_pc tail, an oversubscribed-grid row, forced software FP6 encoding, and a group= config-mismatch negative test.
Dispatch/combine, which uses the shared helpers: op_tests/multigpu_tests/test_mega_moe_v2.py at world 2.
Test Result
gfx950, 0 failures. World 4: 47 rows / 1,880 checks. World 2: 43 rows / 904 checks.
Dispatch/combine at world 2: relative L2 error 0.053 against the reference, within the 0.10 tolerance.
gfx942: compile-verified only; not run on hardware.
Benchmark: cache-defeated, world 8, gfx950; fused op against RCCL all_to_all_single plus the exact MHA V4 quantizers. Global sequence lengths 9,419 and 14,867 are padded to 9,472 and 15,104.
This PR adds a new op, AttentionA2AIntraNodeOp, and changes no existing op's behavior. For the Ulysses input hop, xDiT currently runs RCCL all_to_all_single, host-side permutes and a separate quantize pass over Q/K/V. The fused op writes each rank's slice directly into peers' MoRI symmetric buffers in the MHA V4 input layout, quantizing on the way. That cuts the hop from about 290-313 us to 112-169 us at world 8 on gfx950. Dispatch/combine now imports the extracted build_p2p_table and wave_uniform_i64 helpers instead of defining them locally. That refactor changes no behavior.
Validation and unverified scope
gfx950, python3 op_tests/multigpu_tests/test_attention_a2a.py -w <N> --heads 8 40 at 6ef067a: ws2 1882 checks, ws4 4260 checks, ws8 8536 checks, 0 failures in each. That commit is the current head minus the CI-script change and a merge of main. Packed payloads and scales are compared byte-exact against the reference packers, and the MHA V4 consumer output bitwise against canonical MHA V4.
gfx942, the same command at 6ef067a, ws2/4/8: 0 failures, run by TennyWang1223.
Dispatch/combine at world 2 (test_mega_moe_v2.py): relative L2 0.053, under the 0.10 tolerance.
CI Multi-GPU (8 GPU, MI350X) on 6cf62e68b295 ran the dedicated invocation: test_attention_a2a.py 271 rows / 14,678 checks, 0 failures. That run failed only because bench_attention_a2a.py ran without arguments; 96b42e568462 adds it to skip_tests and changes nothing else. At ed982eb on gfx950, op_tests/multigpu_tests/test_attention_a2a.py passed at ws=2 (rows=44 checks=960 failures=0), ws=4 (rows=47 checks=2160 failures=0) and ws=8 (rows=47 checks=4328 failures=0). The new fp6p-mxfp6_p-tail recipe fails on the pre-fix kernel (V scale E8M0 125 vs canonical 131) and passes after. Unverified: end-to-end xDiT integration (xDiT add kernels from general tilemxtilen 32x{1...8}x128x{1...8} #907) is not covered by this PR, and the benchmark numbers come from gfx950 only.
PR-specific question
The CI change is confined to .github/scripts/aiter_test.sh: a skip_tests entry for op_tests/multigpu_tests/bench_attention_a2a.py, and a new case arm that, for op_tests/multigpu_tests/test_attention_a2a.py, runs timeout 60m python3 "$file" -w 2 4 8 --heads 8 40 in place of the default command. The arm uses a fixed path and literal arguments and interpolates no PR title, body, branch name or other PR text. It does not change workflow triggers, permissions:, runners, tokens or secrets. The script runs in the same multi-GPU test job, under the same trust model as every other op test that job already executes from the PR checkout. So this change opens no new path for fork code or text to reach a privileged context. The 60-minute timeout bounds a hung multi-rank run.
Changed op tests
op_tests/multigpu_tests/test_attention_a2a.py: the correctness test for the new op, which no existing test covers. It checks every Q/K and V codec recipe byte-exact against the reference packers. It also checks fused MHA V4 output bitwise against canonical MHA V4 on gathered inputs, and codec quality against BF16. Edge cases: %32 and %64 sequences, a non-multiple-of-32 e4m3_pc tail, an oversubscribed grid and forced software FP6. It includes negative tests for group=None, config mismatch, a swapped rank and a stream change. The fp6p-mxfp6_p-tail recipe is the regression for the split FP6-P V tail-amax fix; no existing recipe places a valid_kv_len tail inside the split frame.
op_tests/multigpu_tests/bench_attention_a2a.py: the perf harness for the op. It runs cache-defeated and compares against RCCL all_to_all_single plus the exact MHA V4 quantizers at Wan2.2 and ticket shapes. It is the source of the speedup table above. No existing benchmark measures this op. It has no correctness checks, so CI skips it via skip_tests. It now skips non-gfx950 devices before spawning workers.
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 5815 --add-label <label>
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 opt this PR out.
… layouts
Typed buffer views, ordered-memory completion flags, layout algebra for work and address
mappings, named helpers for FP8/native FP6 conversion and wave-local LDS waits.
Non-wrapping peer idx2crd outer modes use UNBOUNDED_OUTER_EXTENT.
…c buffer reuse
Use the private HIP DEFAULT-layout MXFP4 V producer for packed references, and run
the e4m3_pc zero/tiny stress submits after the attention comparison so they do
not overwrite the parity buffers it consumes.
Collect any exception into the cross-rank verdict so a rank-local
error cannot strand peers in the Gloo all_reduce; add a packed
mxfp8 Q/K recipe; correct the submit_role return docstring.
Emit canonical compact K/V layouts while retaining the padded Q length.
Match valid rather than padded MHA tile counts and remove the need for
xDiT to copy packed K/V buffers. Reject transports with sequence-wide
scales and padding outside the final rank.
Co-authored-by: Kristian Sikiric <[email protected]>
Pass an explicit compact K/V length through the existing consumer recipes
while retaining padded Q. Bound the reference score matrix so Wan-length
cases can run with a selected head count.
Without sched_barrier(0), LLVM serializes the Wan-shape amax loads: 20 loads
in flight drop to 1 (vmcnt(0) per load). Each Q/K amax launch goes from 40.4
to 56.8 us, and the E4M3 trio is 10% slower.
PASS — current-SHA answers are present and structurally specific
Show the author's self-review answers
Behavior and intent
This PR adds a new op, `AttentionA2AIntraNodeOp`, and changes no existing op's behavior. For the Ulysses input hop, xDiT currently runs RCCL `all_to_all_single`, host-side permutes and a separate quantize pass over Q/K/V. The fused op writes each rank's slice directly into peers' MoRI symmetric buffers in the MHA V4 input layout, quantizing on the way. That cuts the hop from about 290-313 us to 112-169 us at world 8 on gfx950. Dispatch/combine now imports the extracted `build_p2p_table` and `wave_uniform_i64` helpers instead of defining them locally. That refactor changes no behavior.
Validation and unverified scope
- gfx950, `python3 op_tests/multigpu_tests/test_attention_a2a.py -w <N> --heads 8 40` at 6ef067a151: ws2 1882 checks, ws4 4260 checks, ws8 8536 checks, 0 failures in each. That commit is the current head minus the CI-script change and a merge of main. Packed payloads and scales are compared byte-exact against the reference packers, and the MHA V4 consumer output bitwise against canonical MHA V4.
- gfx942, the same command at 6ef067a15, ws2/4/8: 0 failures, run by TennyWang1223.
- Dispatch/combine at world 2 (`test_mega_moe_v2.py`): relative L2 0.053, under the 0.10 tolerance.
- CI Multi-GPU (8 GPU, MI350X) on `6cf62e68b295` ran the dedicated invocation: `test_attention_a2a.py` 271 rows / 14,678 checks, 0 failures. That run failed only because `bench_attention_a2a.py` ran without arguments; `96b42e568462` adds it to `skip_tests` and changes nothing else. At ed982ebbe3 on gfx950, `op_tests/multigpu_tests/test_attention_a2a.py` passed at ws=2 (rows=44 checks=960 failures=0), ws=4 (rows=47 checks=2160 failures=0) and ws=8 (rows=47 checks=4328 failures=0). The new `fp6p-mxfp6_p-tail` recipe fails on the pre-fix kernel (V scale E8M0 125 vs canonical 131) and passes after. Unverified: end-to-end xDiT integration (xDiT #907) is not covered by this PR, and the benchmark numbers come from gfx950 only.
PR-specific question
The CI change is confined to `.github/scripts/aiter_test.sh`: a `skip_tests` entry for `op_tests/multigpu_tests/bench_attention_a2a.py`, and a new `case` arm that, for `op_tests/multigpu_tests/test_attention_a2a.py`, runs `timeout 60m python3 "$file" -w 2 4 8 --heads 8 40` in place of the default command. The arm uses a fixed path and literal arguments and interpolates no PR title, body, branch name or other PR text. It does not change workflow triggers, `permissions:`, runners, tokens or secrets. The script runs in the same multi-GPU test job, under the same trust model as every other op test that job already executes from the PR checkout. So this change opens no new path for fork code or text to reach a privileged context. The 60-minute timeout bounds a hung multi-rank run.
Changed op tests
- `op_tests/multigpu_tests/test_attention_a2a.py`: the correctness test for the new op, which no existing test covers. It checks every Q/K and V codec recipe byte-exact against the reference packers. It also checks fused MHA V4 output bitwise against canonical MHA V4 on gathered inputs, and codec quality against BF16. Edge cases: `%32` and `%64` sequences, a non-multiple-of-32 `e4m3_pc` tail, an oversubscribed grid and forced software FP6. It includes negative tests for `group=None`, config mismatch, a swapped rank and a stream change. The `fp6p-mxfp6_p-tail` recipe is the regression for the split FP6-P V tail-amax fix; no existing recipe places a valid_kv_len tail inside the split frame.
- `op_tests/multigpu_tests/bench_attention_a2a.py`: the perf harness for the op. It runs cache-defeated and compares against RCCL `all_to_all_single` plus the exact MHA V4 quantizers at Wan2.2 and ticket shapes. It is the source of the speedup table above. No existing benchmark measures this op. It has no correctness checks, so CI skips it via `skip_tests`. It now skips non-gfx950 devices before spawning workers.
PR state
PASS — pull request is marked ready for review
Copilot findings
PASS — no active Copilot finding lacks a substantive author reply
Code and op-test hygiene
PASS — no committed artifact or conflict marker detected
Required CI
PASS — Black: passed
PASS — Ruff: passed
PASS — Repository dependency: passed
PASS — Aiter Test Gate: passed
Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Split FP6-P tail handling produces incorrect scales and bytes, P2P table initialization can race with submission, and rank-local validation failures can strand peer ranks until timeout.
The partial-max path zero-masked tokens past valid_kv_len while the payload
path clamps to the final token first, so a split group published amax 1
instead of the canonical value. Mirror the payload clamp for mxfp6_p only;
add a ws=2 valid_kv_len=33 regression recipe.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The runtime architecture check introduces a separate gcnArchName probe instead of using the shared get_gfx_runtime() helper that owns runtime dispatch and FP8-format selection.
Use aiter.jit.utils.chip_info.get_gfx_runtime() for this runtime architecture check rather than introducing a local gcnArchName probe. The shared helper explicitly owns runtime dispatch and FP8-format selection (aiter/jit/utils/chip_info.py:114–149); keeping this allow-list on that helper avoids a separate detection path.
Re Copilot's note on attention_a2a_intranode.py:280: the local probe is intentional. get_gfx_runtime() takes no device argument, is lru_cached per process, and reports the first gfx* entry from rocminfo. Line 280 checks the op's own device via get_device_properties(self.device), which is the same pattern as fmha_kernels.py, hc_mix.py and topk.py.
@TennyWang1223 Re-confirmed on gfx950 at ed982eb: op_tests/multigpu_tests/test_attention_a2a.py passes at ws=2 (960 checks), ws=4 (2160 checks) and ws=8 (4328 checks), with 0 failures. Since your last look, this head also fixes a split FP6-P V tail-scale mismatch that Copilot found (0781f2f), with a new regression recipe fp6p-mxfp6_p-tail, and adds a gfx950 gate to the benchmark (ed982eb).
…e input hop
The attention-output packed copy now takes the MXFP6 tile geometry (tile
rows, K tile, K guard tiles, payload and scale tile bytes) from
aiter.ops.gemm_op_a6w6 instead of restating it. Construction checks that
mxfp6_gemm_pack_size for the source packs and the destination matches the
tiles the copy addresses and raises on every rank, before any collective or
symmetric allocation, if it does not. A negative-construction case patches
the packer's pack size and checks that every rank raises. The docstring
names each MX codec's layout owner: mxfp4 is the A4W4 activation layout of
the per_1x32 quantizer, not the H32-rotated FP4 operand for A6W4 weights.
The input-hop kernel from #5815 moves to the stable FlyDSL forms:
flyc.get_backend().target.arch instead of
flydsl.compiler.backends.current_target, fx.max/fx.min instead of
maximumf/minimumf, and fx.gpu.shuffle_xor instead of Numeric.shuffle_xor.
For xDiT's A2A profiles and the benchmark's recipes, every compiled
kernel's ISA is unchanged.
…ather (#7804)
#6575 made the mha_v4 launcher require MX Q descales to be backed out to a
whole 256-row query tile (check_scale_backing_storage), but the fused
intranode A2A op (#5815) still allocated packed Q scales unpadded. Whenever
world_size * sequence is not a multiple of 256, feeding its packed MX Q
scales to mha_v4 failed, e.g. in test_attention_a2a.py e4m3_pc at ws=4
s=1184 h=8:
MX Q descale needs 38912 mapped bytes ... but only 37888 are backed
Reserve the same zeroed slack as mha_v4_quant.query_block_scale for
mxfp4/mxfp6/mxfp8 Q scales in packed return. Logical shape and strides are
unchanged; aligned sequences and non-MX Q codecs get no padding.
Co-authored-by: TennyWang1223 <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
…ather (#7804)
#6575 made the mha_v4 launcher require MX Q descales to be backed out to a
whole 256-row query tile (check_scale_backing_storage), but the fused
intranode A2A op (#5815) still allocated packed Q scales unpadded. Whenever
world_size * sequence is not a multiple of 256, feeding its packed MX Q
scales to mha_v4 failed, e.g. in test_attention_a2a.py e4m3_pc at ws=4
s=1184 h=8:
MX Q descale needs 38912 mapped bytes ... but only 37888 are backed
Reserve the same zeroed slack as mha_v4_quant.query_block_scale for
mxfp4/mxfp6/mxfp8 Q scales in packed return. Logical shape and strides are
unchanged; aligned sequences and non-MX Q codecs get no padding.
Co-authored-by: TennyWang1223 <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
…nce-parallel attention (ROCm#5815)
* Extract shared P2P table and wave-uniform helpers from FlyDSL dispatch/combine
Add FP6 RNE and native conversion helpers to quant_utils.
* Add FlyDSL fused intranode all-to-all for Ulysses attention
Seven Q/K/V transport codecs, stream-ordered launches, MoRI symmetric buffers.
* Add attention A2A multi-GPU test and CI skip entry
* Move A2A payload, ordering and addressing onto FlyDSL typed views and layouts
Typed buffer views, ordered-memory completion flags, layout algebra for work and address
mappings, named helpers for FP8/native FP6 conversion and wave-local LDS waits.
Non-wrapping peer idx2crd outer modes use UNBOUNDED_OUTER_EXTENT.
* Match reference E4M3 Q/K scale rounding and e4m3_pc zero-channel clamp
Packed E4M3 Q/K descale uses fp32 reciprocal multiply like torch amax/dtype_max;
e4m3_pc clamps channel amax to 1e-12 like quantize_v_fp8. Adds tests.
* Return per-role packed payload and scale from submit_role
submit_role returns PackedRoleResult(payload, scale) for Q, K and V in packed
mode so callers get each role's buffers right after submission.
* Fix attention A2A test after main removed quantize_v_mxfp4 and e4m3_pc buffer reuse
Use the private HIP DEFAULT-layout MXFP4 V producer for packed references, and run
the e4m3_pc zero/tiny stress submits after the attention comparison so they do
not overwrite the parity buffers it consumes.
* Address Copilot review on A2A test and docs
Collect any exception into the cross-rank verdict so a rank-local
error cannot strand peers in the Gloo all_reduce; add a packed
mxfp8 Q/K recipe; correct the submit_role return docstring.
* Add valid_kv_len to AttentionA2AIntraNodeOp for compact K/V output
Emit canonical compact K/V layouts while retaining the padded Q length.
Match valid rather than padded MHA tile counts and remove the need for
xDiT to copy packed K/V buffers. Reject transports with sequence-wide
scales and padding outside the final rank.
Co-authored-by: Kristian Sikiric <[email protected]>
* Add --valid-kv-len and --heads to attention A2A test
Pass an explicit compact K/V length through the existing consumer recipes
while retaining padded Q. Bound the reference score matrix so Wan-length
cases can run with a selected head count.
* Restore A2A scheduler barrier after per-tensor Q/K preload
Without sched_barrier(0), LLVM serializes the Wan-shape amax loads: 20 loads
in flight drop to 1 (vmcnt(0) per load). Each Q/K amax launch goes from 40.4
to 56.8 us, and the E4M3 trio is 10% slower.
* a2a: kernel guards, exact INT8 E8M0 exponent, trimmed descriptor extents
* a2a: host init/config checks and docstring clarifications
* a2a: async reuse, trimming and software-FP6 test coverage
* a2a: optional group arg for cross-rank config agreement check
* a2a: add maintained RCCL+quantizer baseline benchmark
* a2a: sync only the init stream before the MoRI barrier
* Update aiter/ops/flydsl/kernels/attention_a2a_intranode_kernel.py
Co-authored-by: Mohsen <[email protected]>
* Harden fused A2A: mandatory group, PE/offset checks, stream rule, debug spin trap
Require group, check MoRI PE/npes, verify symmetric offsets across ranks,
reject null p2p pointers, reject cross-stream trios, add
AITER_A2A_SPIN_TIMEOUT_ITERS debug trap, negative tests, and restore
aiter_test.sh to origin/main plus the one skip line.
* Treat v4-consumer output mismatch as known upstream MHA V4 race
The gfx950 MHA V4 asm consumers publish the V LDS slot before their
buffer_load ... lds copies complete, so mha_v4_packed output varies under
concurrent same-GPU work. Transport bytes are now checked strictly before
the consumer; consumer-output equality and the accuracy checks that read
it are recorded as known-upstream unless AITER_A2A_STRICT_V4_CONSUMER=1.
* Drop Q-scale tile padding in fused A2A after ROCm#6841
Upstream mha_v4_quant no longer pads Q block scales; the ASM gather clamps past the sequence end via the buffer descriptor.
* Make v4-consumer mismatch a hard failure again
The MHA V4 V-LDS publication race is fixed upstream in ROCm#6841 (merged via main); strict ws4 validation passes.
* Restore strict transport-byte checks in fused A2A test
Keeps transport faults distinguishable from consumer faults; the KNOWN-UPSTREAM soft-fail stays removed.
* Run fused A2A multi-GPU test in CI
MoRI is now installed in the multi-GPU job, so drop test_attention_a2a.py
from skip_tests and run it at world sizes 2/4/8 with heads 8 and 40.
* [CI] Skip bench_attention_a2a.py in multi-GPU suite
The benchmark is a perf harness with no correctness checks and requires
-w, so the default no-argument invocation failed the job.
* a2a: clamp FP6-P V partial-amax token to valid_kv_len-1
The partial-max path zero-masked tokens past valid_kv_len while the payload
path clamps to the final token first, so a split group published amax 1
instead of the canonical value. Mirror the payload clamp for mxfp6_p only;
add a ws=2 valid_kv_len=33 regression recipe.
* bench a2a: gate on gfx950 before spawning workers
Workers initialize distributed and MoRI before the op rejects gfx942 packed
MX recipes; skip in main using get_gfx_runtime().
---------
Co-authored-by: Kristian Sikiric <[email protected]>
Co-authored-by: Mohsen <[email protected]>
Co-authored-by: TennyWang1223 <[email protected]>
…l for Ulysses sequence-parallel attention (#7648)
* [FlyDSL] Add quantized attention-output intranode A2A
* [FlyDSL] Test attention-output A2A at world sizes 2, 4 and 8
* [FlyDSL] [CI] Add attention-output A2A benchmark and skip it in the multi-GPU suite
* [FlyDSL] Address review of the attention-output A2A
- E4M3 matches per_1x128 for NaN and infinite inputs: a NaN-ignoring group
amax from aiter::kAmaxFloor and a clamp that saturates NaN as v_med3_f32 does.
- e4m3_external_scale is documented as TorchAO's per-tensor quantization
(divide, clamp, cast), with its caller preconditions.
- The push kernel only builds the two E4M3 modes; the unused MX encoder is gone.
- The wrapper passes its arch to the builders, checks it against the FlyDSL
target, requires one stream across calls, records a side-stream input, checks
every raw-buffer extent and symmetric-buffer offsets, aggregates missing peer
pointers on every rank, and wires AITER_A2A_SPIN_TIMEOUT_ITERS.
- The test adds a slow reader against the parity reuse gate, NaN/Inf corners, a
stream change, and MXFP4 tail scales of real rows.
- The benchmark moves into bench_attention_a2a.py --hop output, times aiter's HIP
per-tensor quantizer for e4m3_external_scale, and reports min/median/max.
* [FlyDSL] Take the A6W6 copy layout from the packer; stable APIs in the input hop
The attention-output packed copy now takes the MXFP6 tile geometry (tile
rows, K tile, K guard tiles, payload and scale tile bytes) from
aiter.ops.gemm_op_a6w6 instead of restating it. Construction checks that
mxfp6_gemm_pack_size for the source packs and the destination matches the
tiles the copy addresses and raises on every rank, before any collective or
symmetric allocation, if it does not. A negative-construction case patches
the packer's pack size and checks that every rank raises. The docstring
names each MX codec's layout owner: mxfp4 is the A4W4 activation layout of
the per_1x32 quantizer, not the H32-rotated FP4 operand for A6W4 weights.
The input-hop kernel from #5815 moves to the stable FlyDSL forms:
flyc.get_backend().target.arch instead of
flydsl.compiler.backends.current_target, fx.max/fx.min instead of
maximumf/minimumf, and fx.gpu.shuffle_xor instead of Numeric.shuffle_xor.
For xDiT's A2A profiles and the benchmark's recipes, every compiled
kernel's ISA is unchanged.
* [FlyDSL] Drop the attention-output A2A cache-key leftovers; rename its bench report
FlyDSL 0.5.0 keys its JIT cache on the traced IR, so the _JIT_CACHE_TAG and
the key tuples kept alive in both launchers are redundant; this drops them
as #7600 did for the input hop.
The output hop of bench_attention_a2a.py now writes
/tmp/bench_attention_a2a_output_w{world}.md, a name derived from the merged
script, instead of the removed bench_attention_output_a2a.py's.
Since #5985, per_1x128 skips a bf16 signalling NaN like a quiet one, while
the e4m3 path resets the running maximum it is folded into. The docstring
now claims byte identity for finite, infinite and quiet-NaN inputs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Ulysses sequence parallelism needs an all-to-all that turns per-rank sequence slices of all heads into the full sequence for a subset of heads. The xDiT reference path uses RCCL
all_to_all_single, host-side permutes and a separate quantize step.This PR adds a FlyDSL op,
AttentionA2AIntraNodeOp, that does the input hop on the device. Each rank writes its slice into every peer's MoRI symmetric-memory buffers, optionally applying a Q/K Hadamard rotation and quantizing on the way, in the layout MHA V4 reads. Only the input hop is covered; RMSNorm, RoPE and the reverse all-to-all are out of scope.Technical Details
[1, S_local, H, 128]per role (Q, K, V), submitted withsubmit_role(role, input, stream=None). Tokensof rankrlands at global tokenr * S_local + s.uint8payloads plus scales, logically[1, S, H_local, ...], in MHA V4 layouts.[1, H_local, S, 128].e4m3,e4m3_pc,int8,mxfp4,mxfp6,mxfp6_p,mxfp8; Q/K and V codecs are chosen independently.e4m3_pcandmxfp6_pare V-only and packed-only;mxfp6_pneedsV_FOR_FP6_P. Scales are E8M0 for MX codecs and FP32 descales for E4M3 and INT8. The class docstring has the per-codec scale table.S_local % 32 == 0for every V codec excepte4m3_pc. Dense MXFP4/MXFP6 K/V consumers needS_full % 128 == 0. Q/K + V pairings are not restricted to those MHA V4 supports; choosing a supported pairing is the caller's responsibility.group=constructor argument: ranks compare configurations over that group before allocation and raiseValueErroron every rank on mismatch.build_p2p_table(newcommunication_ops_host_utils.py) andwave_uniform_i64(communication_ops_utils.py) are shared with the existing FlyDSL dispatch/combine op, which now imports them..github/scripts/aiter_test.sh; the CI image does not include MoRI.Test Plan
op_tests/multigpu_tests/test_attention_a2a.py(needs MoRI andENABLE_CK=0) compares every recipe against a reference, byte-exact for packed payloads and scales. An MHA V4 consumer check verifies bitwise equality of fused output against canonical MHA V4 on the gathered inputs, then checks codec quality against BF16. Cases include%64controls,%32FP6-P sequences, a non-multiple-of-32e4m3_pctail, an oversubscribed-grid row, forced software FP6 encoding, and agroup=config-mismatch negative test.Dispatch/combine, which uses the shared helpers:
op_tests/multigpu_tests/test_mega_moe_v2.pyat world 2.Test Result
Benchmark: cache-defeated, world 8, gfx950; fused op against RCCL
all_to_all_singleplus the exact MHA V4 quantizers. Global sequence lengths 9,419 and 14,867 are padded to 9,472 and 15,104.Submission Checklist
PR Self-Review
Reviewed revision
ed982eb
Behavior and intent
This PR adds a new op,
AttentionA2AIntraNodeOp, and changes no existing op's behavior. For the Ulysses input hop, xDiT currently runs RCCLall_to_all_single, host-side permutes and a separate quantize pass over Q/K/V. The fused op writes each rank's slice directly into peers' MoRI symmetric buffers in the MHA V4 input layout, quantizing on the way. That cuts the hop from about 290-313 us to 112-169 us at world 8 on gfx950. Dispatch/combine now imports the extractedbuild_p2p_tableandwave_uniform_i64helpers instead of defining them locally. That refactor changes no behavior.Validation and unverified scope
python3 op_tests/multigpu_tests/test_attention_a2a.py -w <N> --heads 8 40at 6ef067a: ws2 1882 checks, ws4 4260 checks, ws8 8536 checks, 0 failures in each. That commit is the current head minus the CI-script change and a merge of main. Packed payloads and scales are compared byte-exact against the reference packers, and the MHA V4 consumer output bitwise against canonical MHA V4.test_mega_moe_v2.py): relative L2 0.053, under the 0.10 tolerance.6cf62e68b295ran the dedicated invocation:test_attention_a2a.py271 rows / 14,678 checks, 0 failures. That run failed only becausebench_attention_a2a.pyran without arguments;96b42e568462adds it toskip_testsand changes nothing else. At ed982eb on gfx950,op_tests/multigpu_tests/test_attention_a2a.pypassed at ws=2 (rows=44 checks=960 failures=0), ws=4 (rows=47 checks=2160 failures=0) and ws=8 (rows=47 checks=4328 failures=0). The newfp6p-mxfp6_p-tailrecipe fails on the pre-fix kernel (V scale E8M0 125 vs canonical 131) and passes after. Unverified: end-to-end xDiT integration (xDiT add kernels from general tilemxtilen 32x{1...8}x128x{1...8} #907) is not covered by this PR, and the benchmark numbers come from gfx950 only.PR-specific question
The CI change is confined to
.github/scripts/aiter_test.sh: askip_testsentry forop_tests/multigpu_tests/bench_attention_a2a.py, and a newcasearm that, forop_tests/multigpu_tests/test_attention_a2a.py, runstimeout 60m python3 "$file" -w 2 4 8 --heads 8 40in place of the default command. The arm uses a fixed path and literal arguments and interpolates no PR title, body, branch name or other PR text. It does not change workflow triggers,permissions:, runners, tokens or secrets. The script runs in the same multi-GPU test job, under the same trust model as every other op test that job already executes from the PR checkout. So this change opens no new path for fork code or text to reach a privileged context. The 60-minute timeout bounds a hung multi-rank run.Changed op tests
op_tests/multigpu_tests/test_attention_a2a.py: the correctness test for the new op, which no existing test covers. It checks every Q/K and V codec recipe byte-exact against the reference packers. It also checks fused MHA V4 output bitwise against canonical MHA V4 on gathered inputs, and codec quality against BF16. Edge cases:%32and%64sequences, a non-multiple-of-32e4m3_pctail, an oversubscribed grid and forced software FP6. It includes negative tests forgroup=None, config mismatch, a swapped rank and a stream change. Thefp6p-mxfp6_p-tailrecipe is the regression for the split FP6-P V tail-amax fix; no existing recipe places a valid_kv_len tail inside the split frame.op_tests/multigpu_tests/bench_attention_a2a.py: the perf harness for the op. It runs cache-defeated and compares against RCCLall_to_all_singleplus the exact MHA V4 quantizers at Wan2.2 and ticket shapes. It is the source of the speedup table above. No existing benchmark measures this op. It has no correctness checks, so CI skips it viaskip_tests. It now skips non-gfx950 devices before spawning workers.