Repository navigation
Conversation
An out-of-range id made the logit bias callback raise IndexError inside the ctypes sampler callback, where the exception is swallowed, so every bias in the request was silently dropped for every token. Negative ids indexed from the end of the vocabulary instead of failing.
This branch has not been deployed
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.
What broke
A
logit_biasentry whose token id is outside the vocabulary silently turns off the wholelogit_biasfor that request, including the valid entries.On the released 0.3.38 server with Qwen3-0.6B (vocab 151936),
temperature=0, prompt"The capital of France is":The server log gets one traceback per generated token:
Why
logit_bias_processorindexes the scores array with each id.It runs inside the custom sampler's ctypes callback, and ctypes prints and swallows exceptions raised there, so the
IndexErrornever reaches the caller and the biased copy of the scores is thrown away.A negative id is a valid numpy index, so
-1biases the last vocabulary entry instead of failing.Fix
_create_completionchecks everylogit_biasid against0 <= id < n_vocabwhen it builds the map and raisesValueErrornaming the bad id.The chat path goes through the same code, so
/v1/chat/completionsgets the same error.Tests
test_logit_bias_rejects_out_of_vocab_token_ids(stories15M):n_vocaband-1raiseValueError, and a valid id still forces its token. Fails onmainwithDID NOT RAISE, passes with the fix.pytest tests: 26 passed.test_llama_cpp_tokenizationfails with and without the change because thevendor/llama.cppvocab file wasn't checked out locally.ruff checkandruff format --checkclean." banana banana banana", and later requests are fine.