Fix broken streaming response with --incremental-streaming-output#22549
Merged
Kangyan-Zhou merged 1 commit intomainfrom Apr 12, 2026
Merged
Fix broken streaming response with --incremental-streaming-output#22549Kangyan-Zhou merged 1 commit intomainfrom
Kangyan-Zhou merged 1 commit intomainfrom
Conversation
When incremental_streaming_output is enabled, content["text"] from the tokenizer manager is already the incremental delta (new text only), not the full accumulated text. The delta computation in _generate_chat_stream incorrectly sliced into this delta using the accumulated buffer length, producing garbled fragments like "rge", "age", "eable" instead of "large", "language", "trainable". Fixes #22510 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Collaborator
Author
|
/tag-run-ci-label |
Collaborator
Author
|
/rerun-test test/registered/openai_server/basic/test_serving_chat.py |
Contributor
|
✅ |
alexnails
approved these changes
Apr 11, 2026
JustinTong0323
approved these changes
Apr 11, 2026
Collaborator
Author
|
/rerun-failed-ci |
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
Fixes #22510
--incremental-streaming-output+stream=Trueproduces garbled text for all models (not just Gemma 4).Root cause: #21037 (c37200f) changed
tokenizer_manager.pyto emit incremental deltas (state.text[last_text_offset:]) instead of cumulative text (state.text) whenincremental_streaming_outputis enabled.serving_chat.pywas not updated and still slices the already-incremental text by the accumulated buffer length, producing garbage fragments.Repro on any model:
Modifications
serving_chat.py: Whenincremental_streaming_outputis enabled, usecontent["text"]directly as the delta instead of slicing by accumulated buffer length.test_serving_chat.py: Add regression testtest_incremental_streaming_output_delta.Checklist