Repository navigation
Conversation
`allreduce_fusion_kernel_launcher` caps its grid at one cluster-group per SM:
grid_size = (min(sm_count, cluster_num * cluster_size) / cluster_size) * cluster_size
For the two-shot kernel that cap is load-bearing. Its `Barrier` makes every
block wait on the peer rank's block with the same `blockIdx.x`, and the flag
array holds one entry per block up to `kBarrierFlagCount`, so a grid whose
blocks are not all co-resident can deadlock.
The one-shot kernel has no such coupling -- its Lamport handshake is per element
and all of its loops are grid-strided -- so the cap only costs it parallelism.
One 256-thread block per SM occupies 8 of the 64 warps an SM holds on sm_100,
which is too few to keep enough of the uncacheable peer loads it spins on in
flight.
Size the one-shot path to the kernel's real occupancy instead, queried with
`cudaOccupancyMaxActiveBlocksPerMultiprocessor` through a new
`get_max_blocks_per_sm` helper next to the existing `get_sm_count()`.
`threads_per_block` and `cluster_size` are computed by exactly the same code as
before, the round-down is preserved, and the grid is still bounded by
`cluster_num * cluster_size`. The two-shot path keeps the old budget.
At the shape below the grid goes (148,1,1) -> (592,1,1) at blockDim 256 --
148 SMs x 4 blocks, register-limited (REG 59, SHARED 1160 B on sm_100f) -- so
8 -> 32 warps/SM.
Measured serving Qwen3.6-35B-A3B-NVFP4 on 2xB200, attention TP2 + MoE EP2,
ISL 1024 / OSL 6144, one-model MTP, against the same warmed server:
AR-fusion kernel 30.74 -> 19.18 us/call (launch count and byte
volume unchanged)
exposed communication 2.147 -> 1.374 ms/iter
decode iteration 16.512 -> 15.501 ms (-6.12%, device idle flat)
Output throughput rises 2.30% on the mean of concurrency 64/128/256/512,
tracking the grid multiplier across the band -- weakest at c=64 (+0.88%,
multiplier 1.30x), strongest at c=512 (+3.38%, multiplier 4.0x). TTFT, TPOT,
ITL and E2EL all improved together at c=512; nothing was traded.
Below concurrency 32 the change is inert by construction: `token_num` there is
smaller than `sm_count`, so `cluster_num * cluster_size` still selects the same
grid.
Tests: `tests/unittest/_torch/multi_gpu/test_allreduce.py::test_allreduce_fusion_patterns`
42/42 pass on 2xB200.
Signed-off-by: Kaiyu Xie <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 12 included reviews per hour; 10 remain after this review. WalkthroughThe change adds a CUDA occupancy helper and uses its result to size one-shot all-reduce fusion grids. Two-shot execution retains one cluster per SM. The copyright year is updated to 2026. ChangesAll-reduce launch sizing
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to One-shot fused all-reduce launches now use available kernel occupancy to improve throughput, while synchronized two-shot launches retain their prior sizing behavior. No current merge-blocking risk remains. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
| auto kernel = params.trigger_completion_at_end | ||
| ? &allreduce_fusion_kernel_oneshot_lamport<Pattern, DType, NRanks, Fp32Acc, true> | ||
| : &allreduce_fusion_kernel_oneshot_lamport<Pattern, DType, NRanks, Fp32Acc, false>; | ||
| block_budget = sm_count * get_max_blocks_per_sm(kernel, block_size); |
There was a problem hiding this comment.
[P1] Preserve forward progress when increasing the one-shot grid. In the Lamport path, each CTA polls for peer data that may be published by a CTA that has yet to run, and CTA 0 waits for counter_ptr == gridDim.x. cudaOccupancyMaxActiveBlocksPerMultiprocessor estimates per-SM capacity. Multiplying it by SM count can overestimate residency for the actual cluster launch or when other work shares the GPU. If effective residency or block scheduling differs across ranks, polling CTAs can hold the slots needed by their peer producers. Can we keep the existing grid cap until the enlarged launch has a forward-progress argument, and cover cluster launches and concurrent GPU work with a multi-rank stress test?
Description
allreduce_fusion_kernel_launchercaps its grid at one cluster-group per SM:For the two-shot kernel that cap is load-bearing. Its
Barriermakes every block wait on the peer rank's block with the sameblockIdx.x, and the flag array holds one entry per block up tokBarrierFlagCount, so a grid whose blocks are not all co-resident can deadlock.The one-shot kernel has no such coupling — its Lamport handshake is per element and all of its loops are grid-strided — so the cap only costs it parallelism. One 256-thread block per SM occupies 8 of the 64 warps an SM holds on
sm_100, which is too few to keep enough of the uncacheable peer loads it spins on in flight.This PR sizes the one-shot path to the kernel's real occupancy, queried with
cudaOccupancyMaxActiveBlocksPerMultiprocessorthrough a newget_max_blocks_per_smhelper placed next to the existingget_sm_count().threads_per_blockandcluster_sizeare computed by exactly the same code as before, the round-down is preserved, and the grid is still bounded bycluster_num * cluster_size. The two-shot path keeps the old budget.At the shape measured below the grid goes
(148,1,1) -> (592,1,1)atblockDim 256— 148 SMs × 4 blocks, register-limited (REG 59,SHARED 1160 Bonsm_100f) — so 8 → 32 warps/SM.Measured effect
Serving
Qwen3.6-35B-A3B-NVFP4on 2×B200, attention TP2 + MoE EP2, ISL 1024 / OSL 6144, one-model MTP, against the same warmed server:Launch count and byte volume are unchanged; device idle is flat. Output throughput rises +2.30% on the mean of concurrency 64/128/256/512, tracking the grid multiplier across the band — weakest at c=64 (+0.88%, multiplier 1.30×), strongest at c=512 (+3.38%, multiplier 4.0×). TTFT, TPOT, ITL and E2EL all improved together at c=512; nothing was traded.
Below concurrency 32 the change is inert by construction:
token_numthere is smaller thansm_count, socluster_num * cluster_sizestill selects the same grid.Test Coverage
tests/unittest/_torch/multi_gpu/test_allreduce.py::test_allreduce_fusion_patterns— 42/42 passed on 2×B200 (all fusion patterns × hidden sizes × sequence lengths). This is a launch-geometry change with no new API surface, so it is covered by the existing pattern matrix rather than by new tests.PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
If PR introduces API changes, an appropriate PR label is added - either
api-compatibleorapi-breaking. Forapi-breaking, includeBREAKINGin the PR title.Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
Update tava architecture diagram if there is a significant design change in PR.
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.
GitHub Bot Help
To see a list of available CI bot commands, please comment
/bot help.🤖 Generated with Claude Code
Related PRs
Split out of a single branch; each one is cherry-picked onto
mainindependently and can be reviewed and merged on its own — there are no ordering dependencies between them.MambaHybridCacheManagerV2)All five were measured on the same deployment (
Qwen3.6-35B-A3B-NVFP4, 2×B200, attention TP2 + MoE EP2, ISL 1024 / OSL 6144, one-model MTP), so the per-PR numbers are not additive across the set.Dev Engineer Review
get_max_blocks_per_smusingcudaOccupancyMaxActiveBlocksPerMultiprocessor.QA Engineer Review
No test changes. The existing AllReduce fusion pattern test passed 42/42 cases on 2×B200.