-
-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Fixing various issues of async servers #135
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
Merged
Merged
Changes from 31 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
263c286
Separate AsyncLLMServer
zhuohan123 18f8097
rename fastapi frontend
zhuohan123 fb73a1b
small fix
zhuohan123 b990239
[WIP] add WIP openai frontend
zhuohan123 00c84e2
fix async_llm_server
zhuohan123 1c71b88
Basic support for OpenAI Completion API
zhuohan123 5415281
Merge branch 'main' into openai-server
zhuohan123 63c5d3c
Implement finsh_reason
zhuohan123 8321b47
support bestof and stop
zhuohan123 5c82790
Support non-streaming requests
zhuohan123 0e12ecb
Support logprobs
zhuohan123 aa9e83c
Fix streaming corner case.
zhuohan123 abb1bf1
Merge branch 'main' into openai-server
zhuohan123 8e14b2e
Optimize file locations
zhuohan123 788d070
Fix some review comments
zhuohan123 6cc6118
Fix client
zhuohan123 205b7ed
Fix review comments
zhuohan123 489e55e
Fix
zhuohan123 ee59d78
Fix other examples.
zhuohan123 dd03d97
Remove currently unused chat completion protocols
zhuohan123 2cca826
add served_model_name
zhuohan123 9fd49e5
Fix some review comments
zhuohan123 02f46cd
Use number based request ids
zhuohan123 ad1db5e
better benchmark scripts
zhuohan123 9609d5c
Merge branch 'main' into async-server-performance
zhuohan123 ddfd2e1
fix benchmark script arguments
zhuohan123 b935221
Select async server mode
zhuohan123 7b95efa
Support aborting requests
zhuohan123 c1296ac
Support aborting request for openai frontend
zhuohan123 6c76625
Merge branch 'main' into async-server-performance
zhuohan123 075ed4e
Small fixes
zhuohan123 8808179
Fix review comments
zhuohan123 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 hidden or 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,57 @@ | ||
| import argparse | ||
| import json | ||
|
|
||
| import requests | ||
| import threading | ||
| import time | ||
|
|
||
| def main(args: argparse.Namespace): | ||
| prompts = [f"Tell me a story with more than {''.join([str(i+1)] * 5)} words" | ||
| for i in range(args.n_threads)] | ||
|
|
||
| headers = {"User-Agent": "CacheFlow Benchmark Client"} | ||
| ploads = [{ | ||
| "prompt": p, | ||
| "max_tokens": args.max_tokens, | ||
| "temperature": 0.0, | ||
| "ignore_eos": True, | ||
| } for p in prompts] | ||
|
|
||
| def send_request(results, i): | ||
| response = requests.post(args.api_url, headers=headers, | ||
| json=ploads[i], stream=True) | ||
| results[i] = response | ||
|
|
||
| # use args.n_threads to prompt the backend | ||
| tik = time.time() | ||
| threads = [] | ||
| results = [None] * args.n_threads | ||
| for i in range(args.n_threads): | ||
| t = threading.Thread(target=send_request, args=(results, i)) | ||
| t.start() | ||
| threads.append(t) | ||
|
|
||
| for t in threads: | ||
| t.join() | ||
|
|
||
| print(f"Time (POST): {time.time() - tik} s") | ||
| n_words = 0 | ||
|
|
||
| for i, response in enumerate(results): | ||
| k = list(response.iter_lines(chunk_size=8192, decode_unicode=False, delimiter=b"\0")) | ||
| response_new_words = json.loads(k[-2].decode("utf-8"))["text"][0] | ||
| n_words += len(response_new_words.split(" ")) - len(prompts[i].split(" ")) | ||
|
|
||
| time_seconds = time.time() - tik | ||
| print(f"Time (total): {time_seconds:.3f}s to finish, n_threads: {args.n_threads}, " | ||
| f"throughput: {n_words / time_seconds} words/s.") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| parser = argparse.ArgumentParser() | ||
| parser.add_argument("--api-url", type=str, default="http://localhost:8001/generate") | ||
| parser.add_argument("--max-tokens", type=int, default=128) | ||
| parser.add_argument("--n-threads", type=int, default=128) | ||
| args = parser.parse_args() | ||
|
|
||
| main(args) | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.