Repository navigation
[Feat] sgl-router: Render Qwen3.8 (Max, 27B, Flash-Next) through sglang-processor - #43689
Merged
Merged
Conversation
sherlockwu
force-pushed
the
kan/sgl-router-qwen38
branch
from
October 11, 2026 17:49
595a22e to
1098847
Compare
This was referenced Oct 11, 2026
sherlockwu
force-pushed
the
kan/sgl-router-qwen38
branch
from
October 13, 2026 07:07
1098847 to
713de89
Compare
sherlockwu
force-pushed
the
kan/sgl-router-qwen38
branch
from
October 13, 2026 07:14
713de89 to
00230df
Compare
sherlockwu
force-pushed
the
kan/sgl-router-qwen38
branch
from
October 13, 2026 08:06
fd51a31 to
6082a09
Compare
ShangmingCai
force-pushed
the
kan/sgl-router-qwen38
branch
from
October 14, 2026 07:09
6082a09 to
f82ea4c
Compare
…cessor sglang-processor renders Qwen3.8 (ChatFormatter::Qwen38) as SGLang's Jinja path does: picked by its template, with the template context _process_messages and _apply_jinja_template build (pydantic dumps of messages, tools and tool calls, content in the template's content format, kwargs over the effort, server defaults), rendered by Dynamo's Jinja formatter. A later system turn fails as the template makes it fail, where Dynamo would demote it. Media, a chat_template kwarg, and text or numbers Python's trim or json.dumps treat unlike Dynamo's are left to the engine. sgl-router renders Qwen3.8 through the processor, so every text chat forwards input_ids. The parity generator now renders through _process_messages with SGLang's TemplateManager, records a Jinja checkpoint's template, and takes per-case server default kwargs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Dump each tool's `type` as sent: `Tool.type` is any string, and the template prints it, where the shared normalizer always wrote "function". - Check reserved kwargs after the server defaults merge in, as GLM-5.3 does: a default `tokenize` or `tools` fails `apply_chat_template`. - Reject `documents` that do not iterate as dicts, as `render_jinja_template` does (GLM-5.3's `valid_documents`). - Regenerate the three fixtures on the rebased generator. SGLang now rejects a request `chat_template` kwarg and, serving the checkpoint text-only, an image part, so both gaps are closed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- think/: `qwen3` (`Qwen3Detector`), the base detector over `<think>` with `<tool_call>` ending the reasoning. - tool_call/: `qwen3_coder` (`Qwen3CoderDetector`), streaming and one-shot. Argument values are typed by the request's tool schemas as `_convert_param_value` types them (`int()`, `float()`, `json.loads`, and the JSON-like subset of `ast.literal_eval`); literals `json.dumps` cannot serialize stay strings, where Python fails the call. Tool detectors now take the request's tools rather than their names, and the parser stream gives an id and name only to a named call item. - openai/: `ChatModel.reasoning_toggle` carries the template's toggle (`enable_thinking`, on by default for Qwen3.8), which `_get_reasoning_from_request` reads before the parser's default. - sgl-router sets it from the formatter, so with the cookbook's `qwen3` and `qwen3_coder` parsers Qwen3.8 text chats are rendered, tokenized and parsed by the router and sent to the engine's /generate. - Fixtures from SGLang's Python: reasoning_parity/qwen3.json, tool_parity/qwen3_coder.json (44 outputs, 49 chunkings), and openai_parity/qwen3.8-27b.json (13 cases recorded on a live Qwen3.8-27B engine). The OpenAI-parity generator drops unread meta keys before encoding stream deltas, since this engine sends `response_sent_to_client_ts` on the first frame only. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- sglang-server: the ported `qwen3` detector needs the reasoning state the template sets, as Python's does, where Dynamo's parser split an output without an opening `<think>` on its own. The server already forced it for DeepSeek-V4 when the prompt ends in `<think>`; Qwen3.8's prompt does too, with a newline. - `parallel_tool_calls=false` kept only a choice's first call item, which for `qwen3_coder` is the name alone. The response processor and the server's stream now keep every item of the first call index. - `qwen3_coder`: `int()` and `float()` read Unicode decimal digits (`123`, `١٢.٥`), and a sign takes a parenthesized number (`-(1)`), as in Python. tool_parity covers both. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…izer does - Blank and comment-only lines around a literal argument are skipped, at any indentation, as Python's tokenizer skips them; a last line of bare spaces is still an `IndentationError`. - Hexadecimal, octal and binary integers keep arbitrary precision, as decimal ones did. `int()` and decimal literals stop at Python's 4300-digit limit, and values `json.dumps` cannot print past it stay strings. tool_parity covers comment lines, 129-bit and larger radix literals, and the digit limit. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
sherlockwu
force-pushed
the
kan/sgl-router-qwen38
branch
from
October 14, 2026 07:48
04d2d3e to
21a0e8d
Compare
2 tasks done
ShangmingCai
added a commit
that referenced
this pull request
Oct 14, 2026
…main The fixture from #43689 was recorded before #43027, so its responses still carried `"tool_calls": null`, which this branch now omits like Python does. Regenerated with tests/scripts/generate_openai_parity.py from main's Python at the pinned revision, replaying the recorded engine output. Besides the dropped `tool_calls`, only `created`/tool-call ids change and the defaults pick up `watermark` (#37577) and `return_flat_raw_output_top_logprobs`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
3 of 5 tasks
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.
Note
Stack 3/3, merge in order: #43625 (GLM-5.3) → #43608 (Kimi-K3) → #43689 (Qwen3.8). This PR is based on #43608 (
kan/sgl-router-kimi-k3), so its diff shows only the Qwen3.8 commits. After the PRs below merge it gets rebased ontomain.Adds Qwen3.8 to sglang-processor and serves it from sgl-router end to end: Qwen3.8-Max (
Qwen/Qwen3.8-2.4T-A95B), Qwen3.8-27B and Qwen3.8-Flash-Next. With the cookbook'sqwen3andqwen3_coderparsers, the router renders, tokenizes and parses every text chat and talks to the engine through/generate.Modifications
Render:
ChatFormatter::Qwen38(render/models/qwen38.rs), picked infrom_tokenizer_configby its template. SGLang renders Qwen3.8 withapply_chat_template(no encoding spec), so the processor builds the template context_process_messagesand_apply_jinja_templatebuild and renders it with Dynamo's Jinja formatter:Tool.typeas sent,Tool's nulldefer_loading,FunctionResponse's nullarguments);documentsare checked after the defaults merge in, as for GLM-5.3.Where Dynamo departs from Python, the processor fails rather than render differently, so hosts leave the chat to the engine: a later system turn (Dynamo demotes it, the template raises), media, text whose
trimdiffers (U+001C..U+001F), and numbers serde_json prints unlike Python.Parsing:
think/models/qwen3.rs:Qwen3Detector, the base detector over<think>with<tool_call>ending the reasoning.tool_call/models/qwen3_coder.rs:Qwen3CoderDetector, streaming and one-shot. Argument values are typed by the request's tool schemas as_convert_param_valuetypes them (int(),float(),json.loads, and the JSON-like subset ofast.literal_eval). Tool detectors now take the request's tools rather than their names, and theparserfeature's stream gives an id and name only to a named call item, as Python does.qwen3starts in reasoning when the prompt ends in a prefilled<think>(as it already did for DeepSeek-V4), andparallel_tool_calls=falsekeeps every delta of the first call, whichqwen3_coderstreams as a name and argument fragments (the response processor too).ChatModel.reasoning_toggle: the template's toggle (enable_thinking, on by default for all three checkpoints), which_get_reasoning_from_requestreads. The template prefills<think>\n, so this decidesrequire_reasoningand the forced reasoning split.Router: renders Qwen3.8 through the processor, so every text chat forwards
input_ids(AllText), and with the cookbook's parsers lowers it to/generate.required, named and strict tool choices, media andsglextfields such asreturn_meta_infokeep the engine's route.Left as known differences, where Python itself fails or the case is out of reach:
json.dumpscannot serialize (sets, bytes, complex numbers) stay strings; Python drops the call in unary responses and raises mid-stream;\N{...}escapes and lone surrogates in literal-typed arguments stay strings.Checks
Render: 136 cases per checkpoint match SGLang's prompt text and token ids at the pinned revisions; 5 per checkpoint are
known_gaps the processor leaves to the engine (trim separators, exponent floats, huge integers).Parsers (fixtures from SGLang's Python):
reasoning_parity/qwen3.json(88 cases) andtool_parity/qwen3_coder.json(45 outputs, 50 chunkings, covering schema typing, Unicode decimal digits, Python-literal fallbacks including parenthesized signed numbers, the 200-bracket nesting limit and key merging, truncation, marker splits). A throwaway randomized comparison also matched Python on 60,000 typed values and 50,000 chunked streams (apart from an empty function name, which is served identically).OpenAI layer:
openai_parity/qwen3.8-27b.json, 13 cases recorded fromOpenAIServingChatagainst a live Qwen3.8-27B engine (thinking on/off/effort, truncation, continuation, tools with and without thinking, typed arguments, unary and streaming,tool_choice: none, andrequiredleft to the engine); generic OpenAI-layer behavior is covered by the other models' fixtures and the live run below: the/generatebody and the OpenAI response match.Live, Qwen3.8-27B on one B300 (cookbook GB300 BF16 cell with its default overlays, plus
--log-requests-level 3); each chat was sent to the engine directly and through the realsgl-routerbinary, flushing the cache before each:/generateGenerateReqInputon thosereasoning_effort=low, greedy)/generateThe two differing responses are a seeded-sampling request that also varies between runs on the engine alone, and an
n=2stream whose choices interleave differently with the same per-choice text. The 11 chats on the engine's route arerequired/named/strict tools, an image, and rejected requests, which return the same 400 on both paths.cargo test,cargo clippy --all-targets -- -D warningsandcargo fmt --checkpass forrust/andexperimental/sgl-router, as docargo check -p sglang-processor --no-default-features --features render,tokenizerand--features render,openai.CI States
Latest PR Test (Base): 🚫 Run #38530778150
Latest PR Test (Extra): ❌ Run #38530778201
Latest PR Test (AMD ROCm 10): ➖ No AMD PR run found for this commit.