Skip to content

[FlyDSL] [Kernel] Add a DCP mailbox query gather and LSE combine - #6972

Merged
valarLip merged 13 commits into
mainfrom
dcp-mailbox-flydsl-rebase
Nov 13, 2026
Merged

valarLip merged 13 commits into
mainfrom
dcp-mailbox-flydsl-rebase

Conversation

@xiaohuguo2023

@xiaohuguo2023 xiaohuguo2023 commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Summary

Add two model-agnostic FlyDSL kernels for decode-context-parallel (DCP) attention. dcp_query_gather and dcp_quant_query_gather replace the DCP query all-gather, including the fp8 quant of ql_nope and q_pe. dcp_lse_combine replaces the log-sum-exp (LSE) all-to-all reduce. Each kernel uses one tagged peer buffer. Larger batches process several tokens per CTA to reduce epoch-counter contention.

Motivation

A DCP rank must gather the query from its peers and combine partial attention outputs with their LSE values. NCCL all-gather and all-to-all do that as several launches and do not keep a tagged peer mailbox. These kernels do both steps in one launch per operator. The API takes ranks, heads, and head dim from the caller, so any model can use it.

Changes

  • Add aiter/ops/flydsl/dcp_mailbox/ and export dcp_lse_combine, dcp_query_gather, dcp_quant_query_gather, CombineWorkspace, and GatherWorkspace from aiter.ops.flydsl.
  • The combine CTA runs dim / 4 threads. Each thread owns four values. dim is a multiple of 4, and 4 * ranks <= dim <= 4096. Thread r pushes the LSE to rank r. One build covers head dims 64, 128, 512, and 576.
  • Combine and gather use 1, 2, 4, or 8-token CTA tiles. The build key and kernel name include the selected tile.
  • The gather supports a plain bf16 gather through dim 512 and an fp8 (float8_e4m3fn) quant gather.
  • Debug workspaces publish epoch plus one, set an unconditional timeout bit with atomic OR, and reject graph capture explicitly.
  • Split-phase gather advances the epoch only after phase 2. Epochs wrap at 2^30, and tiled debug timeouts skip later polls after the first timeout.
  • FlyDSL 0.5.0 provides the JIT specialization key. The mailbox kernels do not create manual source keys.
  • Launchable kernel bodies and shared device helpers live under aiter/ops/flydsl/kernels/dcp_mailbox/. Public wrappers, compile caches, workspaces, and peer allocation stay under aiter/ops/flydsl/dcp_mailbox/.
  • New mailbox data movement uses FlyDSL buffer tensors and fx.copy, not the legacy buffer_ops module. Retained raw timer, sleep, and wave-broadcast operations have comments that name the missing stable API and ISA behavior.
  • dcp_lse_combine accepts optional contiguous int32 row_counts[tokens]; rows with zero locally owned keys contribute -inf LSE.
  • Every rank must issue the identical call sequence on each workspace, including warmup and capture. One extra call can silently misalign later results.
  • Existing AITER call sites stay the same. This PR only adds the new operators.

Performance

MI355X, 8 DCP ranks, 12 local heads per rank, CUDA Graph replay. Results are medians of ten aligned replays. Lower is better.

Tokens Operation Existing DCP (us) Mailbox (us) Saved (us) Reduction Speedup
8 Plain BF16 query gather 16.60 9.77 6.83 41.1% 1.70x
8 FP8 quantize + query gather 25.67 7.36 18.31 71.3% 3.49x
8 LSE output combine 21.93 14.20 7.73 35.2% 1.54x
8 FP8 gather + combine 47.60 21.56 26.04 54.7% 2.21x
16 Plain BF16 query gather 21.43 15.73 5.70 26.6% 1.36x
16 FP8 quantize + query gather 39.40 12.08 27.32 69.3% 3.26x
16 LSE output combine 32.05 21.24 10.81 33.7% 1.51x
16 FP8 gather + combine 71.45 33.32 38.13 53.4% 2.14x

The combine shape is BF16 with head dim 512. The quantized gather reads BF16 ql_nope dim 512 plus q_pe dim 64 and produces FP8 dim 576.

The existing DCP baseline uses separate query quantization and all-gather operations. Its output reduction uses _dcp_a2a_pack_send, all_to_all_single, and _dcp_a2a_unpack_combine. The mailbox implementation fuses each sequence into one kernel. Each value is the median of ten aligned CUDA Graph replays; the benchmark prints the full [min, max] range.

The optional VLLM_BASELINE=1 arm requires vLLM commit a2bcb5657a881a002e79d0adab3c6b5e39436121, tested with image vllm/vllm-openai-rocm:nightly-rocm100-a2bcb5657a881a002e79d0adab3c6b5e39436121.

High-concurrency mailbox scaling

At 240 tokens, one-token CTAs contend on the per-workspace epoch counter. Token tiling reduces the CTA count while keeping one launch. Same-node CUDA Graph timings on n244:

Operation One token/CTA (us) Selected tile (us) Delta
LSE combine, dim 128 72.84 51.26 -29.6%
LSE combine, dim 512 216.43 135.06 -37.6%
LSE combine, dim 576 254.84 148.54 -41.7%
BF16 query gather, dim 512 126.55 120.02 -5.2%
FP8 quantize + query gather, dim 576 80.04 69.63 -13.0%

Tile 4 is fastest at 128 tokens. Tile 8 is fastest at 240 tokens. Tile 16 loses occupancy. At 16 tokens, all operators keep one token per CTA and remain within 2% of the previous revision.

The vLLM C48 integration uses max_tokens=480 and shares one workspace per geometry across all MLA layers. At DCP8 with 12 local heads, the dim-512 combine peer allocation is about 181 MiB/GPU. The fp8 dim-576 gather peer allocation is about 101 MiB/GPU, and its persistent gathered-query output is about 34 MiB/GPU. The measured KV-capacity delta is -1.07%.

Kimi-K3 MI355X AgentX C48 e2e evaluation

Measured in vLLM using a local integration branch. The PR does not change AITER call sites, so the integration is not part of this PR. Same-node A/B on MI355X n244 with image a2bcb565, TP8/DCP8, DSpark K4 (AL 3.36), SimpleCPU offload, and a 3,600-second replay. Both arms used the same frozen image; the control disabled mailbox dispatch.

Metric Stock DCP Mailbox DCP Delta
Intvty@P90 (tok/s) 23.96 24.06 +0.43%
Total throughput/GPU (tok/s) 17,748.7 17,861.1 +0.63%
Output throughput (tok/s) 993.70 998.38 +0.47%
Full-response ITL avg (ms) 30.60 30.46 -0.46%
Full-response ITL p90 (ms) 41.74 41.56 -0.43%
Full-response ITL p99 (ms) 80.55 76.31 -5.26%
TTFT avg (ms) 2,074 2,002 -3.45%
TTFT p90 (ms) 2,955 2,905 -1.68%
TTFT p95 (ms) 5,358 4,757 -11.20%
Completed requests 3,762 3,785 +0.61%
Request error rate 0.29% 0.13% -0.16 pp
GPU KV capacity (tokens) 19.23M 19.02M -1.07%

Intvty@P90 = 1000 / full_response_inter_token_latency.p90_ms.
Throughput/GPU uses total input-plus-output token throughput divided by TP8.

Dashboard comparison

Metric Mailbox DCP IX MI355X vLLM vs MI355X IX B300 vLLM vs B300
Intvty@P90 (tok/s) 24.06 20.49 +17.4% N/A N/A
Total throughput/GPU (tok/s) 17,861.1 15,886.3 +12.4% N/A N/A

The live dashboard has no matching B300 vLLM C48 result. The e2e primary-metric gains are positive but remain inside the run-to-run noise floor; the kernel-level gains above are the performance claim.

Testing

  • Unit test: op_tests/multigpu_tests/test_dcp_mailbox.py
  • Performance benchmark: op_tests/op_benchmarks/flydsl/bench_dcp_mailbox.py
  • FlyDSL version: 0.5.0, as pinned by current AITER main.
  • MI355X validation: WORLD=8 python3 op_tests/multigpu_tests/test_dcp_mailbox.py printed DCP_MAILBOX OK for default token counts 8 and 99.
  • Prior high-concurrency validation: TOKENS=240 WORLD=8 python3 op_tests/multigpu_tests/test_dcp_mailbox.py printed DCP_MAILBOX OK.
  • CUDA-Graph mailbox arm: TOKENS=8,16 WORLD=8 python3 op_tests/op_benchmarks/flydsl/bench_dcp_mailbox.py.
  • CUDA-Graph vLLM arm: VLLM_BASELINE=1 TOKENS=8,16 WORLD=8 python3 op_tests/op_benchmarks/flydsl/bench_dcp_mailbox.py.
  • High-concurrency sweeps: TOKENS={128,240} with tile overrides 1/2/4/8/16.
  • Black 26.3.0 and CI-pinned Ruff 0.16.0 pass on all changed Python files.
  • MI250X and MI300X validation remain unverified.

The combine test loops dims 64, 128, 512, and 576, base-e and base-2 LSE, with request and per-row masking, and checks return_lse=False against the returned output. It also checks epoch-zero missing peers, timeout with a zero rank mask, one timeout flag per tile, explicit debug graph rejection, BF16 dim-576 rejection, split-phase gather, six calls across the 2^30 epoch modulus, and workspace teardown. Token count 99 covers a partial tile tail. The gather test uses dim 512. The quant-gather test uses nope 512 and pe 64.

Kernel checklist

  • Repr: the FlyDSL kernel name carries the config. Combine: aiter_dcp_lse_combine_t{tokens}_n{ranks}_h{heads}_d{dim}_m{max_tokens}_s{seqs}_e{base_e}_l{ret_lse}_g{debug}_r{row_mask}_bt{token_tile}. Gather: aiter_dcp_qgather_t{tokens}_n{ranks}_h{heads}_w{words}_p{pad_heads}_m{max_tokens}_q{nope}_f{fold}x{qlen}_s{phase}_g{debug}_bt{token_tile}.
  • Test: op_tests/multigpu_tests/test_dcp_mailbox.py.
  • Benchmark: op_tests/op_benchmarks/flydsl/bench_dcp_mailbox.py.
  • Paths: kernel bodies and shared device helpers live under aiter/ops/flydsl/kernels/dcp_mailbox/. Wrappers, compile caches, workspaces, and peer allocation live under aiter/ops/flydsl/dcp_mailbox/.
  • Duplicate search: AITER has no tagged peer mailbox that gathers a DCP query or combines LSE partials in one launch.
  • Shared helpers: mailbox loads and stores use tensor_shim buffer tensors and fx.copy. Raw s_sleep, s_memrealtime, and readfirstlane remain only where FlyDSL has no stable typed API.
  • Comments stay short.

Reviewed revision

f602738

Behavior and intent

This revision moves both launchable kernel bodies and shared device helpers under aiter/ops/flydsl/kernels/dcp_mailbox/. It replaces new legacy buffer_ops use with FlyDSL buffer tensors and fx.copy. Raw sleep, timer, and wave-broadcast operations remain only where FlyDSL has no stable typed API, with a short comment at each boundary. The wrapper ABI, kernel names, split phases, graph behavior, epoch wrap, token tiling, and public APIs are unchanged.

Validation and unverified scope

For this revision, Black 26.3.0, CI-pinned Ruff 0.16.0, python3 -m py_compile, git diff --check, and IDE lints pass. On 8x MI355X n180 with FlyDSL 0.5.0, the default 8- and 99-token cases and TOKENS=240 printed DCP_MAILBOX OK. This includes split-phase gather, epoch wrap, debug timeout, partial-tile, and CUDA Graph coverage.

The reverse-order C48 operator replicate stayed within the measured ranges. Baseline to refactor: combine dim 128 18.95 -> 18.68 us (-1.4%), dim 512 43.75 -> 42.77 us (-2.2%), dim 576 45.94 -> 46.38 us (+1.0%), BF16 gather 33.97 -> 33.35 us (-1.8%), and FP8 quant-gather 22.02 -> 22.07 us (+0.2%). MI250X and MI300X remain unverified.

PR-specific question

Before this PR, the new mailbox behavior was unavailable: the test could not import or call dcp_lse_combine, dcp_query_gather, or dcp_quant_query_gather. The test validates the multi-rank tagged-mailbox protocol, numerical LSE combination, FP8 query gather, request and per-row masking, multiple LSE bases, supported head dimensions, timeout diagnostics, graph-debug rejection, and workspace teardown. Existing canonical tests cover other communication paths and do not cover these operators or their mailbox protocol.

Changed op tests

  • op_tests/multigpu_tests/test_dcp_mailbox.py: Before this PR, the test could not import or call the new mailbox operators. It covers combine, BF16 gather, and FP8 quantized gather across 8 ranks; dimensions 64/128/512/576; both LSE bases; request and per-row masking; epoch-zero and empty-mask timeouts; one timeout wait per tile; debug graph rejection; BF16 dim-576 rejection; split-phase gather; epoch wrap; workspace teardown; and a partial tile tail. It is not redundant because no existing canonical test covers these tagged-mailbox operators.
  • op_tests/op_benchmarks/flydsl/bench_dcp_mailbox.py: Before this PR, the mailbox workspaces and operators were unavailable. It measures mailbox and independent vLLM A2A, all-gather, and quantize-plus-gather arms at configurable token counts. It reports median [min, max] from ten aligned graph replays. It is not redundant with the correctness test because it measures synchronized operator latency rather than numerics.

@xiaohuguo2023
xiaohuguo2023 requested review from a team and a balanced review from Copilot October 26, 2026 23:39

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.

