Skip to content
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

[Bugfix] Guided decoding falls back to outlines when fails to import xgrammar #12976

Merged
merged 7 commits into from
Feb 11, 2025

Conversation

terrytangyuan
Copy link
Contributor

@terrytangyuan terrytangyuan commented Feb 9, 2025

This fixes the issue when xgrammar module cannot be imported successfully for some reason, e.g. triton is not available. This fallback allows users to still use guided decoding when xgrammar cannot be used.

  File "/usr/local/lib/python3.10/dist-packages/vllm/engine/multiprocessing/client.py", line 606, in _process_request
    params = await \
  File "/usr/local/lib/python3.10/dist-packages/vllm/engine/async_llm_engine.py", line 553, in build_guided_decoding_logits_processor_async
    processor = await get_guided_decoding_logits_processor(
  File "/usr/local/lib/python3.10/dist-packages/vllm/model_executor/guided_decoding/__init__.py", line 109, in get_guided_decoding_logits_processor
    return get_local_xgrammar_guided_decoding_logits_processor(
  File "/usr/local/lib/python3.10/dist-packages/vllm/model_executor/guided_decoding/xgrammar_decoding.py", line 38, in get_local_xgrammar_guided_decoding_logits_processor
    config = GrammarConfig.from_guided_params(guided_params=guided_params,
  File "/usr/local/lib/python3.10/dist-packages/vllm/model_executor/guided_decoding/xgrammar_decoding.py", line 174, in from_guided_params
    tokenizer_data = TokenizerDataCache.get_tokenizer_data(tokenizer)
  File "/usr/local/lib/python3.10/dist-packages/vllm/model_executor/guided_decoding/xgrammar_decoding.py", line 87, in get_tokenizer_data
    vocab_type = xgr.VocabType.RAW
NameError: name 'xgr' is not defined

…xgrammar

Signed-off-by: Yuan Tang <terrytangyuan@gmail.com>
@terrytangyuan terrytangyuan requested a review from mgoin as a code owner February 9, 2025 04:03
Copy link

github-actions bot commented Feb 9, 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.

🚀

@terrytangyuan
Copy link
Contributor Author

This is easier to review when hiding the whitespaces: https://github.com/vllm-project/vllm/pull/12976/files?diff=unified&w=1

Signed-off-by: Yuan Tang <terrytangyuan@gmail.com>
Signed-off-by: Yuan Tang <terrytangyuan@gmail.com>
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.

just some minor style feedback. thanks for the fix!

Signed-off-by: Yuan Tang <terrytangyuan@gmail.com>
Signed-off-by: Yuan Tang <terrytangyuan@gmail.com>
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.

lgtm, thanks!

Signed-off-by: Yuan Tang <terrytangyuan@gmail.com>
Signed-off-by: Yuan Tang <terrytangyuan@gmail.com>
@mgoin mgoin enabled auto-merge (squash) February 10, 2025 18:18
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label Feb 10, 2025
@terrytangyuan
Copy link
Contributor Author

Ci failures seem unrelated: requests.exceptions.HTTPError: 504 Server Error: Gateway Time-out for url: https://huggingface.co/api/models/openai-community/gpt2/tree/main?recursive=True&expand=False

@mgoin Would you like to merge this manually?

@mgoin mgoin merged commit 14ecab5 into vllm-project:main Feb 11, 2025
43 of 47 checks passed
@terrytangyuan terrytangyuan deleted the xgrammar-import branch February 11, 2025 18:23
SzymonOzog pushed a commit to SzymonOzog/vllm that referenced this pull request Feb 12, 2025
…xgrammar (vllm-project#12976)

Signed-off-by: Yuan Tang <terrytangyuan@gmail.com>
Signed-off-by: SzymonOzog <szymon.ozog@aleph-alpha.com>
kwang1012 pushed a commit to kwang1012/vllm that referenced this pull request Feb 12, 2025
…xgrammar (vllm-project#12976)

Signed-off-by: Yuan Tang <terrytangyuan@gmail.com>
panf2333 pushed a commit to yottalabsai/vllm that referenced this pull request Feb 18, 2025
…xgrammar (vllm-project#12976)

Signed-off-by: Yuan Tang <terrytangyuan@gmail.com>
kerthcet pushed a commit to kerthcet/vllm that referenced this pull request Feb 21, 2025
…xgrammar (vllm-project#12976)

Signed-off-by: Yuan Tang <terrytangyuan@gmail.com>
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants