Fix overlapping stop sequence matching - #2303
Open
tandede wants to merge 1 commit into
Open
Conversation
tandede
marked this pull request as ready for review
August 19, 2026 11:29
tandede
requested review from
andyland,
k223kim,
lianakoleva and
t-vi
as code owners
August 19, 2026 11:29
Author
|
Hi maintainers, just a gentle follow-up on this PR when you have time. It fixes overlapping stop-sequence matching and includes regression coverage for single-prompt and batched generation. All reported checks are currently passing, and I’m happy to address any feedback or adjust the implementation if needed. Thanks for maintaining LitGPT. |
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
Why
The previous matcher tracked only one prefix length and reset it to zero on every mismatch. A token that ended the current partial match but also began a new one was therefore discarded as a possible prefix. The immediate return path could also drop safe buffered tokens, while the batched path recorded the final stop token rather than the start of the full sequence.
This made streaming output depend on token repetition and stop-sequence ordering, and could either miss a stop sequence, omit valid output, or emit part of a multi-token stop sequence.
Fixes #2302
Validation
pytest -q tests/: 1490 passed, 634 skipped, 3 xfailed, 2 xpassed, 1 rerunpre-commit run --all-files