Fix benchmark generating empty prompts when random_input_len is small#21492
Merged
Fix benchmark generating empty prompts when random_input_len is small#21492
Conversation
Collaborator
Author
|
/rerun-ut test_bench_serving_2gpu.py |
Contributor
|
✅ Triggered |
Contributor
Collaborator
Author
|
/tag-and-rerun-ci |
Collaborator
Author
|
/rerun-stage stage-a-cpu-only |
Contributor
|
❌ Stage NVIDIA stages:
AMD stages:
Other stages will be added soon. For now, use |
satyamk7054
pushed a commit
to satyamk7054/sglang
that referenced
this pull request
Apr 3, 2026
JustinTong0323
pushed a commit
to JustinTong0323/sglang
that referenced
this pull request
Apr 7, 2026
yhyang201
pushed a commit
to yhyang201/sglang
that referenced
this pull request
Apr 22, 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.
Summary
random_input_len=1, subtracting special tokens viamax(0, input_len - num_special_tokens)can produce 0-length input, causingtokenizer.decode([])to return an empty stringValueError: texts cannot be empty and tokenizer must be initializedfor every such requestmax(0, ...)tomax(1, ...)to guarantee at least 1 token after adjustmentSpotted in CI: https://github.com/sgl-project/sglang/actions/runs/23617944361/job/68790866885?pr=21413
Note: the streaming error response (HTTP 200 instead of 400) is a separate issue tracked by #20027.
Test plan
test_pp_offline_throughput_default_decode(which usesrandom_input_len=1) — confirmed the error messages disappear after the fix