Repository navigation
[Kimi K3 Bug] Fix kimi k3 reasoning parser - #57098
Conversation
Signed-off-by: yewentao256 <zhyanwentao@126.com>
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
|
/ci run |
|
β This PR is 2 commits behind upstream |
sfeng33
left a comment
There was a problem hiding this comment.
Thanks for the work! The truncation fix makes sense: the non-streaming path was inconsistent with is_reasoning_end, _extract_content_ids, and streaming, which already treat markerless output as ongoing reasoning.
However, removing the guard unconditionally may regress cases where thinking parsing is enabled but the prompt did not open a <|open|>think<|sep|> channel. For example, output beginning with <|open|>response<|sep|> is now returned entirely as reasoning with content=None. Since no remainder reaches KimiK3Parser._extract_tool_calls, any tools channel is also silently lost.
Suggestion: take the truncated-reasoning path only when the text has no _response_open_re match (a response opener is positive evidence the think channel was never in play); otherwise keep the old content fallthrough.
yewentao256
left a comment
There was a problem hiding this comment.
Thanks @sfeng33 fixed, could you take another look?
|
/ci run |
|
β
Triggered Buildkite CI #89422 for commit |
β¦ and response-opener parse Follow-up to vllm-project#57098: cover the three non-stream fallback shapes it introduced -- marker-free truncated output stays reasoning, an open marker without a close stays reasoning, and a response opener without any think marker stays content. Signed-off-by: linnea-lin-00638949 <247557940+linnea-lin-00638949@users.noreply.github.com>
extract_reasoning gained the four-shape split in vllm-project#57098, but extract_reasoning_streaming still falls through to "everything is reasoning" whenever no think-close marker exists. A completion that opens straight into the response channel (no think markers at all) is content in the non-streaming path, yet streamed entirely as reasoning_content (raw XTML markers included) with content left empty. Latch the response-only shape once the opener completes, route the stream through strip_content_streaming from then on, and hold back a partial response opener in _reasoning_text_ready_to_emit so the first ambiguous chunks are not emitted as reasoning while the marker is still arriving. Reasoning that already streamed before a mid-stream response opener (think prefix consumed, close never sent) stays reasoning; only the response body switches. Fixes vllm-project#57688 Co-authored-by: Kimi Code <kimi-code@moonshot.cn> Signed-off-by: Yufeng He <40085740+he-yufeng@users.noreply.github.com>
Signed-off-by: yewentao256 <zhyanwentao@126.com> Co-authored-by: Flora Feng <4florafeng@gmail.com>
extract_reasoning gained the four-shape split in vllm-project#57098, but extract_reasoning_streaming still falls through to "everything is reasoning" whenever no think-close marker exists. A completion that opens straight into the response channel (no think markers at all) is content in the non-streaming path, yet streamed entirely as reasoning_content (raw XTML markers included) with content left empty. Latch the response-only shape once the opener completes, route the stream through strip_content_streaming from then on, and hold back a partial response opener in _reasoning_text_ready_to_emit so the first ambiguous chunks are not emitted as reasoning while the marker is still arriving. Reasoning that already streamed before a mid-stream response opener (think prefix consumed, close never sent) stays reasoning; only the response body switches. Fixes vllm-project#57688 Co-authored-by: Kimi Code <kimi-code@moonshot.cn> Signed-off-by: Yufeng He <40085740+he-yufeng@users.noreply.github.com>
Purpose
This bug from a real user case, minimal reproduce command:
vllm serve moonshotai/Kimi-K3 \ --trust-remote-code \ --tensor-parallel-size 8 \ --load-format fastsafetensors \ --gpu-memory-utilization 0.9 \ --enable-prefix-caching \ --reasoning-parser kimi_k3 \ --enable-auto-tool-choice \ --tool-call-parser kimi_k3 \ --host 0.0.0.0 \ --port 30000 \ --max-model-len auto \ --speculative-config '{"model":"RedHatAI/Kimi-K3-speculator.dspark","method":"dspark","num_speculative_tokens":8,"draft_sample_method":"probabilistic","rejection_sample_method":"standard"}' --use-replayssm --max-num-seqs 48Test
Use this script
Before:
python repro_kimi_k3_truncated_reasoning.py finish_reason: length content: 'We need solve. Need return only JSON after reasoning. Need compute exact number of' reasoning: None BUG reproduced: truncated reasoning was incorrectly returned as content.Now