Skip to content

[Frontend] Omit absent fields from /inference/v1/generate stream chunks - #57264

Merged
DarkLight1337 merged 2 commits into
vllm-project:mainfrom
aoshen02:generate-stream-null-parity
Sep 17, 2026
Merged

DarkLight1337 merged 2 commits into
vllm-project:mainfrom
aoshen02:generate-stream-null-parity

Conversation

@aoshen02

@aoshen02 aoshen02 commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Follow-up to #53187. Python /inference/v1/generate stream chunks serialized absent optional fields as null, except for the two prompt-metadata keys that #53187 excluded per-field. The Rust frontend omits every absent field (skip_serializing_none), and the Python final usage chunk already uses exclude_none=True.

Serialize all Python data chunks with exclude_none=True so:

Non-streaming responses are unchanged on both sides. Clients that read chunk["finish_reason"] on non-final Python chunks must use .get(); the OpenAI-style clients and prime-rl's generate client already do.

Why this is not a duplicate

Searched open PRs for exclude_none, skip_serializing_none, generate stream and token_in_token_out. #47933 changes abort finish_reason on this path but not serialization; no overlap. Independent of #57265 (empty-chunk skip rule).

Test Plan

  • Python: new test_stream_chunks_omit_absent_fields; existing key-absence assertions for the metadata fields unchanged.
  • Rust: new stream_chunk_omits_absent_fields unit test locking the existing skip_serializing_none contract.

Test Result

.venv/bin/python -m pytest tests/entrypoints/scale_out/token_in_token_out/test_generate_stream.py \
  tests/entrypoints/scale_out/token_in_token_out/test_protocol.py -q
# 33 passed
cargo test --manifest-path rust/Cargo.toml -p vllm-server --no-default-features
# 413 passed
cargo clippy --manifest-path rust/Cargo.toml -p vllm-server --tests --no-default-features -- -D warnings
# clean; cargo fmt --check clean

Model evaluation is not applicable: wire-format-only change, generated tokens are unchanged.

Developed with AI assistance (Claude Code); the human submitter has reviewed every changed line.

🤖 Generated with Claude Code

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

Follow-up to vllm-project#53187. Python stream chunks serialized absent optional fields
as null except for the two prompt-metadata keys, which vllm-project#53187 excluded
per-field; the Rust frontend omits every absent field via
skip_serializing_none, and the Python final usage chunk already uses
exclude_none. Serialize all Python data chunks with exclude_none so the two
frontends emit the same JSON and the per-field special case goes away.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: aoshen02 <aoshen@inferact.ai>
@aoshen02 aoshen02 changed the title [Frontend] Serialize absent stream fields as null in /inference/v1/generate [Frontend] Omit absent fields from /inference/v1/generate stream chunks Sep 17, 2026
@aoshen02
aoshen02 force-pushed the generate-stream-null-parity branch from 1ddcbce to 98ad990 Compare September 17, 2026 01:18
@DarkLight1337
DarkLight1337 enabled auto-merge (squash) September 17, 2026 04:25
@DarkLight1337

Copy link
Copy Markdown
Member

/ci run

@github-actions github-actions Bot added the ready ONLY add when PR is ready to merge/full CI is needed label Sep 17, 2026
@github-actions

Copy link
Copy Markdown

❌ This PR is 16 commits behind upstream main. Your branch must contain every commit currently on upstream main. No new CI build was started. Merge or rebase onto the latest main, then rerun /ci run. To test this branch at your own risk, use /ci run --allow-stale.

@DarkLight1337

Copy link
Copy Markdown
Member

/ci run

@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #89535 for commit 306ff57636af.

@DarkLight1337
DarkLight1337 merged commit 8538017 into vllm-project:main Sep 17, 2026
88 of 89 checks passed
@aoshen02

Copy link
Copy Markdown
Contributor Author

Sorry cyrus, it's not ready yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend ready ONLY add when PR is ready to merge/full CI is needed rust

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants