Skip to content

Conversation

@gaocegege
Copy link
Contributor

@gaocegege gaocegege commented Mar 7, 2025

This is a quick refactor to get us ready to tackle a few issues like #14399, #14170, #14335, #14511, #14429 and #14490

Right now, we’ve got two separate abstractions of handling reasoning—one for OpenAI chat and another for structured outputs.

But if we want to fix #14399, which involves adding checks for reasoning tokens in the stopChecker, we’d probably end up with even more abstractions.

To keep things clean and avoid a mess, we’re merging these into one unified approach.

@github-actions
Copy link

github-actions bot commented Mar 7, 2025

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

🚀

@mergify mergify bot added documentation Improvements or additions to documentation frontend structured-output labels Mar 7, 2025
@gaocegege gaocegege marked this pull request as ready for review March 7, 2025 10:10
@gaocegege
Copy link
Contributor Author

/cc @alex-jw-brooks

@gaocegege
Copy link
Contributor Author

I hope this can be merged after PR #14202 is finalized, as there might be some conflicts. I’m happy to resolve those conflicts directly in this PR. I’ll wait for @alex-jw-brooks to confirm if this approach works.

@gaocegege gaocegege changed the title [Refactor][Reasoning] Keep all logic about reasoning into one class [Refactor][Frontend] Keep all logic about reasoning into one class Mar 10, 2025
Copy link
Collaborator

@aarnphm aarnphm left a comment

Choose a reason for hiding this comment

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

Given that this is strictly frontend, I think we should keep it under entrypoint.

@gaocegege
Copy link
Contributor Author

Given that this is strictly frontend, I think we should keep it under entrypoint.

Thanks for your review.

It’s used in model_executor.guided_decoding. is it okay to import entrypoints there?

@aarnphm
Copy link
Collaborator

aarnphm commented Mar 17, 2025

It’s used in model_executor.guided_decoding. is it okay to import entrypoints there?

hmm, thinking more about this, it is probably ok to add a vllm.reasoning (iirc we don't do any import in entrypoints, but that is not guarantee)

@mergify
Copy link

mergify bot commented Mar 19, 2025

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

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

@mergify mergify bot added the needs-rebase label Mar 19, 2025
Copy link
Collaborator

@aarnphm aarnphm left a comment

Choose a reason for hiding this comment

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

Just some small comments, and a rename preference to vllm.reasoning, otherwise LGTM.

Copy link
Collaborator

@aarnphm aarnphm left a comment

Choose a reason for hiding this comment

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

ok, final round of review. just final few thoughts

force: bool = True) -> None:
def _register_module(
cls,
module: type,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
module: type,
module: type[Any],

? or does it take in a type variable ? iirc we can also pass in a generic type here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

let's do it in a separate PR then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I created an issue to keep track. #15658

cls,
module: type,
module_name: Optional[Union[str, list[str]]] = None,
force: bool = True,
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: This seems to be the strict behaviour. I would prefer renaming this variable to strict here.

also iiuc this is internal anyways, should we just make it strict by default?

I dont' really see the reason for user overriding this any time soon (given that we are maintaining this anw)?

Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: for register_module I think would be nice if we can transform the target class into a dataclass, so that we can enforce start_token and end_token string

And setup start_token_id and end_token_id accordingly based on the vocab

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ditto. This is copied from the tool parser, maybe we could have another PR to change both of them?

Comment on lines +26 to +30
start_token_id: int
end_token_id: int

start_token: str = "<think>"
end_token: str = "</think>"
Copy link
Collaborator

Choose a reason for hiding this comment

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

above for logics.

Signed-off-by: Ce Gao <cegao@tensorchord.ai>
@gaocegege
Copy link
Contributor Author

@DarkLight1337 @mgoin @simon-mo Could you please help merge this?

@DarkLight1337 DarkLight1337 enabled auto-merge (squash) March 28, 2025 02:49
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label Mar 28, 2025
@gaocegege
Copy link
Contributor Author

The entrypoints test timed out. Could we merge it manually?

@vllm-bot vllm-bot merged commit 32b14ba into vllm-project:main Mar 28, 2025
45 of 47 checks passed
@gaocegege gaocegege deleted the refactor branch March 28, 2025 07:56
Alex4210987 pushed a commit to LeiWang1999/vllm-bitblas that referenced this pull request Apr 5, 2025
…llm-project#14428)

Signed-off-by: Ce Gao <cegao@tensorchord.ai>
Signed-off-by: xinyuxiao <xinyuxiao2024@gmail.com>
lulmer pushed a commit to lulmer/vllm that referenced this pull request Apr 7, 2025
…llm-project#14428)

Signed-off-by: Ce Gao <cegao@tensorchord.ai>
Signed-off-by: Louis Ulmer <ulmerlouis@gmail.com>
lk-chen pushed a commit to lk-chen/vllm that referenced this pull request Apr 29, 2025
shreyankg pushed a commit to shreyankg/vllm that referenced this pull request May 3, 2025
RichardoMrMu pushed a commit to RichardoMrMu/vllm that referenced this pull request May 12, 2025
…llm-project#14428)

Signed-off-by: Ce Gao <cegao@tensorchord.ai>
Signed-off-by: Mu Huai <tianbowen.tbw@antgroup.com>
huiqiwa pushed a commit to huiqiwa/vllm-fork that referenced this pull request Oct 21, 2025
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 frontend ready ONLY add when PR is ready to merge/full CI is needed structured-output

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: stop_sequences is applied to both reasoning_content and content

4 participants