Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bugfix] Fix disagg hang caused by the prefill and decode communication issues #12723

Merged
merged 2 commits into from
Feb 8, 2025

Conversation

houseroad
Copy link
Contributor

@houseroad houseroad commented Feb 4, 2025

Now prefill acts as a server to wait for decode kv request. But when the kv is not ready, prefill return None and decode can proceed. This caused prefill kv buffer accumulate and block other prefill from moving forward. Fix by poll wait + relinquish to ensure kv ready and send the correct kv to decode.

The PR was created by @jiayisuse. He is in China for holiday, so submit the PR on his behalf to get review first.

Copy link

github-actions bot commented Feb 4, 2025

👋 Hi! Thank you for contributing to the vLLM project.
Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

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 do one of these:

  • Add ready label to the PR
  • Enable auto-merge.

🚀

@houseroad
Copy link
Contributor Author

@KuntaiDu, friendly ping for the review :-)

@KuntaiDu
Copy link
Collaborator

KuntaiDu commented Feb 6, 2025

But when the kv is not ready, prefill return None and decode can proceed

Oh right, when the buffer is almost full, the prefill instance can finish inference of this request, but the KV cache of this request won't be added to the buffer, so the prefill instance will return None when decode instance request this KV.

Copy link
Collaborator

@KuntaiDu KuntaiDu left a comment

Choose a reason for hiding this comment

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

Let me also test this PR locally.

Comment on lines 169 to 170
while not is_buffer_available(tokens_roi_recver):
self.buffer_cv.wait()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would be nice if we can log here to make sure people know that the engine is waiting for the KV cache that is already generated but not entered into the lookup buffer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added some logging.

# repeatedly.
logger.debug("KV transfer buffer is full. Handling...")
while self.buffer_size > self.buffer_size_threshold:
self.full_handler()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe also remove the code for full_handler if we don't use it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

@KuntaiDu
Copy link
Collaborator

KuntaiDu commented Feb 6, 2025

Just tested, it works (and the performance gets much better). Thank you for contributing!

Copy link
Collaborator

@KuntaiDu KuntaiDu left a comment

Choose a reason for hiding this comment

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

LGTM!

@KuntaiDu KuntaiDu enabled auto-merge (squash) February 7, 2025 16:43
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label Feb 7, 2025
@simon-mo simon-mo disabled auto-merge February 8, 2025 00:39
@simon-mo simon-mo merged commit 45cbc49 into vllm-project:main Feb 8, 2025
61 of 64 checks passed
AoyuQC pushed a commit to AoyuQC/vllm that referenced this pull request Feb 8, 2025
ShangmingCai pushed a commit to ShangmingCai/vllm that referenced this pull request Feb 10, 2025
SzymonOzog pushed a commit to SzymonOzog/vllm that referenced this pull request Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready ONLY add when PR is ready to merge/full CI is needed v1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants