fix: avoid redundant device-to-device copy in NCCL weight-transfer receiver#3089
Open
dumko2001 wants to merge 1 commit into
Open
Conversation
…ceiver Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
dumko2001
marked this pull request as ready for review
July 20, 2026 11:41
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.
Summary
receive_state_dict(src/prime_rl/inference/vllm/worker/nccl.py) doesconcatenated[...].view(shape).clone()before yielding each tensor, and every consumer then copies that tensor straight into its destination parameter. So each weight is copied twice on-device on every sync.load_weights_kernelcallsparam.copy_(tensor), and vLLM'sload_weightsusesdefault_weight_loader(param.data.copy_(...)).concatenatedstays alive for the whole dtype group, so a plain view is valid until the consumer has copied from it and the clone is pure overhead.concatenated[offset : offset + numel].view(shape)without.clone().Verification
Microbenchmark of the split-and-consume pattern on an RTX 3090 (torch 2.8, CUDA 12.8), a 4 GB bf16 group in 2000 tensors:
About 2x on the copy, scaling with checkpoint size (~0.7 s/sync at 100 GB). Peak memory is unchanged — the allocator reuses the transient clone — so this is bandwidth, not memory.
Note
Low Risk
Single-path performance change with unchanged copy semantics; views remain valid for the lifetime of the dtype-group buffer.
Overview
receive_state_dictinnccl.pyno longer calls.clone()on each slice of the per-dtype concatenated broadcast buffer. It yieldsview(shape)slices only, with comments noting thatload_weights_kerneland vLLM’sload_weightsalreadycopy_into destination parameters before the next tensor is consumed, whileconcatenatedstays alive for the whole dtype group.The per-tensor
try/finallythat deleted each yielded tensor was removed as unnecessary with views.Reviewed by Cursor Bugbot for commit 28db8ac. Bugbot is set up for automated code reviews on this repo. Configure here.