Skip to content

Add reset_running_requests to reset_prefix_cache call for async RL - #1824

Merged
SumanthRH merged 6 commits into
mainfrom
reset-prefix-cache
Jun 24, 2026
Merged

Add reset_running_requests to reset_prefix_cache call for async RL#1824
SumanthRH merged 6 commits into
mainfrom
reset-prefix-cache

Conversation

@SumanthRH

@SumanthRH SumanthRH commented Jun 23, 2026

Copy link
Copy Markdown
Member

What does this PR do?

Adds reset_running_requests to reset_prefix_cache for async RL.

This unifies the behaviour of reset_prefix_cache for sync and async RL

Currently, we call reset_prefix_cache without any arguments here. In vLLM, this is finally passed to the scheduler in  the engine core process of each GPU worker:

https://github.com/vllm-project/vllm/blob/635c38338afe132f9555ebf4a7c8ac7dfb05b2a0/vllm/v1/core/sched/scheduler.py#L2154-L2190

if there are running requests, nothing is done, as can be seen in the KV Cache Block pool implementation here. Thus, even if clear_kv_cache_on_weight_sync is set , stale KV cache is not cleared after a weight update with async RL right now, except at epoch boundaries.

This PR adds reset_running_requests to clear kv cache for running requests.

I did a quick test on the fully_async_gsm8k.sh script.

With clear cache (purple), TTFT shoots up when there are running requests as expected.

image image

Signed-off-by: SumanthRH <sumanthrh@anyscale.com>
@SumanthRH
SumanthRH marked this pull request as ready for review June 23, 2026 21:01
@SumanthRH
SumanthRH requested a review from erictang000 June 23, 2026 21:01

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces an optional "reset_running_requests" parameter (defaulting to False) to the "reset_prefix_cache" method across various inference engines, clients, and servers, allowing workers to optionally reset in-flight requests during weight synchronization. Feedback on these changes highlights potential AttributeError risks in "vllm_server.py" and "vllm_server_actor.py" if the parsed JSON payload is not a dictionary, and notes that the synchronous "reset_prefix_cache" implementation in "BaseVLLMInferenceEngine" is redundant and violates the asynchronous interface contract.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread skyrl/backends/skyrl_train/inference_engines/vllm/vllm_server.py
Comment thread skyrl/backends/skyrl_train/inference_servers/vllm_server_actor.py
Comment thread skyrl/backends/skyrl_train/inference_engines/vllm/vllm_engine.py
x
Signed-off-by: SumanthRH <sumanthrh99@gmail.com>
Comment on lines +506 to +510
clear_kv_cache_on_weight_sync: bool = False
"""Whether or not to clear the KV cache on weight sync. Defaults to False.
If False, we reuse KV cache from stale policies during generation
(avoids recomputation at the cost of using slightly stale KV cache).
"""

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False by default. We will run more ablations on throughput vs accuracy for clear_kv_cache_on_weight_sync=True soon.

"""Whether or not to clear the KV cache on weight sync. Defaults to True, matching synchronous RL.
Set to False for fully async training to reuse KV cache from stale policies during generation
(avoids recomputation at the cost of using slightly stale KV cache)."""
clear_kv_cache_on_weight_sync: bool = False

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok unfortunately, currently, this default cannot be false, since we currently don't have a conditional in the workers on whether or not we are doing fully async training or just sync

and self.cfg.fully_async.clear_kv_cache_on_weight_sync

so changing this default to false would make it so that kv cache isn't cleared for sync training as well. We should improve how this is gated but per charlie's comment on my pr: #1798 (comment) we didn't want to gate on max_staleness > 0 in case the async trainer is used with no staleness for testing.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Crazy. let me fix

@SumanthRH SumanthRH Jun 24, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed now! Thanks !

I am explictly avoiding the alternative of clear_cache=True for pause_generation because that is a deprecated param in vLLM - we will remove it soon

Signed-off-by: SumanthRH <sumanthrh99@gmail.com>
x
Signed-off-by: SumanthRH <sumanthrh99@gmail.com>
Signed-off-by: SumanthRH <sumanthrh99@gmail.com>
x
Signed-off-by: SumanthRH <sumanthrh99@gmail.com>
@SumanthRH
SumanthRH merged commit bd7608b into main Jun 24, 2026
5 checks passed
@SumanthRH
SumanthRH deleted the reset-prefix-cache branch July 30, 2026 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants