Conversation
15 tasks
Ubospica
marked this pull request as ready for review
July 30, 2026 15:38
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.
改动内容
这个请求优化大型结构标签语法的编译。结构标签语法是把“可调用函数名”和“函数参数的 JSON 数据结构规则”组合成生成约束的语法。
性能结果
测试对象是固定的 400 函数结构标签语法,使用 Qwen3 词元表、发布构建和 8 个固定处理器核心。
本请求原有结果
以下两项只统计语法转换和状态图构造,不包含同一次调用中的词元掩码预计算,因此不能与完整编译时间混用:
92.170 ms,llguidance 为120.977 ms,快23.8%。llguidance 是另一个生成约束实现,这里作为对照。90.472 ms,llguidance 为121.391 ms,快25.5%。新增的工作线程局部结果表
单独移除这项优化后再比较,它在大型结构标签的完整编译中将
213.632 ms降至194.677 ms,降低8.9%。另外三种较小或不同类型输入没有稳定收益,最差为小型结构标签增加8.2%;因此这项优化主要针对大型结构标签。这项优化与单独请求 #783 的“跳过重复结构标签规范化”组合后,旧实验记录中的完整编译中位数为:
143.810 ms151.295 ms组合后的 XGrammar 快
4.95%。该结果使用 15 个稳定样本;它是两个请求的组合结果,不是这个请求单独达到的结果。正确性验证
39项通过。1024项通过。11项通过,9项跳过。9项通过,12项跳过。20项通过,21项跳过。跳过的测试需要额外下载受访问限制的模型词表;本次改动不涉及这些模型。