Skip to content

[Rust Frontend] Report every invalid logit_bias key like Python - #63313

Merged
BugenZhao merged 3 commits into
vllm-project:mainfrom
BugenZhao:bz/rust-parity-logit-bias-all-invalid-keys
Oct 23, 2026
Merged

BugenZhao merged 3 commits into
vllm-project:mainfrom
BugenZhao:bz/rust-parity-logit-bias-all-invalid-keys

Conversation

@BugenZhao

Copy link
Copy Markdown
Member

Overview

When several logit_bias keys are not token IDs, Python returns one 400 naming all of them. The Rust frontend stops at the first key that fails to parse, and since the request map is a HashMap, which key it reports is arbitrary. This PR reports every invalid key, and enables the Python test that pins it in the Rust frontend CI.

Claims

  • logit_bias: {"bad1": 50.0, "bad2": 20.0} on chat or completions returns one 400 with param = "logit_bias" naming both keys, in sorted order: logit_bias contains key(s) that are not valid token IDs: ["bad1", "bad2"]. Token IDs must be non-negative integers.
  • test_chat_logit_bias_validation.py::test_chat_logit_bias_multiple_non_integer_keys now passes under the Rust frontend and runs in the Rust OpenAI Coverage step.

Validation

Commands from .buildkite/scripts/run-rust-frontend-cargo-ci.sh (style-clippy and test), run from the repo root:

cargo fmt --manifest-path rust/Cargo.toml --all -- --check   # ok
cargo sort --workspace --check rust                          # ok
cargo deny --manifest-path rust/Cargo.toml --config rust/deny.toml check bans   # ok
cargo clippy --manifest-path rust/Cargo.toml --workspace --all-targets --all-features --locked -- -D warnings   # ok
cargo nextest run --manifest-path rust/Cargo.toml --workspace --all-features --locked --no-fail-fast
# 2296 tests run: 2296 passed, 13 skipped
  • Unit test utils::tests::convert_logit_bias_reports_all_invalid_keys uses keys bad2, 7, bad1 and -1 and snapshots the error, which names -1, bad1 and bad2 in sorted order. With the old function it fails, naming only the first key the map yields. convert_logit_bias_converts_valid_keys covers the success path.
  • E2E on one GB200 GPU, vllm-rs built from this branch, VLLM_USE_RUST_FRONTEND=1: pytest entrypoints/openai/chat_completion/test_chat_logit_bias_validation.py: 4 passed.

Details

Python's SamplingParams.from_optional converts each key with int(), collects every failure, and raises one VLLMValidationError (param="logit_bias"). In Rust, string keys exist only in the OpenAI JSON wire format: gRPC carries a map<uint32, float> and vllm-text takes HashMap<u32, f32>. So the HTTP DTO lowering (convert_logit_bias in rust/src/server/src/utils.rs, shared by chat and completions) is the only consumer of string keys, and the existing function now collects errors instead of returning on the first.

Difference kept: a negative key such as "-1" passes Python's int() and is then rejected by the vocabulary check with a different message; Rust token IDs are u32, so Rust reports "-1" with the other invalid keys. Both are a 400 with param = "logit_bias".

The second commit drops -k "not multiple" from the Rust OpenAI Coverage step in .buildkite/test_areas/rust_frontend.yaml.

Not a duplicate: no open PR changes Rust logit_bias validation.

AI assistance (Claude Code) was used to prepare this change; the human submitter reviewed every changed line.

🤖 Generated with Claude Code

https://claude.ai/code/session_012jJ3QaARmRe3jZJYTfHsCB


Pull Request Checklist
  • I used vLLM's /pr-checklist skill. (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.

BugenZhao and others added 2 commits October 23, 2026 09:14
Python's SamplingParams collects every logit_bias key that is not an
integer and names all of them in one 400. Rust stopped at the first bad
key in HashMap order, so the reported key was arbitrary and the others
were hidden. Collect them all and sort them for a stable message.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
…inst the Rust frontend

test_chat_logit_bias_multiple_non_integer_keys asserts that the 400 names
every invalid key, which the Rust frontend now does.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>

@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.

@BugenZhao

Copy link
Copy Markdown
Member Author

/ci run

@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #96852 for commit a2deb95d29c2.

ℹ️ This PR is 1 commit behind upstream main. Merged upstream main into this branch as a2deb95d29c2 before starting CI. Pull the branch before pushing more changes.

@BugenZhao
BugenZhao merged commit 5c465dd into vllm-project:main Oct 23, 2026
30 checks passed
BugenZhao added a commit to BugenZhao/vllm that referenced this pull request Oct 23, 2026
…26-10-22-e2e

Resolve the .buildkite/test_areas/rust_frontend.yaml conflict with
vllm-project#63313 by keeping this branch's step list and taking
vllm-project#63313's removal of -k "not multiple" from the logit bias validation test.

Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DuEV4Temoctig8sAjQHcFP
bantianyue pushed a commit to bantianyue/vllm that referenced this pull request Oct 28, 2026
…-project#63313)

Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: vllm-agent <claw@inferact.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants