-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
[Frontend] Support guidance:no-additional-properties for compatibility with xgrammar #15949
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
russellb
merged 4 commits into
vllm-project:main
from
tjohnson31415:guidance-addl-props
Apr 23, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ee73460
refactor: have v1 backends handle their options
tjohnson31415 64305c8
support guidance:no-additional-properties
tjohnson31415 fe7c77f
refactor how supported guided backends are checked
tjohnson31415 65d96e0
feat: allow guidance backend for V0
tjohnson31415 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to limit recursion depth to some reasonable amount here since it's processing untrusted user input. It could be abused to crash a vllm instance by causing excessive recursion depth. Google says the default recursion depth limit is 1000-ish, so that would be pretty trivial to exploit.
Or we can catch
RecursionError
and handle it cleanly, I suppose ... but a reasonable hard limit seems safer.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, good point. I wonder where else a deeply-nested JSON guide could break vllm. Guarding against / limiting the depth of the guide JSON seems like something that should be handled consistently across backends/options higher in the stack.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I generated a deeply nested JSON schema and ran some tests. vLLM V1 actually handles the
RecursionError
and doesn't crash; the result is just a 400 or 500 back to the request. There's a few ways that it manifests:RecursionError
is raised during chat templating whentojson
is called in the templatehas_xgrammar_unsupported_json_features()
ValueError
is raised fromvalidate_guidance_grammar()
which callsserialize_guidance_grammar()
but doesn't set any options so it doesn't hit it from the new codeHowever, the V0 engine does crash when using
v1/completions
. In addition to the new recursion withguidance:no-additional-properties
, there areRecursionError
raised in calls tohas_*_unsupported_json_features()
that can crash it.So I don't think adding recursion here makes anything worse. IMO, there can be a follow-up PR to limit the depth of the JSON schema in one place.