-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[Frontend][Core] Update Outlines Integration from FSM
to Guide
#4109
Conversation
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.
vllm/model_executor/guided_decoding/outlines_logits_processors.py
Outdated
Show resolved
Hide resolved
Co-authored-by: Simon Mo <[email protected]>
I think the test failure in the entrypoints test might be related, and there's merge conflict. 🙏 |
Co-authored-by: Simon Mo <[email protected]>
…5-outlines-guides
I'll have a look at the failing frontend test. |
I can reproduce the error in the test on my dev environment. The generation does not stop when it should, generating IP addresses like this: I have pushed some small improvements to the test code:
|
I'm having a call with outlines contributors on Thursday. While there is no guarantee we will have a solution for the problem, I'd propose to wait until then. If there's no progress by the end of the week, I'd open a separate PR for the unpinning. What do you think? |
I have opened #4558 because moving to the |
I have closed #4558 in favor of this PR. I expect to make progress on this next week. Waiting for dottxt-ai/outlines#874. |
dottxt-ai/outlines#874 merged, thank you for your patience! |
Great, thanks for the support @rlouf! Can you tell already when you plan to release? |
Next week I think. I need to make sure other downstream libraries have pinned the outlines version to avoid surprises. |
Sorry, missed @simon-mo tagging me above. Yes we encountered the same problem and had been thinking to introduce a vLLM would then ensure to call this separately for each sequence. Stateless LP factories can just return a constant LP from the method. Note this is currently also problem if a list of prompts is passed in the API, and/or if WDYT? @maxdebayser has started prototyping this. |
@njhill I like the direction of your proposal. This would allow us to invert control and get rid of the 10 lines setting up guided decoding in the While I think this is the right thing to do on the long run, I believe we should fix this problem ASAP. Would you mind having a look at the code in this PR which handles this issue by pushing the cache one level down? I believe this would work nicely as a band-aid until the refactoring you proposed is implemented. The core changes are:
|
PS: this PR is ready for review @simon-mo I'm just waiting for outlines to be released, so that we can get rid of the regression in the tests. |
Hi @br3no, we also found a problem with the FSM state being shared between sequences. This curl here causes a crash:
We have a sketch for a PR here: IBM/vllm#38 . It uses factories like @njhill mentioned, so that each sequence can have it's own logits processor copy. The changes in our PR solve this particular issue, but I think the CFGLogitsProcessor would still crash if the sequence is preempted with the recompute policy. But I don't know yet how to test this hypothesis. |
@br3no , I've tested your changes with the curl command above. The code doesn't crash anymore, but I think the output ends prematurely:
So while I do think that your changes are an improvement, I think we need to add the factory PR as well to deal with stateful LogitsProcessors properly. Just for reference, the curl request returns this on our PR:
|
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
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.
Actually, if I run
curl http://localhost:8000/v1/completions -H "Content-Type: application/json" -d '{
"model": "<MY_MODEL>",
"prompt": ["An example of a json document: ", "Another example of a json document: "],
"max_tokens": 100,
"temperature": 0,
"guided_decoding_backend": "outlines",
"response_format": {"type":"json_object"},
"logit_bias": {"100": -100}
}'
followed by
curl http://localhost:8000/v1/completions -H "Content-Type: application/json" -d '{
"model": "<MY_MODEL>",
"prompt": ["An example of a json document: "],
"max_tokens": 100,
"temperature": 0,
"guided_decoding_backend": "outlines",
"response_format": {"type":"json_object"},
"logit_bias": {"100": -100}
}' | jq
I get this crash:
File "/home/develop/.local/lib/python3.11/site-packages/vllm/model_executor/guided_decoding/outlines_logits_processors.py", line 47, in __call__
instruction = self._guide.get_next_instruction(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/develop/.local/lib/python3.11/site-packages/outlines/fsm/guide.py", line 349, in get_next_instruction
interactive.exhaust_lexer()
File "/opt/vllm/lib/python3.11/site-packages/lark/parsers/lalr_interactive_parser.py", line 52, in exhaust_lexer
return list(self.iter_parse())
^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/vllm/lib/python3.11/site-packages/lark/parsers/lalr_interactive_parser.py", line 43, in iter_parse
for token in self.lexer_thread.lex(self.parser_state):
File "/opt/vllm/lib/python3.11/site-packages/lark/lexer.py", line 674, in lex
raise UnexpectedToken(token, e.allowed, state=parser_state, token_history=[last_token], terminals_by_name=self.root_lexer.terminals_by_name)
lark.exceptions.UnexpectedToken: Unexpected token Token('LBRACE', '{') at line 7, column 2.
Expected one of:
* UNESCAPED_STRING
* RBRACE
Previous tokens: [Token('LBRACE', '{')]
If I restart the server and just send the curl request with a single prompt several times, only the first request generates useful JSON. After that it returns:
{
"id": "cmpl-948cb1c4033b40f1a07846bed5ac4de9",
"object": "text_completion",
"created": 1717518689,
"model": "/llama_eval_storage/LLaMa/models/hf/7B-F",
"choices": [
{
"index": 0,
"text": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",
"logprobs": null,
"finish_reason": "length",
"stop_reason": null
}
],
"usage": {
"prompt_tokens": 9,
"total_tokens": 109,
"completion_tokens": 100
}
}
I'm testing with LLama2 7b and outlines==0.0.41
@maxdebayser thanks for looking into it!
I have just looked into Outlines and while I'll check if I can increase the size of the band-aid a bit to deal with this case... |
I have pushed a commit that comes close to what was there before and at the same time does not lead to crashes on n > 1. It's still not correct, though... Every It probably makes sense to pre-build a (large) pool of To really solve this, Outlines would need to be changed to make the @rlouf, could you give us your expert opinion on this? |
@br3no , I can confirm that your latest commit fixes the problem where state from previous single-sequence requests is carried over to new requests. |
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.
Thank you for doing this. Please let me know when this PR is ready to be merged!
Actually it seems complete given @maxdebayser's comment. I will merge now. |
…llm-project#4109) Co-authored-by: Simon Mo <[email protected]> Co-authored-by: Breno Faria <[email protected]>
…llm-project#4109) Co-authored-by: Simon Mo <[email protected]> Co-authored-by: Breno Faria <[email protected]>
…llm-project#4109) Co-authored-by: Simon Mo <[email protected]> Co-authored-by: Breno Faria <[email protected]>
…llm-project#4109) Co-authored-by: Simon Mo <[email protected]> Co-authored-by: Breno Faria <[email protected]>
…llm-project#4109) Co-authored-by: Simon Mo <[email protected]> Co-authored-by: Breno Faria <[email protected]>
…llm-project#4109) Co-authored-by: Simon Mo <[email protected]> Co-authored-by: Breno Faria <[email protected]>
…llm-project#4109) Co-authored-by: Simon Mo <[email protected]> Co-authored-by: Breno Faria <[email protected]>
This PR updates the Outlines Integration from
FSM
to the newGuide
interface.Since I'm not sure where to place the change, I added both labels
[Frontend]
and[Core]
.FIX #3715
BEFORE SUBMITTING, PLEASE READ THE CHECKLIST BELOW AND FILL IN THE DESCRIPTION ABOVE
PR Checklist (Click to Expand)
Thank you for your contribution to vLLM! Before submitting the pull request, please ensure the PR meets the following criteria. This helps vLLM maintain the code quality and improve the efficiency of the review process.
PR Title and Classification
Only specific types of PRs will be reviewed. The PR title is prefixed appropriately to indicate the type of change. Please use one of the following:
[Bugfix]
for bug fixes.[CI/Build]
for build or continuous integration improvements.[Doc]
for documentation fixes and improvements.[Model]
for adding a new model or improving an existing model. Model name should appear in the title.[Frontend]
For changes on the vLLM frontend (e.g., OpenAI API server,LLM
class, etc.)[Kernel]
for changes affecting CUDA kernels or other compute kernels.[Core]
for changes in the core vLLM logic (e.g.,LLMEngine
,AsyncLLMEngine
,Scheduler
, etc.)[Hardware][Vendor]
for hardware-specific changes. Vendor name should appear in the prefix (e.g.,[Hardware][AMD]
).[Misc]
for PRs that do not fit the above categories. Please use this sparingly.Note: If the PR spans more than one category, please include all relevant prefixes.
Code Quality
The PR need to meet the following code quality standards:
format.sh
to format your code.docs/source/
if the PR modifies the user-facing behaviors of vLLM. It helps vLLM user understand and utilize the new features or changes.Notes for Large Changes
Please keep the changes as concise as possible. For major architectural changes (>500 LOC excluding kernel/data/config/test), we would expect a GitHub issue (RFC) discussing the technical design and justification. Otherwise, we will tag it with
rfc-required
and might not go through the PR.What to Expect for the Reviews
The goal of the vLLM team is to be a transparent reviewing machine. We would like to make the review process transparent and efficient and make sure no contributor feel confused or frustrated. However, the vLLM team is small, so we need to prioritize some PRs over others. Here is what you can expect from the review process:
action-required
label on the PR if there are changes required. The contributor should address the comments and ping the reviewer to re-review the PR.Thank You
Finally, thank you for taking the time to read these guidelines and for your interest in contributing to vLLM. Your contributions make vLLM a great tool for everyone!