Repository navigation
[Bugfix][Parser] Stream DeepSeek V4/V3.2 string tool arguments incrementally #58780
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
Open
jayzuccarelli
wants to merge
4
commits into
vllm-project:main
Choose a base branch
from
jayzuccarelli:dsv4-stream-string-args
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0081655
[Bugfix][Parser] Stream DeepSeek V4/V3.2 string tool arguments increm…
jayzuccarelli e6eb667
Merge remote-tracking branch 'upstream/main' into dsv4-stream-string-…
jayzuccarelli 3273d47
Merge remote-tracking branch 'upstream/main' into dsv4-stream-string-…
jayzuccarelli 3062cb2
[Bugfix][Parser] Stream DSML string arguments via arg_value_extender
jayzuccarelli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I believe this new regex is itself quadratic in time. It tries the optional
{start}[^>]*branch at every<|DSML|parameterinside the value, and each attempt scans ahead to the next>. Both the converter and the extender factory run it on every conversion.The lazy group plus
$also causes a smaller bug:$matches just before a trailing\n, so for...string="true">def f():\nthe checkpm.end(3) != len(raw_args)is true and the extender never arms. Those deltas then go back to waiting for the next>.My coding assistant suggested a fix like below for this to avoid the quadratic regex and take a test with 2,200 literal markers in one string value from 3.7 seconds for the converter + extender call down to 5 milliseconds on my machine.
Below is one suggested fix and analysis created by my coding assistant, but please review this suggestion and only copy it verbatim if it also looks good to you.
Suggested fix: match greedily and do the holdback in Python. The holdback is the earliest
param_startafter the last>. That is exactly what the current regex selects, in O(n):The converter and
_dsml_arg_value_extenderboth call this. The extender skips arming whenheld_backis true, which replaces thepm.end(3)check._dsml_arg_convertertakes aparam_startkwarg, anddeepseek_v41_configpassesDSML_PARAM_STARTto it. I fuzzed this against the current regex on 200k inputs: results match except for trailing-\ninputs.Please also add tests for the holdback, which currently has no direct coverage:
_dsml_arg_converter(open + 'a > b<|DSML|parameter name="j', True)returns{"k": "a > b"}, and the extender returnsNonefor the same input.deepseek_v41_config().arg_converterwith the spaced tags."\n". This fails on the current head.