Repository navigation
[HIP] [CustomAR] Keep CUDA-graph buffer registration in step across ranks - #6819
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
On the registered capture path, register_graph_buffers added every captured output to output_buffers_, the map of eagerly registered outputs. A later capture looks that map up before recording, so when the allocator handed a rank the same address again, that rank reused the stale entry and skipped the buffer while the other ranks recorded theirs. flush_graph_buffers pairs buffer i with every peer's buffer i, so the shifted lists made peers open the wrong IPC handles; with matching counts the rank would instead have pointed at its peers' old buffers, silently. vLLM hit this with DSpark on Muse Spark (TP8, fp32 MoE reduce): the draft graphs, captured after the target graphs, recorded 3488 buffers on one rank and 3492 on the other seven, and hipIpcOpenMemHandle failed with "invalid argument". Only fp32/fp16 all-reduces record outputs; bf16 does not. - Do not add graph-captured outputs to output_buffers_. Their RankData slots are baked into the captured kernels, so nothing reads the map entry after flush; a later capture now records the buffer on every rank. The gfx1250 header gets the same change for consistency only: that transport never registers graph buffers. - flush_graph_buffers agrees on the per-rank count before exchanging handles and raises the same error on every rank when they differ. This also stops a rank with nothing recorded from returning early and leaving the others blocked on its handles. - Add test_custom_allreduce_graph_buffer_reuse.py (address reuse on rank 0 only, plus rank-divergent captures that must raise on every rank), and drop the stale-pointer warning from test_custom_allreduce.py. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Oxana Korzh <[email protected]>
2afdf84 to
5801cfa
Compare
|
@TennyWang1223 could you please help to review? CI is passing |
Motivation
vLLM on ROCm crashes at startup with DSpark speculative decoding at TP8 when custom all-reduce is on. It reproduces on stock vLLM. During the third CUDA-graph capture round (the DSpark verify/draft graphs), the ranks record different numbers of graph buffers:
flush_graph_bufferspairs buffer i with every peer's buffer i, so the lists end up misaligned andhipIpcOpenMemHandlefails with "invalid argument" / "invalid device pointer". The current workaround is--disable-custom-all-reduce, which falls back to RCCL and slows the all-reduces down.Root cause
On the registered capture path,
register_graph_buffersadded every captured output tooutput_buffers_, the map of eagerly registered outputs.get_output_buffer_RDchecks that map before recording. So when the allocator gave a rank an address that an earlier capture had already used, only that rank:Only fp32/fp16 all-reduces record outputs; the bf16 dispatch never passes
is_broadcast_reg_outptr. Muse Spark's MoE does its TP reduction in fp32, which is what exposes the bug. Inputs were never cached this way, so they are unaffected.Changes
csrc/include/custom_all_reduce.cuh: stop adding graph-captured outputs tooutput_buffers_. TheirRankDataslots are already baked into the captured kernels, so nothing reads the map entry after flush. A later capture now records the buffer on every rank. The map keeps only eagerly registered buffers, and a comment states that rule.csrc/include/custom_all_reduce_gfx1250.cuh: the same change, for consistency only. gfx1250 never registers graph buffers, so it has no runtime effect there.IPCBufferPool.flush_graph_buffers: before exchanging handles, the ranks all-gather their counts. If the counts differ, every rank raises the sameRuntimeError, instead of opening the wrong peer handles. This also fixes a hang: a rank with 0 recorded buffers used to return early while the other ranks waited for its handles.op_tests/multigpu_tests/test_custom_allreduce_graph_buffer_reuse.py(fp32), run at TP 2/4/8:reuse: in the second capture, rank 0 writes into the first capture's output and the other ranks into a fresh tensor. Every rank must record 2 buffers per capture, and both graphs must replay to the exact sum.extra/none: rank 0 captures one extra all-reduce, or none at all. Every rank must raise, and none may hang.op_tests/multigpu_tests/test_custom_allreduce.py: remove the docstring warning about stale peer pointers on address reuse, which no longer applies.Test plan
python op_tests/multigpu_tests/test_custom_allreduce_graph_buffer_reuse.pyfails onmainand passes on this branch (MI355X, TP 2/4/8)python op_tests/multigpu_tests/test_custom_allreduce.pyandtest_custom_allreduce_capture_registration.pystill pass