Skip to content

[FlyDSL] [CI] Add FlyDSL fused intranode all-to-all for Ulysses sequence-parallel attention - #5815

Merged
johannes-graner merged 35 commits into
mainfrom
jograner/ulysses-a2a-SILOTIGER-952
Nov 3, 2026
Merged

johannes-graner merged 35 commits into
mainfrom
jograner/ulysses-a2a-SILOTIGER-952

Conversation

@johannes-graner

@johannes-graner johannes-graner commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

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

  • 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.

python3 op_tests/multigpu_tests/test_attention_a2a.py -w 2 4 8 --heads 8 40

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.

python3 op_tests/multigpu_tests/bench_attention_a2a.py -w 8 --shapes wan2.2 ticket
Recipe Wan2.2 [1, 9419, 40, 128] [1, 14867, 24, 128]
MXFP4 Q/K + MXFP4 V 296 -> 127 us (2.33x) 292 -> 117 us (2.50x)
MXFP4 Q/K + MXFP6-P V 290 -> 137 us (2.12x) 288 -> 112 us (2.57x)
E4M3 Q/K/V 313 -> 169 us (1.85x) 309 -> 151 us (2.05x)
INT8 Q/K + E4M3 V 301 -> 126 us (2.39x) 298 -> 131 us (2.27x)

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 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.

@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

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

Extended tests (opt-in via labels):

Label Tests
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs; main branch always runs both MI35X and MI300X
multigpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 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.

…h/combine

Add FP6 RNE and native conversion helpers to quant_utils.
Seven Q/K/V transport codecs, stream-ordered launches, MoRI symmetric buffers.
… 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.
@johannes-graner
johannes-graner force-pushed the jograner/ulysses-a2a-SILOTIGER-952 branch from e0ea256 to d2ce870 Compare October 5, 2026 07:28
johannes-graner and others added 4 commits October 5, 2026 12:51
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.
submit_role returns PackedRoleResult(payload, scale) for Q, K and V in packed
mode so callers get each role's buffers right after submission.
…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.

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.

Copilot review overview

🔵 Needs a closer look

The large multi-GPU kernel still has uncovered MXFP8 behavior and a rank-failure path that can hang validation.

Review effort: Balanced
Findings: 1 High severity · 1 Medium severity · 1 Low severity

Open (3)
What changed in this PR

Adds a FlyDSL fused intranode all-to-all for Ulysses attention, including optional quantization and MHA V4-compatible packing.

Changes:

  • Adds the host wrapper, GPU kernels, codecs, synchronization, and buffer reuse.
  • Extracts shared communication and quantization helpers.
  • Adds multi-GPU correctness/performance coverage and CI exclusion for MoRI requirements.
File Description
aiter/​ops/​flydsl/​attention_a2a_intranode.py Defines the public host-side operator.
aiter/​ops/​flydsl/​kernels/​attention_a2a_intranode_kernel.py Implements transport, quantization, packing, and synchronization kernels.
aiter/​ops/​flydsl/​communication_ops_host_utils.py Adds shared P2P table construction.
aiter/​ops/​flydsl/​kernels/​communication_ops_utils.py Adds shared wave and LDS helpers.
aiter/​ops/​flydsl/​kernels/​quant_utils.py Adds FP6 and FP8 conversion helpers.
aiter/​ops/​flydsl/​kernels/​flydsl_dispatch_combine_intranode_op.py Uses the extracted host helper.
aiter/​ops/​flydsl/​kernels/​flydsl_dispatch_combine_intranode_kernel.py Uses the extracted wave helper.
op_tests/​multigpu_tests/​test_attention_a2a.py Adds multi-rank correctness and performance testing.
.github/​scripts/​aiter_test.sh Skips the MoRI-dependent test in standard CI.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the 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.
@johannes-graner
johannes-graner requested a balanced review from Copilot October 7, 2026 11:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

johannes-graner and others added 3 commits October 8, 2026 09:53
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.
@aiter-bot

aiter-bot commented Oct 29, 2026 •

Copy link
Copy Markdown

READY FOR HUMAN REVIEW

PR Self-Review

Revision ed982ebbe3dd · mode shadow

Author self-review accepted. Readiness report:

Author answers

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

Behavior and intent

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 benchmark is a perf harness with no correctness checks and requires
-w, so the default no-argument invocation failed the job.
Copilot AI balanced review requested due to automatic review settings October 29, 2026 12:28

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@TennyWang1223

Copy link
Copy Markdown
Contributor

Thanks @johannes-graner ! Once the merge conflict is resolved, I'll approve and merge.

…SILOTIGER-952

# Conflicts:
#	.github/scripts/aiter_test.sh
Copilot AI balanced review requested due to automatic review settings November 2, 2026 06:40

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

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.

4 open issues

Review effort: Balanced

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.
Workers initialize distributed and MoRI before the op rejects gfx942 packed
MX recipes; skip in main using get_gfx_runtime().
Copilot AI balanced review requested due to automatic review settings November 2, 2026 07:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

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.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Use the shared runtime architecture helper

aiter/​ops/​flydsl/​attention_a2a_intranode.py:280

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.

4 resolved since last review

Review effort: Balanced

@johannes-graner

Copy link
Copy Markdown
Contributor Author

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).

@TennyWang1223 TennyWang1223 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.

LGTM @zufayu

@johannes-graner
johannes-graner merged commit d4d80a0 into main Nov 3, 2026
@johannes-graner
johannes-graner deleted the jograner/ulysses-a2a-SILOTIGER-952 branch November 3, 2026 09:28
ksikiric added a commit that referenced this pull request Nov 11, 2026
…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.
gyohuangxin pushed a commit that referenced this pull request Nov 11, 2026
…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]>
vpietila-amd pushed a commit that referenced this pull request Nov 12, 2026
…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]>
shantipriya-amd pushed a commit to shantipriya-amd/aiter that referenced this pull request Nov 18, 2026
…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]>
TennyWang1223 pushed a commit that referenced this pull request Nov 20, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants