Feat: Enable structured output in Mini-SGLang - #115
Open
YzXiao101 wants to merge 13 commits into
Open
Conversation
YzXiao101
marked this pull request as draft
April 2, 2026 01:47
YzXiao101
force-pushed
the
feat/structured_output
branch
from
April 4, 2026 05:07
d9bdb56 to
90c978b
Compare
YzXiao101
force-pushed
the
feat/structured_output
branch
from
April 4, 2026 16:22
90c978b to
e40888c
Compare
YzXiao101
force-pushed
the
feat/structured_output
branch
from
April 11, 2026 07:34
7f8b30d to
d078a9f
Compare
YzXiao101
marked this pull request as ready for review
April 12, 2026 13:45
YzXiao101
force-pushed
the
feat/structured_output
branch
from
May 10, 2026 16:10
073590b to
501574c
Compare
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.
Motivation
Mini-SGLang lacked structured output and reasoning-model-aware constrained decoding.
Description
Adds OpenAI
response_format.json_schemasupport with XGrammar, async grammar compilation, constrained decoding, scheduler/TP integration, and reasoning-model support.Callout
Initial JSON-schema structured output support only.
response_format={"type":"json_schema", ...}is supported.xgrammar==0.1.27.Test & Performance
Benchmark config:
NousResearch/json-mode-eval100; filtered benchmark requests:94max_tokens:4096temperature=0.0,top_k=1)MINISGL_TORCH_NUM_THREADS=1nvidia-smi):Qwen/Qwen2-0.5BQwen/Qwen2-0.5BQwen/Qwen2-1.5BQwen/Qwen2-1.5BQwen/Qwen2-7BQwen/Qwen2-7BNotes:
max_tokens=4096cases.Performance Analysis
Nsight profile:
Qwen/Qwen2-0.5B,100samples,max_tokens=4096, CUDA graph enabled, overlap scheduling enabled.Samplertotalapply_grammar_maskfill_vocab_maskmove_apply_vocab_maskObvious bottleneck: CPU-side XGrammar mask filling.
Checklist