Skip to content

qwen3.8-flash-next: ban the <tool_call> opener when a request declares no tools - #320

Merged
AzeezIsh merged 4 commits into
mainfrom
fix/qwen38-no-tools-ban-tool-call
Nov 3, 2026
Merged

AzeezIsh merged 4 commits into
mainfrom
fix/qwen38-no-tools-ban-tool-call

Conversation

@AzeezIsh

@AzeezIsh AzeezIsh commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Bug: a fresh chat sometimes gets literal tool markup as Qwen3.8-Flash-Next's first reply, e.g. <tool_call>\n</tool_call> or <tool_call>\n<function=web_search>\n<parameter=queries>….

This adds a [behavior] key, ban_tool_call_without_tools (default false), and ships it true for qwen3.8-flash-next. When a request declares no tools, the <tool_call> opener gets a -inf logit bias:

  • the same ban convention as min_tokens_ban;
  • not applied under --reference-mode;
  • covers chat, /v1/messages and /v1/responses, which all reach build_sampling.

Requests with tools are unchanged. vLLM doesn't do this; the MODEL.toml comment says so.

Test plan

  • spark-server bin tests 3047/0. clippy (with and without --tests) is clean.

  • 4 new tests:

    • no tools gets the ban;
    • tools declared gets no ban;
    • reference mode gets no ban;
    • a MODEL.toml guard on the shipped key.
  • Pair repro and fix on reiner + spark2 (TP=EP=2, FP4-Local, default sampling, 8 runs per shape). Receipts are in reiner's ~/code/night1027/out/tcrepro/ and tcban/.

    Runs whose reply contains literal tool markup, main vs this PR:

    request shape rc16: main → PR spark: main → PR
    no tools, tool-describing system prompt 8/8 → 0/8 6/8 → 0/8
    Open-WebUI JSON-in-system 1/8 → 0/8 0/8 → 0/8

    Native tools, streamed and blocking, give 8/8 clean tool_calls both before and after. tool_probe is 21/21.

  • What replies look like now. On rc16 the no-tools replies are short "I'll research…" texts, with the model pretending to look things up, since its system prompt claims it can. In spark mode they're full answers.

    • The real remedy for such clients is to send the tools natively.
    • What this fixes is the server no longer returning markup that no client can execute.
  • KL + bench gate against main (job 01094, running). Prompts without tools can only change where <tool_call> had probability mass.

Generated with Devin

AzeezIsh and others added 4 commits November 2, 2026 04:16
A request with no tools whose system prompt describes tool abilities —
clients without native function calling — made qwen3.8-flash-next answer
with literal <tool_call> markup nobody can execute (8/8 on rc16, 6/8 in
spark mode, job tcrepro). Banning the opener restores a prose answer.

- MODEL.toml [behavior] ban_tool_call_without_tools (default false),
  true on qwen3.8-flash-next. vLLM does not do this.
- sampling_setup pushes NEG_INFINITY on tool_call_start_token_id when
  !tools_active and the model opted in, off under --reference-mode.
  /v1/messages and /v1/responses reach the same code.
…g_setup

The no-tools <tool_call> ban (#320) put a -inf entry in logit_bias, and
any non-empty logit_bias took a sequence off the GPU-argmax and fast
verify paths (fast_greedy classify_penalties, raw_argmax_is_pick): decode
-1.7..-2.4% on every request without tools on the pair. Treat -inf
entries as hard bans: banned_ids masks them like the min_tokens end-token
ban (fix_raw_picks, mask_row), raw_pick_masked redoes a banned raw pick on
the host, and a bias of only hard bans keeps the fast paths. The floor
logic stays for the end-token ban only; F2 prepick keys on it alone.

sampling_setup.rs was 508 lines: its tool-choice and tool-bias rules move
to sampling_setup_tool_rules.rs unchanged.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…Behavior's Default

Owner decision: banning the <tool_call> opener on requests that declare no
tools is the default for every target (a MODEL.toml can still set it
false; --reference-mode never applies it). lib.rs was at the 500-line cap,
so ModelBehavior's Default impl moves to model_behavior_default.rs.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…l no steering bias

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@AzeezIsh

AzeezIsh commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Ready. The decode slowdown is gone.

What changed:

  • The ban is now a fast-path mask (4618224fa). A -inf logit_bias entry is masked like the min_tokens end-token ban (min_tokens_ban::banned_ids / fix_raw_picks, raw_pick_masked). A bias made only of such bans keeps the GPU-argmax and fast-verify paths, while any other bias still takes the host pipeline. Before, any non-empty logit_bias took a sequence off those paths (fast_greedy classify_penalties, raw_argmax_is_pick).
  • On by default for every target, as you decided (96a6ef8c0). A MODEL.toml can opt out, and --reference-mode never applies the ban. ModelBehavior's Default moved out of lib.rs, which was at the 500-line cap.
  • reference_prompt_tests now allows the hard ban on requests without tools, and still requires no steering bias (8ce09a823).

Pair gate on 4618224fa against its base 9c4519131, spark config (FP4-Local, TP=EP=2, reiner + spark2). Receipts are in ~/code/night1027/out/dap-ban-4618224fa/.

  • Decode: code 92.89 vs 92.63, json 71.15 vs 71.59, prose 61.20 vs 61.27 tok/s, ranges overlapping (n=6). The logit_bias version measured -1.7 to -2.4% with ranges apart.
  • C1/C2/C4 and TTFT at 2K to 28K are inside the base ranges.
  • KL: 6 of 34,245 positions move, max 5.8e-6. That's where the opener had probability mass, which is the intended effect. On rc16 with vision, top-1 is unchanged at every position.
  • rc16: greedy C1 and C8 8/8 identical to base, so the fast path is unchanged. Tools 21/21.
  • No-tools markup: fixed, 0/8 in both configs. That was measured on ebdce2013, whose sampled path is the same as this head's.

CI is green apart from the PR benchmark gate. 8ce09a823 differs from 4618224fa only in the default flip for other targets, the Default split and the test fix.

@AzeezIsh
AzeezIsh merged commit 0fa3dc7 into main Nov 3, 2026
26 of 27 checks passed
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.

1 participant