[Performance] Dynamic Batch Tokenizer#9382
Merged
hnyls2002 merged 7 commits intosgl-project:mainfrom Sep 13, 2025
Merged
Conversation
Collaborator
|
trigger ci, will review it by today or tmr |
zminglei
approved these changes
Aug 25, 2025
Collaborator
Author
|
@zhyncs / @hnyls2002 The unit test failures seems unrelated to this PR. |
Collaborator
|
Could you please split your benchmark scripts first as a separate PR? Also, do not use |
4 tasks
ec40e5f to
41ef215
Compare
Collaborator
Author
|
@hnyls2002 Moved the benchmark scripts to another PR and rebased |
hnyls2002
approved these changes
Sep 12, 2025
merrymercy
reviewed
Oct 8, 2025
| - "cross_encoder_pairs": Cross-encoder pairs like [["query", "document"]] | ||
| """ | ||
| if isinstance(texts, str): | ||
| return "single_string" |
Contributor
There was a problem hiding this comment.
please use ENUM instead of string
23 tasks
This was referenced Apr 13, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
AsyncDynamicBatchTokenizerthat enables batching of tokenization requests to improve throughput and reduce latency for SGLang's tokenizer manager.Performance Impact:
Context
This PR builds upon the tokenization batching infrastructure introduced in PR #5141, which added
enable_tokenizer_batch_encodefor batching multiple texts within a single request.Tokenization Batching Options
enable_tokenizer_batch_encode(PR #5141)enable_dynamic_batch_tokenizer(This PR)Example scenarios:
enable_tokenizer_batch_encode: Client sends{"input": ["text1", "text2", "text3"]}in one requestenable_dynamic_batch_tokenizer: Client sends multiple concurrent requests:{"input": "text1"},{"input": "text2"},{"input": "text3"}Modifications
🚀 Dynamic Batching
max_batch_sizeorbatch_wait_timeout_swhen queue has pending items⚙️ Server Args
max_batch_size(default: 32): Maximum number of requests to batch togetherbatch_wait_timeout_s(default: 0.002s): Maximum time to wait for additional requestsenable_dynamic_batch_tokenizer: Feature flag to enable/disable the functionality🔄 Async Processing
asyncioandThreadPoolExecutorBenchmarking and Profiling
Baseline Results
Batch Tokenizer Results
Checklist