Repository navigation
refactor(fsdp): sleep/wake module, CPU-offloaded models stay put, frozen models reuse host copies - #267
Merged
Rockdu merged 3 commits intoOct 4, 2026
Conversation
This was referenced Sep 27, 2026
Merged
Rockdu
force-pushed
the
fsdp-followups/3-offload-perf
branch
from
September 27, 2026 11:07
3329630 to
b9e4531
Compare
Rockdu
force-pushed
the
fsdp-followups/3-offload-perf
branch
2 times, most recently
from
September 27, 2026 11:26
83d1cf3 to
6ecf518
Compare
Rockdu
force-pushed
the
fsdp-followups/3-offload-perf
branch
from
September 27, 2026 13:06
6ecf518 to
ebae691
Compare
Rockdu
added this pull request to stack #270
September 27, 2026 17:59
Rockdu
force-pushed
the
fsdp-followups/3-offload-perf
branch
3 times, most recently
from
September 27, 2026 18:29
0b206a9 to
a05d4e6
Compare
Rockdu
force-pushed
the
fsdp-followups/3-offload-perf
branch
from
September 27, 2026 19:09
a05d4e6 to
9db1f3d
Compare
…l in sleep_wake.py
…g them back on every sleep
Rockdu
force-pushed
the
fsdp-followups/3-offload-perf
branch
from
September 27, 2026 19:39
9db1f3d to
7f6bf43
Compare
1 of 6 tasks
This was referenced Sep 28, 2026
OnePunchMonk
pushed a commit
to OnePunchMonk/miles_diffusion
that referenced
this pull request
Oct 5, 2026
…zen models reuse host copies (radixark#267) * refactor(fsdp): leave natively CPU-offloaded models out of sleep and wake * refactor(fsdp): replace offload_model and onload_model with move_model in sleep_wake.py * perf(fsdp): reuse frozen models' pinned host copies instead of copying them back on every sleep
OnePunchMonk
pushed a commit
to OnePunchMonk/miles_diffusion
that referenced
this pull request
Oct 5, 2026
OnePunchMonk
pushed a commit
to OnePunchMonk/miles_diffusion
that referenced
this pull request
Oct 5, 2026
…zen models reuse host copies (radixark#267) * refactor(fsdp): leave natively CPU-offloaded models out of sleep and wake * refactor(fsdp): replace offload_model and onload_model with move_model in sleep_wake.py * perf(fsdp): reuse frozen models' pinned host copies instead of copying them back on every sleep
4 of 6 tasks
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.
Stack 3/9 of follow-ups to #263:
main← #265 ← #266 ← this ← #268 ← #269 ← #271 ← #272 ← #273 ← #274.What
refactor(fsdp): leave natively CPU-offloaded models out of sleep and wake: as in miles, a model under FSDP'sCPUOffloadPolicynever sleeps; its parameter shards stay on the host and its buffers on the GPU. This drops thekeep_parameters_on_cpuspecial case.refactor(fsdp): replace offload_model and onload_model with move_model in sleep_wake.py: onemove_model(model, device)next tomove_optimizer, in a module named after the trainer's sleep/wake phases (offload/onload stays the rollout's vocabulary). Rename only.perf(fsdp): reuse frozen models' pinned host copies ...: frozen reference and teacher models getwake_up_frozen_model/sleep_frozen_model. Waking keeps each parameter's pinned host copy, and sleeping points the parameters back at it instead of copying unchanged weights device-to-host again. Buffers are still copied, since a forward may update them.Why
Reference and teacher weights never change after load, so the per-sleep device-to-host copy is pure overhead. Pinned host memory should not grow, because the caching host allocator already kept those blocks between phases (not measured).
Validation
OCR GRPO benchmark (SD3.5-M LoRA, KL 0.04 via
lora_base, 2×H200, 6 rollouts, steady-state means excluding the first step),mainvs #263:The per-microbatch
lora_basereshard costs ~0.14 s per step and sglang release is unchanged, so neither is changed here. That recipe has no independent reference or teacher; this PR's path is covered by the GPU offload worker, which checks that a frozen model's second sleep keeps the same host storage.Files
miles/backends/fsdp_utils/sleep_wake.py(wasoffload.py):move_model,move_optimizer;wake_up_frozen_model/sleep_frozen_modelin their own section.miles/backends/fsdp_utils/actor.py,model_loader.py: which models sleep; frozen models sleep and wake through the frozen functions, each with its ownfrozen_parameter_host_copies.tests/fast-gpu/backends/fsdp_utils/{test_sleep_wake,_sleep_wake_worker}.py(weretest_offload/_offload_worker): natively CPU-offloaded models only move their optimizer and EMA; a frozen model's sleep keeps each evenly sharded parameter's host storage.docs/fsdp_model_roles.md: sleep/wake wording and test paths.Checklist
pre-commit run --all-filespasses — not run locallypytest -xis green — GPU worker runs in CI onlypython3 train.py --helpstill parses — n/a