Repository navigation
Conversation
… without P2P For two-rank tensor-parallel groups whose GPUs NCCL cannot connect peer to peer (P2P disabled or unavailable), one kernel exchanges the FP16 payload through a pinned host buffer both ranks map: each block writes its chunk, fences, raises a flag, waits for the peer's flag and adds the peer's chunk. One FP16 rounding and commutative, so the result has NCCL's bits. No CPU work, capturable in CUDA graphs. It sits after the SM70 ring in the all-reduce chain and takes FP16 payloads up to kernel_config.host_reduce.max_bytes (256 KiB); larger ones stay on NCCL. kernel_config.host_reduce.enabled turns it off. The exchange kernel is adapted from kernels/skinny_ar.cu of mzen17/v100-skinny-unify (MIT, notice kept in the source), turned into handle-based channels so a process can own more than one two-rank group. Co-authored-by: Mike Zeng <92705460+mzen17@users.noreply.github.com> Signed-off-by: Peuqui <43776522+Peuqui@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014ZLMmGB8mjc43VpwPxLQNn (cherry picked from commit f53a668)
This was referenced Oct 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Two-rank tensor-parallel groups whose GPUs cannot reach each other peer to peer (PCIe hosts with P2P disabled or unavailable, KVM guests, mixed boards) fall back to NCCL for every all-reduce, and the custom all-reduce needs P2P/IPC. For the small FP16 all-reduces of single-stream decode, NCCL's latency dominates.
This PR adds a two-rank FP16 all-reduce through pinned host memory that both ranks map. One kernel does the exchange: each block writes its chunk to a host slot, fences, raises a per-block flag, waits for the peer's flag and adds the peer's chunk. The sum is one FP16 rounding and commutative, so both ranks produce the same bits as NCCL's two-rank FP16 sum. There is no CPU work and no stream synchronization, so it is captured in CUDA graphs; slots are double buffered by call parity.
It is placed after the SM70 ring in
CudaCommunicator.all_reduceand takes FP16 payloads of two-rank groups without peer access up tokernel_config.host_reduce.max_bytes(256 KiB); larger payloads and every other case stay on the existing path.kernel_config.host_reduce.enabled=falseturns it off (field outside the compile hash).The exchange kernel is adapted from
kernels/skinny_ar.cuof mzen17/v100-skinny-unify (MIT; the notice is kept incsrc/host_reduce.cu), turned into handle-based channels so one process can own more than one two-rank group. Credit: @mzen17 (Co-authored-by on the commit).Not a duplicate: gh pr list --state all --search "host memory all-reduce", "pinned host", "all-reduce P2P", "skinny_ar", "two-rank" finds no PR for a host-memory collective; #1208 concerns IPC registration of the P2P custom all-reduce and #963 the TP4 push all-reduce.
AI assistance was used for this change. I reviewed every line and ran the tests and measurements below.
Test Plan
test_host_reduce_matches_ncclspawns two ranks withNCCL_P2P_DISABLE=1and compares the host all-reduce bit for bit with NCCL.Serving: Qwen3.8-27B NVFP4 with MTP (k=3), TP2 on two Quadro RTX 8000 that only share a PCIe host bridge (
nvidia-smi topo: PHB),NCCL_P2P_DISABLE=1,--disable-custom-all-reduce, CUDA graphs. Same build and compile artifact, the field off (--kernel-config '{"host_reduce":{"enabled":false}}') and on, alternating boots (off, off, on, off, on). Per boot: four 29k-token prompts, then greedy short prose, code and a 1.9k-token edit task, plus three greedy reference prompts.Path coverage
Acceleration and benchmark contract (required for performance changes)
kernel_config.host_reduce.enabled=falsedisables it.Test Result
NCCL_P2P_DISABLE=1).🤖 Generated with Claude Code
https://claude.ai/code/session_01Ly7LM3m9fa6DRJPYQjnt95