-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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] don't block event loop in tokenization (preprocess) in OpenAI compatible server #10635
Merged
njhill
merged 14 commits into
vllm-project:main
from
tomeras91:async-tokenization-in-oai-server
Nov 27, 2024
Merged
Changes from 7 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
6af8e61
don't block GIL in tokenization (preprocess) in OpenAI compatible ser…
tomeras91 821665b
format
tomeras91 5f2164a
remove commit_id that was mistakenly added
tomeras91 dd01b53
simpler - just assign methods in init
tomeras91 4a6efcb
format
tomeras91 f89eaa0
async tokenization also in serving_score.py
tomeras91 980fff8
format
tomeras91 da646c1
no need to make self._tokenize_prompt_inputs async as it's used only …
tomeras91 b61a04f
make self._tokenize_prompt_input_or_inputs return a list so make_asyn…
tomeras91 e4cb992
introduce threadsafe tokenizer and use in MQLLMEngineClient
tomeras91 e59cc81
format
tomeras91 f0c0a2f
Use ThreadPoolExecutor with max_workers=1 to make tokenization async.…
tomeras91 b35a063
Add tests to validate that (1) truncated and non-truncated requests c…
tomeras91 ff1d6a9
add comment
tomeras91 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
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
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.
I don't think these will work as intended. The methods return a generator which will be done asynchronously but the actual work done to generate the outputs will still be done on the asyncio event loop while iterating.
We'll probably need to think of another way to arrange this, possibly we can change these methods to just return lists rather than generators.
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.
that's a good catch. It really didn't work for /v1/completions which uses these methods. It did work for /v1/chat/completions that uses
_tokenize_prompt_input
which doesn't return a generator and actually does the tokenization work.Anyway, fixed by making
_tokenize_prompt_input_or_inputs
return aList
as you suggested.Will post updated benchmarks and something that shows this works shortly