perf: make server capture requests prefill-only - #756
Merged
Conversation
jiapingW
approved these changes
Aug 9, 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
Server-side spec capture only requires prefill and does not need to generate output tokens.
While profiling SGLang v0.5.14, I observed periodic decode batches accompanied by GPU utilization drops.
SGLang enables overlap scheduling by default. The scheduler may merge a completed prefill batch into
running_batchbefore its CPU-side result processing marks the requests as finished.With
max_new_tokens=1, these requests use the normal generation path. Although prefill already produces the only requested token and the subsequent CPU processing marks the requests as finished, they remain inrunning_batchuntil the scheduler enters the decode scheduling path and callsupdate_running_batch().filter_batch().When prefill requests keep arriving, the scheduler continues selecting prefill batches, so finished capture requests accumulate in
running_batch. Oncemax_running_requestsis reached, no more prefill requests can be admitted. The scheduler then enters the decode scheduling path:All required capture features are already produced during prefill, so this decode work is unnecessary and interrupts the prefill pipeline.
Setting
max_new_tokens=0uses SGLang's prefill-only path, which skips sampling and explicitly filters finished prefill-only requests fromrunning_batch.Modifications
max_new_tokens=1tomax_new_tokens=0.Related Issues
N/A.
Accuracy Test
Not applicable. This change does not modify model computation or the features captured during prefill.
The existing unit test is updated to verify:
{"temperature": 0.0, "max_new_tokens": 0}Benchmark & Profiling
Profiling with
max_new_tokens=1showed finished capture requests accumulating inrunning_batch, followed by periodic unnecessary decode batches whenmax_running_requestswas reached.Using
max_new_tokens=0prevents this accumulation and removes the unnecessary decode phase. The short decode phase could not hide the overlapping CPU-side processing as effectively as prefill phase, exposing CPU latency and producing GPU idle gaps.Checklist