[worker] feat: Avoid redundant base weight sync when engine doesn't sleep#5147
Merged
HollowMan6 merged 2 commits intoverl-project:mainfrom Feb 6, 2026
Merged
Conversation
HollowMan6
reviewed
Feb 2, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces unnecessary base-weight synchronization work for LoRA setups when the rollout engine is configured not to free/sleep weights (rollout.free_cache_engine=False), improving end-to-end training performance.
Changes:
- Gate LoRA base-weight sync in Megatron and engine worker paths on
rollout.free_cache_engine. - In FSDP worker rollout mode, only collect/send
base_model_paramsfor LoRAsleep_level==2whenrollout.free_cache_engine=True.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
verl/workers/megatron_workers.py |
Avoids redundant LoRA base sync when the rollout engine doesn’t free weights. |
verl/workers/fsdp_workers.py |
Skips base model param collection/update for LoRA sleep_level==2 unless the engine actually frees weights. |
verl/workers/engine_workers.py |
Aligns LoRA base sync behavior with free_cache_engine to avoid redundant work. |
Comments suppressed due to low confidence (1)
verl/workers/fsdp_workers.py:752
deviceis referenced inside theper_tensor_base_paramsgenerator but is only defined in theelsebranch above (whenpeft_config is Noneorself.base_sync_doneis false). Ifpeft_config is not Noneandself.base_sync_doneis true, this path will raise aNameErrorwhensleep_level==2 && free_cache_engine(e.g., on subsequent rollout_mode calls). Definedevice = get_device_id()unconditionally before these generators (or inline inside the generator) so it is always available when convertingbase_model_params.
if (
peft_config is not None
and getattr(self.rollout, "sleep_level", None) == 2
and self.config.rollout.free_cache_engine
):
per_tensor_base_params = (
(name, param.to(device, non_blocking=True).full_tensor() if isinstance(param, DTensor) else param)
for name, param in base_model_params.items()
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
HollowMan6
approved these changes
Feb 6, 2026
Collaborator
HollowMan6
left a comment
There was a problem hiding this comment.
Thanks for your contribution!
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 does this PR do?
Fixed unnecessary base weight syncing for LoRA sleep_level=2 when
rollout.free_cache_engine=FalseWhen
free_cache_engine=False, the rollout engine is not actually sleeping in a way that destroys base weights, so syncing base weights is redundant work.Changes
base_model_paramswhensleep_level==2androllout.free_cache_engine=True.Perf (Qwen3-1.7B, 20 steps, mean over steps 1-20, tested on 2 rtx3090)
Checklist