Skip to content

[V1] Structured Outputs + Thinking compatibility #16577

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

Merged

Conversation

aarnphm
Copy link
Collaborator

@aarnphm aarnphm commented Apr 14, 2025

This PR brings thinking support to structured outputs in V1. Currently, if you want to use thinking parser in conjunction with structured outputs, you have to use the V0 engine.

This is also compatible with speculative decoding

This PR also refactor the tokenizer onto the structured_output_manager in order to construct the reasoner.

I have also added tests to cover this case.

Tests with the following:

# thinking + structured outputs
vllm serve deepseek-ai/DeepSeek-R1-Distill-Qwen-32B --tensor-parallel-size 2 --max-model-len 32768 --guided-decoding-backend xgrammar --reasoning-parser deepseek_r1

# thinking + ngram + structured outputs
vllm serve deepseek-ai/DeepSeek-R1-Distill-Qwen-32B --tensor-parallel-size 2 --max-model-len 32768 --guided-decoding-backend xgrammar --reasoning-parser deepseek_r1 --speculative-config '{"method": "ngram", "num_speculative_tokens": 5, "prompt_lookup_max": 5, "prompt_lookup_min": 1}

Closes #14727

Copy link

👋 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.

🚀

@aarnphm
Copy link
Collaborator Author

aarnphm commented Apr 14, 2025

cc @gaocegege might be interested

@aarnphm aarnphm force-pushed the feat/support-thinking-struct-outputs branch 2 times, most recently from cbc3320 to f60e62d Compare April 14, 2025 09:11
Copy link
Contributor

@gaocegege gaocegege left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. Please also update the docs https://docs.vllm.ai/en/latest/features/reasoning_outputs.html#structured-output

- VLLM_USE_V1=0 vllm serve deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B \
    --enable-reasoning --reasoning-parser deepseek_r1
+ vllm serve deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B \
    --enable-reasoning --reasoning-parser deepseek_r1

@mergify mergify bot added the documentation Improvements or additions to documentation label Apr 14, 2025
Copy link

mergify bot commented Apr 17, 2025

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @aarnphm.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@aarnphm aarnphm force-pushed the feat/support-thinking-struct-outputs branch 2 times, most recently from 14490de to 2cf21f0 Compare April 17, 2025 19:48
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
auto-merge was automatically disabled May 13, 2025 00:52

Head branch was pushed to by a user without write access

@simon-mo simon-mo enabled auto-merge (squash) May 13, 2025 04:14
aarnphm added 2 commits May 13, 2025 07:20
auto-merge was automatically disabled May 13, 2025 07:22

Head branch was pushed to by a user without write access

aarnphm added 9 commits May 13, 2025 07:37
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
@hmellor hmellor enabled auto-merge (squash) May 13, 2025 08:36
@aarnphm
Copy link
Collaborator Author

aarnphm commented May 13, 2025

seems like the failure on entrypoint is not related 😿

unaidedelf8777 added a commit to unaidedelf8777/vllm that referenced this pull request May 13, 2025
Signed-off-by: Nathan Hoos <thwackyy.y@gmail.com>
aarnphm added 2 commits May 13, 2025 21:42
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
auto-merge was automatically disabled May 14, 2025 01:44

Head branch was pushed to by a user without write access

@simon-mo simon-mo merged commit 2fc9075 into vllm-project:main May 14, 2025
56 of 58 checks passed
@aarnphm aarnphm deleted the feat/support-thinking-struct-outputs branch May 14, 2025 23:41
aarnphm added a commit to aarnphm/vllm that referenced this pull request May 15, 2025
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
Co-authored-by: Russell Bryant <rbryant@redhat.com>
gshtras pushed a commit to ROCm/vllm that referenced this pull request May 15, 2025
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
Co-authored-by: Russell Bryant <rbryant@redhat.com>
Signed-off-by: Gregory Shtrasberg <Gregory.Shtrasberg@amd.com>
unaidedelf8777 added a commit to unaidedelf8777/vllm that referenced this pull request May 15, 2025
Signed-off-by: Nathan Hoos <thwackyy.y@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation ready ONLY add when PR is ready to merge/full CI is needed structured-output v1
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Feature]: reasoning outputs in structured outputs in v1
5 participants