Repository navigation
[HIP] [FlyDSL] [Bugfix] Size the custom allreduce pool from per-op AR/AG/RS max-size env vars - #7433
Conversation
… env vars Signed-off-by: TennyWang1223 <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
NOT READY FOR HUMAN REVIEWPR Self-ReviewRevision 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
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
…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]>
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]>
|
@aiter-bot review |
|
aiter-bot — queued behind 1 review(s); expect to start in about 50 min. The box reviews one PR at a time. |
Summary
Give custom all-reduce, all-gather and reduce-scatter one size cutoff each (
AITER_CUSTOM_AR_MAX_SIZE, the existing one, plus newAITER_CUSTOM_AG_MAX_SIZEandAITER_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_SIZEabove the pool size logged a warning and dropped back to 64 MiB. Raising the cutoff made it smaller.max_size / (2 * world_size)), and reduce-scatter reused the all-reduce cutoff.registered buffer is too small to contain the input. There was no way to raise the pool.#7367 added a separate
AITER_CAR_POOL_BYTESfor 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_ipcallocates another2 * max_sizeof 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.pyAITER_CUSTOM_AG_MAX_SIZE(per-rank input bytes) andAITER_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:0AITER_CUSTOM_AR_MAX_SIZEAITER_CUSTOM_AG_MAX_SIZEmax_size / (2 * world_size)(unchanged, 128 MiB at TP4)AITER_CUSTOM_RS_MAX_SIZEAITER_CUSTOM_AR_MIN_SIZEnow applies to all-reduce only. Reduce-scatter used to inherit it throughshould_custom_ar._resolve_car_max_sizeis replaced by a pure function_resolve_custom_sizes(is_gfx1250, world_size, max_size)that returns the pool size and the cutoffs: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 exactlymax_size. The pool never shrinks belowmax_size. The 1-stage kernels have no tmp region, so the AR prefill cutoff is no longer halved there.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_rsandshould_custom_ageach check their own cutoff. AR and RS share a_fits_custom_sizehelper.max_sizeconstructor 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 setsAITER_CUSTOM_RS_MAX_SIZE=0instead ofAITER_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
Documentation
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
Breaking Changes
None with the variables unset. With them set, the following change:
AITER_CUSTOM_AR_MAX_SIZEandAITER_CUSTOM_AR_MIN_SIZEno longer affect reduce-scatter. Anyone who usedAITER_CUSTOM_AR_MAX_SIZE=0to turn off custom RS as well must also setAITER_CUSTOM_RS_MAX_SIZE=0.AITER_CUSTOM_AR_MAX_SIZEabove the pool size used to drop back to 64 MiB. Now:AITER_CUSTOM_AR_MAX_SIZEabove 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,0disabling only one op, bad values, gfx9 capping and prefill halving, RS independent of the AR cutoffs, and AR_MIN applying to AR only.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 withmax_size=64 MiB): pass.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.AITER_CUSTOM_AR_DISABLE_GFX1250=1andAITER_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.pyfails withcustom_all_gatherv declined the rows. It fails the same way onmainwithout this change.custom_all_gathervis not touched here.Unverified:
self.max_sizethe same way as IPC, but neither was run.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 throughAITER_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.