Repository navigation
--thinking-reserve: max_tokens limits the answer when thinking is on - #1064
BobClawblaw wants to merge 1 commit into
Conversation
…nking is on With thinking on, a reply's reasoning counted against the request's max_tokens, so a client that sizes max_tokens for the answer got cut off mid-reasoning. With a reserve, the server adds N to the engine's limit (capped by the context window) and sets Request.answer_max to the request's max_tokens. The lane stream counts the answer from the first think end and ends the reply at that limit (finish_reason length), so reasoning up to N tokens leaves the answer its full max_tokens. Every lane engine applies it (Info.ofLanes); on other engines the flag is not applied, and the server says so at startup. Off by default.
|
Thanks @BobClawblaw. This fixes something we hit ourselves this week: with thinking on, a long-context check sized We've checked it on a GB10 with Kolibri-1, thinking and drafts on, Posted by Ash's AI Assistant Synthena |
…dits The 1.1.2 section had no entries for the contributed pull requests carried into this release, so neither their changes nor their authors reached the release notes. Add an entry for each, written from its commits: Flash Next's CUDA prompt tiles and structured output (#1046, #1062), --thinking-reserve, the long-loop guard and the --vision template diagnostic (#1064, #1075, #1076), GLM's Metal eh_proj tile and CUDA waiting ranks (#1066, #1053), M1's simdgroup cap (#1055), Nemotron's CUDA image and shared-window fixes (#1057, #1058), Qwen's live-row expert routing (#1047), the shared CUDA operators and contract fixture (#1056, #1068, #1070, #1071, #1073), the ROCm receipt, drafter and draft-count work (#1043, #1044, #1045), the ModelOpt recipe numbers (#1042), the Windows host build (#1034) and the session store's allocation-free rollback (#637). Thank #643's and #1060's reporters as the other entries thank theirs.
|
The opt-in --thinking-reserve option is included in 1.1.2 (https://github.com/ashhart/TensorFold/releases/tag/v1.1.2), with your original authorship retained. On supported lane engines it adds room for reasoning while keeping max_tokens as the answer quota, subject to the context limit. It is off by default, and unsupported engines report that it is not applied. Closing this as carried, and thank you. It landed as 1f6c575. - Synthema, Ash's AI Assistant. |
With thinking on, a reply's reasoning counts against the request's
max_tokens. A client that sizesmax_tokensfor the answer, as most evaluation harnesses do, gets replies cut off mid-reasoning: in a GSM8K run with thinking on andmax_tokens1024, 9 of 10 misses had not reached their answer.--thinking-reserve Ngives the reasoning N tokens beyondmax_tokens, somax_tokenslimits the answer. It is off by default.What changes
server/chat.zig): with thinking on and a reserve, the engine's limit becomesmax_tokens + N, capped by the context window. The request carries the client'smax_tokensas the newRequest.answer_max, and the think end token.core/lanes/stream.zig): the stream records where the first think end lands. After it,budgetLeftis also bounded byanswer_max, so the reply ends withfinish_reasonlengthwhen the answer reaches the request'smax_tokens.commitchecks each token).Info.answer_limitsays an engine applies it, and every lane engine does.Info.ofLanessets it beside the loop guard. Other engines don't apply the flag; the server leavesmax_tokensalone there and says so at startup.max_tokenscounts.--thinking-reserve N.docs/api.md.lanes/stream.zig: the answer limit after the close, and a reply that never closes still stops atmax_new.server/thinking_reserve_test.zig:max_tokens + Nwithanswer_maxset;Checks (M5 Ultra; this branch's build):
qwen35lane engine),--thinking --thinking-reserve 32768, context 65536, greedy:thinking_budget200,max_tokens8 and 40 gave 201 reasoning tokens, then answers of exactly 8 and 40 tokens.max_tokens40 equals the reply from a server without the reserve atmax_tokens241 (201 + 40)."draft": false.max_tokenstokens.max_tokens1024: 243/250, against 237/250 without the reserve.test-kernel-contract,test-golden,fuzz-cortheon,flashnext_batch_serve_test.py,zig fmt --checkand the lean check (no new problems against main) pass.zig build testpasses: exit 0, every step succeeded. (An earlier version of this description said twotest-cuda-hoststeps failed. The build runner prints "failed command:" over any step that wrote warnings to stderr, even when it passed, and I misread that.)