Add opt-in CPU-staging transport for colocated weight sync (ROLL_WEIGHT_SYNC_USE_CPU) - #486
Open
Donec-x wants to merge 1 commit into
Open
Add opt-in CPU-staging transport for colocated weight sync (ROLL_WEIGHT_SYNC_USE_CPU)#486Donec-x wants to merge 1 commit into
Donec-x wants to merge 1 commit into
Conversation
…ght sync Add ROLL_WEIGHT_SYNC_USE_CPU=1 opt-in path that serializes weight-sync buckets through CPU numpy payloads, for environments where CUDA IPC is unavailable (seccomp-managed containers blocking pidfd_getfd, some accelerator runtimes). Default zero-copy CUDA IPC path is unchanged. Measured on Qwen2.5-3B full-param FSDP2+vLLM colocated: without this path training cannot run on such environments; with it, weight sync costs ~103s/step (n=26) which is ~17% of step wall time. See issue alibaba#485.
|
|
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.
Add opt-in CPU-staging transport for colocated weight sync (ROLL_WEIGHT_SYNC_USE_CPU)
Summary
This PR adds an opt-in CPU-staging transport for
serialize_named_weights, gated by the environment variableROLL_WEIGHT_SYNC_USE_CPU=1. The default zero-copy CUDA IPC path is completely unchanged: when the env var is unset (the default), control flow and serialization behavior are byte-for-byte identical to currentmain. When the opt-in is enabled, the flattened weight bucket is staged to host memory as a contiguous numpy array and serialized viaForkingPickler, producing a portable payload that does not depend on CUDA IPC at deserialization time.Motivation
In seccomp-managed containers (e.g. managed AutoDL instances), the container runtime blocks
pidfd_getfd, which the CUDA IPC handshake uses to transfer file descriptors between processes. As a result, deserializing a CUDA IPC payload fails (CUDA error: invalid argument/ driver errors) even for colocated trainer and inference workers — there is no way to receive the IPC handle across the process boundary. Issue #484 (Megatron + LoRA on accelerator environments hitting a CUDA driver error during weight sync) appears to be independent evidence of the same class of failure.Our case: FSDP2 + vLLM colocated training of Qwen2.5-3B (full-param, ~6.2 GB per model update) on managed AutoDL containers (3x RTX 4090). With the default transport, weight sync crashes at the first
model_updatedue to the blockedpidfd_getfd. WithROLL_WEIGHT_SYNC_USE_CPU=1, training becomes possible at all on such environments; the measured cost is a mean of 103.1 s per model_update (n=26), roughly 17% of step wall time — a trade-off we gladly pay where the zero-copy path simply cannot work.Implementation
roll/utils/send_recv_utils.py:serialize_named_weights, inserted after_bucket_named_tensorsand before the existingis_cuda/FSDP2-CPUOffload check:ifbecomeselif, so the CPU-staged numpy payload never enters the.to(current_platform.device_type)branch.monkey_patch_torch_reductions()is now called only when the bucket is still a CUDA tensor; the numpy payload is pickled through the standardForkingPicklerreduction and needs no monkey patch.named_tensors_from_bucketaccepts a numpy bucket and converts it viatorch.from_numpyfor backwards compatibility of the receiver side.Validation
ROLL_WEIGHT_SYNC_USE_CPU=1, including suspend/resume cycles.tests/utils/test_send_recv_cpu_staging.py(both the numpy staging path and the unchanged default CPU path).Fixes #485