Skip to content

[HIP] [FlyDSL] [Bugfix] Size the custom allreduce pool from per-op AR/AG/RS max-size env vars - #7433

Merged
zufayu merged 3 commits into
mainfrom
custom-collective-size-env
Nov 5, 2026
Merged

zufayu merged 3 commits into
mainfrom
custom-collective-size-env

Conversation

@TennyWang1223

@TennyWang1223 TennyWang1223 commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Give custom all-reduce, all-gather and reduce-scatter one size cutoff each (AITER_CUSTOM_AR_MAX_SIZE, the existing one, plus new AITER_CUSTOM_AG_MAX_SIZE and AITER_CUSTOM_RS_MAX_SIZE). The registered input pool is sized from those same variables, so a cutoff and the pool that has to hold it can no longer disagree. On gfx1250 the pool grows to the largest cutoff set. On gfx9 the pool stays at 1 GiB, because its 2x tmp region would triple the cost, and cutoffs above what the pool holds are capped, with larger inputs going to RCCL. With none of the variables set, behavior is unchanged. This replaces #7367.

Motivation

The registered input pool (CustomAllreduce.max_size, 1 GiB by default) was fixed, and the size cutoffs were set separately from it:

  • AITER_CUSTOM_AR_MAX_SIZE above the pool size logged a warning and dropped back to 64 MiB. Raising the cutoff made it smaller.
  • All-gather had no cutoff of its own (max_size / (2 * world_size)), and reduce-scatter reused the all-reduce cutoff.
  • On gfx1250 the copy-in path stages the whole input in the pool. A DP-attention allgather LM head gathers more than 1 GiB per rank at large decode batches, and graph capture fails with registered buffer is too small to contain the input. There was no way to raise the pool.

#7367 added a separate AITER_CAR_POOL_BYTES for the pool size. That fixes the immediate failure, but it leaves two variables that must be kept in sync by hand. It also grows the pool on every arch: on gfx942/950, _init_ipc allocates another 2 * max_size of uncached meta memory, so a 16 GiB pool costs about 48 GiB per rank. This PR derives the pool from the cutoffs instead, and grows it only on gfx1250.

Changes

  • aiter/dist/device_communicators/custom_all_reduce.py
    • New env vars AITER_CUSTOM_AG_MAX_SIZE (per-rank input bytes) and AITER_CUSTOM_RS_MAX_SIZE (input bytes). Each op's cutoff is independent, and an unset variable takes its own default, never another op's value:
      Variable Default 0
      AITER_CUSTOM_AR_MAX_SIZE 64 MiB (unchanged) custom AR off
      AITER_CUSTOM_AG_MAX_SIZE max_size / (2 * world_size) (unchanged, 128 MiB at TP4) custom AG off
      AITER_CUSTOM_RS_MAX_SIZE 64 MiB (same as before when AR was unset) custom RS off
    • AITER_CUSTOM_AR_MIN_SIZE now applies to all-reduce only. Reduce-scatter used to inherit it through should_custom_ar.
    • _resolve_car_max_size is replaced by a pure function _resolve_custom_sizes(is_gfx1250, world_size, max_size) that returns the pool size and the cutoffs:
      • gfx1250: pool = max(max_size, cutoffs set in env), rounded up to 2 MiB. Only cutoffs that were actually set count, so with nothing set the pool is exactly max_size. The pool never shrinks below max_size. The 1-stage kernels have no tmp region, so the AR prefill cutoff is no longer halved there.
      • gfx9: pool = max_size, regardless of the env. A cutoff larger than the pool logs a warning once and is capped at the pool; inputs above it go to RCCL. The AR prefill cutoff stays at half the pool (2-stage write mode uses the 2x tmp region).
    • should_custom_ar, should_custom_rs and should_custom_ag each check their own cutoff. AR and RS share a _fits_custom_size helper.
    • One info line per rank logs the resolved pool size and cutoffs.
    • Module-level comment documents the variables, the pool rule, and the per-arch memory cost. The max_size constructor argument is now documented as the pool floor (gfx1250) or the pool size (gfx9).
  • op_tests/multigpu_tests/test_reduce_scatter.py: the fallback suite now sets AITER_CUSTOM_RS_MAX_SIZE=0 instead of AITER_CUSTOM_AR_MAX_SIZE=0, since the AR cutoff no longer turns off RS.
  • op_tests/multigpu_tests/test_custom_allreduce_size_env.py (new): single-process tests for the resolver and the three size gates.

