Skip to content

[Bugfix] validate grammar and throw 400 error instead of crashing the engine when xgrammar validation fails #17623

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
merged 12 commits into from
May 12, 2025

Conversation

Jason-CKY
Copy link
Contributor

@Jason-CKY Jason-CKY commented May 4, 2025

API server crashes when xgrammar receives an invalid grammar when the guided_decoding_backend is set to auto. This can be triggered via an invalid json schema, regex, or EBNF grammar. This is due to the assumption that any validation error raised by xgrammar is due to the unsupported json schema features, and backend is reverted to guidance without further validation checks.
The fixes added an additional guidance validation check if the xgrammar validation fails to catch invalid grammar specifications before trying to compile the grammar.

FIX #17248
FIX #17313

Copy link

github-actions bot commented May 4, 2025

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

🚀

@Jason-CKY Jason-CKY force-pushed the validate-guidance branch from 0015e0b to f8bbc08 Compare May 4, 2025 05:27
Signed-off-by: Jason Cheng <[email protected]>
@Jason-CKY
Copy link
Contributor Author

@russellb

Copy link
Member

@russellb russellb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I'm good with this as long as the added tests pass CI (I will kick off the full run now)

@russellb russellb enabled auto-merge (squash) May 7, 2025 17:43
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label May 7, 2025
@russellb russellb moved this to In review in Structured Output May 7, 2025
@russellb russellb self-assigned this May 7, 2025
@russellb russellb added this to the v0.9.0 milestone May 7, 2025
@Jason-CKY
Copy link
Contributor Author

Hi can i get some help on the failing CI jobs?

auto-merge was automatically disabled May 11, 2025 02:53

Head branch was pushed to by a user without write access

@Jason-CKY
Copy link
Contributor Author

@russellb i have fixed the erroneous test cases, the added CI tests have passed now.

@DarkLight1337 DarkLight1337 merged commit 08bf784 into vllm-project:main May 12, 2025
59 checks passed
@github-project-automation github-project-automation bot moved this from In review to Done in Structured Output May 12, 2025
RichardoMrMu pushed a commit to RichardoMrMu/vllm that referenced this pull request May 12, 2025
… engine when xgrammar validation fails (vllm-project#17623)

Signed-off-by: Jason Cheng <[email protected]>
Co-authored-by: Russell Bryant <[email protected]>
Signed-off-by: Mu Huai <[email protected]>
mawong-amd pushed a commit to ROCm/vllm that referenced this pull request May 14, 2025
… engine when xgrammar validation fails (vllm-project#17623)

Signed-off-by: Jason Cheng <[email protected]>
Co-authored-by: Russell Bryant <[email protected]>
zzzyq pushed a commit to zzzyq/vllm that referenced this pull request May 24, 2025
… engine when xgrammar validation fails (vllm-project#17623)

Signed-off-by: Jason Cheng <[email protected]>
Co-authored-by: Russell Bryant <[email protected]>
Signed-off-by: Yuqi Zhang <[email protected]>
@hibukipanim
Copy link

Note that a very similar issue still exists in 0.9.0.1: #19270 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready ONLY add when PR is ready to merge/full CI is needed structured-output v1
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Bug]: clients can crash the openai server with invalid regex [Bug]: Running guided_json with invalid json schema causes the API server to crash
4 participants