Repository navigation
fix(scheduler): match stop strings with incremental decoding - #464
Open
taking-lying-flat wants to merge 1 commit into
Open
taking-lying-flat wants to merge 1 commit into
taking-lying-flat wants to merge 1 commit into
Conversation
JUNQINGV587
added a commit
to JUNQINGV587/FreeToken
that referenced
this pull request
Sep 23, 2026
Stop matching now runs on the same incrementally decoded text the frontend produces (DecodeStatus.update, with partial-UTF-8 hold-back) instead of decoding a bounded suffix of the generated tail on every step, and a terminal EOS the frontend would not emit is excluded (including at the output limit under ignore_eos). Conflict resolution: python/freetoken/core.py -- this fork's extra Req field (output_token_counts) sits exactly where upstream added stop_decode_status; kept both. Verified: tests/tokenizer/ tests/scheduler/ tests/server/test_prepare_stop_accounting.py => 226 passed, 9 skipped.
This was referenced Oct 2, 2026
KarrAcaRn
pushed a commit
to KarrAcaRn/FreeToken-ByAI
that referenced
this pull request
Oct 3, 2026
… with incremental decoding Assisted-by: Claude Opus 5.5
KarrAcaRn
pushed a commit
to KarrAcaRn/FreeToken-ByAI
that referenced
this pull request
Oct 3, 2026
Upstream PR FlashML-org#464 shipped without tests. With a byte-level tokenizer (a CJK character or emoji spans several tokens, as in byte-level BPE) the old max_chars+1-token window never matched a CJK stop, could match the replacement character of a half-decoded emoji, and the detokenizer then failed to trim the stop. Four of the five tests fail before the PR. Assisted-by: Claude Opus 5.5
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.
A stop string such as
🧬can span four byte tokens despite having one Python character. The scheduler's character-sized token window could decode only part of it and let generation continue past the stop.Reuse the frontend's incremental decode state for scheduler matching. Preserve the token context needed to finish decoding characters, and bound only the retained matching text. Keep both sides consistent when a frontend batch contains multiple messages for one request and when an ignored EOS participates in a matched stop. No new tokenizer dependency or model-specific handling is introduced.
Validation on Linux x86_64, Intel Core i7-12800HX, Python 3.12.13; CPU only, with no model checkpoint or GPU inference. Host GPU: NVIDIA RTX A1000 Laptop GPU (4 GiB), driver 595.84.
08d728d5, 32 failed and 22 passed; all 54 pass with this change. The harness is retained locally and is not included in this PR.git diff --checkpassed.Commands run from the source checkout: