{{ message }}
Repository navigation
[Bugfix][Rust Frontend] Always include token_ids in completion stream choices - #60286
Merged
BugenZhao merged 2 commits intoOct 8, 2026
Conversation
Signed-off-by: devshah-cohere <dev.shah@cohere.com>
devshah-cohere
force-pushed
the
devshah/fix-rust-completion-stream-token-ids
branch
from
October 6, 2026 19:31
402e127 to
5435597
Compare
devshah-cohere
marked this pull request as ready for review
October 6, 2026 21:45
|
✅ @devshah-cohere, CI is now available for this PR.
|
Member
|
/ci run |
6 tasks done
michael-gpu
pushed a commit
to practical-inference/vllm-ampere-extended
that referenced
this pull request
Oct 20, 2026
… choices (vllm-project#60286) Co-authored-by: Bugen Zhao <i@bugenzhao.com> Signed-off-by: devshah-cohere <dev.shah@cohere.com>
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.

Overview
Ensure the Rust
/v1/completionsstream includestoken_idson every choice whenreturn_token_ids=true.Claims
token_ids: []alongsideprompt_token_ids.token_ids: [].return_token_ids=falseare unchanged.Validation
Manually verified the affected streaming behavior with
return_token_ids=true.Added
completion_stream_serializes_requested_token_ids_on_every_choice, which serializes the prompt, generated-token, and terminal chunks and asserts their exacttoken_idsvalues.The regression test is covered by the existing Rust Frontend Cargo CI for changes under
rust/.Focused pre-commit checks passed:
Rust formatting passed locally in a Rust 1.95 container:
The targeted regression test passed locally in a Rust 1.95 container:
cargo test --manifest-path rust/Cargo.toml -p vllm-server \ completion_stream_serializes_requested_token_ids_on_every_choiceDetails
CompletionStreamChoiceskips fields whose value isNone. Generated deltas already populatedtoken_ids, but prompt and terminal choices left the field asNone, so it disappeared from serialized responses even when requested.The Python frontend already enforces this contract in
OpenAIServingCompletion.completion_stream_generator: every emittedCompletionResponseStreamChoicesetstoken_idstoas_list(output.token_ids)wheneverreturn_token_idsis enabled. This explicitly supplies a list, including an empty list, instead of leaving the optional field unset. The Rust frontend only set the field on generated-token chunks, so prompt and terminal choices omitted it.The existing stream-yield path now fills only missing
token_idsvalues with an empty list whenreturn_token_idsis enabled. Centralizing this at emission covers every completion choice while preserving real IDs already attached to generated-token chunks. The only payload change is an empty list on opt-in prompt and terminal chunks; no dependencies or public request fields change.Pull Request Checklist
I used vLLM's
/pr-checklistskill. (Mandatory for agents, optional for humans).AI assistance was used during the creation of this PR.
Design Fit: Minimizes impact on core components, reuses existing functionality, and justifies added complexity.
Testing and Validation: Validates the change and ensures any added tests are meaningful and reliable, with CI coverage or documented CI resource constraints and validation performed outside CI.
Code Quality and Style: Keeps code and comments clear and concise, and updates relevant documentation and examples.
Pull Request Contents: Includes a brief summary and relevant links, supports claims with evidence, explains root causes and implementation trade-offs, and follows the contributing guide.