-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
[Frontend] Kill the server on engine death #6594
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0df9465
:goal_net: kill server on engine death
joerunde 0f8ffc9
:triangular_flag_on_post: gate automatic shutdown
joerunde 6c20c20
:recycle: shutdown server programatically
joerunde fc386c4
:art: format
joerunde d94a88b
:bug: fix server ref
joerunde 1537c9d
:white_check_mark: add shutdown test
joerunde ecd88b3
:bug: fixup shutdown test for CI
joerunde cff5a19
:recycle: move cli arg to envs
joerunde bb459bc
Merge remote-tracking branch 'upstream/main' into kill-the-server
joerunde 214585f
:recycle: move shutdown handling to launcher
joerunde b846a86
Merge remote-tracking branch 'upstream/main' into kill-the-server
joerunde bd491bb
:bug: fix abort bug
joerunde 8e34011
:bug: add exception handling to abort in rpc server
joerunde f98b441
:art: fmt
joerunde 34a46ec
:bug: fix log line
joerunde 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import json | ||
import os | ||
|
||
import openai | ||
import pytest | ||
|
||
from ...utils import RemoteOpenAIServer | ||
|
||
MODEL_NAME = "HuggingFaceH4/zephyr-7b-beta" | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_shutdown_on_engine_failure(tmp_path): | ||
# Use a bad adapter to crash the engine | ||
# (This test will fail when that bug is fixed) | ||
adapter_path = tmp_path / "bad_adapter" | ||
os.mkdir(adapter_path) | ||
with open(adapter_path / "adapter_model_config.json", "w") as f: | ||
json.dump({"not": "real"}, f) | ||
with open(adapter_path / "adapter_model.safetensors", "wb") as f: | ||
f.write(b"this is fake") | ||
|
||
# dtype, max-len etc set so that this can run in CI | ||
args = [ | ||
"--dtype", | ||
"bfloat16", | ||
"--max-model-len", | ||
"8192", | ||
"--enforce-eager", | ||
"--max-num-seqs", | ||
"128", | ||
"--enable-lora", | ||
"--lora-modules", | ||
f"bad-adapter={tmp_path / 'bad_adapter'}", | ||
] | ||
|
||
with RemoteOpenAIServer(MODEL_NAME, args) as remote_server: | ||
client = remote_server.get_async_client() | ||
|
||
with pytest.raises(openai.APIConnectionError): | ||
# This crashes the engine | ||
await client.completions.create(model="bad-adapter", | ||
prompt="Hello, my name is") | ||
|
||
# Now the server should shut down | ||
return_code = remote_server.proc.wait(timeout=1) | ||
assert return_code is not None |
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
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
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 |
---|---|---|
|
@@ -96,14 +96,17 @@ async def is_server_ready(self, identity): | |
|
||
async def abort(self, identity, request: RPCAbortRequest): | ||
"""Abort request and notify the client of success.""" | ||
# Abort the request in the llm engine. | ||
await self.engine.abort(request.request_id) | ||
|
||
# Send confirmation to the client. | ||
await self.socket.send_multipart([ | ||
identity, | ||
cloudpickle.dumps(VLLM_RPC_SUCCESS_STR), | ||
]) | ||
try: | ||
# Abort the request in the llm engine. | ||
await self.engine.abort(request.request_id) | ||
except Exception: | ||
logger.warning("Failed to abort request %s", request.request_id) | ||
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. It might be good for this to be But don't want to trigger another whole round of CI tests just for this, we can address it in follow-on cleanup of the zmq decoupling that's being done anyhow. |
||
finally: | ||
# Send confirmation to the client. | ||
await self.socket.send_multipart([ | ||
identity, | ||
cloudpickle.dumps(VLLM_RPC_SUCCESS_STR), | ||
]) | ||
|
||
async def generate(self, identity, generate_request: RPCGenerateRequest): | ||
try: | ||
|
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
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.
(This has just triggered me every time I see the log)