Performance (if applicable)

test later(todo on gfx1250 server)

Testing

  • Unit tests added or updated
  • Performance benchmarks run
  • Tested on MI250X
  • Tested on MI300X
  • Tested on MI455X (gfx1250), 4 GPUs

Documentation

  • Docstrings updated
  • User guide updated
  • Performance guide updated
  • No documentation change is needed, with the reason stated below

The env vars are documented in the module-level comment next to their definitions, where the existing AITER_CUSTOM_AR_* variables are documented. There is no user-guide page listing them.

Dependencies

  • No new third-party dependencies added
  • New dependencies are listed and justified below

Breaking Changes

None with the variables unset. With them set, the following change:

  • AITER_CUSTOM_AR_MAX_SIZE and AITER_CUSTOM_AR_MIN_SIZE no longer affect reduce-scatter. Anyone who used AITER_CUSTOM_AR_MAX_SIZE=0 to turn off custom RS as well must also set AITER_CUSTOM_RS_MAX_SIZE=0.
  • AITER_CUSTOM_AR_MAX_SIZE above the pool size used to drop back to 64 MiB. Now:
    • gfx9: capped at the pool (1 GiB); larger inputs go to RCCL.
    • gfx1250: the pool grows to fit it.
  • On gfx1250, the AR prefill cutoff is no longer halved. This only matters for AITER_CUSTOM_AR_MAX_SIZE above half the pool.

PR Self-Review

Reviewed revision

Behavior and intent

Each collective now has its own size cutoff, and the input pool is sized from those cutoffs instead of from a separate setting. Before, the pool was fixed at 1 GiB and the AR cutoff fell back to 64 MiB when set above it, so there was no way to run a larger custom collective. On gfx1250 that made graph capture fail for all-gathers over 1 GiB. #7367 added a second pool-size variable that must be kept in sync with the cutoffs, and grew the gfx9 pool at about 3x memory cost. Here the pool follows the cutoffs on gfx1250 only. On gfx9 the pool is unchanged and oversize cutoffs are capped, with larger inputs going to RCCL. With none of the variables set, routing and pool size are identical to main.

Validation and unverified scope

Hardware: 4x MI455X (gfx1250), ROCm 10.1 (IPC transport).

  • python3 op_tests/multigpu_tests/test_custom_allreduce_size_env.py: 11/11 pass. Covers defaults, gfx1250 pool growth and 2 MiB rounding, no shrinking, 0 disabling only one op, bad values, gfx9 capping and prefill halving, RS independent of the AR cutoffs, and AR_MIN applying to AR only.
  • With no env set, these match main:
    • test_reduce_scatter.py -t 4 -s all: custom and fallback suites pass, max abs error 0.
    • test_custom_allreduce_rank_order.py: all AR and RS cases pass.
    • test_sp_head_exchange.py (constructs with max_size=64 MiB): pass.
  • gfx1250 end-to-end, TP4, AITER_CUSTOM_AG_MAX_SIZE=2147483648: pool resolves to 2 GiB on every rank. A 1.25 GiB-per-rank fp32 all-gather runs on the custom kernel and is bit-exact, both eager and captured in a CUDA graph on the copy-in path (enable_register_for_capturing=False) and replayed on new input. This is the case that failed in [fix] Size the custom all-reduce input pool from AITER_CAR_POOL_BYTES #7367.
  • gfx9 code path, run on gfx1250 hardware with AITER_CUSTOM_AR_DISABLE_GFX1250=1 and AITER_CUSTOM_AR_MAX_SIZE=4294967296: warning logged, pool stays 1 GiB, AR cutoff 1 GiB, prefill 512 MiB. A 512 MiB all-reduce runs custom and is exact; 768 MiB prefill and 1.5 GiB are routed to RCCL.
  • test_custom_allgatherv.py fails with custom_all_gatherv declined the rows. It fails the same way on main without this change. custom_all_gatherv is not touched here.

