Repository navigation
[sgl-router] Render GLM-5.3 and GLM-5.3-Flash through sglang-processor - #43625
Merged
Merged
Conversation
sglang-processor renders GLM-5.3 (ChatFormatter::Glm53) as SGLang's Jinja path does: picked by its template like template_detection._is_glm53, with the template context _process_messages and _apply_jinja_template build, rendered by Dynamo's Jinja formatter. Media, a chat_template kwarg, apply_chat_template's own arguments as kwargs, and numbers serde_json prints unlike Python are left to the engine. sgl-router renders GLM-5.3 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]>
sherlockwu
force-pushed
the
kan/sgl-router-glm53
branch
from
October 11, 2026 17:48
cbf36a1 to
decde51
Compare
- Reserved template kwargs (apply_chat_template's own arguments) are checked after the server's defaults merge in, so a default chat_template or tokenize no longer renders a prompt SGLang would not. - History tool calls are dumped to ToolCall's fields, as Pydantic does; GLM's template reads tool_call_id before id when it pairs results with calls. - Tool schemas get _validate_request's in-place type normalization (varchar becomes string), for DeepSeek-V4 and V4.1 too. generate_parity.py now runs _validate_request, so fixtures see it. - dynamo-renderer 7.1.1 prints floats in tojson as Python does (ai-dynamo/frontend-crates#368), so only -0, which serde_json reads as -0.0, is left to the engine; the float known gaps are dropped. Co-Authored-By: Claude Opus 5.5 <[email protected]>
With the cookbook's glm45 reasoning parser the router now serves GLM-5.3 chats through the engine's /generate: think/ ports glm45 (Glm45Detector), and ChatModel.always_thinks carries template_detection's always-on reasoning for GLM-5.3's template, which require_reasoning and the reasoning split read. Lowering also accepts assistant thinking parts and tool_reference parts. A chat with tools under glm47 keeps the engine's own route, with the router's input_ids: SGLang constrains it with a grammar flagged ebnf_full_assistant, which /generate's API (proto/sglang/api/v1/sampling.proto) does not accept. openai_parity/glm-5.3.json records SGLang's handler on hand-written GLM-5.3 outputs; generate_openai_parity.py loads a Jinja checkpoint's TemplateManager. The processor-model-parity skill states the goal: every text request works, and chat and completions go through /generate. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…o the engine - The template strips assistant content. Python's str.strip also strips U+001C..U+001F, the only characters Python counts as whitespace and Rust does not; minijinja's strip keeps them, so such content renders on the engine. - apply_chat_template iterates a documents kwarg and rejects a non-dict item, so documents that are not a list of objects (or an empty string or object) are rejected, as SGLang rejects them, instead of rendering. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hanged generate_openai_parity.py records always_thinks only when it is set, so the DeepSeek OpenAI fixtures stay as on main. The U+001C..U+001F workaround names its retirement condition, ai-dynamo/frontend-crates#395. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The base <think> splitter and the generic OpenAI layer are covered by the DeepSeek fixtures, so glm45's reasoning cases cover the tool-call boundary and the GLM-5.3 OpenAI cases cover the reasoning split, continuation, and lowering (lower_only), plus the requests that stay on the engine's route. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-only The generator's stub reports every checkpoint as text-only, so a media case records SGLang's text-only rejection even for multimodal checkpoints (DeepSeek-V4.1-Flash, GLM-5.3-Flash). That matches the processor's policy: render_request fails on media parts and hosts leave those chats to the engine. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The processor's ported `glm45` detector needs the reasoning state the template sets, as Python's does; Dynamo's parser, which the server used before, split an output without an opening `<think>` on its own. GLM-5.3 prefills `<think>`, so the server forces it as it already did for DeepSeek-V4 when the prompt ends in `<think>`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 1/3, merge in order: #43625 (GLM-5.3) → #43608 (Kimi-K3) → #43689 (Qwen3.8). This PR is based on
main.Adds GLM-5.3 and GLM-5.3-Flash to sglang-processor. The router renders them, so every text chat forwards the
input_idsSGLang would build, and chats without tools are served through the engine's/generate. Follows #43000.Modifications
render/models/glm53.rs): picked by the template, as_is_glm53does. It builds the template context SGLang's Jinja path builds (Pydantic dumps of messages, history tool calls and tools,_validate_request's schema-type rewrite, kwargs over effort and server defaults) and renders it with Dynamo's Jinja formatter.chat_templatekwarg,-0, and U+001C..U+001F in assistant content (until fix(renderer): strip and split with Python's whitespace in HF templates ai-dynamo/frontend-crates#395). Kwargs SGLang rejects (apply_chat_template's own arguments, invaliddocuments) are rejected here too./generate: ports theglm45reasoning parser, addsChatModel.always_thinks, and accepts assistant thinking andtool_referenceparts. Withglm47, chats with tools stay on the engine's route, still with routerinput_ids./generatemust acceptebnf_full_assistantbefore tool requests can go through the/generatepath; SGLang constrains them with a grammar flagged that way.tojson._validate_requestand load a Jinja checkpoint'sTemplateManager.processor-model-parityskill now states the goal: all text works, and chat and completions go through/generate.Checks
GLM-5.3@aca966e,GLM-5.3-Flash@eb9eb20), generated with transformers 5.19.0. Each matches SGLang's prompt text and token ids or is rejected as SGLang rejects it, except 3 known gaps left to the engine. The DeepSeek fixtures still pass with token ids.openai_parity/glm-5.3.json(SGLang's handler on hand-written GLM outputs) andreasoning_parity/glm45.json./generate: 20 chats. The engine logged the sameGenerateReqInputfor each as when sent directly, and the responses are identical, except two cases that vary between direct runs too (sampling, a 9.8k-token prompt).cargo test,clippy -D warningsand the pre-commit hooks pass.CI States
Latest PR Test (Base): 🚫 Run #38364917377
Latest PR Test (Extra): ❌ Run #38364916866
Latest PR Test (AMD ROCm 10): ➖ No AMD PR run found for this commit.