[config] remove deprecated actor_rollout_ref.rollout.mode config field#5352
Open
dhruvnigam93 wants to merge 2 commits intoverl-project:mainfrom
Open
[config] remove deprecated actor_rollout_ref.rollout.mode config field#5352dhruvnigam93 wants to merge 2 commits intoverl-project:mainfrom
dhruvnigam93 wants to merge 2 commits intoverl-project:mainfrom
Conversation
The `mode` field in `RolloutConfig` only ever supported `"async"` (sync mode was already removed). This PR removes all internal branching on `mode`/`async_rollout_mode` and simplifies the codebase to always use the async code path. Changes: - `verl/workers/config/rollout.py`: change `mode: str = "async"` to `mode: Optional[str] = None`; emit `DeprecationWarning` in `__post_init__` when field is set, so old configs continue to work - `verl/workers/rollout/base.py`: simplify `_ROLLOUT_REGISTRY` keys from `(name, mode)` tuples to plain `name` strings; remove `mode` parameter from `get_rollout_class()` - `verl/workers/fsdp_workers.py`, `megatron_workers.py`, `engine_workers.py`, `checkpoint_engine/base.py`: update all `get_rollout_class(name, mode)` call sites to `get_rollout_class(name)` - `verl/trainer/ppo/ray_trainer.py`: remove `self.async_rollout_mode` assignment and dead conditional branches - `verl/experimental/fully_async_policy/`, `one_step_off_policy/`, `transfer_queue/`: remove `assert rollout.mode == "async"` guards and dead `async_rollout_mode` assignments - `verl/experimental/vla/rob_ray_trainer.py`, `sac/sac_ray_trainer.py`: remove `mode == "async_envloop"` check; always use `EnvLoop` - `verl/trainer/config/rollout/rollout.yaml`: remove `mode: async` default; generated reference YAMLs regenerated accordingly - `tests/experimental/agent_loop/agent_utils.py`: always use `AsyncActorRolloutRefWorker`; remove dead sync-mode branch - `tests/trainer/config/test_legacy_config_on_cpu.py`: add `"mode"` to `ignored_keys` to account for intentional field removal from schema Old configs with `mode: async` continue to load without errors and display a clear deprecation message guiding users to remove the field. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request effectively removes the deprecated rollout.mode configuration field, simplifying the codebase by eliminating dead conditional branches. The changes are well-executed, replacing conditional logic with a single async code path and updating the configuration schema to issue a DeprecationWarning for backward compatibility. The refactoring is consistent, clean, and improves maintainability. Both the code review and security review found no critical or high-severity issues or vulnerabilities in the submitted changes.
Collaborator
|
Could you resolve conflict? |
Author
|
resolved conflict, was a minor whitespace issue. |
Author
|
@vermouth1992 please have a look |
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?
The
modefield inRolloutConfig(i.e.actor_rollout_ref.rollout.mode) only ever supported"async"— sync mode was removed in v0.7. Every internal code path already hard-coded async behaviour, leaving ~50+ lines of dead conditional branches throughout the codebase.This PR removes all internal branching on
mode/async_rollout_mode, simplifying the codebase to always use the async code path, while keeping the field in the config schema asOptional[str] = Noneso that old configs withmode: asynccontinue to load without errors and display a clear deprecation message.Related issue: #4604
Checklist Before Starting
Test
All changes are pure refactoring (no algorithmic or behavioral change). Tested as follows:
Pre-commit hooks — all pass:
ruff(lint) ✅ruff format✅mypy✅autogen-trainer-cfg(generated YAMLs regenerated —modefield no longer appears) ✅check-docstring-coverage✅check-license✅compile-python✅CPU unit tests —
pytest -s --asyncio-mode=auto tests/— 295 passed, 16 failed, 27 skipped. The 16 failures are pre-existing (unrelatedhuggingface_hubvalidation error on absolute local paths). Zero new failures introduced.End-to-end PPO training — a full training job ran successfully through multiple steps with healthy metrics (actor loss, critic loss, grad norms, ~1482 tokens/sec throughput) and no
DeprecationWarningforrollout.mode, confirming the production config does not setmode.API and Usage Example
Old configs (still work, emit a deprecation warning):
New configs (no warning):
Deprecation warning text (emitted from
RolloutConfig.__post_init__):Rollout class lookup — simplified API (internal):
Design & Code Changes
High-level design
Keep the
modefield in the dataclass asOptional[str] = None(backward-compatible default) but never read it anywhere in the code. ADeprecationWarningis emitted in__post_init__when the field is explicitly set, guiding users to remove it from their configs. All internal code always uses the async path directly.Specific changes
verl/workers/config/rollout.pymode: str = "async"→mode: Optional[str] = None;__post_init__emitsDeprecationWarningwhen field is set; removed oldValueErrorfor sync modeverl/workers/rollout/base.py_ROLLOUT_REGISTRYkeys changed from(name, mode)tuples to plainnamestrings;get_rollout_class(name, mode)→get_rollout_class(name)verl/workers/fsdp_workers.pyget_rollout_class(name, mode)→get_rollout_class(name)verl/workers/megatron_workers.pyverl/workers/engine_workers.pyverl/checkpoint_engine/base.pyverl/trainer/ppo/ray_trainer.pyself.async_rollout_mode = Trueassignment and associated dead commentverl/experimental/fully_async_policy/fully_async_rollouter.pyassert rollout.mode == "async"andself.async_rollout_mode = Trueverl/experimental/fully_async_policy/fully_async_trainer.pyverl/experimental/one_step_off_policy/ray_trainer.pyverl/experimental/transfer_queue/ray_trainer.pyif rollout.mode == "async":conditional; always sets up async manager directlyverl/experimental/vla/rob_ray_trainer.pyEnvLoopdirectlyverl/experimental/vla/sac/sac_ray_trainer.pyverl/trainer/config/rollout/rollout.yamlmode: asyncdefault lineverl/trainer/config/_generated_ppo_trainer.yamlmodefield)verl/trainer/config/_generated_ppo_megatron_trainer.yamlverl/trainer/config/_generated_ppo_veomni_trainer.yamltests/experimental/agent_loop/agent_utils.pyAsyncActorRolloutRefWorker; removed conditional and unusedActorRolloutRefWorkerimporttests/trainer/config/test_legacy_config_on_cpu.py"mode"toignored_keys(intentional schema field removal)Checklist Before Submitting
pre-commit run --all-files— all hooks pass ✅pytest --asyncio-mode=auto tests/); no new failuresrecipesubmodule — not affected by this PROpen Questions for Maintainers
The following decisions are not blocking this PR, but I will make more changes based on the answers.
Q1: Deprecation timeline — when to remove
modeentirely?The
modefield is nowOptional[str] = Nonewith aDeprecationWarningso that this is not a breaking change. No behavior depends on it. Should we remove it now or in the next minor/major release?Q2: Should example scripts and tutorial configs remove
mode: asyncnow?I have not changed the examples and docs yet, but this is a straightforward change. Let me know if you want me to include it in this PR or defer to a follow-up.
Q3: Should the 10 GPU test files that set
mode = "async"be cleaned up?The following test files still set
config.actor_rollout_ref.rollout.mode = "async"and will emit aDeprecationWarningin CI logs:tests/workers/rollout/rollout_vllm/test_vllm_abort.pytests/workers/rollout/perf/vllm_async_rollout.pytests/workers/rollout/rollout_trtllm/test_adapter.pytests/workers/rollout/rollout_trtllm/test_async_server.pytests/experimental/agent_loop/test_basic_agent_loop.pytests/experimental/agent_loop/test_multi_modal.pytests/experimental/agent_loop/test_standalone_rollout.pytests/experimental/reward_loop/test_agent_reward_loop_colocate.pytests/experimental/reward_loop/test_agent_reward_loop_standalone.pytests/experimental/reward_loop/test_math_verify.pyAdditionally,
tests/experimental/reward_loop/test_agent_reward_loop_colocate.py:83has a dead code branch that still readsrollout.modeto select a worker class — this should be fixed regardless of the deprecation timeline. Happy to include it in this PR.Q4: Phase 7 documentation — now or deferred?
docs/advance/fully_async.mdand related docs still referenceactor_rollout_ref.rollout.modein example scripts. Should it be removed now or later?