Skip to content

[HIP] [JIT] Add M3 sequence-parallel collectives - #6031

Merged
junhaha666 merged 1 commit into
mainfrom
hexwang/m3-sp-hip-collectives
Oct 9, 2026
Merged

junhaha666 merged 1 commit into
mainfrom
hexwang/m3-sp-hip-collectives

Conversation

@whx-sjtu

@whx-sjtu whx-sjtu commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Add the HIP communication kernels used by ROCm/ATOM#2364 for four-rank M3 sequence parallelism: an INT4 QuickReduce reduce-scatter that writes contiguous rank shards, and a head exchange that writes the final token-major head layout directly.

aiter/ops/quick_reduce_scatter.py   -> module_quick_reduce_scatter
aiter/ops/sp_head_exchange.py       -> module_sp_head_exchange
aiter/jit/optCompilerConfig.json    -> HIP source/build registration
csrc/kernels/ + csrc/pybind/        -> two HIP kernels and bindings
op_tests/multigpu_tests/            -> head-exchange regression coverage
  • QuickRS reuses the existing QuickReduce communicator and INT4 codec, performs one payload phase, and retains a consumption barrier before IPC-buffer reuse. It accepts contiguous FP16/BF16 inputs with four input elements per output element and a 16-byte-aligned output byte count.
  • Head exchange uses the existing CustomAllreduce registration and synchronization protocol to map [tokens, heads] to [tokens / 4, heads * 4]. It supports staged inputs and registered graph inputs, and validates the address read by vectorized loads in both paths.

This PR contains the eight HIP/JIT files split from #5822. The Triton tiled sorter and its integration remain in #5822. Both PRs target main and can be reviewed and merged independently.

Evidence

  • Before: main has no qr_reduce_scatter or sp_head_exchange public entry points.
    After: both are exposed through their own compile_ops wrappers and registered JIT modules.
  • After the split, 3 four-GPU head-exchange tests pass on gfx950 with a fresh JIT directory. They cover staged and registered graph execution, changed-input replay, BF16/FP16/byte layouts, and rejection of misaligned staged and registered addresses.
  • The existing four-rank QuickRS harness passes exact contiguous-shard checks across changing shapes and partial tiles, plus zero-tolerance graph-versus-eager checks at six token counts (16 through 32,768). All 12 rank/distribution numerical samples are finite. QuickRS and QuickAllReduce were compiled from this branch into the same fresh JIT directory.
  • The eight-file patch is byte-identical to the HIP contribution in a70f4fef9071f8b9b2bf25884b38bb6184b4d207. Combining it with the Triton patch reconstructs that source tree exactly. Black, Ruff, and git diff --check pass.
python -m pytest -q op_tests/multigpu_tests/test_sp_head_exchange.py
# 3 passed on four gfx950 GPUs

The QuickRS harness also measures BF16 [tokens, 6144] inputs on four gfx950 GPUs. Latency is the maximum across ranks over 200 timed CUDA-graph invocations per shape; results below are from the split HIP branch.

Tokens Existing reduce-scatter Baseline (µs) QuickRS (µs) Speedup
2,048 Custom BF16 122.06 101.67 1.20×
8,192 RCCL 523.57 315.29 1.66×
32,768 RCCL 2047.76 1241.67 1.65×

The combined SP serving and model-quality measurements are documented in ROCm/ATOM#2364; those measurements evaluate the complete downstream SP path.

Merge Danger

Door: two-way

Blast Radius: collectives

Calls sharing a communicator must remain serialized on its current stream. QuickRS uses lossy INT4 communication and shares the existing QuickReduce state layout, so both modules must be built from the same AITER revision. Callers remain responsible for choosing the supported four-rank shape, dtype, and communication policy.

Split the unchanged HIP contribution out of PR #5822: four-rank INT4 QuickReduce reduce-scatter and direct token-major head exchange, with JIT registration, public wrappers, and head-exchange tests. The Triton sorter remains independent in #5822.
@whx-sjtu
whx-sjtu requested a review from a team October 1, 2026 03:44
@github-actions

github-actions Bot commented Oct 1, 2026

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

@junhaha666
junhaha666 merged commit 229c4a5 into main Oct 9, 2026
55 checks passed
@junhaha666
junhaha666 deleted the hexwang/m3-sp-hip-collectives branch October 9, 2026 12:45
hubertlu-tw added a commit to hubertlu-tw/aiter that referenced this pull request Oct 16, 2026
quick_reduce_scatter.cu, added on main by ROCm#6031, uses kWavefront, which this branch had renamed to kBlockX. Restore main's definition so the merged tree builds. The launch geometry is unchanged ({64, 4, 1}).
zufayu pushed a commit that referenced this pull request Oct 21, 2026
* Enable gfx1250 QuickReduce for TP2 and TP4

* Address review feedback and extend gfx1250 QuickReduce to TP8 for DPX mode

* Restore kWavefront in quick_all_reduce_base.h

quick_reduce_scatter.cu, added on main by #6031, uses kWavefront, which this branch had renamed to kBlockX. Restore main's definition so the merged tree builds. The launch geometry is unchanged ({64, 4, 1}).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants