Skip to content

[fix] Size the custom all-reduce input pool from AITER_CAR_POOL_BYTES - #7367

Closed
karverma-amd wants to merge 3 commits into
ROCm:mainfrom
karverma-amd:karverma/custom-ar-pool-size-env
Closed

karverma-amd wants to merge 3 commits into
ROCm:mainfrom
karverma-amd:karverma/custom-ar-pool-size-env

Conversation

@karverma-amd

@karverma-amd karverma-amd commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Let CudaCommunicator size the custom all-reduce / all-gather registered input pool from AITER_CAR_POOL_BYTES. The default stays 1 GiB, so nothing changes unless the variable is set.

Motivation

CudaCommunicator creates CustomAllreduce with its default max_size of 1 GiB, and there is no way to raise it. That pool caps the largest custom all-gather. On gfx1250, CUDA-graph buffer registration is not available, so the copy-in path stages the whole input into the pool, and the kernel throws registered buffer is too small to contain the input (csrc/kernels/custom_all_reduce_gfx1250.cu) when it does not fit.

A DP-attention model with an allgather LM head (ATOM ATOM_DP_LM_HEAD_MODE=allgather, ATOM_USE_CUSTOM_ALL_GATHER=1) gathers [dp * rows, vocab / dp] logits in every decode graph. For DeepSeek-V4.1-Flash on 4x MI455X that input passes 1 GiB at large decode batches, and graph capture fails.

Changes

_resolve_car_pool_bytes reads AITER_CAR_POOL_BYTES once when CudaCommunicator builds CustomAllreduce. Unset, empty, non-integer, or <= 0 keeps the 1 GiB default and warns on a bad value. The variable is honored only on gfx1250. Off gfx1250 it is ignored, because _init_ipc also allocates 2 * max_size of uncached meta (about 3x the pool per rank). The custom-AR cutoff from an unset AITER_CUSTOM_AR_MAX_SIZE is min(64 MiB, pool), so should_custom_ar cannot accept an input the pool cannot hold.

Performance (if applicable)

Hardware Workload/configuration Before After Change
4x MI455X (gfx1250) DeepSeek-V4.1-Flash TP+EP4 DP attention, allgather LM head, decode graphs through batch 1024 capture fails: registered buffer is too small to contain the input that error is gone with AITER_CAR_POOL_BYTES=17179869184 fixes capture
4x MI455X (gfx1250) Same, decode graphs through batch 640, concurrency 1024, 10 min — 54,395 tok/s (13,599 tok/s/GPU), 0 failed samples —

Batch 1024 then stops at a separate limit (the gfx1250 all-gather's int32 element count), so serving caps decode graphs at 640.

Testing

  • Unit tests added or updated
  • Performance benchmarks run (serving runs above)
  • Tested on MI250X
  • Tested on MI300X
  • Tested on MI455X (gfx1250)

Documentation

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

The variable is opt-in with an unchanged default; the in-code comment states what it controls.

Dependencies

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

Breaking Changes

None. Unset, the pool is 1 GiB, as today.

PR Self-Review

Reviewed revision

b8c347f

Behavior and intent

CudaCommunicator sizes the custom all-reduce pool from AITER_CAR_POOL_BYTES (default 1 << 30) on gfx1250 only. The 1 GiB pool is otherwise hard-coded, and on gfx1250 a custom all-gather larger than the pool fails during CUDA-graph capture. Unset, the pool stays 1 GiB. A value below the 64 MiB AR cutoff no longer leaves should_custom_ar accepting inputs the pool cannot stage: the unset cutoff is min(64 MiB, pool). Off gfx1250 the variable is ignored so the IPC meta buffer does not grow by 2 * pool.

Validation and unverified scope

One gfx1250 node (4x MI455X), 20261102 Atom image, DeepSeek-V4.1-Flash TP+EP4 with DP attention and the allgather LM head. Unset (1 GiB), with decode graphs through batch 1024: capture fails with registered buffer is too small to contain the input. With AITER_CAR_POOL_BYTES=17179869184 that error is gone; with graphs through 640, concurrency 1024 served 10 min at 54,395 tok/s with 0 failed samples. What remains unverified: a 1 GiB pool with graphs capped at 640, and a re-run on the per-op cutoff design in #7433. tests/test_car_pool_bytes.py covers parsing, the gfx1250-only gate, the 1 GiB default, and the cutoff cap. gfx9 no longer grows the pool, so the 3x meta cost does not apply to this variable.

PR-specific question

What sets the pool size, and can this change default behavior? Only AITER_CAR_POOL_BYTES, and only on gfx1250. Unset, non-integer, or <= 0, max_size is 1 << 30, the same default as before. Off gfx1250 the variable is ignored and the pool stays 1 GiB.

Changed op tests

None. The new coverage is tests/test_car_pool_bytes.py, not an op test: it checks pool parsing, the 1 GiB default, the gfx1250-only gate, and that an unset AITER_CUSTOM_AR_MAX_SIZE cannot exceed the pool.

The registered pool caps the largest custom all-gather. On gfx1250 the copy-in path stages the whole input into it and throws when it does not fit, which a DP-attention allgather LM head hits at large decode batches. The default stays 1 GiB.

Co-authored-by: Cursor <[email protected]>
@karverma-amd
karverma-amd requested a review from a team November 3, 2026 00:35
@github-actions

github-actions Bot commented Nov 3, 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 7367 --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 3, 2026 •

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision b8c347f7f1ae · 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

`CudaCommunicator` sizes the custom all-reduce pool from `AITER_CAR_POOL_BYTES` (default `1 << 30`) on gfx1250 only. The 1 GiB pool is otherwise hard-coded, and on gfx1250 a custom all-gather larger than the pool fails during CUDA-graph capture. Unset, the pool stays 1 GiB. A value below the 64 MiB AR cutoff no longer leaves `should_custom_ar` accepting inputs the pool cannot stage: the unset cutoff is `min(64 MiB, pool)`. Off gfx1250 the variable is ignored so the IPC meta buffer does not grow by `2 * pool`.

Validation and unverified scope

One gfx1250 node (4x MI455X), 20261102 Atom image, DeepSeek-V4.1-Flash TP+EP4 with DP attention and the allgather LM head. Unset (1 GiB), with decode graphs through batch 1024: capture fails with `registered buffer is too small to contain the input`. With `AITER_CAR_POOL_BYTES=17179869184` that error is gone; with graphs through 640, concurrency 1024 served 10 min at 54,395 tok/s with 0 failed samples. What remains unverified: a 1 GiB pool with graphs capped at 640, and a re-run on the per-op cutoff design in #7433. `tests/test_car_pool_bytes.py` covers parsing, the gfx1250-only gate, the 1 GiB default, and the cutoff cap. gfx9 no longer grows the pool, so the 3x meta cost does not apply to this variable.

PR-specific question

What sets the pool size, and can this change default behavior? Only `AITER_CAR_POOL_BYTES`, and only on gfx1250. Unset, non-integer, or `<= 0`, `max_size` is `1 << 30`, the same default as before. Off gfx1250 the variable is ignored and the pool stays 1 GiB.

Changed op tests

None. The new coverage is `tests/test_car_pool_bytes.py`, not an op test: it checks pool parsing, the 1 GiB default, the gfx1250-only gate, and that an unset `AITER_CUSTOM_AR_MAX_SIZE` cannot exceed the pool.

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply
  • ADVISORY — Copilot did not review the current head SHA

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
  • FAIL — Aiter Test Gate: failed
  • Required CI failed; fix it before requesting human review.

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

@karverma-amd karverma-amd changed the title Size the custom all-reduce input pool from AITER_CAR_POOL_BYTES [fix] Size the custom all-reduce input pool from AITER_CAR_POOL_BYTES Nov 3, 2026

@valarLip valarLip left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The default path is unchanged, and the C++ side checks the registered size (int64) before staging, so an input bigger than the pool fails loudly rather than overflowing. A few small changes before merge:

  1. When AITER_CAR_POOL_BYTES is below 64 MiB and AITER_CUSTOM_AR_MAX_SIZE is unset, _resolve_car_max_size still returns the 64 MiB default. should_custom_ar then accepts inputs the pool cannot hold, and the kernel throws "registered buffer is too small" instead of falling back to RCCL, which breaks graph capture. Please cap the default at the pool size, or enforce a lower bound on the pool.
  2. The variable applies to every arch. On gfx942/950, _init_ipc also allocates 2*max_size of uncached meta, so 16 GiB costs about 48 GiB per rank. Please document this in the comment, or read the variable only on gfx1250.
  3. Please parse it like AITER_CUSTOM_AR_MAX_SIZE: strip the value, warn and fall back on non-integer or <= 0 values, and log the effective pool size. A small unit test for the parsing and the default (1 << 30) would help.

@TennyWang1223

TennyWang1223 commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Setting the pool size through AITER_CAR_POOL_BYTES can leave it out of sync with AITER_CUSTOM_AR_MAX_SIZE; the two have to be kept consistent by hand. It also applies to every arch, and on gfx942/950 _init_ipc allocates another 2 * max_size of meta, so a 16 GiB pool costs about 48 GiB per rank.

I think a more robust fix is to give all-gather and reduce-scatter their own cutoffs (AITER_CUSTOM_AG_MAX_SIZE / AITER_CUSTOM_RS_MAX_SIZE) and size the pool from the largest of the three, with no separate pool variable. The pool only grows on gfx1250; gfx9 stays at 1 GiB and routes larger inputs to RCCL. See #7433

For your case, AITER_CUSTOM_AG_MAX_SIZE= should be enough. Could you check that DeepSeek-V4.1-Flash capture works on #7433? If it works, we can close this PR.

…250 only.

A pool below 64 MiB left should_custom_ar accepting inputs the copy-in path cannot stage. The unset cutoff is now capped at the pool. AITER_CAR_POOL_BYTES is parsed like AITER_CUSTOM_AR_MAX_SIZE and ignored off gfx1250, where the IPC meta buffer also holds 2 * pool of uncached memory.
@karverma-amd

Copy link
Copy Markdown
Contributor Author

The three points from the review are in 03152ea.

  1. An unset AITER_CUSTOM_AR_MAX_SIZE now resolves to min(64 MiB, pool). A pool below 64 MiB no longer lets should_custom_ar accept an input the copy-in path cannot stage. A cutoff above the pool falls back inside the pool too.
  2. AITER_CAR_POOL_BYTES is honored only on gfx1250. Off gfx1250 it is ignored and the pool stays 1 GiB, so _init_ipc does not also allocate 2 * pool of uncached meta.
  3. Parsing matches AITER_CUSTOM_AR_MAX_SIZE: the value is stripped, a non-integer or <= 0 warns and keeps 1 GiB, and the effective pool size is logged. tests/test_car_pool_bytes.py covers the default (1 << 30), the bad values, the gfx1250 gate, and the cutoff cap.

On #7433: sizing the pool from AITER_CUSTOM_AG_MAX_SIZE / AITER_CUSTOM_RS_MAX_SIZE, and only growing it on gfx1250, is the cleaner API, and it removes the separate pool variable that can drift from the cutoff. I have not re-run the DeepSeek-V4.1-Flash capture on that branch. The failure this PR hit is the gfx1250 copy-in all-gather of the DP-attention logits once the input passes the registered pool. AITER_CUSTOM_AG_MAX_SIZE growing that pool is the same condition. I will close this PR if that capture succeeds on #7433.

The aiter logger does not propagate, so pytest's caplog stays empty while the warning is on stderr. The three failing assertions now use capfd.

Co-authored-by: Cursor <[email protected]>
@karverma-amd

Copy link
Copy Markdown
Contributor Author

The Standard Tests failure is the new unit test, not the pool logic. The warnings are on stderr ([aiter] ... is not an integer, ignored off gfx1250, exceeds the custom-AR pool size) because the aiter logger sets propagate = False. caplog therefore stayed empty. b8c347f reads those lines with capfd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants