Repository navigation
[Rust Frontend] Report every invalid logit_bias key like Python - #32
Closed
richard-for-bugen[bot] wants to merge 2 commits into
Closed
richard-for-bugen[bot] wants to merge 2 commits into
richard-for-bugen[bot] wants to merge 2 commits into
Conversation
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: richard-for-bugen[bot] <342439978+richard-for-bugen[bot]@users.noreply.github.com>
BugenZhao
approved these changes
Oct 23, 2026
BugenZhao
left a comment
Owner
There was a problem hiding this comment.
Unblocks test_chat_logit_bias_validation.py::test_chat_logit_bias_multiple_non_integer_keys for the Rust-frontend e2e CI once this merges (tracked in the e2e coverage ledger).
Please either unblock in this PR or add to the run PR now
…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: richard-for-bugen[bot] <342439978+richard-for-bugen[bot]@users.noreply.github.com>
Author
|
Unblocked in this PR (10640e2): the Rust OpenAI Coverage step now runs |
Author
|
Promoted as vllm-project#63313. |
Author
|
Merged upstream as vllm-project#63313. |
richard-for-bugen
Bot
deleted the
richard/parity-fix-logit-bias-all-invalid-keys
branch
October 25, 2026 19:18
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
Python.
SamplingParams.from_optional(vllm/sampling_params.py) converts the OpenAIlogit_biaskeys to integer token IDs. When any key fails, it collects every bad key and raises oneVLLMValidationError(400,param="logit_bias") naming all of them:logit_bias contains key(s) that cannot be converted to integer token IDs: ['bad1', 'bad2'].tests/entrypoints/openai/chat_completion/test_chat_logit_bias_validation.py::test_chat_logit_bias_multiple_non_integer_keyspins this: it sends{"bad1": 50.0, "bad2": 20.0}and asserts that both keys appear in the 400.Rust today.
convert_logit_bias(rust/src/server/src/utils.rs), used by both chat and completions lowering, stops at the first key that fails to parse. The request map is aHashMap, so which key gets reported is arbitrary, and the others are never mentioned. That Python test fails under the Rust frontend.This PR.
convert_logit_biascollects every key that is not au32and returns one 400 withparam = "logit_bias", sorting the keys so the message is stable:logit_bias contains key(s) that are not valid token IDs: ["bad1", "bad2"]. Token IDs must be non-negative integers.Ownership and layering. The string keys only exist in the OpenAI JSON wire format. gRPC already carries a
map<uint32, float>, andvllm-texttakesHashMap<u32, f32>. The HTTP DTO lowering invllm-serveris therefore the only consumer of string keys, and the fix stays there. No new helper: the existing function now collects errors instead of short-circuiting.Intentional difference. A negative key such as
"-1"passes Python'sint()and is then rejected by the out-of-vocabulary check with a different message. Rust's token IDs areu32, so Rust reports"-1"together with the other invalid keys. Both return a 400 withparam = "logit_bias"; this PR keeps that existing difference.chat+completions.logit_bias_report_all_invalid_keysSamplingParams.from_optionallogit_bias conversionvllm/sampling_params.pyfrom_optional, reached from the chat and completionsto_sampling_paramsconvert_logit_biasThe second commit (10640e2, per review) drops
-k "not multiple"from the Rust OpenAI Coverage step, sotest_chat_logit_bias_validation.py::test_chat_logit_bias_multiple_non_integer_keysruns in Rust CI with this fix. With this branch'svllm-rson one GB200 GPU, all four tests of the file pass.Validation
utils::tests::convert_logit_bias_reports_all_invalid_keysuses keysbad2,7,bad1and-1, and snapshots the error, which names-1,bad1andbad2in sorted order. Red-green check: with the old function restored, the test fails because the error names only'-1', the first key the map yields.convert_logit_bias_converts_valid_keyscovers the success path of the rewritten loop..buildkite/scripts/run-rust-frontend-cargo-ci.sh, run in a per-worktree target dir:cargo fmt --manifest-path rust/Cargo.toml --all -- --checkcargo sort --workspace --check rustcargo deny --manifest-path rust/Cargo.toml --config rust/deny.toml check banscargo clippy --manifest-path rust/Cargo.toml --workspace --all-targets --all-features --locked -- -D warningscargo nextest run --manifest-path rust/Cargo.toml --workspace --all-features --locked --no-fail-fastCodex review
Independent Codex review (
gpt-6.1-sol, high effort): approve, with no findings and no nits. Codex confirmed both HTTP lowering paths (chat and completions, including their render endpoints) as the only consumers of string keys. It reproduced the red-green result itself, and an in-process HTTP probe of chat and completions, streaming and non-streaming, failed onorigin/mainand passed with this change (400,param="logit_bias", every key in sorted order).