perf(fsdp): accelerate pinned sleep and wake - #182
Draft
Rockdu wants to merge 2 commits into
Draft
Conversation
Move complete padded FSDP shards directly between CUDA and pinned host storage so colocated rollout transitions avoid pageable copies while preserving sharding metadata. Co-authored-by: Cursor <cursoragent@cursor.com>
Rebuild sharded parameters through FSDP's native wrapper helper so sleep-time EMA updates and state dict access observe matching CPU tensor metadata. Co-authored-by: Cursor <cursoragent@cursor.com>
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.
What
to_sharded_dtensor()helper and atomically swap it into the existingParameteridentity.Why
The previous sleep path moved the model to pageable CPU memory. This made wakeup synchronous and slow. Pinning after
model.cpu()is also insufficient because it performs an extra full pageable-to-pinned copy and only exposes the logical DTensor shard, which can omit FSDP's physical padding.This change transfers
FSDPParam._sharded_param_datadirectly, preserves the logical DTensor view over the complete padded shard, and enables non-blocking host-to-device wakeup. It does not mutate DTensor's private_local_tensor; the wrapper and physical storage therefore keep consistent device metadata while preserving the original parameter object identity.Validation
Settings:
Results use the slowest rank:
Sleep releases CUDA allocations for the measured model and optimizer storage to 0 GiB.
Tests:
pytest -q tests/fast-gpu/backends/fsdp_utils/test_sleep_wakeup.pypytest -q tests/fast/backends/fsdp_utils/test_model_backend.py tests/fast/backends/fsdp_utils/test_scaler_bf16_passthrough.pyFiles
miles/backends/fsdp_utils/actor.py: pinned physical-shard and optimizer sleep/wake.miles/backends/fsdp_utils/ema.py: EMA device and pinned-memory migration.tests/fast-gpu/backends/fsdp_utils/_sleep_wakeup_worker.py: distributed lifecycle regression worker.tests/fast-gpu/backends/fsdp_utils/test_sleep_wakeup.py: GPU CI entry point.Checklist
pre-commit run --all-filespasses — not runpytest -xis green — targeted FSDP tests pass; full suite not runpython3 train.py --helpstill parses — N/A, no launch flags changed