Repository navigation
[https://nvbugs/7015107][fix] Keep the Lamport all-reduce clear size in bytes - #21283
Conversation
…in bytes All one-shot Lamport kernels on a mapping share one workspace and clear the previous call's sub-buffer by a size that call left behind. Store it in bytes, not in elements of the writer's dtype, so a bf16 call followed by an fp32 call no longer over-clears into live data (hang) and the reverse no longer leaves stale data (wrong results). Signed-off-by: Pranav Shrestha <[email protected]>
|
@coderabbitai review |
✅ Action performed
|
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Byte-based Lamport clear sizes cpp/tensorrt_llm/kernels/communicationKernels/*, cpp/tensorrt_llm/kernels/moe/communication/moeAllReduceFusionKernels.cu, tensorrt_llm/_torch/distributed/allreduce_helper.py |
Lamport kernels now record communication-buffer sizes in bytes and round clear sizes up to float4 stores. Workspace comments specify that the clear size is measured in bytes. |
Multi-GPU shared-workspace validation tests/unittest/_torch/multi_gpu/test_allreduce.py, tests/unittest/_torch/multi_gpu/test_vocab_parallel_selection.py, tests/integration/test_lists/test-db/l0_dgx_b200.yml |
Tests cover mixed-dtype ONESHOT all-reduces, odd-token MiniMax RMS calls, and vocab-parallel exchanges around large bf16 all-reduces. The B200 test list adds the two-GPU all-reduce cases. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Suggested reviewers: juney-nvidia
Merge Risk: 
Minimal · up to 731ca
-
This change keeps the Lamport all-reduce clear size in bytes, which prevents hangs or wrong results when calls with different dtypes share one workspace. It adds multi-GPU regression tests for that case. No concrete merge-blocking risk was found in the supplied context; CI reports the multi-GPU tests as pending the full pre-merge label.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Title check
-
Explanation
The title names the main change: the Lamport all-reduce clear size is now stored in bytes. It also carries an NVBugs ID and the [fix] type, which match the repository template. The changeset matches this summary: the one-shot fusion kernel, MiniMax reduce-RMS kernels, and MoE reduction/finalize kernels all switch the clear size to bytes, with 16-byte rounding on the read side.
Full details: Description check
-
Explanation
The description covers the problem, the fix, and the test coverage. It explains the mixed-dtype workspace clear-size bug and why the fix is in the kernels rather than the vocab-parallel exchange. It lists the new tests, the target kernels, and the reported validation results. It follows the template's Description and Test Coverage sections. The PR Checklist is reduced to a single checked box and does not show the individual template items. The description says the changes were tested on 4x GB300, but those results are author-reported and not verified in this review.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 15.79% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 19 functions across 7 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
… bf16 all-reduces test_vocab_parallel_exchange_after_large_allreduce runs the VocabParallelHead pair exchange on one-shot right after and before a large bf16 one-shot all-reduce. Both mixed-dtype tests start one rank late per round and fail on a thread timeout instead of hanging; the Lamport test runs in the DGX B200 2-GPU pre-merge stage. Signed-off-by: Pranav Shrestha <[email protected]>
…e 16-byte stores The scalar MiniMax reduce-RMS kernel writes 4-byte variances, so at TP2 an odd token count left the tail of its sub-buffer uncleared. Readers now round the byte count up, and writers compute it in int64. test_minimax_allreduce_rms_odd_tokens covers it. Signed-off-by: Pranav Shrestha <[email protected]>
|
@coderabbitai review |
✅ Action performed
|
|
/bot run |
|
PR_Github #81584 [ run ] triggered by Bot. Commit: |
|
PR_Github #81584 [ run ] completed with state
|
…dencies at module level The workers already import tensorrt_llm at module level. The Triton sample kernel stays a local import: cloudpickle ships the check by value and cannot pickle it. Signed-off-by: Pranav Shrestha <[email protected]>
…e-bytes test_allreduce.py keeps both appended test groups: the Lamport mixed-dtype and odd-token tests and main's NCCL_SYMMETRIC unregistered-input test. Signed-off-by: Pranav Shrestha <[email protected]>
|
/bot run |
|
PR_Github #82075 [ run ] triggered by Bot. Commit: |
…r size in bytes Since NVIDIA#21283 the one-shot Lamport kernels keep the workspace's clear size in bytes. The fused mHC boundary all-reduce still wrote and read it in BF16 elements, so after a fused launch the next library all-reduce cleared only half of the fused launch's slots. When that buffer came around again, a rank could read a peer's stale slice before the fresh one arrived. A mismatch on one rank stopped that rank while the other waited for it in the next all-reduce, which is how test_mhc_allreduce_boundary_matches_allreduce_then_boundary hung on GB200. The fused kernel now records the bytes it pushed and clears the previous launch's bytes in whole 16-byte stores, as the library kernels do. Test (GB300): a fused launch followed by a library all-reduce leaves 2560 of the fused launch's 5120 slot words dirty without the fix, none with it. test_mhc_allreduce_boundary_matches_allreduce_then_boundary fails without the fix on every run (3/3) and passes with it (5/5). Signed-off-by: ziyixiong-nv <[email protected]>
…r size in bytes Since NVIDIA#21283 the one-shot Lamport kernels keep the workspace's clear size in bytes. The fused mHC boundary all-reduce still wrote and read it in BF16 elements, so after a fused launch the next library all-reduce cleared only half of the fused launch's slots. When that buffer came around again, a rank could read a peer's stale slice before the fresh one arrived. A mismatch on one rank stopped that rank while the other waited for it in the next all-reduce, which is how test_mhc_allreduce_boundary_matches_allreduce_then_boundary hung on GB200. The fused kernel now records the bytes it pushed and clears the previous launch's bytes in whole 16-byte stores, as the library kernels do. Test (GB300): a fused launch followed by a library all-reduce leaves 2560 of the fused launch's 5120 slot words dirty without the fix, none with it. test_mhc_allreduce_boundary_matches_allreduce_then_boundary fails without the fix on every run (3/3) and passes with it (5/5). Signed-off-by: ziyixiong-nv <[email protected]>
…r size in bytes Since NVIDIA#21283 the one-shot Lamport kernels keep the workspace's clear size in bytes. The fused mHC boundary all-reduce still wrote and read it in BF16 elements, so after a fused launch the next library all-reduce cleared only half of the fused launch's slots. When that buffer came around again, a rank could read a peer's stale slice before the fresh one arrived. A mismatch on one rank stopped that rank while the other waited for it in the next all-reduce, which is how test_mhc_allreduce_boundary_matches_allreduce_then_boundary hung on GB200. The fused kernel now records the bytes it pushed and clears the previous launch's bytes in whole 16-byte stores, as the library kernels do. Test (GB300): a fused launch followed by a library all-reduce leaves 2560 of the fused launch's 5120 slot words dirty without the fix, none with it. test_mhc_allreduce_boundary_matches_allreduce_then_boundary fails without the fix on every run (3/3) and passes with it (5/5). Signed-off-by: ziyixiong-nv <[email protected]>
…r size in bytes Since NVIDIA#21283 the one-shot Lamport kernels keep the workspace's clear size in bytes. The fused mHC boundary all-reduce still wrote and read it in BF16 elements, so after a fused launch the next library all-reduce cleared only half of the fused launch's slots. When that buffer came around again, a rank could read a peer's stale slice before the fresh one arrived. A mismatch on one rank stopped that rank while the other waited for it in the next all-reduce, which is how test_mhc_allreduce_boundary_matches_allreduce_then_boundary hung on GB200. The fused kernel now records the bytes it pushed and clears the previous launch's bytes in whole 16-byte stores, as the library kernels do. Test (GB300): a fused launch followed by a library all-reduce leaves 2560 of the fused launch's 5120 slot words dirty without the fix, none with it. test_mhc_allreduce_boundary_matches_allreduce_then_boundary fails without the fix on every run (3/3) and passes with it (5/5). Signed-off-by: ziyixiong-nv <[email protected]>
…r size in bytes Since NVIDIA#21283 the one-shot Lamport kernels keep the workspace's clear size in bytes. The fused mHC boundary all-reduce still wrote and read it in BF16 elements, so after a fused launch the next library all-reduce cleared only half of the fused launch's slots. When that buffer came around again, a rank could read a peer's stale slice before the fresh one arrived. A mismatch on one rank stopped that rank while the other waited for it in the next all-reduce, which is how test_mhc_allreduce_boundary_matches_allreduce_then_boundary hung on GB200. The fused kernel now records the bytes it pushed and clears the previous launch's bytes in whole 16-byte stores, as the library kernels do. Test (GB300): a fused launch followed by a library all-reduce leaves 2560 of the fused launch's 5120 slot words dirty without the fix, none with it. test_mhc_allreduce_boundary_matches_allreduce_then_boundary fails without the fix on every run (3/3) and passes with it (5/5). Signed-off-by: ziyixiong-nv <[email protected]>
…r size in bytes Since NVIDIA#21283 the one-shot Lamport kernels keep the workspace's clear size in bytes. The fused mHC boundary all-reduce still wrote and read it in BF16 elements, so after a fused launch the next library all-reduce cleared only half of the fused launch's slots. When that buffer came around again, a rank could read a peer's stale slice before the fresh one arrived. A mismatch on one rank stopped that rank while the other waited for it in the next all-reduce, which is how test_mhc_allreduce_boundary_matches_allreduce_then_boundary hung on GB200. The fused kernel now records the bytes it pushed and clears the previous launch's bytes in whole 16-byte stores, as the library kernels do. Test (GB300): a fused launch followed by a library all-reduce leaves 2560 of the fused launch's 5120 slot words dirty without the fix, none with it. test_mhc_allreduce_boundary_matches_allreduce_then_boundary fails without the fix on every run (3/3) and passes with it (5/5). Signed-off-by: ziyixiong-nv <[email protected]>
…r size in bytes Since NVIDIA#21283 the one-shot Lamport kernels keep the workspace's clear size in bytes. The fused mHC boundary all-reduce still wrote and read it in BF16 elements, so after a fused launch the next library all-reduce cleared only half of the fused launch's slots. When that buffer came around again, a rank could read a peer's stale slice before the fresh one arrived. A mismatch on one rank stopped that rank while the other waited for it in the next all-reduce, which is how test_mhc_allreduce_boundary_matches_allreduce_then_boundary hung on GB200. The fused kernel now records the bytes it pushed and clears the previous launch's bytes in whole 16-byte stores, as the library kernels do. Test (GB300): a fused launch followed by a library all-reduce leaves 2560 of the fused launch's 5120 slot words dirty without the fix, none with it. test_mhc_allreduce_boundary_matches_allreduce_then_boundary fails without the fix on every run (3/3) and passes with it (5/5). Signed-off-by: ziyixiong-nv <[email protected]>
…r size in bytes Since NVIDIA#21283 the one-shot Lamport kernels keep the workspace's clear size in bytes. The fused mHC boundary all-reduce still wrote and read it in BF16 elements, so after a fused launch the next library all-reduce cleared only half of the fused launch's slots. When that buffer came around again, a rank could read a peer's stale slice before the fresh one arrived. A mismatch on one rank stopped that rank while the other waited for it in the next all-reduce, which is how test_mhc_allreduce_boundary_matches_allreduce_then_boundary hung on GB200. The fused kernel now records the bytes it pushed and clears the previous launch's bytes in whole 16-byte stores, as the library kernels do. Test (GB300): a fused launch followed by a library all-reduce leaves 2560 of the fused launch's 5120 slot words dirty without the fix, none with it. test_mhc_allreduce_boundary_matches_allreduce_then_boundary fails without the fix on every run (3/3) and passes with it (5/5). Signed-off-by: ziyixiong-nv <[email protected]>
…r size in bytes Since NVIDIA#21283 the one-shot Lamport kernels keep the workspace's clear size in bytes. The fused mHC boundary all-reduce still wrote and read it in BF16 elements, so after a fused launch the next library all-reduce cleared only half of the fused launch's slots. When that buffer came around again, a rank could read a peer's stale slice before the fresh one arrived. A mismatch on one rank stopped that rank while the other waited for it in the next all-reduce, which is how test_mhc_allreduce_boundary_matches_allreduce_then_boundary hung on GB200. The fused kernel now records the bytes it pushed and clears the previous launch's bytes in whole 16-byte stores, as the library kernels do. Test (GB300): a fused launch followed by a library all-reduce leaves 2560 of the fused launch's 5120 slot words dirty without the fix, none with it. test_mhc_allreduce_boundary_matches_allreduce_then_boundary fails without the fix on every run (3/3) and passes with it (5/5). Signed-off-by: ziyixiong-nv <[email protected]>
…r size in bytes Since NVIDIA#21283 the one-shot Lamport kernels keep the workspace's clear size in bytes. The fused mHC boundary all-reduce still wrote and read it in BF16 elements, so after a fused launch the next library all-reduce cleared only half of the fused launch's slots. When that buffer came around again, a rank could read a peer's stale slice before the fresh one arrived. A mismatch on one rank stopped that rank while the other waited for it in the next all-reduce, which is how test_mhc_allreduce_boundary_matches_allreduce_then_boundary hung on GB200. The fused kernel now records the bytes it pushed and clears the previous launch's bytes in whole 16-byte stores, as the library kernels do. Test (GB300): a fused launch followed by a library all-reduce leaves 2560 of the fused launch's 5120 slot words dirty without the fix, none with it. test_mhc_allreduce_boundary_matches_allreduce_then_boundary fails without the fix on every run (3/3) and passes with it (5/5). Signed-off-by: ziyixiong-nv <[email protected]>
…r size in bytes Since NVIDIA#21283 the one-shot Lamport kernels keep the workspace's clear size in bytes. The fused mHC boundary all-reduce still wrote and read it in BF16 elements, so after a fused launch the next library all-reduce cleared only half of the fused launch's slots. When that buffer came around again, a rank could read a peer's stale slice before the fresh one arrived. A mismatch on one rank stopped that rank while the other waited for it in the next all-reduce, which is how test_mhc_allreduce_boundary_matches_allreduce_then_boundary hung on GB200. The fused kernel now records the bytes it pushed and clears the previous launch's bytes in whole 16-byte stores, as the library kernels do. Test (GB300): a fused launch followed by a library all-reduce leaves 2560 of the fused launch's 5120 slot words dirty without the fix, none with it. test_mhc_allreduce_boundary_matches_allreduce_then_boundary fails without the fix on every run (3/3) and passes with it (5/5). Signed-off-by: ziyixiong-nv <[email protected]>
…r size in bytes Since NVIDIA#21283 the one-shot Lamport kernels keep the workspace's clear size in bytes. The fused mHC boundary all-reduce still wrote and read it in BF16 elements, so after a fused launch the next library all-reduce cleared only half of the fused launch's slots. When that buffer came around again, a rank could read a peer's stale slice before the fresh one arrived. A mismatch on one rank stopped that rank while the other waited for it in the next all-reduce, which is how test_mhc_allreduce_boundary_matches_allreduce_then_boundary hung on GB200. The fused kernel now records the bytes it pushed and clears the previous launch's bytes in whole 16-byte stores, as the library kernels do. Test (GB300): a fused launch followed by a library all-reduce leaves 2560 of the fused launch's 5120 slot words dirty without the fix, none with it. test_mhc_allreduce_boundary_matches_allreduce_then_boundary fails without the fix on every run (3/3) and passes with it (5/5). Signed-off-by: ziyixiong-nv <[email protected]>
…r size in bytes Since NVIDIA#21283 the one-shot Lamport kernels keep the workspace's clear size in bytes. The fused mHC boundary all-reduce still wrote and read it in BF16 elements, so after a fused launch the next library all-reduce cleared only half of the fused launch's slots. When that buffer came around again, a rank could read a peer's stale slice before the fresh one arrived. A mismatch on one rank stopped that rank while the other waited for it in the next all-reduce, which is how test_mhc_allreduce_boundary_matches_allreduce_then_boundary hung on GB200. The fused kernel now records the bytes it pushed and clears the previous launch's bytes in whole 16-byte stores, as the library kernels do. Test (GB300): a fused launch followed by a library all-reduce leaves 2560 of the fused launch's 5120 slot words dirty without the fix, none with it. test_mhc_allreduce_boundary_matches_allreduce_then_boundary fails without the fix on every run (3/3) and passes with it (5/5). Signed-off-by: ziyixiong-nv <[email protected]>
…r size in bytes Since NVIDIA#21283 the one-shot Lamport kernels keep the workspace's clear size in bytes. The fused mHC boundary all-reduce still wrote and read it in BF16 elements, so after a fused launch the next library all-reduce cleared only half of the fused launch's slots. When that buffer came around again, a rank could read a peer's stale slice before the fresh one arrived. A mismatch on one rank stopped that rank while the other waited for it in the next all-reduce, which is how test_mhc_allreduce_boundary_matches_allreduce_then_boundary hung on GB200. The fused kernel now records the bytes it pushed and clears the previous launch's bytes in whole 16-byte stores, as the library kernels do. Test (GB300): a fused launch followed by a library all-reduce leaves 2560 of the fused launch's 5120 slot words dirty without the fix, none with it. test_mhc_allreduce_boundary_matches_allreduce_then_boundary fails without the fix on every run (3/3) and passes with it (5/5). Signed-off-by: ziyixiong-nv <[email protected]>
…r size in bytes Since NVIDIA#21283 the one-shot Lamport kernels keep the workspace's clear size in bytes. The fused mHC boundary all-reduce still wrote and read it in BF16 elements, so after a fused launch the next library all-reduce cleared only half of the fused launch's slots. When that buffer came around again, a rank could read a peer's stale slice before the fresh one arrived. A mismatch on one rank stopped that rank while the other waited for it in the next all-reduce, which is how test_mhc_allreduce_boundary_matches_allreduce_then_boundary hung on GB200. The fused kernel now records the bytes it pushed and clears the previous launch's bytes in whole 16-byte stores, as the library kernels do. Test (GB300): a fused launch followed by a library all-reduce leaves 2560 of the fused launch's 5120 slot words dirty without the fix, none with it. test_mhc_allreduce_boundary_matches_allreduce_then_boundary fails without the fix on every run (3/3) and passes with it (5/5). Signed-off-by: ziyixiong-nv <[email protected]>
…r size in bytes Since NVIDIA#21283 the one-shot Lamport kernels keep the workspace's clear size in bytes. The fused mHC boundary all-reduce still wrote and read it in BF16 elements, so after a fused launch the next library all-reduce cleared only half of the fused launch's slots. When that buffer came around again, a rank could read a peer's stale slice before the fresh one arrived. A mismatch on one rank stopped that rank while the other waited for it in the next all-reduce, which is how test_mhc_allreduce_boundary_matches_allreduce_then_boundary hung on GB200. The fused kernel now records the bytes it pushed and clears the previous launch's bytes in whole 16-byte stores, as the library kernels do. Test (GB300): a fused launch followed by a library all-reduce leaves 2560 of the fused launch's 5120 slot words dirty without the fix, none with it. test_mhc_allreduce_boundary_matches_allreduce_then_boundary fails without the fix on every run (3/3) and passes with it (5/5). Signed-off-by: ziyixiong-nv <[email protected]>
…r size in bytes Since NVIDIA#21283 the one-shot Lamport kernels keep the workspace's clear size in bytes. The fused mHC boundary all-reduce still wrote and read it in BF16 elements, so after a fused launch the next library all-reduce cleared only half of the fused launch's slots. When that buffer came around again, a rank could read a peer's stale slice before the fresh one arrived. A mismatch on one rank stopped that rank while the other waited for it in the next all-reduce, which is how test_mhc_allreduce_boundary_matches_allreduce_then_boundary hung on GB200. The fused kernel now records the bytes it pushed and clears the previous launch's bytes in whole 16-byte stores, as the library kernels do. Test (GB300): a fused launch followed by a library all-reduce leaves 2560 of the fused launch's 5120 slot words dirty without the fix, none with it. test_mhc_allreduce_boundary_matches_allreduce_then_boundary fails without the fix on every run (3/3) and passes with it (5/5). Signed-off-by: ziyixiong-nv <[email protected]>
…r size in bytes Since NVIDIA#21283 the one-shot Lamport kernels keep the workspace's clear size in bytes. The fused mHC boundary all-reduce still wrote and read it in BF16 elements, so after a fused launch the next library all-reduce cleared only half of the fused launch's slots. When that buffer came around again, a rank could read a peer's stale slice before the fresh one arrived. A mismatch on one rank stopped that rank while the other waited for it in the next all-reduce, which is how test_mhc_allreduce_boundary_matches_allreduce_then_boundary hung on GB200. The fused kernel now records the bytes it pushed and clears the previous launch's bytes in whole 16-byte stores, as the library kernels do. Test (GB300): a fused launch followed by a library all-reduce leaves 2560 of the fused launch's 5120 slot words dirty without the fix, none with it. test_mhc_allreduce_boundary_matches_allreduce_then_boundary fails without the fix on every run (3/3) and passes with it (5/5). Signed-off-by: ziyixiong-nv <[email protected]>
…r size in bytes Since NVIDIA#21283 the one-shot Lamport kernels keep the workspace's clear size in bytes. The fused mHC boundary all-reduce still wrote and read it in BF16 elements, so after a fused launch the next library all-reduce cleared only half of the fused launch's slots. When that buffer came around again, a rank could read a peer's stale slice before the fresh one arrived. A mismatch on one rank stopped that rank while the other waited for it in the next all-reduce, which is how test_mhc_allreduce_boundary_matches_allreduce_then_boundary hung on GB200. The fused kernel now records the bytes it pushed and clears the previous launch's bytes in whole 16-byte stores, as the library kernels do. Test (GB300): a fused launch followed by a library all-reduce leaves 2560 of the fused launch's 5120 slot words dirty without the fix, none with it. test_mhc_allreduce_boundary_matches_allreduce_then_boundary fails without the fix on every run (3/3) and passes with it (5/5). Signed-off-by: ziyixiong-nv <[email protected]>
…r size in bytes Since NVIDIA#21283 the one-shot Lamport kernels keep the workspace's clear size in bytes. The fused mHC boundary all-reduce still wrote and read it in BF16 elements, so after a fused launch the next library all-reduce cleared only half of the fused launch's slots. When that buffer came around again, a rank could read a peer's stale slice before the fresh one arrived. A mismatch on one rank stopped that rank while the other waited for it in the next all-reduce, which is how test_mhc_allreduce_boundary_matches_allreduce_then_boundary hung on GB200. The fused kernel now records the bytes it pushed and clears the previous launch's bytes in whole 16-byte stores, as the library kernels do. Test (GB300): a fused launch followed by a library all-reduce leaves 2560 of the fused launch's 5120 slot words dirty without the fix, none with it. test_mhc_allreduce_boundary_matches_allreduce_then_boundary fails without the fix on every run (3/3) and passes with it (5/5). Signed-off-by: ziyixiong-nv <[email protected]>
…r size in bytes Since NVIDIA#21283 the one-shot Lamport kernels keep the workspace's clear size in bytes. The fused mHC boundary all-reduce still wrote and read it in BF16 elements, so after a fused launch the next library all-reduce cleared only half of the fused launch's slots. When that buffer came around again, a rank could read a peer's stale slice before the fresh one arrived. A mismatch on one rank stopped that rank while the other waited for it in the next all-reduce, which is how test_mhc_allreduce_boundary_matches_allreduce_then_boundary hung on GB200. The fused kernel now records the bytes it pushed and clears the previous launch's bytes in whole 16-byte stores, as the library kernels do. Test (GB300): a fused launch followed by a library all-reduce leaves 2560 of the fused launch's 5120 slot words dirty without the fix, none with it. test_mhc_allreduce_boundary_matches_allreduce_then_boundary fails without the fix on every run (3/3) and passes with it (5/5). Signed-off-by: ziyixiong-nv <[email protected]>
…r size in bytes Since NVIDIA#21283 the one-shot Lamport kernels keep the workspace's clear size in bytes. The fused mHC boundary all-reduce still wrote and read it in BF16 elements, so after a fused launch the next library all-reduce cleared only half of the fused launch's slots. When that buffer came around again, a rank could read a peer's stale slice before the fresh one arrived. A mismatch on one rank stopped that rank while the other waited for it in the next all-reduce, which is how test_mhc_allreduce_boundary_matches_allreduce_then_boundary hung on GB200. The fused kernel now records the bytes it pushed and clears the previous launch's bytes in whole 16-byte stores, as the library kernels do. Test (GB300): a fused launch followed by a library all-reduce leaves 2560 of the fused launch's 5120 slot words dirty without the fix, none with it. test_mhc_allreduce_boundary_matches_allreduce_then_boundary fails without the fix on every run (3/3) and passes with it (5/5). Signed-off-by: ziyixiong-nv <[email protected]>
…r size in bytes Since NVIDIA#21283 the one-shot Lamport kernels keep the workspace's clear size in bytes. The fused mHC boundary all-reduce still wrote and read it in BF16 elements, so after a fused launch the next library all-reduce cleared only half of the fused launch's slots. When that buffer came around again, a rank could read a peer's stale slice before the fresh one arrived. A mismatch on one rank stopped that rank while the other waited for it in the next all-reduce, which is how test_mhc_allreduce_boundary_matches_allreduce_then_boundary hung on GB200. The fused kernel now records the bytes it pushed and clears the previous launch's bytes in whole 16-byte stores, as the library kernels do. Test (GB300): a fused launch followed by a library all-reduce leaves 2560 of the fused launch's 5120 slot words dirty without the fix, none with it. test_mhc_allreduce_boundary_matches_allreduce_then_boundary fails without the fix on every run (3/3) and passes with it (5/5). Signed-off-by: ziyixiong-nv <[email protected]>
…r size in bytes Since NVIDIA#21283 the one-shot Lamport kernels keep the workspace's clear size in bytes. The fused mHC boundary all-reduce still wrote and read it in BF16 elements, so after a fused launch the next library all-reduce cleared only half of the fused launch's slots. When that buffer came around again, a rank could read a peer's stale slice before the fresh one arrived. A mismatch on one rank stopped that rank while the other waited for it in the next all-reduce, which is how test_mhc_allreduce_boundary_matches_allreduce_then_boundary hung on GB200. The fused kernel now records the bytes it pushed and clears the previous launch's bytes in whole 16-byte stores, as the library kernels do. Test (GB300): a fused launch followed by a library all-reduce leaves 2560 of the fused launch's 5120 slot words dirty without the fix, none with it. test_mhc_allreduce_boundary_matches_allreduce_then_boundary fails without the fix on every run (3/3) and passes with it (5/5). Signed-off-by: ziyixiong-nv <[email protected]>
…r size in bytes Since NVIDIA#21283 the one-shot Lamport kernels keep the workspace's clear size in bytes. The fused mHC boundary all-reduce still wrote and read it in BF16 elements, so after a fused launch the next library all-reduce cleared only half of the fused launch's slots. When that buffer came around again, a rank could read a peer's stale slice before the fresh one arrived. A mismatch on one rank stopped that rank while the other waited for it in the next all-reduce, which is how test_mhc_allreduce_boundary_matches_allreduce_then_boundary hung on GB200. The fused kernel now records the bytes it pushed and clears the previous launch's bytes in whole 16-byte stores, as the library kernels do. Test (GB300): a fused launch followed by a library all-reduce leaves 2560 of the fused launch's 5120 slot words dirty without the fix, none with it. test_mhc_allreduce_boundary_matches_allreduce_then_boundary fails without the fix on every run (3/3) and passes with it (5/5). Signed-off-by: ziyixiong-nv <[email protected]>
…r size in bytes Since NVIDIA#21283 the one-shot Lamport kernels keep the workspace's clear size in bytes. The fused mHC boundary all-reduce still wrote and read it in BF16 elements, so after a fused launch the next library all-reduce cleared only half of the fused launch's slots. When that buffer came around again, a rank could read a peer's stale slice before the fresh one arrived. A mismatch on one rank stopped that rank while the other waited for it in the next all-reduce, which is how test_mhc_allreduce_boundary_matches_allreduce_then_boundary hung on GB200. The fused kernel now records the bytes it pushed and clears the previous launch's bytes in whole 16-byte stores, as the library kernels do. Test (GB300): a fused launch followed by a library all-reduce leaves 2560 of the fused launch's 5120 slot words dirty without the fix, none with it. test_mhc_allreduce_boundary_matches_allreduce_then_boundary fails without the fix on every run (3/3) and passes with it (5/5). Signed-off-by: ziyixiong-nv <[email protected]>
…r size in bytes Since NVIDIA#21283 the one-shot Lamport kernels keep the workspace's clear size in bytes. The fused mHC boundary all-reduce still wrote and read it in BF16 elements, so after a fused launch the next library all-reduce cleared only half of the fused launch's slots. When that buffer came around again, a rank could read a peer's stale slice before the fresh one arrived. A mismatch on one rank stopped that rank while the other waited for it in the next all-reduce, which is how test_mhc_allreduce_boundary_matches_allreduce_then_boundary hung on GB200. The fused kernel now records the bytes it pushed and clears the previous launch's bytes in whole 16-byte stores, as the library kernels do. Test (GB300): a fused launch followed by a library all-reduce leaves 2560 of the fused launch's 5120 slot words dirty without the fix, none with it. test_mhc_allreduce_boundary_matches_allreduce_then_boundary fails without the fix on every run (3/3) and passes with it (5/5). Signed-off-by: ziyixiong-nv <[email protected]>
…r size in bytes Since NVIDIA#21283 the one-shot Lamport kernels keep the workspace's clear size in bytes. The fused mHC boundary all-reduce still wrote and read it in BF16 elements, so after a fused launch the next library all-reduce cleared only half of the fused launch's slots. When that buffer came around again, a rank could read a peer's stale slice before the fresh one arrived. A mismatch on one rank stopped that rank while the other waited for it in the next all-reduce, which is how test_mhc_allreduce_boundary_matches_allreduce_then_boundary hung on GB200. The fused kernel now records the bytes it pushed and clears the previous launch's bytes in whole 16-byte stores, as the library kernels do. Test (GB300): a fused launch followed by a library all-reduce leaves 2560 of the fused launch's 5120 slot words dirty without the fix, none with it. test_mhc_allreduce_boundary_matches_allreduce_then_boundary fails without the fix on every run (3/3) and passes with it (5/5). Signed-off-by: ziyixiong-nv <[email protected]>
… fence the Helix sender before refilling shared memory (#9379) <!-- .github/pull_request_template.md --> ## 📌 Description Two fixes to the TRT-LLM-derived communication kernels, from upstream TensorRT-LLM commits FlashInfer's copies predate. - **Lamport clear size kept in elements of the writer's dtype** ([NVIDIA/TensorRT-LLM#21283](NVIDIA/TensorRT-LLM#21283)). `LamportComm` in `trtllm_allreduce_fusion.cuh` and `trtllm_moe_allreduce_fusion.cuh` recorded `params.size * NRanks` elements for the next kernel to clear, and that kernel divided by its own `VEC_SIZE`. Every Lamport kernel on a workspace shares the slot. The Python wrapper refuses a call whose dtype disagrees with the workspace's `use_fp32_lamport`, so the mismatch needs a lower-level call that bypasses that check on a workspace created with `use_fp32_lamport=True`: a bf16 kernel following an fp32 one then cleared half the bytes and read stale data, and the reverse over-cleared. Within one dtype the old count was right; the fix makes the slot's unit independent of the writer. The slot now counts 16-bit units and readers round up to whole 16-byte stores. Upstream switched the slot to bytes; FlashInfer cannot, because the cake kernels on the same workspace (`csrc/cake_trtllm_moe_allreduce_union/`, `csrc/cake_moe_finalize_allreduce_fusion/`, 36 generated files) write bf16 / fp16 element counts and read `clear_size / 8`. Two-byte units keep bf16 / fp16 bitwise as before, stay compatible with cake, and still fix fp32. The workspace layout is unchanged (`kernel_flag_ptr[4]`, initialized to 0); its docstring now names the unit (`5da38d8bc`). - **Lamport clear stores wrote the clearing kernel's own `-0`** (FlashInfer-side, found in review). A bf16 / fp16 kernel cleared with `0x8000` pairs, which an fp32 kernel two calls later reads as `0x80008000`, not fp32 `-0`, and takes as arrived data. The clear now writes the fp32 `-0` pattern (`0x80000000` per word) whatever the dtype: fp32 readers see `-0`, bf16 / fp16 readers (trtllm and cake both test each 16-bit half) see `0x8000` in the high half. Remaining gap, not touched here: the cake kernels still clear with bf16 `-0` pairs, so cake followed by an fp32 trtllm kernel on one workspace is still unsafe; no caller does that today. - **Helix all-to-all sender refill ordering** ([NVIDIA/TensorRT-LLM#20939](NVIDIA/TensorRT-LLM#20939), fence part). In `helixAllToAll.cu` the sender's `protoPack` stores and the register S2G loads go through the generic proxy, and the next iteration refills the same shared memory with `cp.async.bulk` (async proxy) without a fence between them. A `fence.proxy.async.shared::cta` before the `__syncwarp` orders them, matching the receiver side that #5172 already fenced. ## 🔍 Related Issues [NVIDIA/TensorRT-LLM#21283](NVIDIA/TensorRT-LLM#21283), [NVIDIA/TensorRT-LLM#20939](NVIDIA/TensorRT-LLM#20939). ## 🚀 Pull Request Checklist Thank you for contributing to FlashInfer! Before we review your pull request, please make sure the following items are complete. ### ✅ Pre-commit Checks - [x] I have installed `pre-commit` by running `pip install pre-commit` (or used your preferred method). - [x] I have installed the hooks with `pre-commit install`. - [x] I have run the hooks manually with `pre-commit run --all-files` and fixed any reported issues. > If you are unsure about how to set up `pre-commit`, see [the pre-commit documentation](https://pre-commit.com/). ## 🧪 Tests - [ ] Tests have been added or updated as needed. - [ ] All tests are passing (`unittest`, etc.). The existing multi-rank tests (`tests/comm/test_trtllm_allreduce_fusion*.py`, `test_trtllm_moe_allreduce_fusion*.py`, `test_dcp_alltoall.py`) cover the touched kernels; they need 2+ GPUs, which the development node does not have, so this PR relies on the GitLab multi-GPU lane. Local: the `trtllm_comm` and DCP all-to-all JIT modules build on the branch (CUDA 13.0 CI container). `trtllm_comm`, `dcp_alltoall` and `dcp_alltoall_generated` built on B200 in the CUDA 13.0 CI container. ## 🔬 Experimental Track <!-- Only for PRs submitted under the experimental policy (CONTRIBUTING.md → "Experimental APIs and Backends"). Leave this section untouched for normal PRs. --> - [ ] This PR is **experimental**: it adds or changes code under `flashinfer/experimental/` and/or an `@flashinfer_experimental_api`. Tracking issue: # - [ ] The tracking issue names an owner, the reason for the experimental path, and a graduation plan with a target release. - [ ] Core changes are limited to a thin entry point (signature, shared validation, feature-gate check, backend selection, handoff). - [ ] Tests live in `tests/experimental/` and were validated on the intended hardware; a runnable example is included. - [ ] Nothing is registered in `flashinfer/aot.py`, and no experimental backend is reachable from `backend="auto"` without `FLASHINFER_ALLOW_EXPERIMENTAL_AUTO_BACKENDS=1`. (Calling an `@flashinfer_experimental_api` or naming a backend explicitly is itself the opt-in and needs no environment variable.) - [ ] **Test scope declared below.** The experimental CI lane runs exactly these targets, so keep them as narrow as the change allows. <!-- Required for experimental PRs. Replace the commented lines below with your targets. Do not delete the fence or change its `experimental-tests` tag — the experimental-track watcher reads it verbatim to decide which targets to ask CI for. --> ```experimental-tests # One target per line: a directory or a file. (A pytest ::selector is not # supported -- the sharding runner cannot consume one.) Must be under # tests/experimental/ and must exist. Delete these comment lines and add yours, e.g. # # tests/experimental/test_my_backend.py # tests/experimental/my_backend/ # # Declaring the whole tree (tests/experimental/) is allowed but means every # experimental PR pays for every other feature's tests, in every matrix cell. ``` ## Reviewer Notes Upstream also moved the clear size to a 64-bit slot in a new workspace word; FlashInfer keeps the existing `int` slot because `clear_size <= lamport_comm_size`, which the Python side caps at `MAX_COMM_SIZE`. The bf16-after-fp32 case needs a workspace used with both dtypes, and the cake interplay a workspace alternating `backend="trtllm"` / `"cake"` with different inputs; no existing test does either, and same-input A/B runs pass even when stale data is read. A mixed-dtype / mixed-backend case would be the regression test if reviewers want one. The GitLab lane for the latest push includes `test_cake_moe_allreduce_union.py` and `test_cake_moe_finalize_allreduce.py`. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Improved synchronization for data transfers on supported GPUs, helping ensure copied data is available in the correct order. * Standardized temporary-buffer clearing across data types, with sizes rounded to the required alignment. * **Documentation** * Clarified how temporary-buffer clear sizes are measured. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Dev Engineer Review
The change stores the shared Lamport clear size in bytes. Readers round the byte count up to 16-byte stores. Writers calculate the size in 64-bit arithmetic. This aligns the one-shot all-reduce, MiniMax, and MoE kernels when calls with different dtypes share a workspace. The two-shot kernel and MNNVL workspace are outside this change because they use separate size conventions. No public API change is reported.
Review finding counts are unavailable. Reported CI results are mixed:
PR_Github #81584succeeded, while the/LLM/main/L0_MergeRequest_PR pipeline #67251was unstable. Multi-GPU CI requires theci: full pre-merge approvedlabel. The reported serve-pattern and performance checks are author-reported, not independently verified.QA Engineer Review
The change adds
test_allreduce_lamport_mixed_dtypeandtest_minimax_allreduce_rms_odd_tokensintest_allreduce.py, andtest_vocab_parallel_exchange_after_large_allreduceintest_vocab_parallel_selection.py. These tests cover shared-workspace reuse across dtype orders, odd-token MiniMax clearing, and vocab-parallel exchanges after large BF16 one-shot all-reduces. The B200 CI list adds the two all-reduce tests and retains the vocab-parallel module selector. Coverage verdict: sufficient for the reported byte-size, rounding, and reuse cases. CI results are mixed as noted above; the listed serve-pattern and performance results are reported by the author.Per-File QA Perspective
cpp/tensorrt_llm/kernels/communicationKernels/MiniMaxReduceRMSKernel.cu— Verify byte-based clear sizes in the scalar and float4 Q/K paths, including odd-token inputs.cpp/tensorrt_llm/kernels/communicationKernels/allReduceFusionKernels.cu— Verify that the one-shot Lamport kernel reads and writes the shared clear size in bytes across mixed-dtype calls.cpp/tensorrt_llm/kernels/communicationKernels/allReduceWorkspace.cu— The workspace comment defineslayout_buffer[0]as a byte count. Verify that Lamport workspace users follow this convention.cpp/tensorrt_llm/kernels/moe/communication/moeAllReduceFusionKernels.cu— Verify byte-based size updates and rounded clearing in both MoE reduction paths.tensorrt_llm/_torch/distributed/allreduce_helper.py— The workspace comment now specifies bytes. No executable behavior change is reported.tests/unittest/_torch/multi_gpu/test_allreduce.py— The new tests cover mixed-dtype workspace reuse and odd-token MiniMax clearing. Both are listed in the B200 CI test list.tests/unittest/_torch/multi_gpu/test_vocab_parallel_selection.py— The new test covers vocab-parallel exchange after large all-reduces in both dtype orders. The module is listed in the B200 CI test list.tests/integration/test_lists/test-db/l0_dgx_b200.yml— Adds the two all-reduce test selectors to B200 CI and updates the vocab-parallel selection comment. No manual-QA list change is reported.Description
The one-shot Lamport all-reduce kernels share one workspace per mapping (
get_allreduce_workspace), and each call clears the sub-buffer that the previous call wrote, using a size the previous call left in the workspace.allreduce_fusion_kernel_oneshot_lamportstored that size in elements of its own dtype (params.size * NRanks), and the next call divided it by its own elements per 16-byte access. Calls of one dtype agree with each other, but mixed dtypes on the same mapping do not. A bf16 call followed by an fp32 call clears twice the bytes the bf16 call wrote. For a large bf16 message that spills into the live data buffer, and the ranks wait forever on-0.0. An fp32 call followed by a bf16 call clears half of what was written, and stale fp32 data is later read as already arrived, so the result is silently wrong.Main now hits this: the vocab-parallel LM-head token exchange builds
AllReduce(mapping, strategy=AUTO, dtype=torch.float32)(tensorrt_llm/_torch/speculative/vocab_parallel.py), which shares the workspace with the model's bf16 all-reduces. On GB300 every TP4 MiniMax-M3.1 + DSpark serve with default configs hangs in the autotuner warmup, which profiles bf16 ONESHOT up to the workspace limit and then the fp32 exchange. With the target all-reduces on NCCL the drafter's bf16 all-reduces still alternate with the fp32 exchange, and acceptance length varies from run to run.This PR stores the clear size in bytes and converts it to 16-byte accesses on the read side, in every kernel that uses the slot: the all-reduce fusion one-shot kernel, the MiniMax reduce-RMS kernels, and the MoE reduction/finalize all-reduce kernels. Readers round the byte count up to whole 16-byte stores, because the scalar MiniMax reduce-RMS kernel writes 4-byte variances: at TP2 an odd token count leaves a size that is not a multiple of 16, whose tail was never cleared before and returned stale variances three calls later. Writers compute the size in int64. Arithmetic within one dtype is otherwise unchanged. The two-shot kernel uses the separate non-Lamport flag and does not touch the slot, and the MNNVL kernels have their own workspace, which already counts in bytes.
This is the root fix, and I'd prefer it over #21279, which moves the vocab-parallel exchange to NCCL as a stopgap. With the kernel fixed, the exchange can stay on AUTO, and #21279 can be closed, or reverted if it has already merged.
Test Coverage
The new tests are listed in the DGX B200 pre-merge stages. The two
test_allreduce.pytests run in the 2-GPU block, and the vocab-parallel test runs through the existingtest_vocab_parallel_selection.pyentry in the 4-GPU block. The H100 multi-GPU stage collects all three as well. In every test that mixes dtypes, one rank starts each call late in each round, so the other rank reads that rank's part of the buffer before it arrives and takes any stale value. Apytest-timeoutthread timeout turns a hang into a failure.tests/unittest/_torch/multi_gpu/test_allreduce.py::test_allreduce_lamport_mixed_dtype(2 GPUs, both orders). It alternates a bf16 and an fp32 ONESHOT all-reduce of about 0.9x the workspace with small calls of the other dtype on one mapping, over three rounds of the triple buffer, and checks exact sums of small integers. On GB300 without the fix,bf16_then_fp32hangs andfp32_then_bf16returns 2048 wrong elements on the large bf16 call.tests/unittest/_torch/multi_gpu/test_vocab_parallel_selection.py::test_vocab_parallel_exchange_after_large_allreduce(2 GPUs, both orders). It runs theVocabParallelHeadpair exchange on the one-shot kernel right after a bf16 all-reduce filling 0.9x the workspace, and in the other order a large exchange followed by bf16 calls that reuse its sub-buffer. Untuned AUTO sends the exchange to NCCL, so the test pins the one-shot kernel that the autotuner profiles at warm-up. Without the fix, the first order hangs and the second returns 62250 wrong elements.tests/unittest/_torch/multi_gpu/test_allreduce.py::test_minimax_allreduce_rms_odd_tokens(2 GPUs). It runs twelve one-token MiniMax reduce-RMS calls whose per-rank inputs change every step and checks the normalized output. Without the rounding, every output element of the call that reuses the first call's sub-buffer is wrong (3072/3072).test_allreduce.py(fusion patterns, MoE reduction/finalize, MiniMax RMS/QK),test_ar_residual_norm.py,test_mnnvl_allreduce.pyandtest_vocab_parallel_selection.pypass on 4x GB300.PR Checklist
GitHub Bot Help
To see a list of available CI bot commands, please comment
/bot help.