Unverified:

  • Real gfx942/gfx950 hardware. The gfx9 path was only exercised through the gfx1250 escape hatch.
  • gfx1250 VMM (ROCm < 7.15) and symm_mem transports. Both take self.max_size the same way as IPC, but neither was run.
  • Pools above 2 GiB, and serving end to end with ATOM.
  • Ranks with different env values are not checked. Same as before; the launcher is expected to give every rank the same environment.

PR-specific question

Changed op tests

  • op_tests/multigpu_tests/test_custom_allreduce_size_env.py (new): covers env parsing, pool sizing per arch, and how each size gate routes. It runs in one process without a process group, so every combination of variables can be covered in seconds. The existing multi-GPU tests only exercise the defaults.
  • op_tests/multigpu_tests/test_reduce_scatter.py: the fallback suite now turns off custom RS through AITER_CUSTOM_RS_MAX_SIZE=0. Without this, after this PR the suite would run the custom kernel instead of the pynccl fallback it is meant to cover.

@TennyWang1223
TennyWang1223 requested a review from a team November 4, 2026 07:35
@github-actions

github-actions Bot commented Nov 4, 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
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 7433 --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.

@aiter-bot

aiter-bot commented Nov 4, 2026 •

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision b6628462a52e · mode shadow

Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision.

Questions to answer in the PR description

  1. What behavior does this PR change, and why is the existing behavior insufficient?
  2. What did you validate, and what remains unverified? Include commands, hardware/configuration and results.
  3. Which architecture, dtype and shape boundaries select the changed kernel path, and what invariant prevents unsupported inputs from reaching it?
  4. For every changed op_tests/ file, what behavior does it cover and why is it not redundant? Write None if no op test changed.

Edit the PR Self-Review section in the PR description. Include the current revision SHA; this comment refreshes automatically.

Missing or invalid answers

  • FAIL — Reviewed revision must contain at least the first 7 characters of the current head SHA
  • FAIL — PR-specific question has no substantive answer
  • FAIL — changed op test not explained in Changed op tests: op_tests/flydsl_tests/test_flydsl_allreduce_rank_agreement.py

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

…ize env vars

should_custom_ag admits inputs up to AITER_CUSTOM_AG_MAX_SIZE bytes, but
_all_gather rejected any output past INT_MAX elements. With AG_MAX at 2 GiB,
a bf16 gather of 1.25 GiB a rank at TP4 (2.68e9 output elements) passed the
gate and then raised, with no fallback to RCCL.

The vec, naive and lastdim kernels already index the output in 16-byte
packs; only the int launcher arguments, which took the element count before
dividing it by the pack size, and the element-based check limited them.
The launchers now take int64_t and each checks its own kernel's range before
narrowing: packs * world_size <= INT_MAX for the pack-indexed kernels (16 *
INT_MAX bytes of output, whatever the dtype), elements * world_size for
allgather_scalar. Device code is unchanged.

_resolve_custom_sizes caps the gfx1250 cutoffs at the same bounds before
sizing the pool, with one warning each: AG at 16 * (INT_MAX // world_size)
bytes a rank, AR and RS at 2 * INT_MAX bytes (their element count is an int,
and 2 bytes is the narrowest dtype). The pool no longer grows for a size no
kernel takes. gfx9 is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot changed the title [Bugfix] Size the custom allreduce pool from per-op AR/AG/RS max-size env vars [HIP] [Bugfix] Size the custom allreduce pool from per-op AR/AG/RS max-size env vars Nov 4, 2026
@github-actions github-actions Bot added the HIP label Nov 4, 2026
Resolve the conflict in custom_all_reduce.py by keeping both
_fits_custom_ar_size (this branch) and _should_fly_oneshot (main, #5461).

Port test_flydsl_allreduce_rank_agreement.py from the removed
_resolve_car_max_size to _resolve_custom_sizes(...).ar.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot changed the title [HIP] [Bugfix] Size the custom allreduce pool from per-op AR/AG/RS max-size env vars [HIP] [FlyDSL] [Bugfix] Size the custom allreduce pool from per-op AR/AG/RS max-size env vars Nov 5, 2026
@github-actions github-actions Bot added the FlyDSL label Nov 5, 2026
@zufayu

zufayu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@aiter-bot review

@aiter-bot

Copy link
Copy Markdown

aiter-bot — queued behind 1 review(s); expect to start in about 50 min. The box reviews one PR at a time.

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.

3 participants