Repository navigation
[HIP] fix(custom_ar): make 6-rank custom collectives correct - #7149
Conversation
… kernel The custom all-reduce runs at 2, 4, 6 and 8 ranks, but the all-gather, all-gatherv and reduce-scatter kernels exist for 2, 4 and 8 only. At 6 ranks custom_all_gatherv threw after copying into the pool, and the reduce-scatter and all-gather printed and returned, leaving their outputs uninitialized. - _has_gather_scatter_kernel() (always true on gfx1250, which has its own kernels) gates custom_all_gatherv, should_custom_rs, should_custom_ag and GroupCoordinator.all_gather(use_custom=True), so they fall back to NCCL. - The reduce-scatter and all-gather dispatches throw on a world size or split dim they have no kernel for instead of printing. - test_custom_allgatherv.py at 6 ranks checks every path declines and that all_gatherv, reduce_scatter_tensor and all_gather come out right. Co-Authored-By: Claude Opus 5.5 (1M context) <[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 Author self-review accepted. Readiness report: Author answers
Show the author's self-review answersBehavior and intentValidation and unverified scopePR-specific questionChanged op testsPR state
Copilot findings
Code and op-test hygiene
Required CI
Shadow mode reports what would block but keeps the status successful. Set |
|
@aiter-bot review |
…GPUs cross_device_reduce_1stage splits its 512 threads into ngpus groups of 512 / ngpus. At 6 ranks that leaves threads 510 and 511 with warp_id 6: they read through dp.ptrs[6], a slot a 6-rank group never fills, and store into tmp_smem past the six rank groups. DeepSeek-V4 at -pcp 6 faulted there in decode (rocm-debug-agent: cross_device_reduce_1stage< bf16, 6, false>, MEMORY_VIOLATION). - Threads with warp_id >= ngpus skip the loads and stores and only join the barriers; 2, 4 and 8 divide 512 and are unchanged. - test_custom_allreduce.py adds a (79, 512) tail shape at 6 ranks, under the 80 KiB one-stage cutoff; it fails with an illegal memory access without the fix. - Note on the two-stage dispatch why 6 ranks take the naive kernels. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
ROCm/aiter#7149 makes custom_all_gatherv decline group sizes it has no kernel for, so all_gatherv falls back to NCCL there. The grouped gather now takes the one-collective path at every PCP size, 6 included. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
TennyWang1223
left a comment
There was a problem hiding this comment.
review summary
Verdict: Request changes. One small fix, then approve.
The approach is sound. At 6 ranks, gather/scatter now falls back to NCCL, and the one-stage all-reduce no longer reads out of bounds. Main has no merge conflict, there are no CI failures, and Multi-GPU tests were skipped because the PR has no multi-GPU label.
Must fix
- [verified] aiter/dist/parallel_state.py:1183: regression in GroupCoordinator.all_gather.
- self.device_communicator.ca_comm is read unconditionally, even when use_custom=False. device_communicator is None for the world group (init_world_group), and for standard groups when custom_group_config is set.
- Repro: two ranks on gloo, init_world_group([0,1]).all_gather(x, dim=0). Head raises AttributeError: 'NoneType' object has no attribute 'ca_comm'. Main's version gets past this line.
- Fix:
dc = self.device_communicator
ca_comm = dc.ca_comm if (use_custom and dc is not None) else None
Notes
- [verified] One entry point is still ungated. GroupCoordinator.custom_all_gather / tensor_model_parallel_custom_all_gather call ca_comm.custom_all_gather without checking _has_gather_scatter_kernel(). At 6 ranks off gfx1250 they now raise instead of returning garbage. That is better than main, but please either gate them or document that they raise.
- [verified] CI never runs the 6-rank paths. The tests default to -t 2 (all-gatherv) and -t 8 (all-reduce), so the new 6-rank branches never run in CI. Please run CI with the multi-GPU label and consider adding a -t 6 case.
Checked, no issues
- 1-stage all-reduce fix: the leftover threads skip both load/store sites and still reach every barrier. Ranks 2, 4 and 8 are unchanged.
- Other kernels sized by THREAD_NUM / ngpus: none of them is dispatched at 6 ranks, or they already throw. The new allreduce_residual from main (#6270) uses the _naive kernel at 6 ranks.
- gfx1250: unaffected, because it uses its own *_gfx1250 ops.
- printf → throw in the C++ dispatch: these are host-side, so the error reaches Python as a RuntimeError.
…runs Review follow-ups on #7149: - GroupCoordinator.all_gather read device_communicator.ca_comm on every call, so a group built without a device communicator (the world group) raised AttributeError even with use_custom=False. It reads it only when use_custom is set and a communicator exists. - GroupCoordinator.custom_all_gather / tensor_model_parallel_custom_all_gather take the custom kernel with no fallback: they now raise a clear error before launching at a group size without one, and say so. - CI runs test_custom_allreduce.py (-t 6 --regression) and test_custom_allgatherv.py (-t 6) at 6 ranks after their default sizes, where the runner has 6 GPUs. - tests/test_group_coordinator_all_gather.py covers the path choice on CPU. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Thanks. Fixed in 5dd0493:
|
* [HIP] fix(custom_ar): decline gather / scatter at group sizes with no kernel The custom all-reduce runs at 2, 4, 6 and 8 ranks, but the all-gather, all-gatherv and reduce-scatter kernels exist for 2, 4 and 8 only. At 6 ranks custom_all_gatherv threw after copying into the pool, and the reduce-scatter and all-gather printed and returned, leaving their outputs uninitialized. - _has_gather_scatter_kernel() (always true on gfx1250, which has its own kernels) gates custom_all_gatherv, should_custom_rs, should_custom_ag and GroupCoordinator.all_gather(use_custom=True), so they fall back to NCCL. - The reduce-scatter and all-gather dispatches throw on a world size or split dim they have no kernel for instead of printing. - test_custom_allgatherv.py at 6 ranks checks every path declines and that all_gatherv, reduce_scatter_tensor and all_gather come out right. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * [HIP] fix(custom_ar): one-stage all-reduce reads past its ranks at 6 GPUs cross_device_reduce_1stage splits its 512 threads into ngpus groups of 512 / ngpus. At 6 ranks that leaves threads 510 and 511 with warp_id 6: they read through dp.ptrs[6], a slot a 6-rank group never fills, and store into tmp_smem past the six rank groups. DeepSeek-V4 at -pcp 6 faulted there in decode (rocm-debug-agent: cross_device_reduce_1stage< bf16, 6, false>, MEMORY_VIOLATION). - Threads with warp_id >= ngpus skip the loads and stores and only join the barriers; 2, 4 and 8 divide 512 and are unchanged. - test_custom_allreduce.py adds a (79, 512) tail shape at 6 ranks, under the 80 KiB one-stage cutoff; it fails with an illegal memory access without the fix. - Note on the two-stage dispatch why 6 ranks take the naive kernels. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * [HIP] fix(dist): all_gather without a device communicator; 6-rank CI runs Review follow-ups on #7149: - GroupCoordinator.all_gather read device_communicator.ca_comm on every call, so a group built without a device communicator (the world group) raised AttributeError even with use_custom=False. It reads it only when use_custom is set and a communicator exists. - GroupCoordinator.custom_all_gather / tensor_model_parallel_custom_all_gather take the custom kernel with no fallback: they now raise a clear error before launching at a group size without one, and say so. - CI runs test_custom_allreduce.py (-t 6 --regression) and test_custom_allgatherv.py (-t 6) at 6 ranks after their default sizes, where the runner has 6 GPUs. - tests/test_group_coordinator_all_gather.py covers the path choice on CPU. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
* [PCP] Fewer prefill collectives per layer, no reindex readback Each V4 attention layer under PCP prefill issued 3-5 separate all-gathers (main compressor input, indexer compressor input, extend K -- two under fp8 KV -- and positions), each through torch.distributed. Now it issues two: - `pcp_allgather_rerange_many` gathers several tensors in one grouped `all_gatherv` and restores token order per tensor. One-byte dtypes travel as uint8, since past aiter's custom all-gather limit the call falls back to PyNCCL, which has no fp8 dtype. - The extend K is gathered together with the positions its SWA write addresses the ring by. Positions are gathered rather than read off the forward context: an MTP draft pass runs at the target's positions + 1. - `_launch_compressors` projects both compressors' inputs and gathers them in one collective; `Compressor.forward(combined=)` takes the result. V4-Pro (30 CSA + 31 HCA layers): 397 -> 245 collectives per prefill step. `pcp_reindex_ragged` sized its output with a blocking `.item()`, four times per prefill step (sixteen under PCP+TBO). The builder already computes the four prefill indptrs in numpy; it now keeps them on the metadata (`paged_prefill_indptr_cpu`) and each rank's local indptr is computed on the host (`pcp_local_indptr`), in both the full-batch and the per-request-group paths. `pcp_round_robin_split` returns unit strides: `.contiguous()` leaves a one-row shard at row stride pcp_size, which aiter's cached-positions RoPE rejects. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * [PCP] DSpark: project context KV on each rank's own rows After a PCP prefill the aux hooks hold only this rank's round-robin rows. `compute_draft_kv` all-gathered the three aux hidden states (~42 KiB a row) and every rank then projected all rows into window KV, the same work on every rank. The projection (main_proj + norm, then per stage wqkv_a + norm + RoPE + fake-quant) works row by row, so project only the local rows at their own positions, gather the projected KV rows (1 KiB a row a stage, one grouped collective for all stages), and write them as before. `DSparkLayer.write_context_kv` is split into `context_kv_rows` and `write_context_kv_rows`. A draft opts in with `context_kv_by_rows`; only V4 DSpark does, and any other draft keeps gathering the aux states. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * [PCP] Grouped gather: fall back off aiter's 2/4/8 ranks; check row counts aiter's custom all-reduce, which `all_gatherv` tries first, runs at 6 ranks, but its all-gatherv kernel exists for 2, 4 and 8 only and throws otherwise. The attention-side gathers went through torch.distributed before the grouped gather, so PCP 6 worked; take one tensor at a time there again. Also assert that the grouped inputs share a row count (a mismatch threw on the custom path but passed on PyNCCL), and fix two review nits. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * fix(config): key the compile cache on the KV cache dtype The DSpark drafter branches on the KV cache dtype while tracing (`dspark_fp8_planned`), but `Config.compute_hash` left it out -- the known limitation #2566 deferred. A DSV4-Pro DSpark run with `--kv-cache-dtype bf16` after an fp8 one in the same container hashed to the same directory, loaded the fp8 drafter graph and died in warmup on every rank (`IndexError: list index out of range` on the split graph's outputs). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * [PCP] TBO: hold comm-stream gather outputs until the compute stream reads them Under TBO a PCP gather runs on the comm stream, so its output is allocated there, while the compute stream reads it. When the forward frees it, the caching allocator hands the memory straight back to the comm stream, and the comm stream waits only on its own ubatch's compute: the other ubatch's next collective can overwrite it before this ubatch's kernels have read it. On main this corrupts the gathered extend K. DSV4-Pro, pcp8 + `--enable-tbo`, gsm8k (200 q): main 0.69 / 0.675 on two nodes. With only the extend-K gathers on the main code path: 0.71 (K alone: 0.70, positions alone: 0.975); the same plus `record_stream` on the gathered tensors: 0.965. The grouped gathers of this branch have the same shape, and score 0.96 only by timing. `tbo_mark_used_on_compute` records the compute stream on such tensors after `tbo_switch_to_compute_sync`, for the attention-side gathers (extend K and positions, the compressor inputs) and FusedMoE's PCP routed-rows gather and reduce-scatter. The DP and mori TBO paths have the same shape and are left alone here. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * [PCP] TBO: run the PCP comm phases through tbo_on_comm The previous commit marked the comm-stream outputs by hand at four call sites, and nothing would notice one going missing: this branch scores 0.96 under TBO with or without the marks. `tbo_on_comm(fn, *args)` makes the comm phase one call -- yield, `fn` on the comm stream, switch back, hold every tensor it returns -- so a phase cannot skip the hold, and a test fails if V4 attention or `FusedMoE._run_experts` writes a phase out by hand. `tbo_mark_used_on_compute` now takes the compute stream from the TBO context instead of the current stream, so it no longer depends on being called after the switch back. `pcp_aux_rows` documents that it describes the base layer-hook capture; EAGLE3 strips aux off the target's output instead. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * [PCP] TBO: hold every comm-stream output; one wire format for grouped gathers Review follow-ups on #2789: - tbo_all_reduce and FusedMoE's DP gather / reduce-scatter run through tbo_on_comm, like the PCP comm phases, so their comm-stream outputs are held for the compute stream; the hold walks nested lists and tuples. Mori is unchanged: it returns views of its own per-ubatch buffers. - Under a graph the V4 compressors read their PCP-gathered inputs on side streams; hold them for those streams. - gather_rows moves to pcp_utils and carries one-byte dtypes as uint8 and the rest as is (aiter's all_gatherv copies bytes; only its PyNCCL fallback lacks fp8 / e8m0). MoE's DP, PCP and comm-fused gathers and the PCP grouped gather share it. - The allocator-reuse positive control skips under expandable_segments. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * test(tbo): stub aiter's communication_op in the TP all-reduce test tbo_all_reduce imports it ahead of the TBO branch, and the non-GPU CI's aiter has no aiter.dist.communication_op. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * [PCP] Grouped gather: drop the 6-rank special case, rely on aiter ROCm/aiter#7149 makes custom_all_gatherv decline group sizes it has no kernel for, so all_gatherv falls back to NCCL there. The grouped gather now takes the one-collective path at every PCP size, 6 included. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * test(h2d): give the PCP reindex test the host prefill indptr _apply_pcp_reindex now derives each rank's indptr from the host copy the builder publishes (paged_prefill_indptr_cpu); the test builds its metadata by hand, so it sets that copy beside kv_indptr_extend. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * test(h2d): bring the V4 indexer publication GPU test up to date The file failed 20 of 22 cases on main with RUN_H2D_GPU_TESTS=1, all from fixtures that fell behind the code: - set_pcp patched pcp_round_robin_query_indices (removed in #2688); the builder reads get_pcp_rank. - make_runner lacked forward_vars["batch_info"], config.max_num_seqs and the builder's csa_layers, max_model_len_idx, _local_heads and index_logits_workspace. - The padded decode case modelled the bucket width through UBatchWrapper._decode_ub_running_bs; since #2692 the split comes from _prepare_ubatch_decode's split_bs, so the test passes the bucket. - prepare_prefill was called with a total_tokens_num the fake batch lacks. 22/22 pass on this branch and on its merge base. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * DSV4 PCP: assert host and GPU paged-prefill indptrs agree in length Both PCP reindex paths (rank and PCP+TBO group) compute local offsets from the host copy and reindex the GPU copy; a length mismatch would silently reindex against a different query set. Clarify that after either reindex both copies describe the same rank- or group-local queries. Co-Authored-By: Claude Opus 5.5 <[email protected]> * DSV4 PCP: stage only this rank's paged-prefill rows on main's stage/finish split Port the per-rank paged-prefill build onto main's stage_prefill / finish_prefill structure (#3136): - Under PCP, stage_prefill stages this rank's own rows (pcp_split) and finish_prefill reindexes them; pad query segments get length 0 and the per-step indptr/indices fill and reindex helpers are gone. - Under PCP+TBO each group stages and finishes its own ub{i}_ inputs (_stage_pcp_group / _finish_pcp_group) with group-rebased cu_seqlens_q, block_tables and replay ranges. - _pcp_split_rows takes scheduled and running token counts separately. - Move shared comm helpers into atom/distributed/comm_utils.py. - Tests: rank segments with running > scheduled, PP relay _aux_blocks in the DSpark drafter stubs. gsm8k 5-shot 200q, V4-Pro -tp 1 -pcp 8: 0.965, +TBO prefill 0.970, DSpark k=5 0.975 (acceptance 63.76%). Co-Authored-By: Claude Opus 5.5 <[email protected]> * Drop the duplicate kv_cache_dtype compile-hash factor left by the main merge main's #3072 keys the compile cache on kv_cache_dtype as this branch's 222feeb did; the merge kept both, repeating the keyword in two test fixtures (SyntaxError at collection) and the hash factor in Config. Keep main's version. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(spec_decode): check target_pcp_split before PCP world size in pcp_aux_rows Non-PCP steps no longer query the PCP group, which is a MagicMock under the aiter stub and broke test_deepseek_v41_mono_hi_served_step in CI. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(v4 attn): make _apply_pcp_reindex take cu_q / block_tables explicitly The 1110 port defaulted cu_q_per_seq_gpu and block_tables_gpu to the whole batch's, so a PCP+TBO group caller that forgot them would build indices from the wrong rows without an error. Make both keyword-only and required; the whole-batch caller passes its own rows. Also note in pcp_aux_rows that target_pcp_split implies PCP is enabled. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(comm-fused-moe): ids travel as int32, drop the no-op view `gather_rows` passes int32 through unchanged since it moved to `comm_utils`; the float-carrier comment and its `.view` were stale. Co-Authored-By: Claude Opus 5.5 <[email protected]> * dspark(v4.1): drop the unreachable PCP branch from write_context_kv V4.1 refuses context parallel at startup, so the proposer never passes it `pcp_num_tokens`. Restore main's signature, drop its split test, and keep it out of the override scan. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
* [HIP] fix(custom_ar): decline gather / scatter at group sizes with no kernel The custom all-reduce runs at 2, 4, 6 and 8 ranks, but the all-gather, all-gatherv and reduce-scatter kernels exist for 2, 4 and 8 only. At 6 ranks custom_all_gatherv threw after copying into the pool, and the reduce-scatter and all-gather printed and returned, leaving their outputs uninitialized. - _has_gather_scatter_kernel() (always true on gfx1250, which has its own kernels) gates custom_all_gatherv, should_custom_rs, should_custom_ag and GroupCoordinator.all_gather(use_custom=True), so they fall back to NCCL. - The reduce-scatter and all-gather dispatches throw on a world size or split dim they have no kernel for instead of printing. - test_custom_allgatherv.py at 6 ranks checks every path declines and that all_gatherv, reduce_scatter_tensor and all_gather come out right. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * [HIP] fix(custom_ar): one-stage all-reduce reads past its ranks at 6 GPUs cross_device_reduce_1stage splits its 512 threads into ngpus groups of 512 / ngpus. At 6 ranks that leaves threads 510 and 511 with warp_id 6: they read through dp.ptrs[6], a slot a 6-rank group never fills, and store into tmp_smem past the six rank groups. DeepSeek-V4 at -pcp 6 faulted there in decode (rocm-debug-agent: cross_device_reduce_1stage< bf16, 6, false>, MEMORY_VIOLATION). - Threads with warp_id >= ngpus skip the loads and stores and only join the barriers; 2, 4 and 8 divide 512 and are unchanged. - test_custom_allreduce.py adds a (79, 512) tail shape at 6 ranks, under the 80 KiB one-stage cutoff; it fails with an illegal memory access without the fix. - Note on the two-stage dispatch why 6 ranks take the naive kernels. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * [HIP] fix(dist): all_gather without a device communicator; 6-rank CI runs Review follow-ups on ROCm#7149: - GroupCoordinator.all_gather read device_communicator.ca_comm on every call, so a group built without a device communicator (the world group) raised AttributeError even with use_custom=False. It reads it only when use_custom is set and a communicator exists. - GroupCoordinator.custom_all_gather / tensor_model_parallel_custom_all_gather take the custom kernel with no fallback: they now raise a clear error before launching at a group size without one, and say so. - CI runs test_custom_allreduce.py (-t 6 --regression) and test_custom_allgatherv.py (-t 6) at 6 ranks after their default sizes, where the runner has 6 GPUs. - tests/test_group_coordinator_all_gather.py covers the path choice on CPU. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Motivation
CustomAllreduceoffers four collectives, but not at the same group sizes:The Python gates that decide whether a collective takes the custom path read the all-reduce list (
_SUPPORTED_WORLD_SIZES = [2, 4, 6, 8]), or no list at all. At 6 ranks all three gather / scatter collectives are sent to a kernel that does not exist:custom_all_gathervthrow "allgatherv world_size error": the process diescustom_reduce_scatter(should_custom_rs→should_custom_ar)default: printf(...)and returns: no kernel launches, the output is uninitialized memorycustom_all_gather(should_custom_ag;GroupCoordinator.all_gather(use_custom=True)skips even that)The crash is at least visible; the other two degrade accuracy with nothing but a line on stdout.
The all-reduce, which does run at 6 ranks, has its own bug there.
cross_device_reduce_1stage(the small-message path, under 80 KiB at 6 ranks) splits its 512 threads into one group per rank,tnum_gpu = 512 / ngpus. At 6 ranks that is 85, so threads 510 and 511 getwarp_id == 6: they read throughdp.ptrs[6], which a 6-rank group never fills (zero after graph registration, uninitialized in eager), and store intotmp_smempast the six rank groups. The 2-stage path already sends 6 ranks to its_naivekernel; the 1-stage path did not.test_custom_allreduce.py -t 6hits it at once (illegal memory access), and so does any 6-rank model decode: rocm-debug-agent namedcross_device_reduce_1stage<bf16, 6, false>(MEMORY_VIOLATION).ATOM hits all of this at
-pcp 6: in prefill each MoE layer gathers the routed rows across ranks withall_gathervand reduce-scatters the result back, and in decode it all-reduces the MoE output across the same 6 ranks. Today the gather crashes; with only the gather fixed, the reduce-scatter would return garbage; with both fixed, decode still faults in the 1-stage all-reduce. So all of them are fixed together.Technical Details
_GATHER_SCATTER_WORLD_SIZES = (2, 4, 8)and_has_gather_scatter_kernel(). Every entry to the three collectives asks it and declines without a kernel, the same way they already decline past their size limits, so the caller falls back to NCCL:custom_all_gathervreturns None;should_custom_rsandshould_custom_agreturn False;GroupCoordinator.all_gather(use_custom=True), which calls the custom all-gather directly withoutshould_custom_ag, checks it before choosing the custom path.*_gfx1250gather / scatter kernels with their own group sizes; the gate is always true there.throwon a world size or split dim they have no kernel for (7 places) instead of printing and returning, so an entry a future change misses crashes instead of corrupting outputs.all_gatherwithout a device communicator.GroupCoordinator.all_gatherreadsdevice_communicator.ca_commonly whenuse_customis set and a communicator exists; the world group has none, andall_gatheron it worked on main.GroupCoordinator.custom_all_gather/tensor_model_parallel_custom_all_gathertake the custom kernel with no fallback (callers checkshould_custom_ag()first, as ATOM's indexer does). At a size without a kernel they now raise aRuntimeErrornamingall_gather(use_custom=True)before launching, instead of the dispatch'sallgather world_size error..github/scripts/aiter_test.shrunstest_custom_allreduce.py -t 6 --regressionandtest_custom_allgatherv.py -t 6after their default sizes when the runner has at least 6 GPUs.cross_device_reduce_1stagetheTHREAD_NUM % ngpusleftover threads (warp_id == ngpus) skip the loads and shared-memory stores and only join the barriers. 2, 4 and 8 divide 512, so nothing changes for them. Of the other kernels sized byTHREAD_NUM / ngpus, the 2-stage ones are not used at 6 ranks (_naiveinstead) and the gather / scatter ones are 2 / 4 / 8 only.Once this lands, ATOM can drop its 2 / 4 / 8 special case (ROCm/ATOM#2789 already does).
Test Plan
At a group size with no kernel the test checks that
custom_all_gathervreturns None andshould_custom_rs/should_custom_agare False, and that the NCCL fallbacks come out right:all_gatherv(uniform, ragged, one rank empty),reduce_scatter_tensor(small integers, so the sums are exact in bf16) andall_gather(use_custom=True). Whether a group size has a kernel comes from the communicator itself, so gfx1250 still runs the custom checks.Test Result
MI355X, 8 GPUs:
-t 6, this PRall_gatherv(uniform, ragged, one rank empty),reduce_scatter_tensorandall_gather(use_custom=True), rows 1 to 384-t 8, this PR-t 6,custom_all_gathervgate removedRuntimeError: allgatherv world_size error-t 6,should_custom_rsgate removedassert not should_custom_rs-t 6,should_custom_aggate removedassert not should_custom_ag-t 6,GroupCoordinator.all_gathergate removedRuntimeError: allgather world_size error(silent garbage before thethrow)test_custom_allreduce.py -t 6 -m graph, before the 1-stage fixHIP error: an illegal memory access was encounteredtest_custom_allreduce.py -t 6 --regression(new(79, 512)tail shape, one-stage)test_custom_allreduce.py -t 6, eager size sweeptest_custom_allreduce.py -t 8, graph sweep-tp 1 -pcp 6, custom all-reduce on, gsm8k 100 qUnrelated failure: the first tail check,
(1023, 512)bf16 (two-stage), can mismatch on the first call of a fresh process (480 elements in one-t 6run, 956 in one-t 8run). Both runs came right after a test that had crashed with a GPU memory fault on the same GPUs; reproducing that order failed 5 / 5, while 27 runs not preceded by a fault all passed. The one-stage kernel is not launched before the failure and at 8 ranks the new guard is always true, so it predates this PR and is not covered here.PR Self-Review
Reviewed revision
5dd0493
Behavior and intent
At 6 ranks (off gfx1250) the custom all-gather, all-gatherv and reduce-scatter fall back to NCCL and the one-stage all-reduce no longer reads or writes out of bounds. The all-gather, all-gatherv and reduce-scatter have no 6-rank kernels:
custom_all_gatherv,should_custom_rs,should_custom_agandGroupCoordinator.all_gather(use_custom=True)now decline, so they run through NCCL, where before the all-gatherv crashed and the other two returned uninitialized memory; their C++ dispatch throws on such a size instead of printing. The one-stage all-reduce does run at 6 ranks, but its two leftover threads per block read through a peer pointer slot the group never fills; they now skip the memory accesses.GroupCoordinator.all_gatherno longer reads a device communicator a group may not have (the world group), and the custom-only all-gather entries raise a clear error at 6 ranks.Validation and unverified scope
MI355X, 8 GPUs:
python op_tests/multigpu_tests/test_custom_allgatherv.py -t 6passed (0 bad bytes forall_gatherv,reduce_scatter_tensor,all_gather(use_custom=True)),-t 8passed with unchanged timings, and removing each of the four gates alone makes-t 6fail at that gate.test_custom_allreduce.py -t 6 --regressionwith the new one-stage shape(79, 512)passed, and failed with an illegal memory access with the one-stage fix reverted; the-t 6eager sweep and-t 8graph sweep passed. In ATOM, DeepSeek-V4-Pro at-tp 1 -pcp 6with the custom all-reduce on scored gsm8k 0.97 (100 q, aiter 3511006 plus these changes); before, decode graph capture faulted. At5dd049325, the two multi-GPU tests as the updatedaiter_test.shruns them passed: default size, then-t 6 --regression/-t 6.python -m pytest tests/test_group_coordinator_all_gather.pypassed, and fails with main'sAttributeErrorwhen theall_gatherline is reverted.Unverified: gfx1250 (the gates are always true there and the one-stage change only affects group sizes that do not divide 512) and MI300X / MI250X were not tested. The CI multi-GPU job has not run the new 6-rank commands yet. The prefetch guard in the one-stage kernel is defensive at 6 ranks (the dispatch keeps one iteration there). A first-call two-stage mismatch that appears only right after another process faulted on the same GPUs (see Test Result) predates this PR and is not covered.
PR-specific question
The CI change runs two more commands inside the existing multi-GPU job: after
python3 "$file"fortest_custom_allreduce.pyandtest_custom_allgatherv.py, the same file again with-t 6 --regression/-t 6whentorch.cuda.device_count()is at least 6. It runs with that job's existing permissions and environment, adds no secrets, tokens or new inputs, and reads no PR text or labels; the only PR-controlled code it executes is these two test files, which the job already ran from the PR checkout. So it does not widen what fork PR code can reach.Changed op tests
op_tests/multigpu_tests/test_custom_allgatherv.py: it is the only test ofcustom_all_gatherv, and it only ran at group sizes that have the kernel. It now also covers a group size without one (-t 6): every custom entry must decline and the NCCL fallbacks ofall_gatherv,reduce_scatter_tensorandall_gather(use_custom=True)must match the reference byte for byte. No existing test runs these collectives at 6 ranks; before this PR it fails there (the all-gatherv throws, the others return garbage).op_tests/multigpu_tests/test_custom_allreduce.py: at 6 ranks the tail regression adds(79, 512)bf16, the only shape in--regressionunder the 80 KiB one-stage cutoff, so-t 6 --regressionreachescross_device_reduce_1stage<T, 6>; its existing shapes all take the two-stage path. It fails with an illegal memory access without the one-stage fix. Other group sizes keep their shapes.Submission Checklist
🤖 Generated with Claude Code