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] Fix CFGGuide and use outlines for grammars that can't convert to GBNF #11389

Merged

Conversation

mgoin
Copy link
Member

@mgoin mgoin commented Dec 21, 2024

@afeldman-nm found this issue while trying the offline and online structured output examples like python examples/offline_inference_structured_outputs.py. We were failing to convert the sql lark grammar into gbnf format for xgrammar and had that check+conversion in the wrong place to fallback to another backend.

It turns out that our outlines backend actually regressed on this example as well with the upgrade to 0.1.11 (it works fine if I use outlines==0.0.46). I made this PR to make xgrammar fallback to outlines in this case, and get outlines back to functional for it.

Copy link

👋 Hi! Thank you for contributing to the vLLM project.
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 do one of these:

  • Add ready label to the PR
  • Enable auto-merge.

🚀

Signed-off-by: mgoin <[email protected]>
@mgoin mgoin changed the title [Bugfix] Fall back to outlines for grammars that can't convert to GBNF [Bugfix] Use outlines for grammars that can't convert to GBNF Dec 21, 2024
@mgoin mgoin added the ready ONLY add when PR is ready to merge/full CI is needed label Dec 21, 2024
@mgoin mgoin changed the title [Bugfix] Use outlines for grammars that can't convert to GBNF [Bugfix] Fix CFGGuide and use outlines for grammars that can't convert to GBNF Dec 21, 2024
@DarkLight1337 DarkLight1337 merged commit 5bfb30a into vllm-project:main Dec 23, 2024
66 checks passed
ayylemao pushed a commit to ayylemao/vllm that referenced this pull request Dec 24, 2024
ZenPuzzle pushed a commit to ZenPuzzle/vllm that referenced this pull request Dec 25, 2024
BKitor pushed a commit to BKitor/vllm that referenced this pull request Dec 30, 2024
joennlae pushed a commit to 44ai-labs/vllm that referenced this pull request Jan 19, 2025
joennlae pushed a commit to 44ai-labs/vllm that referenced this pull request Jan 19, 2025
abmfy pushed a commit to abmfy/vllm-flashinfer that referenced this pull request Jan 24, 2025
abmfy pushed a commit to abmfy/vllm-flashinfer that referenced this pull request Jan 24, 2025
mgawarkiewicz pushed a commit to HabanaAI/vllm-fork that referenced this pull request Feb 12, 2025
This PR mostly ports vllm-project#11389 to
the design introduced by #358
and makes the custom caching code a little bit more robust.
Currently there are two problems with guided decode:
- `mask[list(allowed_tokens)] = 0` is causing crashes due to
allowed_tokens containing tensors. Pretty easy fix.
- The value type of `self._fsm_state` was changed from `int` to union of
`int` and `outlines.state.CFGState`, which may cause
`self._cached_get_mask_tensor(state_id, scores.size(-1), scores.device)`
to crash, as `outlines.state.CFGState` is not hashable. This PR changes
the caching mechanism so that if function arguments are not hashable,
their id is taken as key. This might cause some cache misses, but that's
better than crashing, as it does right now.
None of the above is problem on upstream, as this stems from code
introduced in #358.
I've also added guided decode tests to CI suite.
lk-chen pushed a commit to lk-chen/vllm that referenced this pull request Mar 5, 2025
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants