Skip to content

Conversation

zzhx1
Copy link
Contributor

@zzhx1 zzhx1 commented Aug 25, 2025

Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.

Purpose

Similar with #22509
We hope that lmhead can also support the custom_op feature so that I can make modifications to lmhead on different platforms without needing to change the vllm code.

Test Plan

No need to add new test.

Test Result

all tests should pass


Essential Elements of an Effective PR Description Checklist
  • [x ] The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • [x ] The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.

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 ask your reviewers to trigger select CI tests on top of fastcheck CI.

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.

If you have any questions, please reach out to us on Slack at https://slack.vllm.ai.

🚀

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request aims to add CustomOp support for LMHead and LogitsProcessor to allow for platform-specific implementations. The changes correctly update the class definitions to inherit from CustomOp and register them. However, there's a critical issue in both implementations: the existing forward methods are not renamed to forward_native. This will cause them to be shadowed by the CustomOp's dispatcher, leading to NotImplementedError at runtime. My review includes comments on the affected class definitions, explaining the necessary changes to make these custom ops functional.

Comment on lines +24 to +26
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

Inheriting from CustomOp overrides the forward method with the CustomOp dispatcher. The existing forward method in this class (lines 56-87) must be renamed to forward_native to serve as the default implementation. Without this change, calls to this op will fail with a NotImplementedError.

Copy link
Contributor

Choose a reason for hiding this comment

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

critical

Since ParallelLMHead is now registered as a CustomOp (and inherits from CustomOp via VocabParallelEmbedding), its forward method is overridden. The existing forward method (lines 475-477) must be renamed to forward_native to act as the default implementation. Otherwise, this will raise a NotImplementedError at runtime.

@wangxiyuan
Copy link
Contributor

LGTM, the CI failure looks doesn't relate to this PR.

@zzhx1
Copy link
Contributor Author

zzhx1 commented Sep 8, 2025

@wangxiyuan Help to push and merge this PR

@wangxiyuan
Copy link
Contributor

@Yikun @youkaichao please take a look. The change is quite simple and clear IMO

@Yikun Yikun added the ready ONLY add when PR is ready to merge/full CI is needed label Sep 9, 2025
@Yikun
Copy link
Collaborator

Yikun commented Sep 10, 2025

Just enbale function level register for LogitsProcessor and ParallelLMHead,It's same as #22509 more background to see #22509 (comment) .

so, LGTM

@vllm-bot vllm-bot merged commit 736569d into vllm-project:main Sep 10, 2025
37 of 39 checks passed
skyloevil pushed a commit to skyloevil/vllm that referenced this pull request Sep 13, 2025
FeiDaLI pushed a commit to FeiDaLI/vllm that referenced this pull request Sep 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready ONLY add when PR is ready to merge/full CI is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants