-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Updated xgrammar backend to not deny supported string formats #27253
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
Updated xgrammar backend to not deny supported string formats #27253
Conversation
Signed-off-by: CNE Pierre FICHEPOIL <[email protected]>
Signed-off-by: CNE Pierre FICHEPOIL <[email protected]>
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.
Code Review
This pull request updates the xgrammar backend to correctly handle supported string formats, which were previously being denied. The changes involve adding a list of supported formats and modifying the validation logic to check against this list. The tests have also been updated to reflect this change. My review focuses on improving the maintainability of the new code by adhering to Python's PEP 8 style guide for constants and by using a permanent link for the source reference. These changes will make the code more robust and easier to maintain in the future.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: ExtReMLapin <[email protected]>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: ExtReMLapin <[email protected]>
|
cc main contributors of the backend : |
|
LGTM if the test passed. |
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.
lgtm, thanks!
…roject#27253) Signed-off-by: CNE Pierre FICHEPOIL <[email protected]> Signed-off-by: ExtReMLapin <[email protected]> Co-authored-by: CNE Pierre FICHEPOIL <[email protected]> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…roject#27253) Signed-off-by: CNE Pierre FICHEPOIL <[email protected]> Signed-off-by: ExtReMLapin <[email protected]> Co-authored-by: CNE Pierre FICHEPOIL <[email protected]> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: sstamenk <[email protected]>
…roject#27253) Signed-off-by: CNE Pierre FICHEPOIL <[email protected]> Signed-off-by: ExtReMLapin <[email protected]> Co-authored-by: CNE Pierre FICHEPOIL <[email protected]> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…roject#27253) Signed-off-by: CNE Pierre FICHEPOIL <[email protected]> Signed-off-by: ExtReMLapin <[email protected]> Co-authored-by: CNE Pierre FICHEPOIL <[email protected]> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: Alberto Perdomo <[email protected]>
…roject#27253) Signed-off-by: CNE Pierre FICHEPOIL <[email protected]> Signed-off-by: ExtReMLapin <[email protected]> Co-authored-by: CNE Pierre FICHEPOIL <[email protected]> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: 0xrushi <[email protected]>
…roject#27253) Signed-off-by: CNE Pierre FICHEPOIL <[email protected]> Signed-off-by: ExtReMLapin <[email protected]> Co-authored-by: CNE Pierre FICHEPOIL <[email protected]> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: 0xrushi <[email protected]>
Purpose
Fixing string formats when using xgrammar, xgrammar is required when we want to prevent infinite generation (reasoning) with
--structured-outputs-config "{\"disable_any_whitespace\": true, \"backend\": \"xgrammar\"}"Source of the supported formats :
https://github.com/mlc-ai/xgrammar/blob/a32ac892676d2eedc0327416105b9b06edfb94b2/cpp/json_schema_converter.cc#L2992
Test Plan
updated tests to not deny 'email' format (it's supported) and to check if a non existing string is still denied.
Test Result
/opt/vllm$ CUDA_VISIBLE_DEVICES=-1 pytest vllm_last/tests/v1/structured_output/test_utils.py ================================================================================= test session starts ================================================================================= platform linux -- Python 3.10.12, pytest-8.4.2, pluggy-1.6.0 rootdir: /opt/vllm/vllm_last configfile: pyproject.toml plugins: anyio-4.11.0 collected 6 items vllm_last/tests/v1/structured_output/test_utils.py ...... [100%] ================================================================================== warnings summary =================================================================================== <frozen importlib._bootstrap>:241 <frozen importlib._bootstrap>:241: DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute <frozen importlib._bootstrap>:241 <frozen importlib._bootstrap>:241: DeprecationWarning: builtin type SwigPyObject has no __module__ attribute -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html ============================================================================ 6 passed, 2 warnings in 1.27s ============================================================================ sys:1: DeprecationWarning: builtin type swigvarlink has no __module__ attributeEssential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.