Skip to content

fix: scope reasoning user stops to answer content - #42

Merged
agiping merged 1 commit into
Infrawaves:decode-scheduler-loop-reduce-itl-max-tool-validationfrom
luke396:decode-scheduler-loop-reduce-itl-max-tool-validation-stop
Sep 30, 2026
Merged

agiping merged 1 commit into
Infrawaves:decode-scheduler-loop-reduce-itl-max-tool-validationfrom
luke396:decode-scheduler-loop-reduce-itl-max-tool-validation-stop

Conversation

@luke396

@luke396 luke396 commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

reasoning → ignore user stops; preserve system EOS and length checks
content   → apply user stops
finish    → preserve reasoning; trim the first matched content stop
  • Gate user stop strings, regexes and token IDs on the existing reasoning boundary; withhold streaming stop prefixes only after reasoning.
  • Scope string-stop trimming to content, preserving first-match semantics even when one decoded token contains repeated matches. Reuse existing reasoning counts/read offsets without new request state or IPC fields.
  • Replay f335fea8fb onto 5fcaf71773 as 110202dea5: identical patch, one commit, three files.
  • Adapted from sgl-project/sglang#33152 (eb800ddcd97fb7a27886580941b607017770da93); address the trimming defect in #33151 (efb505ebce378db6b55336f4917be83f68049628) without a global find → rfind change. Exclude #33154's reasoning-to-content fallback.

Evidence

  • Before: TestReasoningStop fails against the unfixed new base. Restoring only the old detokenizer while retaining the scheduler fix reproduces 36 failing subtests.
    After: the focused stop/Kimi suite passes: 83 tests + 53 subtests. Coverage includes streaming/non-streaming string stops, immediate stops, split/repeated matches and decoder modes; scheduler-level checks cover regex/token stops, EOS and length limits.

  • Identical expanded suite on both revisions, including manager tests and the new base's changed tool-validation/preprocessing/disaggregation tests:

    Revision Passed Subtests passed Failed Errors Skipped
    Base 5fcaf71773 1006 889 23 7 15
    Fix 110202dea5 1012 942 23 7 15

    Failure/error identities match; no additional failures. Existing failures include incomplete fixtures and macOS lacking Linux facilities (lscpu, /dev/shm); they are not changed here.

  • Ruff, formatting, isort, git diff --check, patch-ID and range-diff checks pass.

Merge Danger

Door: Two-way — revert the single commit; no state/schema migration.

Blast Radius: Generation

The shared scheduler and Python detokenizer paths affect reasoning-enabled requests, not only Kimi K3. Non-reasoning behavior and existing EOS/length checks are preserved. Reasoning-aware stop handling is scoped to non-speculative decoding only; speculative compatibility is intentionally out of scope, with no new disabling switch. Validation is CPU-based with a fake tokenizer and real request/accumulator/detokenizer/Kimi parser code; no real-model, GPU or live API validation has been performed.


CI States

Latest PR Test (Base): ❌ Run #36680717107
Latest PR Test (Extra): ❌ Run #36680717002
Latest PR Test (AMD ROCm 10): ➖ No AMD PR run found for this commit.

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.
@agiping
agiping merged commit 29e482e into Infrawaves:decode-scheduler-loop-reduce-itl-max-tool-validation Sep 30, 2026
77 of 87 checks passed
Zhangmj0621 pushed a commit 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.
luke396 added a commit that referenced this pull request Oct 12, 2026
Restore #42's require_reasoning stop gating at its four sites. Instead, end the reasoning phase once in _maybe_update_reasoning_tokens when no usable terminator exists, so user stops keep their legacy behavior. _is_reasoning_over is read only by the stop logic, and all callers set it before the first stop check.

Drop the empty-encoding filter for channel openers; K3's openers never encode to an empty sequence.

Behavior is unchanged: 131 focused tests + 81 subtests pass, and the expanded suite has the same failure set as before. Without the processor line, the 4 missing-terminator subtests fail again.
luke396 added a commit that referenced this pull request Oct 12, 2026
Restore the matcher-based gating from 79df065 and drop the processor-side fallback added in a54fd39. Some commit paths never run reasoning tracking: the dLLM result path calls update_finish_state without _maybe_update_reasoning_tokens. On those paths, require_reasoning gating ignored user stops for the whole generation. This was introduced by #42 and restored by a54fd39. Without a matcher, the request now keeps legacy stop behavior on every caller.

Add a regression test that commits tokens without reasoning tracking. It fails on the base and on a54fd39, and passes here. Focused suite: 132 tests and 83 subtests pass. The expanded suite failure set is unchanged.
luke396 added a commit that referenced this pull request Oct 12, 2026
#42 gated user stops on require_reasoning. When a request asks for
reasoning but never gets a reasoning boundary matcher, stops stayed
ignored for the whole generation. This happens when there is no reasoning
parser, the terminator cannot be encoded, tokenizer init is skipped, or the
commit path never runs reasoning tracking (the dLLM result path calls
update_finish_state without _maybe_update_reasoning_tokens).

Gate reasoning-aware stops on the request's think-end matcher instead. The
result processor creates it only for a usable terminator. Without one, string,
regex and token-ID stops keep their legacy behavior on every caller. With one,
user stops are still ignored until reasoning ends. require_reasoning itself is
unchanged.

Regressions: 4 missing-terminator subtests (parser absent, tokenizer skipped)
and 2 untracked-commit subtests fail on the base and pass here.
Non-speculative scope, as in #42.
Nozom1ff pushed a commit 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants