Skip to content

[CustomAllreduce] Re-take the expandable_segments decision at capture time - #5799

Merged
zufayu merged 4 commits into
ROCm:mainfrom
okorzh-amd:okorzh/defer-ar-capture-registration
Oct 16, 2026
Merged

zufayu merged 4 commits into
ROCm:mainfrom
okorzh-amd:okorzh/defer-ar-capture-registration

Conversation

@okorzh-amd

@okorzh-amd okorzh-amd commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

CustomAllreduce refuses its registered (copy-free) CUDA-graph capture path while PyTorch expandable_segments is on, because VMM-backed pointers cannot be exported with hipIpcGetMemHandle (#4174). It then stages every all-reduce input through a device-to-device copy (__amd_rocclr_copyBuffer) into the pre-registered input pool.

That veto is decided once, in __init__:

if not self._use_vmm and _expandable_segments_enabled():
    ...
    enable_register_for_capturing = False
self.enable_register_for_capturing = enable_register_for_capturing

A host that wants the registered path has one clean way to get it: keep expandable segments for weights, KV cache and eager allocations, and turn them off only for the duration of graph capture, so the graph pool's activations are ordinary hipMalloc memory and are exportable. Today that does nothing. By the time capture() runs the veto has already latched, and the copy-in path is taken regardless of what the allocator is doing.

The fix

  • Record what the caller asked for (_register_for_capturing_requested) before the expandable_segments veto.
  • In capture(), decide the path from the live allocator state. _expandable_segments_enabled() already reads the allocator snapshot, so no new plumbing. The decision goes both ways: off at capture uses the registered path, on at capture uses copy-in, whatever __init__ decided.
  • All ranks must agree. The registered/unregistered choice changes the kernel's input source and the graph-buffer count, so ranks that split would mismatch at flush and read the wrong peer buffers on replay. Each rank's decision is exchanged through the pool's TCP store (IPCBufferPool.all_gather_object, factored out of _gather_ipc_meta). The registered path is used only if every rank can take it. Otherwise every rank uses copy-in, which is always safe, and a warning lists the per-rank decisions. The exchange is skipped when registration was never requested, since that is the same on every rank.
  • Inputs that cannot be exported raise instead of aborting. On the registered path, each captured collective checks its buffer the way flush_graph_buffers will export it (hipPointerGetAttribute(RANGE_START_ADDR), then hipIpcGetMemHandle on the base), through the HIP runtime torch already loaded. A buffer that fails raises a RuntimeError at the call site. Before, the export failed inside HIP_CALL at flush, which std::abort()s the process with no traceback. The check clears the sticky error a failed HIP call leaves, which the next kernel launch would otherwise report as its own. A caller-provided output on the registered all_reduce is checked too, since flush exports it as well.
  • A capture whose body raised is not flushed: the graph is discarded, and exchanging a partial set of buffers could mismatch ranks.
  • The flag is restored in capture()'s finally, so the decision is scoped to the capture window and never leaks into eager calls.
  • The gfx1250 veto is architectural (peers would dereference unregistered pointers on replay) and is deliberately not re-evaluated. The VMM transport is unaffected.
  • Add a class-level marker, CustomAllreduce.defers_capture_registration = True, so hosts can feature-detect this instead of inferring it from a version number. vLLM's side ([ROCm] Capture CUDA graphs with expandable segments off for AITER all-reduce vllm-project/vllm#57481) probes for it and stays inert without it.

Disabled communicators (unsupported world size, multi-node group, no custom_ar library) are still entered by graph_capture(). Both new attributes are set before __init__ can return early, and capture() skips the exchange there.

What changes for existing callers

  • Which path is taken changes only when expandable segments are in a different state at capture() than at __init__. On at both: copy-in, as before. Off at both: registered, as before.
  • Off at __init__, on at capture now uses copy-in. Before, the latched registered path was kept and flush aborted the process at custom_all_reduce.cuh:4071 (hipIpcGetMemHandle ... invalid argument). Measured on this PR's first revision (bbd272ae8), which handled this case like main.
  • Cost, at capture time only: one TCP-store exchange per capture() when registration was requested, and the export check (about 1 us) per collective captured on the registered path. flush_graph_buffers already exchanges graph-buffer handles through the same store at the end of capture(). Eager calls and graph replay are unchanged.
  • The __init__ warning now says the decision is re-checked at capture instead of saying it forces copy-in.

Precondition for hosts: on the registered path, every collective buffer captured in the window must be allocated inside it. A tensor allocated earlier, while expandable segments were on, is still VMM-backed and cannot be IPC-exported. A graph-capturing host normally meets this, because the graph pool's activations feed the all-reduces. This is now enforced: a violation raises the RuntimeError above at the offending collective, and the process stays usable.

Impact

Measured with vLLM on 8x MI355X, Kimi-K3 decode (conc 1, 131k context, MTP K=6), rank 0, 4 captured passes. The host turns expandable segments off for capture on every rank (vllm-project/vllm#57481). The aiter side was applied as a runtime overlay of this PR's first revision. The second revision adds the cross-rank exchange and the export check, neither of which changes the path when every rank turns expandable segments off.

host toggle only host toggle + this change
__amd_rocclr_copyBuffer launches 1396 236
kernels launched 12188 11028
KDA layer (main stream) 338.6 us 263.3 us
MLA layer (main stream) 591.9 us 475.8 us

The drop is exactly -1160 copies = 792 two-stage + 368 one-stage all-reduce calls, i.e. one staging copy per collective, all gone. To confirm a host is getting the registered path, look for expandable_segments is off at capture time; using the registered custom-allreduce capture path (logged at INFO on each capture).

Test plan

New op_tests/multigpu_tests/test_custom_allreduce_capture_registration.py. Neither existing test covers both axes: test_init_dist_env.py sets expandable segments but captures no graph, and test_custom_allreduce.py captures a graph but never touches the allocator config. Each run builds the communicator, then captures one all-reduce under one of five scenarios:

scenario expandable segments at __init__ at capture expected
keep on on copy-in
toggle on off (every rank) registered
mixed on off (rank 0 only) copy-in on every rank
reverse off on (every rank) copy-in
stale on off (every rank), input allocated before the toggle RuntimeError at the collective on every rank

It asserts that:

  • the __init__ veto still fires exactly when expandable segments are on at construction;
  • inside capture(), every rank is on the expected path (for mixed, rank 0 alone could have registered);
  • the decision does not leak out of capture();
  • the replayed graph produces the correct sum;
  • for stale, every rank raises the new error, and an eager all-reduce afterwards is correct, so no sticky HIP error is left behind.

With no arguments the test sweeps TP 2/3/4/8 (capped at the visible GPU count), which is what CI runs. TP=3 covers a disabled communicator. On platforms where the veto cannot happen (gfx1250, the VMM transport, or a build that ignores expandable_segments), the flag assertions are skipped with a warning and only the result is checked, as test_init_dist_env.py does.

python3 op_tests/multigpu_tests/test_custom_allreduce_capture_registration.py
python3 op_tests/multigpu_tests/test_init_dist_env.py
python3 op_tests/multigpu_tests/test_custom_allreduce.py

Test result

New test: 20/20 pass (TP 2/3/4/8 x 5 scenarios) in both environments:

  • Local: 8x MI355X (gfx950), vllm/vllm-openai-rocm:nightly-rocm100-3df4ae15 (torch 2.12.0+rocm10.0.0), aiter built from source on this PR's base c8325e00c.

This PR's first revision, which re-checked only each rank's own state and only ever relaxed the veto, is the control for the new scenarios (TP=2):

scenario this PR first revision (bbd272ae8)
keep pass (copy-in) pass
toggle pass (registered) pass
mixed pass: copy-in on every rank, warning lists [True, False] hang: rank 0 registers alone; the test times out after 600 s
reverse pass (copy-in) SIGABRT at custom_all_reduce.cuh:4071

On main (1ec3cf48e), toggle fails at every TP size with expected enable_register_for_capturing=True inside capture(), saw False, so the test catches the latched veto.

@okorzh-amd
okorzh-amd requested a review from a team September 23, 2026 21:28
@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; main branch always runs both MI35X and MI300X
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 5799 --add-label <label>

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 opt this PR out.

@okorzh-amd
okorzh-amd force-pushed the okorzh/defer-ar-capture-registration branch from d2b901d to bbd272a Compare September 23, 2026 21:29
okorzh-amd added a commit to okorzh-amd/vllm that referenced this pull request Sep 23, 2026
Under `expandable_segments:True` the caching allocator hands out VMM-backed
pointers, which cannot be exported with `hipIpcGetMemHandle`. AITER's custom
all-reduce therefore declines to register its buffers for IPC and stages
every input through a device-to-device copy instead. On an 8x MI355X
Kimi-K3 decode that is one `__amd_rocclr_copyBuffer` per all-reduce:
with ROCm/aiter#5799, 1160 fewer copies per 4 captured passes on rank 0.

The activations feeding those all-reduces are allocated inside CUDA graph
capture from the graph's private pool, so disabling expandable segments for
the duration of capture is enough to make them exportable and let AITER take
its registered, copy-free path. Weights, KV cache and eager allocations keep
expandable segments.

Off by default behind VLLM_ROCM_NON_EXPANDABLE_CUDAGRAPH_POOL, and inert
unless it can actually pay off: the flag is ignored, with a warning, off
ROCm and on an AITER that still decides whether to register its buffers once
at start-up rather than when capture begins (every release up to
v0.1.22.post1; the capture-time decision is ROCm/aiter#5799). That
capability is probed via `AiterCustomAllreduce.build_defers_capture_registration`,
following the existing `build_supports_per_group_quant` pattern.

The guard also rewrites the PYTORCH_*_ALLOC_CONF variables for the duration
of capture. Consumers fall back to parsing those when they cannot read the
allocator; a consumer that read a stale `expandable_segments:True` while the
allocator said False would pick a different all-reduce path from its peers,
which across ranks of one job is a collective mismatch rather than a local
inefficiency.

Signed-off-by: Oxana Korzh <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@zufayu
zufayu self-requested a review September 24, 2026 01:45
@zufayu zufayu self-assigned this Sep 24, 2026
@zufayu
zufayu requested review from TennyWang1223 and removed request for zufayu September 24, 2026 01:52
@zufayu zufayu assigned TennyWang1223 and unassigned zufayu Sep 24, 2026
@zufayu
zufayu self-requested a review September 24, 2026 01:54
@jamesETsmith jamesETsmith added the ci:multi-gpu Trigger multi-GPU op tests on PR label Sep 24, 2026
@okorzh-amd
okorzh-amd force-pushed the okorzh/defer-ar-capture-registration branch from 581c81d to bb100fa Compare September 30, 2026 01:07
@zufayu

zufayu commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

@TennyWang1223 could please help to review this PR ?

okorzh-amd added a commit to okorzh-amd/vllm that referenced this pull request Oct 12, 2026
Under `expandable_segments:True` the caching allocator hands out VMM-backed
pointers, which cannot be exported with `hipIpcGetMemHandle`. AITER's custom
all-reduce therefore declines to register its buffers for IPC and stages
every input through a device-to-device copy instead. On an 8x MI355X
Kimi-K3 decode that is one `__amd_rocclr_copyBuffer` per all-reduce:
with ROCm/aiter#5799, 1160 fewer copies per 4 captured passes on rank 0.

The activations feeding those all-reduces are allocated inside CUDA graph
capture from the graph's private pool, so disabling expandable segments for
the duration of capture is enough to make them exportable and let AITER take
its registered, copy-free path. Weights, KV cache and eager allocations keep
expandable segments.

Off by default behind VLLM_ROCM_NON_EXPANDABLE_CUDAGRAPH_POOL, and inert
unless it can actually pay off: the flag is ignored, with a warning, off
ROCm and on an AITER that still decides whether to register its buffers once
at start-up rather than when capture begins (every release up to
v0.1.22.post1; the capture-time decision is ROCm/aiter#5799). That
capability is probed via `AiterCustomAllreduce.build_defers_capture_registration`,
following the existing `build_supports_per_group_quant` pattern.

The guard also rewrites the PYTORCH_*_ALLOC_CONF variables for the duration
of capture. Consumers fall back to parsing those when they cannot read the
allocator; a consumer that read a stale `expandable_segments:True` while the
allocator said False would pick a different all-reduce path from its peers,
which across ranks of one job is a collective mismatch rather than a local
inefficiency.

Signed-off-by: Oxana Korzh <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
okorzh-amd added a commit to okorzh-amd/vllm that referenced this pull request Oct 12, 2026
Under `expandable_segments:True` the caching allocator hands out VMM-backed
pointers, which cannot be exported with `hipIpcGetMemHandle`. AITER's custom
all-reduce therefore declines to register its buffers for IPC and stages
every input through a device-to-device copy instead. On an 8x MI355X
Kimi-K3 decode that is one `__amd_rocclr_copyBuffer` per all-reduce:
with ROCm/aiter#5799, 1160 fewer copies per 4 captured passes on rank 0.

The activations feeding those all-reduces are allocated inside CUDA graph
capture from the graph's private pool, so disabling expandable segments for
the duration of capture is enough to make them exportable and let AITER take
its registered, copy-free path. Weights, KV cache and eager allocations keep
expandable segments.

Off by default behind VLLM_ROCM_NON_EXPANDABLE_CUDAGRAPH_POOL, and inert
unless it can actually pay off: the flag is ignored, with a warning, off
ROCm and on an AITER that still decides whether to register its buffers once
at start-up rather than when capture begins (every release up to
v0.1.22.post1; the capture-time decision is ROCm/aiter#5799). That
capability is probed via `AiterCustomAllreduce.build_defers_capture_registration`,
following the existing `build_supports_per_group_quant` pattern.

The guard also rewrites the PYTORCH_*_ALLOC_CONF variables for the duration
of capture. Consumers fall back to parsing those when they cannot read the
allocator; a consumer that read a stale `expandable_segments:True` while the
allocator said False would pick a different all-reduce path from its peers,
which across ranks of one job is a collective mismatch rather than a local
inefficiency.

Signed-off-by: Oxana Korzh <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
TennyWang1223
TennyWang1223 previously approved these changes Oct 13, 2026

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

@okorzh-amd
okorzh-amd force-pushed the okorzh/defer-ar-capture-registration branch from 108cc51 to 5947b83 Compare October 13, 2026 02:56
zufayu
zufayu previously approved these changes Oct 13, 2026
@zufayu

zufayu commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

waiting for CI

@okorzh-amd
okorzh-amd dismissed stale reviews from zufayu and TennyWang1223 via e0af2d4 October 13, 2026 16:44
@okorzh-amd
okorzh-amd force-pushed the okorzh/defer-ar-capture-registration branch 2 times, most recently from e0af2d4 to 06f267f Compare October 13, 2026 19:02
@zufayu
zufayu requested a review from gyohuangxin October 14, 2026 09:13
@zufayu

zufayu commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

@gyohuangxin Could you please help check the MI350X multi-GPU CI environment? The only real failure is test_comm_fused_moe.py, which reports that a compatible mori.cco installation is unavailable, despite ROCm being 7.2.4. The CustomAllreduce tests added by this PR all passed, so this appears unrelated to the PR changes. We may need to install a compatible mori.cco in the CI image or skip this test when the optional dependency is unavailable.

@okorzh-amd

Copy link
Copy Markdown
Contributor Author

@gyohuangxin Could you please help check the MI350X multi-GPU CI environment? The only real failure is test_comm_fused_moe.py, which reports that a compatible mori.cco installation is unavailable, despite ROCm being 7.2.4. The CustomAllreduce tests added by this PR all passed, so this appears unrelated to the PR changes. We may need to install a compatible mori.cco in the CI image or skip this test when the optional dependency is unavailable.

@zufayu @gyohuangxin I believe non of this PR changes are causing test failures.

  1. Multi-GPU Tests (8 GPU): The latest main push (b0869bb, 10-14) fails the same way.
  2. ATOM Accuracy: Failed in "Download Models": HuggingFace returned HTTP 500 for amd/DeepSeek-R1-0528-MXFP4-MTP-MoEFP4. Intermittent.
  3. Aiter Test Gate: Only reports multi-gpu=failure from 1).

can this PR be merged?

@zufayu

zufayu commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

FYI, #6571 has been merged into main. It skips test_comm_fused_moe.py when a compatible MORI CCO is unavailable, which addresses the only failure in this PR's latest MI350X Multi-GPU job.

Please update/rebase this branch onto the latest main and rerun CI. Since the CustomAllreduce tests in this PR already passed, the required Aiter Test Gate should no longer be blocked by that unrelated MORI environment failure.

okorzh-amd and others added 4 commits October 15, 2026 09:40
… time

CustomAllreduce refuses the registered (copy-free) CUDA-graph capture path
while PyTorch expandable_segments is on, because VMM-backed pointers cannot
be exported with hipIpcGetMemHandle (ROCm#4174). It then stages every all-reduce
input through a device-to-device copy.

That decision is taken once, in __init__. A host that disables expandable
segments only for the duration of graph capture -- precisely so that the
graph pool's activations are exportable -- gets nothing from it, because the
veto has already latched by the time capture() runs.

Remember what the caller asked for before the veto, and re-evaluate it in
capture() against the live allocator state (_expandable_segments_enabled()
already reads the allocator snapshot, so no new plumbing). The flag is
restored on exit, so the change is scoped to the capture window. The gfx1250
veto is architectural and is deliberately not re-evaluated.

Measured with vLLM on 8x MI355X running Kimi-K3 decode: __amd_rocclr_copyBuffer
launches per 4 captured passes drop 1396 -> 236, i.e. -1160, exactly one
staging copy per collective (792 two-stage + 368 one-stage all-reduce calls).

Both attributes are set before __init__ can return early, since
graph_capture() still enters capture() on a disabled communicator
(unsupported world size, multi-node group, no custom_ar library), and the
flag is restored even if flush_graph_buffers raises.

`defers_capture_registration` is a class-level marker so hosts can
feature-detect this rather than infer it from a version number. Hosts must
allocate every all-reduce input captured in the window inside it.

Adds op_tests/multigpu_tests/test_custom_allreduce_capture_registration.py.
Neither existing test covers both axes: test_init_dist_env.py sets expandable
segments but captures no graph, and test_custom_allreduce.py captures a graph
but never touches the allocator config. The new test also asserts that all
ranks agree on the capture path, since the registered/unregistered choice
changes the kernel algorithm and the graph-buffer count, and covers a disabled
communicator with -t 3.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…portable inputs

Addresses two review questions on the capture-time re-check.

Cross-rank agreement. capture() used to re-read each rank's own allocator
state. Ranks that disagreed (config drift, a rank whose snapshot read failed)
would pick different kernel input sources and graph-buffer counts: a collective
mismatch, not a local inefficiency. capture() now exchanges each rank's local
decision through the pool's TCP store and uses the registered path only if
every rank can; otherwise every rank uses copy-in, which is always safe, and a
warning lists the per-rank decisions. The exchange is skipped when registration
was never requested, since that is rank-uniform. The decision is also taken in
both directions now: off at __init__ but on at capture falls back to copy-in
instead of registering VMM-backed pointers.

Unexportable inputs. The registered path requires every captured collective
buffer to be allocated inside the window. A buffer allocated while
expandable_segments were on is VMM-backed, and flush_graph_buffers' export of
it failed through HIP_CALL, i.e. SIGABRT with no traceback. Each captured
collective now checks its buffer the way flush will export it
(hipPointerGetAttribute RANGE_START_ADDR, then hipIpcGetMemHandle on the base,
about 1 us, legal during capture) and raises a RuntimeError at the call site.
The check binds the HIP runtime torch already loaded, and clears the sticky
error a failed call leaves behind; without that, the next kernel launch
reports "invalid argument". The registered all_reduce also exports its
output, so a caller-provided output is checked too. A capture whose body
raised is no longer flushed: the graph is discarded, and exchanging a partial
set of buffers could mismatch ranks.

The test now sweeps TP 2/3/4/8 (capped at the visible GPU count) by default,
which is what CI runs, and adds three scenarios: "mixed" (only rank 0 turns
expandable segments off; every rank must fall back to copy-in), "reverse" (off
at __init__, on at capture; copy-in), and "stale" (input allocated before the
toggle; every rank must raise the new error and stay usable for an eager
all-reduce afterwards).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…n test

The test gave each of its 20 runs (TP 2/3/4/8 x 5 scenarios) a fixed,
consecutive MASTER_PORT starting at 49375. Those ports sit inside the
Linux ephemeral range, so on a busy CI runner another connection can
already hold one: both multi-GPU CI runs failed with EADDRINUSE, at a
different port each time (49382 and 49392), after every scenario that
had run passed. Ask the OS for a free port per run with get_open_port(),
as the other multi-GPU tests do.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
ATOM turns the registered capture path off for PIECEWISE CUDA graphs:
before capture it sets enable_register_for_capturing = False on its
TP/DP/EP communicators, because under PIECEWISE a fast rank can
overwrite a pool-recycled input while a slow peer still reads it.
capture() re-derived the path from the constructor argument and the live
allocator state, and turned registration back on. In aiter CI, the
DeepSeek-V4-Pro DSpark job on this branch (DP attention, so only the
DP/EP communicators are live) logs ATOM's "forced aiter ca_comm ... to
unreg" for both groups and then "Registering 2322 cuda graph addresses"
on every rank, where the same job on other PRs registers none.

enable_register_for_capturing is now a property. Assigning False records
an opt-out that capture() keeps. The opt-out is a vote in the existing
all-rank agreement, not a reason to skip it: whether the exchange runs
still depends only on the constructor argument and the arch. ATOM opts
out only where the flag reads True, and that value comes from each
rank's own expandable_segments check at __init__, so ranks that disagree
there all fall back to copy-in instead of leaving their peers blocked in
the store exchange.

Assigning True only withdraws an opt-out: the flag reads the __init__
decision again and capture() decides as before. Unlike a direct write on
main, it no longer turns registration on where __init__ ruled it out,
e.g. on the gfx1250 VMM transport, which cannot register. Assigning
inside the capture window raises, since it would switch one rank's path
without the others.

The test adds four scenarios: the opt-out with expandable_segments off
throughout (ATOM's case), the opt-out combined with the capture-time
toggle, an opt-out on rank 0 only, and an opt-out that is withdrawn.
Every scenario also checks that a write inside the capture window is
refused, and asserts the all-reduce result exactly: checkAllclose only
logs a mismatch, so a wrong result could not fail the test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@okorzh-amd
okorzh-amd force-pushed the okorzh/defer-ar-capture-registration branch from 06f267f to b9bbeab Compare October 15, 2026 14:51
@okorzh-amd

Copy link
Copy Markdown
Contributor Author

FYI, #6571 has been merged into main. It skips test_comm_fused_moe.py when a compatible MORI CCO is unavailable, which addresses the only failure in this PR's latest MI350X Multi-GPU job.

Please update/rebase this branch onto the latest main and rerun CI. Since the CustomAllreduce tests in this PR already passed, the required Aiter Test Gate should no longer be blocked by that unrelated MORI environment failure.

rebased. Thanks!

@zufayu
zufayu merged commit bf46dd1 into ROCm:main Oct 16, 2026
okorzh-amd added a commit to okorzh-amd/vllm that referenced this pull request Oct 19, 2026
Under `expandable_segments:True` the caching allocator hands out VMM-backed
pointers, which cannot be exported with `hipIpcGetMemHandle`. AITER's custom
all-reduce therefore declines to register its buffers for IPC and stages
every input through a device-to-device copy instead. On an 8x MI355X
Kimi-K3 decode that is one `__amd_rocclr_copyBuffer` per all-reduce:
with ROCm/aiter#5799, 1160 fewer copies per 4 captured passes on rank 0.

The activations feeding those all-reduces are allocated inside CUDA graph
capture from the graph's private pool, so disabling expandable segments for
the duration of capture is enough to make them exportable and let AITER take
its registered, copy-free path. Weights, KV cache and eager allocations keep
expandable segments.

Off by default behind VLLM_ROCM_NON_EXPANDABLE_CUDAGRAPH_POOL. The flag is
ignored, with a warning, off ROCm and on an AITER that still decides whether
to register its buffers once at start-up rather than when capture begins:
every release up to v0.1.25. The capture-time decision is ROCm/aiter#5799,
first released in v0.1.26. That capability is probed via
`AiterCustomAllreduce.build_defers_capture_registration`, following the
existing `build_supports_per_group_quant` pattern.

The guard also rewrites the PYTORCH_*_ALLOC_CONF variables for the duration
of capture. AITER falls back to parsing those when it cannot read the
allocator; a rank that read a stale `expandable_segments:True` would vote
against the registered path, and AITER's all-rank agreement would then drop
every rank to copy-in, silently losing the win.

Signed-off-by: Oxana Korzh <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
okorzh-amd added a commit to okorzh-amd/vllm that referenced this pull request Oct 19, 2026
ROCm/aiter#5799 merged and first ships in AITER v0.1.26; vLLM still pins
v0.1.25, so the flag stays a warned no-op on stock images until the pin moves.
Name the release instead of the PR in the warning, the env-var comment and the
probe docstring, and add a TODO to drop the probe once the pin reaches it.

Read the `defers_capture_registration` marker's value rather than only its
presence.

On the registered path, merged AITER checks that every captured collective
input can be IPC-exported and raises a RuntimeError if not; before, such an
input aborted the process in `hipIpcGetMemHandle` when the graph buffers were
flushed. Its own wrappers go through that check, but the per-group fused
AR+RMSNorm+FP8-quant ops in `_aiter_ops` pass `registered=` to the AITER kernel
themselves and skipped it. Route them through a new
`AiterCustomAllreduce.capture_registered()`, which uses AITER's check when it
exists and the old expression otherwise. Like AITER's own wrappers, it also
answers False for a stream captured outside AITER's capture(), which would
never flush and register the inputs.

Run the CPU step that covers these tests when aiter_custom_all_reduce.py
changes.

Signed-off-by: Oxana Korzh <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
okorzh-amd added a commit to okorzh-amd/vllm that referenced this pull request Oct 19, 2026
Under `expandable_segments:True` the caching allocator hands out VMM-backed
pointers, which `hipIpcGetMemHandle` cannot export, so AITER's custom
all-reduce stages every captured input through a device-to-device copy. On an
8x MI355X Kimi-K3 MTP decode that is 1160 extra copies per 4 captured passes on
rank 0 and costs 4% TPOT at conc 1 and 2.3% at conc 8.

The activations feeding those all-reduces are allocated inside graph capture
from the graph's private pool, so turning expandable segments off for the
duration of graph_capture() makes them exportable and lets AITER take its
registered, copy-free path. Weights, KV cache and allocations made outside
graph_capture() keep expandable segments.

Off by default behind VLLM_ROCM_NON_EXPANDABLE_CUDAGRAPH_POOL. Needs AITER
>= v0.1.26, which re-takes the decision when capture begins (ROCm/aiter#5799).
On older AITER, including vLLM's current v0.1.25 pin, the flag gives no
speed-up and only changes how allocations inside graph_capture() are made.

Signed-off-by: Oxana Korzh <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
okorzh-amd added a commit to okorzh-amd/vllm that referenced this pull request Oct 20, 2026
…-reduce

Under `expandable_segments:True` the caching allocator hands out VMM-backed
pointers, which `hipIpcGetMemHandle` cannot export, so AITER's custom
all-reduce stages every captured input through a device-to-device copy.

The activations feeding those all-reduces are allocated inside graph capture
from the graph's private pool, so turning expandable segments off for the
duration of graph_capture() makes them exportable and lets AITER take its
registered, copy-free path. Weights, KV cache and allocations made outside
graph_capture() keep expandable segments.

This happens automatically on ROCm when the TP group's AITER custom
all-reduce requested graph-buffer registration, which AITER exposes from
v0.1.26 (ROCm/aiter#5799, which re-takes the decision when capture begins).
It is skipped when the DP group also runs AITER collectives: under DP+EP the
MoE combine reduce-scatters a persistent workspace allocated before capture,
which the registered path cannot export. On older AITER, without AITER custom
all-reduce, with the cuMem graph pool, or when expandable segments are already
off, nothing changes.

DeepSeek-V4.1-Flash TP8 on MI355X with expandable segments on: decode step
-2.6% at concurrency 1 and -2.0% at concurrency 8, the same as with expandable
segments off; the graph pool grows by ~0.5 GiB per GPU (its size with
expandable segments off) and the KV cache shrinks by 0.2%.

Signed-off-by: Oxana Korzh <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
okorzh-amd added a commit to okorzh-amd/vllm that referenced this pull request Oct 20, 2026
…-reduce

Under `expandable_segments:True` the caching allocator hands out VMM-backed
pointers, which `hipIpcGetMemHandle` cannot export, so AITER's custom
all-reduce stages every captured input through a device-to-device copy.

The activations feeding those all-reduces are allocated inside graph capture
from the graph's private pool, so turning expandable segments off for the
duration of graph_capture() makes them exportable and lets AITER take its
registered, copy-free path. Weights, KV cache and allocations made outside
graph_capture() keep expandable segments.

This happens automatically on ROCm when the TP group's AITER custom
all-reduce requested graph-buffer registration, which AITER exposes from
v0.1.26 (ROCm/aiter#5799, which re-takes the decision when capture begins).
It is skipped when the DP group also runs AITER collectives: under DP+EP the
MoE combine reduce-scatters a persistent workspace allocated before capture,
which the registered path cannot export. On older AITER, without AITER custom
all-reduce, with the cuMem graph pool, or when expandable segments are already
off, nothing changes.

DeepSeek-V4.1-Flash TP8 on MI355X with expandable segments on: decode step
-2.6% at concurrency 1 and -2.0% at concurrency 8, the same as with expandable
segments off; the graph pool grows by ~0.5 GiB per GPU (its size with
expandable segments off) and the KV cache shrinks by 0.2%.

Signed-off-by: Oxana Korzh <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
okorzh-amd added a commit to okorzh-amd/vllm that referenced this pull request Oct 21, 2026
…-reduce

Under `expandable_segments:True` the caching allocator hands out VMM-backed
pointers, which `hipIpcGetMemHandle` cannot export, so AITER's custom
all-reduce stages every captured input through a device-to-device copy.

The activations feeding those all-reduces are allocated inside graph capture
from the graph's private pool, so turning expandable segments off for the
duration of graph_capture() makes them exportable and lets AITER take its
registered, copy-free path. Weights, KV cache and allocations made outside
graph_capture() keep expandable segments.

This happens automatically on ROCm when the TP group's AITER custom
all-reduce registers graph buffers (vLLM did not turn that off, not gfx1250)
and AITER decides it when capture begins, which AITER advertises with the
`defers_capture_registration` class marker from v0.1.26 (ROCm/aiter#5799).
It is skipped when the DP group also runs AITER collectives: under DP+EP the
MoE combine reduce-scatters a persistent workspace allocated before capture,
which the registered path cannot export. On older AITER, without AITER custom
all-reduce, with the cuMem graph pool, or when expandable segments are already
off, nothing changes.

DeepSeek-V4.1-Flash TP8 on MI355X with expandable segments on: decode step
-2.6% at concurrency 1 and -2.0% at concurrency 8, the same as with expandable
segments off; the graph pool grows by ~0.5 GiB per GPU (its size with
expandable segments off) and the KV cache shrinks by 0.2%.

Signed-off-by: Oxana Korzh <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:atom_full ci:multi-gpu Trigger multi-GPU op tests on PR multigpu

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants