-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
[BugFix] Avoid premature async generator exit and raise all exception variations #7698
Conversation
👋 Hi! Thank you for contributing to the vLLM project. 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:
🚀 |
vllm/engine/async_llm_engine.py
Outdated
if isinstance(result, Exception): | ||
if isinstance(result, BaseException) or \ | ||
(isinstance(result, type) and \ | ||
issubclass(result, BaseException)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL! 👍
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.
c397d04
to
db8aebc
Compare
There was a problem hiding this 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
… variations (vllm-project#7698) Signed-off-by: Alvant <[email protected]>
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.