fix(inference): reset requests when discarding KV cache - #2147
Draft
bvolpato wants to merge 1 commit into
Draft
Conversation
Signed-off-by: bvolpato <brunocvcunha@gmail.com>
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.
Fully async weight sync can discard the KV cache of KEEP-paused requests without resetting those requests. With KV offloading and
clear_kv_cache_on_weight_sync=true, dispatch skips the CPU backup, but the FSDP and Megatron workers previously skipped request reset when prefix caching was disabled. Generation then resumed with computed-token/block state referring to discarded KV contents.Both workers now honor the explicit async clear setting independently of reusable prefix caching. They share the same reset policy and retain sender-owned reset handling. Synchronous training without prefix caching still skips reset.
Reproduction and validation
The affected configuration is accepted today:
clear=true, prefix=false. These have not run on this CPU-only host; the draft still needs GPU validation. The smoke test does not establish numerical parity.ANYSCALE_CLI_TOKEN; it did not execute tests. Upstream code-quality and gym checks passed; remaining CPU jobs were still running when submitted.Pinned vLLM's request reset preempts running requests independently of prefix caching. Related to the offload path introduced in #1934.
Downsides
With async clearing explicitly enabled and prefix caching disabled, active requests now recompute their KV after each sync. This adds prefill work proportional to their retained context, which is the intended cost of discarding KV. The default
clear_kv_cache_on_weight_sync=falsepath is unchanged.Risk and rollback
The change affects FSDP and Megatron request-reset decisions during weight sync. Check generation completion and sync latency in the added GPU case before marking ready. To roll back safely, disable
generator.inference_engine.offload_kv_for_weight_syncbefore reverting so in-flight KV is retained rather than discarded.