@xiaohuguo2023
xiaohuguo2023 force-pushed the dcp-mailbox-flydsl-rebase branch from 94f6f30 to 9a12bfc Compare October 26, 2026 23:39
@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 (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the gfx1201 ROCm runner
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 6972 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

@xiaohuguo2023
xiaohuguo2023 marked this pull request as draft October 26, 2026 23:51
@xiaohuguo2023
xiaohuguo2023 force-pushed the dcp-mailbox-flydsl-rebase branch from 8bbad54 to c072a78 Compare October 27, 2026 11:28
@xiaohuguo2023
xiaohuguo2023 marked this pull request as ready for review October 27, 2026 11:28
Copilot AI balanced review requested due to automatic review settings October 27, 2026 11: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.

@xiaohuguo2023
xiaohuguo2023 force-pushed the dcp-mailbox-flydsl-rebase branch from c072a78 to b6d1656 Compare October 27, 2026 16:35
Copilot AI balanced review requested due to automatic review settings October 27, 2026 16:35

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.

@zufayu
zufayu removed the request for review from yadaish October 29, 2026 10:17
@xiaohuguo2023
xiaohuguo2023 force-pushed the dcp-mailbox-flydsl-rebase branch from b6d1656 to 424fff7 Compare October 29, 2026 22:32
Copilot AI balanced review requested due to automatic review settings October 29, 2026 22: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.

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

@aiter-bot

aiter-bot commented Oct 29, 2026 •

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision f602738349e0 · 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 revision moves both launchable kernel bodies and shared device helpers under `aiter/ops/flydsl/kernels/dcp_mailbox/`. It replaces new legacy `buffer_ops` use with FlyDSL buffer tensors and `fx.copy`. Raw sleep, timer, and wave-broadcast operations remain only where FlyDSL has no stable typed API, with a short comment at each boundary. The wrapper ABI, kernel names, split phases, graph behavior, epoch wrap, token tiling, and public APIs are unchanged.

Validation and unverified scope

For this revision, Black 26.3.0, CI-pinned Ruff 0.16.0, `python3 -m py_compile`, `git diff --check`, and IDE lints pass. On 8x MI355X n180 with FlyDSL 0.5.0, the default 8- and 99-token cases and `TOKENS=240` printed `DCP_MAILBOX OK`. This includes split-phase gather, epoch wrap, debug timeout, partial-tile, and CUDA Graph coverage.

The reverse-order C48 operator replicate stayed within the measured ranges. Baseline to refactor: combine dim 128 `18.95 -> 18.68 us` (-1.4%), dim 512 `43.75 -> 42.77 us` (-2.2%), dim 576 `45.94 -> 46.38 us` (+1.0%), BF16 gather `33.97 -> 33.35 us` (-1.8%), and FP8 quant-gather `22.02 -> 22.07 us` (+0.2%). MI250X and MI300X remain unverified.

PR-specific question

Before this PR, the new mailbox behavior was unavailable: the test could not import or call `dcp_lse_combine`, `dcp_query_gather`, or `dcp_quant_query_gather`. The test validates the multi-rank tagged-mailbox protocol, numerical LSE combination, FP8 query gather, request and per-row masking, multiple LSE bases, supported head dimensions, timeout diagnostics, graph-debug rejection, and workspace teardown. Existing canonical tests cover other communication paths and do not cover these operators or their mailbox protocol.

Changed op tests

- `op_tests/multigpu_tests/test_dcp_mailbox.py`: Before this PR, the test could not import or call the new mailbox operators. It covers combine, BF16 gather, and FP8 quantized gather across 8 ranks; dimensions 64/128/512/576; both LSE bases; request and per-row masking; epoch-zero and empty-mask timeouts; one timeout wait per tile; debug graph rejection; BF16 dim-576 rejection; split-phase gather; epoch wrap; workspace teardown; and a partial tile tail. It is not redundant because no existing canonical test covers these tagged-mailbox operators.
- `op_tests/op_benchmarks/flydsl/bench_dcp_mailbox.py`: Before this PR, the mailbox workspaces and operators were unavailable. It measures mailbox and independent vLLM A2A, all-gather, and quantize-plus-gather arms at configurable token counts. It reports median `[min, max]` from ten aligned graph replays. It is not redundant with the correctness test because it measures synchronized operator latency rather than numerics.

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • FAIL — an active Copilot finding has no substantive reply from the PR author
  • FAIL — an active Copilot finding has no substantive reply from the PR author
  • FAIL — an active Copilot finding has no substantive reply from the PR author
  • FAIL — an active Copilot finding has no substantive reply from the PR author
  • ADVISORY — Copilot could not review the current head (for example, quota or service failure)

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.

@xiaohuguo2023
xiaohuguo2023 force-pushed the dcp-mailbox-flydsl-rebase branch from 424fff7 to 79527a2 Compare October 30, 2026 22:37
Copilot AI balanced review requested due to automatic review settings October 30, 2026 22:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@xiaohuguo2023
xiaohuguo2023 force-pushed the dcp-mailbox-flydsl-rebase branch from 79527a2 to 0d02e61 Compare October 31, 2026 22:43
Copilot AI balanced review requested due to automatic review settings October 31, 2026 22:43

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.

@xiaohuguo2023
xiaohuguo2023 force-pushed the dcp-mailbox-flydsl-rebase branch from 0d02e61 to cdbfc6e Compare November 3, 2026 09:57
@xiaohuguo2023

Copy link
Copy Markdown
Member Author

Round 4, head 1679c64e7. The three round-3 fixes hold on 8 × MI355X, each checked with a revert mutation:

  • Split-phase gather: two phase 1→2 rounds match all_gather bit for bit; reverting the gate hangs.
  • Epoch wrap: from 2^31-3 and from 2^30-3, 6/6 calls pass (round 3 faulted at call 4).
  • Sticky timeout: 240-token debug timeout now 11.8 s (was 81.7 s); TOKENS=240 and the default 8,99 pass.

No blocking items. Two should-fix:

  1. FlyDSL 0.5.0. After the rebase this sits on main's FlyDSL ≥ 0.5.0 ([FlyDSL] [CI] [Build] Bump FlyDSL pin to v0.5.0 #7600), which removed hand-made JIT keys (_ = key); the PR still has key_tuple / source_digest / _ = keyed. Please run the test on 0.5.0 and drop the keys if redundant. aiter/ops/flydsl/AGENTS.md also wants kernels under kernels/ and no legacy buffer_ops in new code (overlaps coderfeli's open request). My runs were all on 0.4.1.
  2. The split-phase test hangs instead of failing on a regression (non-debug workspace). A debug GatherWorkspace raises in ~10 s.

Nits: right after the wrap the debug missing-rank mask reads 0x0 for one launch ((((expected - seen) & EPOCH_MASK) == 1) fixes it); use EPOCH_MASK instead of e % (1 << 30) for the tag; Reviewed revision (8d94b5a27) is stale, so aiter-bot fails.

ATOM#3048 needs no change: its 300 DCP tests pass on this head.

fixed, split-phase gather now advances the epoch only after phase 2. Epochs wrap at 2^30, and missing-rank checks use modular arithmetic. After one debug poll expires, later tokens skip their waits. Default tests cover tokens 8 and 99. Manual JIT keys are removed, and all tests pass with FlyDSL 0.5.0. Device checks, shared tile selection, and exact vLLM baseline details are also added.

@yitingw1

Copy link
Copy Markdown
Contributor

@xiaohuguo2023 @coderfeli Round 5 (head 508802cb2): Everything I raised in rounds 3 and 4 is fixed: split-phase gather, the 2^30 epoch wrap, sticky debug timeouts, the tail test (8 and 99), the debug split-phase test, the modular missing-rank mask, and the manual JIT keys are gone. Verified on 8 × MI355X with FlyDSL 0.5.0: the PR test passes at the default tokens (8, 99) and at TOKENS=240. From my side this is good to go.

What remains is coderfeli's open change request, i.e. the rules in aiter/ops/flydsl/AGENTS.md that this PR does not follow yet:

  • @flyc.kernel code is in dcp_mailbox/combine.py:241 and gather.py:126, not under aiter/ops/flydsl/kernels/.
  • New code imports the legacy buffer_ops (combine.py:34, gather.py:41); AGENTS.md asks for FlyDSL buffer tensors and fx.copy.
  • Raw rocdl/llvm calls in the shared helpers (e.g. communication_ops_utils.py:121, llvm.amdgcn.s.memrealtime) need a comment naming the missing stable API.

Could you two agree whether these land in this PR or a follow-up? Then the CHANGES_REQUESTED can be resolved.

@xiaohuguo2023
xiaohuguo2023 force-pushed the dcp-mailbox-flydsl-rebase branch from 508802c to b63594d Compare November 11, 2026 17:05
Copilot AI balanced review requested due to automatic review settings November 11, 2026 17:05

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. Try requesting a review at a lower effort level.

@xiaohuguo2023

Copy link
Copy Markdown
Member Author

@xiaohuguo2023 @coderfeli Round 5 (head 508802cb2): Everything I raised in rounds 3 and 4 is fixed: split-phase gather, the 2^30 epoch wrap, sticky debug timeouts, the tail test (8 and 99), the debug split-phase test, the modular missing-rank mask, and the manual JIT keys are gone. Verified on 8 × MI355X with FlyDSL 0.5.0: the PR test passes at the default tokens (8, 99) and at TOKENS=240. From my side this is good to go.

What remains is coderfeli's open change request, i.e. the rules in aiter/ops/flydsl/AGENTS.md that this PR does not follow yet:

  • @flyc.kernel code is in dcp_mailbox/combine.py:241 and gather.py:126, not under aiter/ops/flydsl/kernels/.
  • New code imports the legacy buffer_ops (combine.py:34, gather.py:41); AGENTS.md asks for FlyDSL buffer tensors and fx.copy.
  • Raw rocdl/llvm calls in the shared helpers (e.g. communication_ops_utils.py:121, llvm.amdgcn.s.memrealtime) need a comment naming the missing stable API.

Could you two agree whether these land in this PR or a follow-up? Then the CHANGES_REQUESTED can be resolved.

@yitingw1 Thanks for the Round 5 validation. I agree that @coderfeli 's requested changes should land in this PR.

  • moved both @flyc.kernel bodies under aiter/ops/flydsl/kernels/dcp_mailbox/,
  • replaced the new buffer_ops use with FlyDSL buffer tensors and fx.copy,
  • retained only raw operations without stable typed APIs
  • and added comments explaining each boundary.

On 8 × MI355X with FlyDSL 0.5.0, the default token cases 8 and 99 pass. TOKENS=240 also passes.

@yitingw1

Copy link
Copy Markdown
Contributor

@xiaohuguo2023 Thanks. The pushed head b63594d5e looks like a rebase only: the PR's own diff is identical to 508802cb2 (apart from rebase context in __init__.py), so the changes described above aren't on the branch yet:

  • the @flyc.kernel bodies are still in dcp_mailbox/combine.py:241 and gather.py:126, and there is no kernels/dcp_mailbox/;
  • combine.py:34, gather.py:41 and communication_ops_utils.py:28 still import buffer_ops;
  • communication_ops_utils.py has no new comments at the raw rocdl/llvm calls.

Could you push them? One more thing from the rebase: main moved UncachedIpcHeap to aiter/ops/flydsl/ipc_heap.py and left quick_allreduce_int4_ipc.py as a shim that will be removed once vLLM migrates. dcp_mailbox/peer.py:10 still imports from the shim; please switch it to from aiter.ops.flydsl.ipc_heap import UncachedIpcHeap, otherwise the mailbox import breaks when the shim goes and ATOM silently falls back to a2a.

The gather replaces the DCP query all-gather, including the fp8 quant of
ql_nope and q_pe. The combine replaces the LSE all-to-all reduce. Both
kernels use one tagged peer buffer and one CTA per token and local head.

Signed-off-by: Xiaohu Guo <[email protected]>
The combine ran a fixed 128 threads per CTA and asserted dim == 256, so it
rejected the 512-dim MLA latent and every other head size. A CTA still owns
one (token, local head); it now runs dim / 4 threads, each owning four
values, so one build covers dim 64, 128, 512, 576 and any multiple of 4 with
4 * ranks <= dim <= 4096 (thread r pushes the LSE to rank r).

The test covers dims 64, 128, 512 and 576 with base-e and base-2 LSE, with
and without seq_lens masking, and checks return_lse=False against the
returned output. The gather case now uses an explicit dim.

The benchmark loops over dims and aligns the ranks before each timed graph
replay. Without the barrier every workspace after the first measured rank
skew, since each rank polls its peers.

MI355X, 8 ranks, 16 tokens, 12 heads per rank, CUDA graph:
  combine dim 128  10.3 us
  combine dim 512  19.2 us
  combine dim 576  19.9 us
  gather  dim 512  14.4 us

Signed-off-by: Xiaohu Guo <[email protected]>
Move the tagged peer mailbox into communication_ops_utils and use its existing agent-scope atomic helper. Consolidate the small DCP build and device helpers in common.py, and remove the copied monokernel execution, tracing, rank, and diagnostic code.

The 8-rank correctness test passed twice on MI355X. Same-node two-run benchmark averages stayed within noise: combine dim 128 10.18 to 10.61 us, dim 512 19.72 to 19.81 us, dim 576 20.88 to 20.89 us, and gather dim 512 15.23 to 15.46 us.

Signed-off-by: Xiaohu Guo <[email protected]>
A debug workspace (debug=True) adds one untagged epoch slot per source
rank after both parities. CTA 0 pushes the launch epoch to every peer,
and every poll is bounded at 10 s. On timeout it records which source
ranks are behind, and the host raises. A normal build compiles the
epoch push and the bounded poll out completely.

Workspace close now unmaps the peers and runs a group barrier before it
frees the local buffer. A buffer freed while a peer still mapped it made
the next allocation fail hipIpcGetMemHandle.

Document the 8-byte tagged-pair alignment that makes the hand-off
fence-free. The test runs the dim 128 combine in a debug build. The
benchmark adds the FP8 quantize + gather path and reports the spread of
two graph replays.

MI355X, 8 ranks, 16 tokens, 12 heads, same node as the control:
  combine dim 128  10.57 us (control 10.57)
  combine dim 512  19.89 us (control 19.98)
  combine dim 576  20.71 us (control 20.70)
  gather  dim 512  14.72 us (control 14.77)

Signed-off-by: Xiaohu Guo <[email protected]>
Process multiple tokens per CTA at larger DCP batches to reduce epoch-counter contention. Keep one token per CTA for small batches and select 2, 4, or 8-token tiles as parallelism increases.

At 240 tokens on 8x MI355X, dim-512 combine improves from 216.43 to 135.06 us and quant-gather improves from 80.04 to 69.63 us. The 240-token correctness test passes, while 16-token timings remain within 2%.

Signed-off-by: Xiaohu Guo <[email protected]>
Publish epoch plus one so zero always means that a rank never entered the launch. Set an unconditional timeout bit with atomic OR so every bounded timeout raises, including an empty missing-rank mask.

Reject debug graph capture explicitly, document the identical-call-sequence contract, validate the BF16 gather limit, and add an optional per-row empty mask to the LSE combine.

The 8-rank test covers epoch-zero missing peers, an empty timeout mask, debug graph rejection, the BF16 gather boundary, and per-row masking.

Signed-off-by: Xiaohu Guo <[email protected]>
Add independent vLLM A2A, BF16 all-gather, and FP8 quantize-plus-gather arms to the mailbox benchmark. Run mailbox and vLLM arms in separate processes so graph-captured collectives do not share protocol state.

Report the median and full range of ten aligned graph replays. Accept a token-count list so the published 8-token and 16-token rows are directly reproducible.

Signed-off-by: Xiaohu Guo <[email protected]>
Keep split-phase gather on one epoch and wrap the int32 epoch at 2^30.

After one debug poll expires, its CTA sets a timeout flag. Later tokens in the tile skip their own waits.

Share and document token-tile selection. Validate mask and gather devices. Identify the exact vLLM baseline revision in the benchmark.

The 8-rank test runs token counts 8 and 99 by default. It covers two split-phase rounds and six calls across the epoch modulus.

Signed-off-by: Xiaohu Guo <[email protected]>
Keep split-phase gather on one epoch and wrap the int32 epoch at 2^30. Later tokens skip their waits after one debug poll expires.

Remove manual JIT keys for FlyDSL 0.5.0. Share token-tile selection and validate mask and gather devices.

The 8-rank test covers token counts 8 and 99, two split-phase rounds, and six calls across both epoch boundaries.

Signed-off-by: Xiaohu Guo <[email protected]>
Place device bodies under kernels/dcp_mailbox and keep launch wrappers in dcp_mailbox. Replace new buffer_ops calls with typed buffer tensor copies and document raw API boundaries.

Import UncachedIpcHeap from the canonical ipc_heap module.

Signed-off-by: Xiaohu Guo <[email protected]>
@xiaohuguo2023
xiaohuguo2023 force-pushed the dcp-mailbox-flydsl-rebase branch from b63594d to f602738 Compare November 12, 2026 09:18
Copilot AI balanced review requested due to automatic review settings November 12, 2026 09:18

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. Try requesting a review at a lower effort level.

@xiaohuguo2023

Copy link
Copy Markdown
Member Author

@xiaohuguo2023 Thanks. The pushed head b63594d5e looks like a rebase only: the PR's own diff is identical to 508802cb2 (apart from rebase context in __init__.py), so the changes described above aren't on the branch yet:

  • the @flyc.kernel bodies are still in dcp_mailbox/combine.py:241 and gather.py:126, and there is no kernels/dcp_mailbox/;
  • combine.py:34, gather.py:41 and communication_ops_utils.py:28 still import buffer_ops;
  • communication_ops_utils.py has no new comments at the raw rocdl/llvm calls.

Could you push them? One more thing from the rebase: main moved UncachedIpcHeap to aiter/ops/flydsl/ipc_heap.py and left quick_allreduce_int4_ipc.py as a shim that will be removed once vLLM migrates. dcp_mailbox/peer.py:10 still imports from the shim; please switch it to from aiter.ops.flydsl.ipc_heap import UncachedIpcHeap, otherwise the mailbox import breaks when the shim goes and ATOM silently falls back to a2a.

@yitingw1 sorry, done!

@yitingw1 yitingw1 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

@valarLip
valarLip merged commit d223b16 into main Nov 13, 2026
@valarLip
valarLip deleted the dcp-mailbox-flydsl-rebase branch November 13, 2026 02:28
vpietila-amd pushed a commit that referenced this pull request Nov 13, 2026
* [FlyDSL] Add the DCP mailbox query gather and LSE combine.

The gather replaces the DCP query all-gather, including the fp8 quant of
ql_nope and q_pe. The combine replaces the LSE all-to-all reduce. Both
kernels use one tagged peer buffer and one CTA per token and local head.

Signed-off-by: Xiaohu Guo <[email protected]>

* [FlyDSL] Support any head dim in the DCP mailbox LSE combine

The combine ran a fixed 128 threads per CTA and asserted dim == 256, so it
rejected the 512-dim MLA latent and every other head size. A CTA still owns
one (token, local head); it now runs dim / 4 threads, each owning four
values, so one build covers dim 64, 128, 512, 576 and any multiple of 4 with
4 * ranks <= dim <= 4096 (thread r pushes the LSE to rank r).

The test covers dims 64, 128, 512 and 576 with base-e and base-2 LSE, with
and without seq_lens masking, and checks return_lse=False against the
returned output. The gather case now uses an explicit dim.

The benchmark loops over dims and aligns the ranks before each timed graph
replay. Without the barrier every workspace after the first measured rank
skew, since each rank polls its peers.

MI355X, 8 ranks, 16 tokens, 12 heads per rank, CUDA graph:
  combine dim 128  10.3 us
  combine dim 512  19.2 us
  combine dim 576  19.9 us
  gather  dim 512  14.4 us

Signed-off-by: Xiaohu Guo <[email protected]>

* [FlyDSL] Reuse shared communication helpers for DCP mailbox

Move the tagged peer mailbox into communication_ops_utils and use its existing agent-scope atomic helper. Consolidate the small DCP build and device helpers in common.py, and remove the copied monokernel execution, tracing, rank, and diagnostic code.

The 8-rank correctness test passed twice on MI355X. Same-node two-run benchmark averages stayed within noise: combine dim 128 10.18 to 10.61 us, dim 512 19.72 to 19.81 us, dim 576 20.88 to 20.89 us, and gather dim 512 15.23 to 15.46 us.

Signed-off-by: Xiaohu Guo <[email protected]>

* [FlyDSL] Fix DCP mailbox review findings

Signed-off-by: Xiaohu Guo <[email protected]>

* [FlyDSL] Reuse shared helpers in DCP mailbox

Signed-off-by: Xiaohu Guo <[email protected]>

* [FlyDSL] Correct DCP mailbox license provenance

Signed-off-by: Xiaohu Guo <[email protected]>

* [FlyDSL] Add DCP mailbox debug diagnostics and the FP8 benchmark arm

A debug workspace (debug=True) adds one untagged epoch slot per source
rank after both parities. CTA 0 pushes the launch epoch to every peer,
and every poll is bounded at 10 s. On timeout it records which source
ranks are behind, and the host raises. A normal build compiles the
epoch push and the bounded poll out completely.

Workspace close now unmaps the peers and runs a group barrier before it
frees the local buffer. A buffer freed while a peer still mapped it made
the next allocation fail hipIpcGetMemHandle.

Document the 8-byte tagged-pair alignment that makes the hand-off
fence-free. The test runs the dim 128 combine in a debug build. The
benchmark adds the FP8 quantize + gather path and reports the spread of
two graph replays.

MI355X, 8 ranks, 16 tokens, 12 heads, same node as the control:
  combine dim 128  10.57 us (control 10.57)
  combine dim 512  19.89 us (control 19.98)
  combine dim 576  20.71 us (control 20.70)
  gather  dim 512  14.72 us (control 14.77)

Signed-off-by: Xiaohu Guo <[email protected]>

* [Perf][FlyDSL] Tile DCP mailbox tokens across CTAs

Process multiple tokens per CTA at larger DCP batches to reduce epoch-counter contention. Keep one token per CTA for small batches and select 2, 4, or 8-token tiles as parallelism increases.

At 240 tokens on 8x MI355X, dim-512 combine improves from 216.43 to 135.06 us and quant-gather improves from 80.04 to 69.63 us. The 240-token correctness test passes, while 16-token timings remain within 2%.

Signed-off-by: Xiaohu Guo <[email protected]>

* [Bugfix][FlyDSL] Make DCP mailbox diagnostics fail closed

Publish epoch plus one so zero always means that a rank never entered the launch. Set an unconditional timeout bit with atomic OR so every bounded timeout raises, including an empty missing-rank mask.

Reject debug graph capture explicitly, document the identical-call-sequence contract, validate the BF16 gather limit, and add an optional per-row empty mask to the LSE combine.

The 8-rank test covers epoch-zero missing peers, an empty timeout mask, debug graph rejection, the BF16 gather boundary, and per-row masking.

Signed-off-by: Xiaohu Guo <[email protected]>

* [Bench][FlyDSL] Add reproducible DCP collective baselines

Add independent vLLM A2A, BF16 all-gather, and FP8 quantize-plus-gather arms to the mailbox benchmark. Run mailbox and vLLM arms in separate processes so graph-captured collectives do not share protocol state.

Report the median and full range of ten aligned graph replays. Accept a token-count list so the published 8-token and 16-token rows are directly reproducible.

Signed-off-by: Xiaohu Guo <[email protected]>

* [Bugfix][FlyDSL] Preserve DCP mailbox phase and epoch state

Keep split-phase gather on one epoch and wrap the int32 epoch at 2^30.

After one debug poll expires, its CTA sets a timeout flag. Later tokens in the tile skip their own waits.

Share and document token-tile selection. Validate mask and gather devices. Identify the exact vLLM baseline revision in the benchmark.

The 8-rank test runs token counts 8 and 99 by default. It covers two split-phase rounds and six calls across the epoch modulus.

Signed-off-by: Xiaohu Guo <[email protected]>

* [Bugfix][FlyDSL] Fix DCP mailbox phase and epoch boundaries

Keep split-phase gather on one epoch and wrap the int32 epoch at 2^30. Later tokens skip their waits after one debug poll expires.

Remove manual JIT keys for FlyDSL 0.5.0. Share token-tile selection and validate mask and gather devices.

The 8-rank test covers token counts 8 and 99, two split-phase rounds, and six calls across both epoch boundaries.

Signed-off-by: Xiaohu Guo <[email protected]>

* [Refactor][FlyDSL] Move DCP mailbox kernels

Place device bodies under kernels/dcp_mailbox and keep launch wrappers in dcp_mailbox. Replace new buffer_ops calls with typed buffer tensor copies and document raw API boundaries.

Import UncachedIpcHeap from the canonical ipc_heap module.

Signed-off-by: Xiaohu Guo <[email protected]>

---------

Signed-off-by: Xiaohu Guo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants