Skip to content

api: SparkQwen 0.4.0 shared API fixes and defaults (errors, refusal content, unset max_tokens, effort default; ported from Enntity) - #285

Merged
AzeezIsh merged 20 commits into
mainfrom
port/sq-api
Oct 31, 2026
Merged

AzeezIsh merged 20 commits into
mainfrom
port/sq-api

Conversation

@AzeezIsh

Copy link
Copy Markdown
Contributor

Summary

SparkQwen 0.4.0's shared API fixes. Ported from Enntity (AGPL-3.0, data-angel):

  • refusal metadata keeps the content (be67bd5ca);
  • a cancelled queued stream leaves the queue (2b1c81282);
  • the admission-hold log names what held a request (bed416e9d);
  • /v1/messages forwards client errors as invalid_request_error (f93387ab6);
  • Responses API errors name input (0169faf6b);
  • a per-request TTFT trace (0f58f7a4b, ATLAS_TTFT_TRACE=1, off by default).

Two shared default changes that affect every model (flagging for review):

  • ebd9feba2: a request that leaves reasoning effort unset gets the template's own default, via [behavior].default_reasoning_effort.
  • 1349e8f19: chat and Responses requests without max_tokens get the rest of the context instead of 4096. This is vLLM's behaviour. /v1/completions keeps 4096.

060199ebc (Anthropic error types) was already on main.

Test plan

  • spark-server bin tests 2902/0. clippy (with and without --tests) is clean.
  • Against SparkQwen 0.4.0's engine on its spark config, error shapes and logprobs are identical: lp_api_probe.py 13/13 (7 malformed requests across chat, messages and responses), api_parity.py 26/26.
  • rc16: C1 and C8 greedy identical to the parent.

Generated with Devin

data-angel and others added 19 commits October 31, 2026 04:19
Keep the full blocking assistant answer when the heuristic refusal classifier matches, consistent with streaming. Retain refusal annotations, tool-call gating, and finish reasons. Add production assembly/serialization and streaming regressions; update the compatibility expectation. Reported in #172.

(cherry picked from commit be67bd5)
queued_first::abandoned caught a streaming client that went away but not
one that cancelled (cancel_flag), so a cancelled queued prompt still ran
its first chunk. Test: a cancelled queued stream is freed with no chunk
command.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 2b1c812)
… only

The INFO line for requests left pending said they waited for a batch slot
even when the scheduling policy had admitted fewer than the free slots for
its own reasons. admission_hold tells the two apart (every free slot taken,
or the policy admitted fewer) and logs a change of (held, reason) only. The
on-change state stays process-wide, as before: one scheduler loop runs per
process; the module says so. Test: the two holds are told apart.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit bed416e)
The messages handler re-shaped every non-success outcome as `api_error`, so
an Anthropic client saw the over-limit vision 400 (and every other 4xx) as a
server fault. It now forwards through `openai_error_to_anthropic`, which
count_tokens already used: the status is kept and a client error is an
`invalid_request_error`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit f93387a)
The chat layer names a message-borne error's field `messages` (an
over-limit vision request); on /v1/responses that field is `input`. Both
Responses paths now rewrite it, keeping the status and headers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 0169faf)
One TTFT_TRACE line per request on the tick its first token leaves:
queue wait, admission cohort, setup, prefill submit, prefill sync (to the
first sampled token), gap to the decode dispatch that emitted the first
visible token (a spontaneous <think> is not streamed), that step's wall
time and the total from queue arrival. Host timestamps only; disarmed
every hook is one OnceLock load.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 0f58f7a)
…fault

With no reasoning_effort from the client or --default-chat-template-kwargs
the render now leaves the variable undefined while thinking is on, as
transformers and vLLM do, so the checkpoint template's default applies
(Qwen3.8: xhigh). The "medium" fallback (2026-08-15) was a cross-template
policy hidden in chat_render; a target that wants it says so in MODEL.toml
[behavior].default_reasoning_effort, folded below the CLI default and
template-side only (the thinking budget stays the model's, as before).
The three Qwen3.8-27B targets and strix-hip Qwen3.8-Flash-Next pin
"medium", so their prompts are unchanged. Mistral's override (unset =
high = medium's mapping) and GLM's (unset = max = medium's) render the
same bytes either way; Qwen3.5/3.6 never read the variable. An unknown or
"none" value fails the boot.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit ebd9feb)
…the context

vLLM's OpenAI server caps an unset max_tokens at max_model_len - prompt;
Atlas capped it at 4096, so a template-default (xhigh) reasoning turn could
end at "length" mid-think. ChatCompletionRequest / Responses now default to
ir::MAX_TOKENS_UNSET, which the chat handler resolves to max_seq_len minus
the prompt (ir::resolve_max_tokens) as soon as the prompt is tokenized; a
client's own cap stands, and /v1/completions keeps its 4096.

KV admission is unchanged: it reserves the resolved cap (honest, no
preemption). A pool smaller than max_num_seqs full contexts queues the
excess; ATLAS_KV_ADMIT_WATERMARK lets it overcommit instead, with
decode-time preemption resuming the victims.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 1349e8f)
… refusal fixture takes the current AppState/InferenceResponse shape
@AzeezIsh
AzeezIsh changed the base branch from port/sq-spec-logprobs to main October 31, 2026 23:03
@AzeezIsh
AzeezIsh marked this pull request as ready for review October 31, 2026 23:03
@AzeezIsh
AzeezIsh merged commit 7199611 into main Oct 31, 2026
21 of 22 checks passed
@AzeezIsh

AzeezIsh commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

GB10 single-Spark confirmation (sparky, post-merge): this PR was gated as part of integ/train-2026-10-31 (#285 + #284 + #287 + #290 + #293 + #294 + #286 on main 170c3ed) against main at the same base, FP4-Local default recipe profile:

  • controls: FP4-Local byte-identical, Flash-Next NVFP4 byte-identical.
  • BFCL ST-995: train 87.54 / 85.94 (run-1793488879414911145) = base 87.54 / 85.94 (run-1793503255896245487); all 15 subsets identical.
  • agentic-webserver 50: train 47/50, 10.80 s/turn (run-1793478986972058487) vs base 47/50, 10.67 s/turn (run-1793493326878881549). The same 3 iterations (0, 18, 27) fail on both arms ("no Cargo.toml was written"), so that comes from main, not this train. Investigating separately.
  • spark-server tests 3002/0; 0 serve errors.
    Campaign log: docs: FP4-Local post-merge campaign log (2026-10, sparky) #211.

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