verl icon indicating copy to clipboard operation
verl copied to clipboard

No actor/rollout weight sync when free_cache_engine is False

Open listar2000 opened this issue 1 year ago • 1 comments

System Info

When actor_rollout_ref.rollout.mode=async, the AgentLoopManager is in charge of generating the sequences during rollout.

The free_cache_engine flag from config is meant to "Offload the KVCache after rollout generation stage" according to the documentation. However, in the agent loop it's actually controlling whether we call the sleep/wake_up methods of the agent loop (and of the reward loop if it exists). https://github.com/volcengine/verl/blob/1c99f4727ed184937e87c5b363ae69c0e79b8049/verl/experimental/agent_loop/agent_loop.py#L759-L762

These sleep/wake_up methods are eventually used to switch between the trainer_mode/rollout_mode within ActorRolloutRefWorker, which are both:

  1. In charge of offloading/loading the KV cache, and
  2. Sync weights from the actor to the rollout engine via await self.rollout.update_weights.

So now if we turn free_cache_engine = False, we are not only disabling the offload of KV Cache, but also trigger the undesirable side effect that there will be no weight sync at all -- i.e. an extreme off-policy case as the rollout model is not updated at all.

In fact, within the trainer_mode/rollout_mode functions, there are explicit/redundant checks for free_cache_engine being true, e.g. https://github.com/volcengine/verl/blob/1c99f4727ed184937e87c5b363ae69c0e79b8049/verl/workers/fsdp_workers.py#L725-L726

https://github.com/volcengine/verl/blob/1c99f4727ed184937e87c5b363ae69c0e79b8049/verl/workers/fsdp_workers.py#L734-L739

these make the current design that checks for this flag at the AgentLoop level even more confusing.


Unfortunately I'm not too familiar with the internals of trainer_mode/rollout_mode, so I'm not too sure whether these functions have any existing parts that rely on free_cache_engine = True. Otherwise I guess simply removing these flags from the AgentLoop level should fix this.

Information

  • [x] The official example scripts
  • [ ] My own modified scripts

Tasks

  • [ ] An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • [ ] My own task or dataset (give details below)

Reproduction

This is an obvious bug within the code logic (that doesn't require experiments to show). Even though simply doing free_cache_engine = False and rollout.mode=async (with any major script) should reproduce this error.

Expected behavior

The free_cache_engine = False/True flag should only affect the engine/KV-cache offloading behavior (e.g. turning it off might increase memory usage), but should not affect the normal weight sync between rollout and trainer.

listar2000 avatar Nov 16 '25 06:11 listar2000

Bumping this as I believe this should be a relatively clear issue/bug.

listar2000 avatar Nov 23 '25 07:11 listar2000