Skip to content

Fix benchmark generating empty prompts when random_input_len is small#21492

Merged
hnyls2002 merged 1 commit intomainfrom
lsyin/fix-bench-empty-prompt
Mar 26, 2026
Merged

Fix benchmark generating empty prompts when random_input_len is small#21492
hnyls2002 merged 1 commit intomainfrom
lsyin/fix-bench-empty-prompt

Conversation

@hnyls2002
Copy link
Copy Markdown
Collaborator

@hnyls2002 hnyls2002 commented Mar 26, 2026

Summary

  • When random_input_len=1, subtracting special tokens via max(0, input_len - num_special_tokens) can produce 0-length input, causing tokenizer.decode([]) to return an empty string
  • The server then raises ValueError: texts cannot be empty and tokenizer must be initialized for every such request
  • Fix: change max(0, ...) to max(1, ...) to guarantee at least 1 token after adjustment

Spotted 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

  • Reproduced locally by running test_pp_offline_throughput_default_decode (which uses random_input_len=1) — confirmed the error messages disappear after the fix

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the sample_random_requests function in the random dataset benchmark to ensure that the input length for prompts is at least 1 after accounting for special tokens. I have no feedback to provide.

@hnyls2002
Copy link
Copy Markdown
Collaborator Author

/rerun-ut test_bench_serving_2gpu.py

@github-actions
Copy link
Copy Markdown
Contributor

✅ Triggered /rerun-ut on 2-gpu-h100 runner:

cd test/ && python3 registered/perf/test_bench_serving_2gpu.py

@github-actions
Copy link
Copy Markdown
Contributor

🔗 View workflow run

@hnyls2002
Copy link
Copy Markdown
Collaborator Author

/tag-and-rerun-ci

@hnyls2002
Copy link
Copy Markdown
Collaborator Author

/rerun-stage stage-a-cpu-only

@github-actions
Copy link
Copy Markdown
Contributor

❌ Stage stage-a-cpu-only doesn't support isolated runs yet.

NVIDIA stages:

  • stage-a-test-1-gpu-small
  • stage-a-test-cpu
  • stage-b-test-1-gpu-small
  • stage-b-test-1-gpu-large
  • stage-b-test-2-gpu-large
  • stage-b-test-4-gpu-b200
  • stage-c-test-4-gpu-h100
  • stage-c-test-8-gpu-h200
  • stage-c-test-8-gpu-h20
  • stage-c-test-4-gpu-b200
  • stage-c-test-4-gpu-gb200
  • stage-c-test-deepep-4-gpu-h100
  • stage-c-test-deepep-8-gpu-h200
  • multimodal-gen-test-1-gpu
  • multimodal-gen-test-2-gpu

AMD stages:

  • sgl-kernel-unit-test-amd
  • sgl-kernel-unit-test-2-gpu-amd
  • stage-a-test-1-gpu-small-amd
  • stage-b-test-1-gpu-small-amd
  • stage-b-test-1-gpu-small-amd-nondeterministic
  • stage-b-test-1-gpu-small-amd-mi35x
  • stage-b-test-1-gpu-large-amd
  • stage-b-test-2-gpu-large-amd
  • multimodal-gen-test-1-gpu-amd
  • multimodal-gen-test-2-gpu-amd
  • stage-c-test-large-8-gpu-amd
  • stage-c-test-large-8-gpu-amd-mi35x

Other stages will be added soon. For now, use /rerun-failed-ci for those stages.

@hnyls2002 hnyls2002 merged commit c580ddd into main Mar 26, 2026
90 of 128 checks passed
@hnyls2002 hnyls2002 deleted the lsyin/fix-bench-empty-prompt branch March 26, 2026 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant