Repository navigation
Conversation
havengit
requested review from
Ying1123,
hnyls2002,
merrymercy and
xiezhq-hermann
as code owners
August 1, 2026 01:02
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
agiping
pushed a commit
to Infrawaves/sglang
that referenced
this pull request
Sep 30, 2026
Limit this change to non-speculative decoding; speculative compatibility is intentionally out of scope. Document that boundary in the scheduler and regression tests. Use the existing reasoning token count to restrict user stop strings, regexes, token IDs and streaming prefix holdback to content. Keep system EOS and length limits effective during thinking. Preserve the thinking prefix when trimming the first stop match in content, including repeated matches inside a single decoded token. Reuse the existing trim interface and IPC fields. Do not include the reasoning-to-content fallback proposed in sgl-project#33154. Adapted from sgl-project#33152 (eb800ddcd97fb7a27886580941b607017770da93), with the trimming defect described in sgl-project#33151 (efb505ebce378db6b55336f4917be83f68049628) addressed without a global find-to-rfind substitution. Validation: 137 CPU tests and 53 subtests passed; 2 opt-in microbenchmarks skipped. Excluded one existing logprob fixture failure reproduced on base 32a0406. New non-speculative regressions fail on that base. Ruff/isort and diff checks pass. Full manager collection needs the missing mlx dependency; no real-model/GPU validation.
Zhangmj0621
pushed a commit
to Infrawaves/sglang
that referenced
this pull request
Oct 8, 2026
Limit this change to non-speculative decoding; speculative compatibility is intentionally out of scope. Document that boundary in the scheduler and regression tests. Use the existing reasoning token count to restrict user stop strings, regexes, token IDs and streaming prefix holdback to content. Keep system EOS and length limits effective during thinking. Preserve the thinking prefix when trimming the first stop match in content, including repeated matches inside a single decoded token. Reuse the existing trim interface and IPC fields. Do not include the reasoning-to-content fallback proposed in sgl-project#33154. Adapted from sgl-project#33152 (eb800ddcd97fb7a27886580941b607017770da93), with the trimming defect described in sgl-project#33151 (efb505ebce378db6b55336f4917be83f68049628) addressed without a global find-to-rfind substitution. Validation: 137 CPU tests and 53 subtests passed; 2 opt-in microbenchmarks skipped. Excluded one existing logprob fixture failure reproduced on base 32a0406. New non-speculative regressions fail on that base. Ruff/isort and diff checks pass. Full manager collection needs the missing mlx dependency; no real-model/GPU validation.
Nozom1ff
pushed a commit
to Infrawaves/sglang
that referenced
this pull request
Oct 29, 2026
Limit this change to non-speculative decoding; speculative compatibility is intentionally out of scope. Document that boundary in the scheduler and regression tests. Use the existing reasoning token count to restrict user stop strings, regexes, token IDs and streaming prefix holdback to content. Keep system EOS and length limits effective during thinking. Preserve the thinking prefix when trimming the first stop match in content, including repeated matches inside a single decoded token. Reuse the existing trim interface and IPC fields. Do not include the reasoning-to-content fallback proposed in sgl-project#33154. Adapted from sgl-project#33152 (eb800ddcd97fb7a27886580941b607017770da93), with the trimming defect described in sgl-project#33151 (efb505ebce378db6b55336f4917be83f68049628) addressed without a global find-to-rfind substitution. Validation: 137 CPU tests and 53 subtests passed; 2 opt-in microbenchmarks skipped. Excluded one existing logprob fixture failure reproduced on base 32a0406. New non-speculative regressions fail on that base. Ruff/isort and diff checks pass. Full manager collection needs the missing mlx dependency; no real-model/GPU validation.
4 of 5 tasks
havengit
force-pushed
the
fix/detokenizer-stop-trim-rfind
branch
from
November 30, 2026 14:20
efb505e to
7e9ae2a
Compare
This comment has been minimized.
This comment has been minimized.
Author
|
@merrymercy @hnyls2002 @cctry — rebased onto latest Part of #40529 (tracking issue with a reproducer and before/after output for each defect). Happy to adjust the approach. |
havengit
force-pushed
the
fix/detokenizer-stop-trim-rfind
branch
3 times, most recently
from
December 1, 2026 06:08
1938f1e to
e568944
Compare
When reasoning is enabled the decoded text concatenates the thinking block and the final answer, and the model may quote the user's stop string verbatim while planning. trim_matched_stop anchored on output.find(matched), i.e. the first occurrence inside the thinking, so the whole answer was truncated away and only the start of the reasoning was returned. The hit that ended generation is the last occurrence: use rfind. no_stop_trim and the token-based path are unchanged.
havengit
force-pushed
the
fix/detokenizer-stop-trim-rfind
branch
from
December 1, 2026 12:02
e568944 to
340bcd7
Compare
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.
Motivation
When reasoning is enabled, the decoded text handed to
trim_matched_stopconcatenates the thinking block and the final answer, and the model may quote the user's stop string verbatim while planning ("...end with fei chang jingcai, ok").trim_matched_stopanchored onoutput.find(matched)— the first occurrence, inside the thinking — so the whole answer was truncated away and only the start of the reasoning was returned.Modifications
Use
output.rfind(matched): the hit that ended generation is the last occurrence.no_stop_trimand the token-based path are unchanged.Reproducer: Anthropic route,
stop_sequences: ["jingcai"], system prompt asking the model to end with "fei chang jingcai!". Before:"<think>...mention jingcai..."(answer gone). After:"<think>plan</think>fei chang ".Part of tracking issue #40529 (defect 5). Masked on stock builds by #33152 (the scheduler stops inside the reasoning first); observable once that lands.
Checklist
test/registered/unit/managers/test_trim_matched_stop.py, CPU).CI States
Latest PR Test (Base): ⊘ Skipped -- a maintainer comments⚠️ Run #46642236465
/tag-and-rerun-cito run CI tests.Latest PR Test (Extra): ⊘ Skipped -- a maintainer comments
/tag-and-rerun-cito run CI tests.Latest PR Test (AMD ROCm 10):
Tip
Base CI only covers the core cases, and its workload may not exercise your change. Use
/rerun-testto run the tests your change touches, or copy this prompt for an agent:Rebased onto
main@e0e9a7f39d(2026-12-01). After #54065 movedReqintopython/sglang/srt/managers/req.py, the scheduler change now lives there; the test importsReqfrom its defining module (upstream'scheck-indirect-importshook rejects importing it throughschedule_batch). No behavioural change from the rebase.