[Bugfix] Replace assertions with defensive guards in KV transfer finished callbacks - #6
Open
Jackie2049 wants to merge 1 commit into
Open
[Bugfix] Replace assertions with defensive guards in KV transfer finished callbacks#6Jackie2049 wants to merge 1 commit into
Jackie2049 wants to merge 1 commit into
Conversation
Jackie2049
force-pushed
the
fix/kv-transfer-race-condition-v2
branch
from
June 4, 2026 05:24
1c78df3 to
91a3f26
Compare
…shed callbacks In disaggregated PD deployments, a race condition exists where a request may be aborted (removed from self.requests) while KV transfer is still in flight. The assertions in _update_from_kv_xfer_finished crash the entire serving process instead of gracefully handling the race. Replace assertions with if/continue guard checks and warning logs. If a request was already removed, its blocks were already freed during the abort path, so skipping is the correct behavior. Closes: #1 Co-authored-by: Boundless <ruihang_wu@163.com>
Jackie2049
force-pushed
the
fix/kv-transfer-race-condition-v2
branch
from
June 4, 2026 05:43
91a3f26 to
d81d4c7
Compare
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.
Summary
Closes #1
In disaggregated PD deployments, a race condition exists where a request may be aborted (removed from
self.requests) while KV transfer is still in flight. Theassertstatements in_update_from_kv_xfer_finished()crash the entire serving process instead of gracefully handling the race.Reference: This fix addresses a production crash scenario in PD-separated deployments, similar to issues discussed in the NIXL KV connector roadmap (vllm-project#33702).
Changes
Replace 3 assertions with defensive guard checks in
vllm/v1/core/sched/scheduler.py:finished_recving— request not found:assert req_id in self.requests→if req_id not in self.requests: logger.warning(...); continuefinished_recving— unexpected status:assert RequestStatus.is_finished(req.status)→if not RequestStatus.is_finished(...): logger.warning(...); continuefinished_sending— request not found:assert req_id in self.requests→if req_id not in self.requests: logger.warning(...); continueWhy this is safe
_free_request)continueensures no other cleanup logic is skipped for remaining requests in the loopTesting plan
tools/test_kv_transfer_guard.pyin rollout-infra repo (standalone, no vLLM dependency)