Skip to content

Reject unsupported thinking budgets before submission - #649

Merged
ashhart merged 1 commit into
ashhart:mainfrom
akol1:fix/thinking-budget-admission
Oct 12, 2026
Merged

ashhart merged 1 commit into
ashhart:mainfrom
akol1:fix/thinking-budget-admission

Conversation

@akol1

@akol1 akol1 commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Problem

Serial-host engines do not enforce thinking budgets. A positive request or configured budget can otherwise reach submission or be silently omitted when the tokenizer lacks a closing marker.

Change

  • Add an engine capability for thinking-budget enforcement; existing lane engines retain their supported behavior, serial hosts explicitly report unsupported.
  • Reject an effective positive budget with HTTP 400 while thinking is enabled, before opening a stream or submitting to the engine.
  • Preserve zero/unset inheritance of the configured server budget and thinking-disabled behavior.
  • Document admission and add route regressions for request/configured budgets, whole/streamed refusals, no-close-marker tokenizers, supported admission, and zero/unset/disabled boundaries.

Verification

Base: a6aa4782 (upstream main). Zig 0.17.0, macOS arm64.

  • Native build and golden check passed; after correcting the reasoning fixture, zig build test -Dcpu=apple_m1 passed.
  • Golden corpus: 309/319 equal, 10 existing known differences, 0 unexpected differences.
  • Throwaway HTTP server using the real server routes and a deterministic engine reporting unsupported budgets: positive budget + thinking + streaming returned HTTP 400 JSON without SSE; zero budget returned a completed HTTP 200 SSE stream; thinking disabled with a positive budget returned HTTP 200 and the expected answer.
  • Lean checker: 542 inherited findings at the pinned base and candidate; zero added findings.

Limits and publication scope

Admission is the changed contract; the controlled engine does not qualify model-side budget enforcement. Six files, no new model dependency, checkpoint fixtures, generated binaries, or runtime artifacts. Public noreply commit identity; publication trees and outgoing metadata checked for private markers.

@ashhart

ashhart commented Oct 12, 2026

Copy link
Copy Markdown
Owner

Thank you, @akol1. This landed in 1.0.8 as your own commit (523de7aeb), rebased onto our 1.0.8 work; the only conflict was the CHANGELOG. Your head commit is merged into the history unchanged (b608200ef), so GitHub shows this PR as merged.

We looked at which engines it touches. The capability defaults to on and only the serial host turns it off. In this release every served model runs on the lane host (Nemotron, Qwen3.5, Qwen3.8-27B and GLM on Macs, and every CUDA family), which enforces budgets inside its rounds, or on Flash Next's own host, and the serial host is built only into test programs. So no served model changes behaviour today, and we checked that it doesn't: on Nemotron 3.5 Lightning (MLX 4-bit, M5 Max), a 24-token budget closed the reasoning at its 24th token with the same tokens as the build without your PRs, drafted, "draft": false and streamed, and a request without a budget matched too.

To see the refusal on a real model we built a gate-only copy (never committed) whose Nemotron lane host reports no budget support:

request result
thinking_budget: 24, whole 400, "thinking_budget is not supported by this native engine"
thinking_budget: 24, streamed the same 400 as JSON, no SSE event
/v1/messages with thinking.budget_tokens: 1024 the same 400
--thinking-budget 64, field absent the same 400
--thinking-budget 64, field 0, streamed the same 400
budget 0, or no budget 200, the normal build's tokens
thinking off with a budget 200

Across every refusal, none of the engine counters in /metrics moved (prompt, cached and generated tokens, rounds, prefill seconds, cache queries), so the request never reached the engine.

This PR also brought a gap to light: Flash Next's host never read the budget, so a Flash Next request with a budget ran without one. That's fixed in 1.0.8 too (e7f5951eb). A request's thinking_budget, thinking.budget_tokens on /v1/messages, or --thinking-budget now ends Flash Next's thinking at the budget, with the chat template's close (\n</think>\n\n) and then the answer. The close lands inside a drafted window, so drafting stays on, and replies under a budget equal "draft": false token for token, whole and streamed. On an M5 Ultra with the 6-bit checkpoint and thinking on, a 64-token budget gave 65 reasoning tokens, counting </think>, on the three of four prompts that think longer, each followed by its answer. Replies without a budget, or with 0, are the same tokens at the same speed. #701 reported the same gap with a repro: 136 reasoning tokens under a 32-token budget, 33 now.

Thanks for writing the tests at the route level, with the submission count beside the client's view. That made it easy to see the refusal lands before anything opens.

BobClawblaw pushed a commit to BobClawblaw/TensorFold that referenced this pull request Oct 12, 2026
@ashhart ashhart mentioned this pull request Oct 14, 2026
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
The change landed rebased onto the 1.0.8 candidate as 9532f2056 with its author kept; this keeps the PR's head in the history with no change to the tree.
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
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