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] Avoid premature async generator exit and raise all exception variations #7698

Merged
merged 2 commits into from
Aug 21, 2024

Conversation

njhill
Copy link
Member

@njhill njhill commented Aug 20, 2024

The async generator returned by AsyncLLMEngine generate() uses a queue of either request outputs and/or exceptions.

But the logic consuming requests from the queue only raises instances of Exceptions, not Exception classes (which are also raisable in python). This means that the CancelledError class instance we add to the queue elsewhere currently isn't being raised from the generator as it should be.

Furthermore, the generator will incorrectly exit prematurely if the sequence is completed in the engine prior to all response outputs being consumed.

I think these problems were introduced in my earlier rework of the async cancellation in #7111.

Added new tests to cover these cases.

Copy link

👋 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 consists a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of default ones by unblocking the steps in your fast-check build on Buildkite UI.

Once the PR is approved and ready to go, please make sure to run full CI as it is required to merge (or just use auto-merge).

To run full CI, you can do one of these:

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

🚀

if isinstance(result, Exception):
if isinstance(result, BaseException) or \
(isinstance(result, type) and \
issubclass(result, BaseException)):
Copy link
Collaborator

Choose a reason for hiding this comment

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

TIL! 👍

njhill added 2 commits August 20, 2024 22:30
The async generator returned by AsyncLLMEngine generate() uses a queue of either request outputs and/or exceptions.

But the logic consuming requests from the queue only raises instances of Exceptions, not Exception classes (which are also raisable in python). This means that the CancelledError class instance we add to the queue elsewhere currently isn't being raised from the generator as it should be.
@njhill njhill force-pushed the fix-raise-cancelled branch from c397d04 to db8aebc Compare August 21, 2024 02:31
@njhill njhill changed the title [BugFix] Raise all exception variations in async generator [BugFix] Avoid premature async generator exit and raise all exception variations Aug 21, 2024
@njhill njhill added the ready ONLY add when PR is ready to merge/full CI is needed label Aug 21, 2024
@njhill njhill marked this pull request as ready for review August 21, 2024 02:40
@njhill njhill added ready ONLY add when PR is ready to merge/full CI is needed and removed ready ONLY add when PR is ready to merge/full CI is needed labels Aug 21, 2024
@njhill njhill mentioned this pull request Aug 21, 2024
Copy link
Collaborator

@robertgshaw2-redhat robertgshaw2-redhat left a comment

Choose a reason for hiding this comment

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

looks good. left a couple comments for clarification, but approving to unblock

@robertgshaw2-redhat robertgshaw2-redhat merged commit c75363f into vllm-project:main Aug 21, 2024
46 checks passed
patrickvonplaten pushed a commit to patrickvonplaten/vllm that referenced this pull request Aug 21, 2024
@njhill njhill deleted the fix-raise-cancelled branch August 21, 2024 17:31
omrishiv pushed a commit to omrishiv/vllm that referenced this pull request Aug 26, 2024
Alvant pushed a commit to compressa-ai/vllm that referenced this pull request Oct 26, 2024
KuntaiDu pushed a commit to KuntaiDu/vllm that referenced this pull request Nov 20, 2024
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants