-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
[Bugfix]: Fix the logic for deciding if tool parsing is used #8366
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 the logic for deciding if tool parsing is used #8366
Conversation
👋 Hi! Thank you for contributing to the vLLM project. 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:
🚀 |
cc @K-Mistele |
if not (self.enable_auto_tools | ||
or not self.tool_parser) and not isinstance( | ||
and not self.tool_parser) and not isinstance( | ||
request.tool_choice, | ||
ChatCompletionNamedToolChoiceParam): |
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.
So the intent here is, "if auto tool parsing is not enabled, and request.tool_choice
is not a named tool choice parameter for guided decoding"
wouldn't this be, if (not (self.enable_auto_tools and self.tool_parser)) and not isinstance(request.tool_choice, ChatCompletionNamedToolChoiceParam):
?
This might be a little redundant in terms of the parentheses, wanted to avoid operator precendence issues.
alternatively, if (not self.enable_auto_tools or not self.tool_parser) and not isinstance(...)
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.
the goal is to make sure that either/both of self.enable_auto_tools
and self.tool_parser
are false.
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.
Either one of your options is great IMO
The original logic was:
if not (self.enable_auto_tools or not self.tool_parser) and not isinstance(...)
.
Comparing to the second alternative you suggested:
if (not self.enable_auto_tools or not self.tool_parser) and not isinstance(...)
shows that the issue is that the first not
is outside of the parentheses instead of inside them.
Unless you have any objections, I'll go with your second suggestion since it does have less parentheses and it's a really small change - just the location of the opening (
(Just to explain my line of thought - the reason I went with
not (self.enable_auto_tools and not self.tool_parser) and not isinstance(...)
is that is it similar to line 165:
not (self.enable_auto_tools and self.tool_parser is not None)
I now understand this is also a bug since the condition will be True
if auto tools is enabled, which is not what we wanted.)
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.
Thanks!
…oject#8366) Signed-off-by: Alvant <[email protected]>
…oject#8366) Signed-off-by: LeiWang1999 <[email protected]>
The great work done in #5649 has a small bug with regards to deciding if tool parsing is enabled or not. This PR fixes said bug
I'm pretty sure the logic in
main
is a bug since I compared the logic used invllm/vllm/entrypoints/openai/serving_chat.py
Line 165 in cea95df
vllm/vllm/entrypoints/openai/serving_chat.py
Line 610 in cea95df
Both are checking the same thing - whether or not tool parsing is used. Yet, they have different truth values for the same truth values of
self.enable_auto_tools
andself.tool_parser
. What I did is to align the logic in line 610 to the one in line 165. It also makes sense given the comment in line 608