Skip to content
← All reviews
ggml-org/llama.cpp #25544 · aldehir · 4mo ago

common : add support for multiple end sequences in the reasoning budget sampler

Needs attention2 findings · openOpen the pull request on GitHub ↗
Panel verdict

The panel surfaced issues that deserve attention before merge.

2
raised by reviewers
2
kept by the panel

Findings

HighArchitectureconfidence 0.85

reasoning_budget_message handler depends on unreliably ordered field processing

The reasoning_budget_message handler now reads ctx.params.sampling.reasoning_budget_end.front() to build the forced token sequence. This vector is populated by the reasoning_budget_end_tags handler (or its alias). If the JSON object is processed in key order (which is not guaranteed per the JSON standard), the reasoning_budget_message handler may execute before the end-tags handler, resulting in an empty reasoning_budget_end and thus a missing forced sequence. The previous code was safe because it used the raw JSON string for reasoning_budget_end_tag directly, without relying on another handler's side effect.

MediumArchitectureconfidence 0.75

Aho-Corasick matcher resets state on match, losing longer overlapping patterns

The token_matcher::advance method calls ac.next(state, token) and if match_pattern(state) returns >= 0, it resets state = 0. This prevents detection of patterns that are a strict prefix of another pattern (e.g., end sequences {101} and {101, 102}). After matching the shorter sequence, the state is reset, so the next token cannot continue into the longer sequence. While the current end sequences (e.g., " response" and "<tool_call>") are not prefixes of each other, this is a latent bug that may appear when future models require overlapping end tags. The original single-sequence matcher had the same limitation, but now that multiple sequences are supported, this design decision becomes more likely to cause incorrect behavior.

3 reviewers · deepseek/deepseek-v4-flash · reviewed in 2m 8s · 14 files, +497 −254

Ship the PR.
Skip the noise.

Free on 2 repositories · No credit card · Advisory only—never blocks a merge