Skip to content

[Bugfix][Core] Ignore stale KV xfer callbacks after request cleanup (#37837)#37859

Draft
rohithj7 wants to merge 1 commit intovllm-project:mainfrom
rohithj7:main
Draft

[Bugfix][Core] Ignore stale KV xfer callbacks after request cleanup (#37837)#37859
rohithj7 wants to merge 1 commit intovllm-project:mainfrom
rohithj7:main

Conversation

@rohithj7
Copy link

@rohithj7 rohithj7 commented Mar 23, 2026

Purpose

#37837: in PD setups you can abort a request on the decode side while a KV transfer is still finishing. Cleanup removes the request from self.requests, then _update_from_kv_xfer_finished() gets a late finished_recving / finished_sending for that id. The code asserted the id was still in self.requests, which isn't true in that case, so the decode node dies.

Fix is to treat that as a stale callback and skip it instead of asserting. Added a couple tests for the late-notification path.

Test Plan

Linux + Python 3.12 + requirements/test.txt is what matches CI (the lockfile is Linux/CUDA oriented).

Lint:

uv pip install -r requirements/lint.txt
pre-commit install
pre-commit run --all-files

Tests (focused):

python -m pytest tests/v1/core/test_scheduler.py -v \
  -k "abort_request_waiting_for_remote_kvs or abort_request_finished_recving or ignore_late_finished"

Whole file if you feel like it:

python -m pytest tests/v1/core/test_scheduler.py -v

Commit with -s for DCO (Signed-off-by).

Test Result

Will paste pytest output here after I run the above on Linux.

Before: n/a (or describe how you repro’d it)

After:

<will add this soon>

Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.
  • (Optional) Release notes update. If your change is user facing, please update the release notes draft in the Google Doc.

@github-actions
Copy link

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

Just a reminder: PRs would not trigger full CI run by default.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

If you have any questions, please reach out to us on Slack at https://slack.vllm.ai.

🚀

@mergify mergify bot added v1 bug Something isn't working labels Mar 23, 2026
Copy link
Contributor

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

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 addresses a race condition where a request can be aborted and cleaned up while a KV cache transfer callback is still in flight. The fix replaces an assertion that the request exists with a check, allowing stale callbacks to be safely ignored for both receiving and sending transfers. This prevents a crash that would otherwise occur. New tests have been added to cover these specific scenarios. The changes appear to correctly resolve the issue.

@markmc
Copy link
Member

markmc commented Mar 23, 2026

in PD setups

Please provide more information about your setup - in particular, which connector you are using

See also #32255 and #25067

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working v1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants