Repository navigation
fix: stop completions at the earliest matching sequence - #2460
Open
remote-controlled-man wants to merge 2 commits into
Open
remote-controlled-man wants to merge 2 commits into
remote-controlled-man wants to merge 2 commits into
Conversation
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 changed
When multiple stop strings become visible in one generated token, non-streaming completions use the first string in the input list rather than the earliest match in the generated text. This can leak part of an earlier stop string and disagree with streaming.
Choose the minimum matched byte offset, using the same rule as the streaming flush. No buffering, tokenization, or sampler behavior changes.
The regression uses the existing Qwen fixture and public logit_bias to hold the sampled token constant. It checks both stop-list orders, overlapping matches, a single effective match, and a nonmatching control, with and without streaming/logprobs.
Reproducer
This uses a published checkpoint and its natural greedy output; no logit bias is needed.
On main (
77fbb5d), plain is " ve" and streamed is " v". With this fix both are " v".Validation
On macOS arm64; the regression and reproducer use CPU (
n_gpu_layers=0).make test: 30 passed, no skips, including the four parametrized regression tests covering 24 combinations.make lint: Ruff lint and formatting checks passed for all 29 source/test files.git diff --check 77fbb5d HEAD: passed.Other platforms and GPU inference were not separately tested.
AI-assisted implementation.