-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
[V1] [6/N] API Server: Better Shutdown #11586
Merged
Merged
Changes from 8 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5d61d13
better shutdown
robertgshaw2-redhat 8f22b4b
shutdown on error
robertgshaw2-redhat 577fe7f
remove EngineDeadError
robertgshaw2-redhat 3ded2a6
remove unnessary changes
robertgshaw2-redhat c4d8782
formatting
robertgshaw2-redhat 39b28b9
spurious change
robertgshaw2-redhat 43cf6e7
update
robertgshaw2-redhat 5450350
cleanup
robertgshaw2-redhat 7c5b564
formatted
robertgshaw2-redhat acbe6e3
use logger.error directly
robertgshaw2-redhat 5087194
passing
robertgshaw2-redhat 492084b
fix
robertgshaw2-redhat 0b22987
fix
robertgshaw2-redhat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
import asyncio | ||
import os | ||
import signal | ||
from typing import AsyncGenerator, Dict, List, Mapping, Optional, Type, Union | ||
|
||
from vllm.config import ModelConfig, VllmConfig | ||
|
@@ -16,6 +18,7 @@ | |
from vllm.transformers_utils.tokenizer import AnyTokenizer | ||
from vllm.transformers_utils.tokenizer_group import init_tokenizer_from_configs | ||
from vllm.usage.usage_lib import UsageContext | ||
from vllm.utils import get_exception_traceback, kill_process_tree | ||
from vllm.v1.engine.core_client import EngineCoreClient | ||
from vllm.v1.engine.detokenizer import Detokenizer | ||
from vllm.v1.engine.processor import Processor | ||
|
@@ -38,6 +41,22 @@ def __init__( | |
log_requests: bool = True, | ||
start_engine_loop: bool = True, | ||
) -> None: | ||
|
||
# The child processes will send SIGQUIT when unrecoverable | ||
# errors happen. We kill the process tree here so that the | ||
# stack trace is very evident. | ||
# TODO: rather than killing the main process, we should | ||
# figure out how to raise an AsyncEngineDeadError and | ||
# handle at the API server level so we can return a better | ||
# error code to the clients calling VLLM. | ||
def sigquit_handler(signum, frame): | ||
logger.fatal( | ||
"AsyncLLM got SIGQUIT from worker processes, shutting " | ||
"down. See stack trace above for root cause issue.") | ||
kill_process_tree(os.getpid()) | ||
|
||
signal.signal(signal.SIGQUIT, sigquit_handler) | ||
|
||
assert start_engine_loop | ||
|
||
self.log_requests = log_requests | ||
|
@@ -273,10 +292,12 @@ async def _run_output_handler(self): | |
|
||
# 4) Abort any requests that finished due to stop strings. | ||
await self.engine_core.abort_requests_async(reqs_to_abort) | ||
raise ValueError("my error!") | ||
|
||
except BaseException as e: | ||
logger.error(e) | ||
raise e | ||
except Exception: | ||
traceback = get_exception_traceback() | ||
logger.error("EngineCore hit an exception: %s", traceback) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logger.error should automatically print traceback? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep, thanks |
||
kill_process_tree(os.getpid()) | ||
|
||
async def abort(self, request_id: str) -> None: | ||
"""Abort RequestId in self, detokenizer, and engine core.""" | ||
|
Oops, something went wrong.
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.
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.
remove this?
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.
my b