Repository navigation
fix(server): a thinking request always leaves room to think - #845
Merged
Merged
Conversation
The reply reserve (hard_limit_reply_budget, 4096 on the Qwen cards) came off max_tokens in full. A request that asked for thinking with max_tokens 4096 or less got none: the phase-1 cap was 0 and the budget hook closed thinking on the first token. The reserve now takes at most half of max_tokens, through one helper, reply_reserve_within(), used by the request parser, the single-request path and the scheduler. Requests with max_tokens above twice the reserve are unchanged.
davide221
commented
Oct 14, 2026
davide221
left a comment
Contributor
Author
There was a problem hiding this comment.
Code review
No issues found. Checked for bugs and logic errors in the changed code.
Reviewed b02afd22 · 0 candidate issues checked, kept at ≥70% confidence · add the code-review label to review again
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.
The reply reserve (
hard_limit_reply_budget, 4096 on the Qwen cards) came offmax_tokensin full. A request that asked for thinking withmax_tokens4096 or less got none: the phase-1 cap was 4096 − 4096 = 0, and the budget hook closed thinking on the first token. tool-eval-bench sendsmax_tokens: 4096, soreasoning_efforthad no effect there, and neither did an Anthropicthinkingbudget with a smallmax_tokens.Change
reply_reserve_within(reserve, max_tokens)incommon/thinking_budget.h: the reserve takes at most half ofmax_tokens. Withmax_tokens4096 on a 4096 card, the reply gets 2048 and thinking up to 2048.apply_request_reasoning(the phase-1 cap),prepare_generation_inputs(the single-request path) and the scheduler's admission. Each subtracted the full reserve on its own before.max_tokensabove twice the reserve (8192 on a 4096 card) are unchanged.docs/specs/thinking-budget.md§3.5, §4.4 and §5.3 describe the new reserve.Measured
Qwen 3.8 27B UD-IQ4_XS on the R9700, with its DFlash2 drafter:
reasoning_effort: high,max_tokens: 4096</think>)thinking.budget_tokens: 2048,max_tokens: 3000--hardmode(97 scenarios, seed 42) withreasoning_effort: highThe bench was measured on this change applied to
54132cac; after the rebase ontoaf91ead7the unit tests were rerun.Tests
test_reply_reserve_leaves_room_to_think: the helper, and the effort cap withmax_tokens1000, 150 and 100 on a 100-token reserve.test_server_unit: 1002 passed, 0 failed (HIP build). The change is host C++ only.🤖 Generated with Claude Code