Skip to content

Conversation

wangxiyuan
Copy link
Contributor

@wangxiyuan wangxiyuan commented Aug 29, 2025

Purpose

The commit #23671 add the custom init logic like SILU_MUL_OP = torch.ops._C.silu_and_mul.default. But it doesn't work on the platform which doesn't support custom ops. It will raise error when setup vLLM.

AttributeError: '_OpNamespace' '_C' object has no attribute 'silu_and_mul'

This PR let activation_quant_fusion be imported only for CUDA case

Test Plan

This is a change for custom platform. No need for new test. and all test should not break. vLLM Ascend e2e test will be happy after this change.

Test Result

Custom platform works well then.

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

The pull request aims to fix an AttributeError on platforms without custom ops by adding hasattr checks. While the intention is correct, the implementation is incomplete and introduces new runtime errors because other parts of the code unconditionally assume these ops are available. The pattern registration logic needs to be made conditional to fully resolve the issue.

@wangxiyuan wangxiyuan changed the title [Platform] Fix Custom Op init error [Platform] Fix custom op init error Aug 29, 2025
@elvischenv
Copy link
Contributor

@wangxiyuan
Copy link
Contributor Author

wangxiyuan commented Aug 29, 2025

@elvischenv there is a platform check when import the file, so it's fine with custom platform

if current_platform.is_cuda_alike():
from .fusion import FusionPass
from .fusion_attn import AttnFusionPass

And I'm not sure if activation_quant_fusion is only used for CUDA, if yes, it can be fixed by this way as well.

Copy link
Collaborator

@jikunshang jikunshang 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 fixing this! maybe we need some refactor to avoid op register issue on multiple platforms.

@jikunshang jikunshang added the ready ONLY add when PR is ready to merge/full CI is needed label Aug 29, 2025
Copy link
Collaborator

@ProExpertProg ProExpertProg left a comment

Choose a reason for hiding this comment

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

This is very ugly, but I understand that we can't set these globals due to other platforms. I think we've already dealt with this in other files and in a nicer way, could you look around briefly?

@ProExpertProg
Copy link
Collaborator

Yeah I see the link now, can you just make the pass a conditional import like it's done for fusion?

@elvischenv
Copy link
Contributor

And I'm not sure if activation_quant_fusion is only used for CUDA, if yes, it can be fixed by this way as well.

Yes, this is only for cuda. Let's follow this conditional import as @ProExpertProg mentioned. Thanks.

@wangxiyuan wangxiyuan changed the title [Platform] Fix custom op init error [Platform] import activation_quant_fusion for CUDA only Aug 29, 2025
@wangxiyuan
Copy link
Contributor Author

@elvischenv @ProExpertProg Done, and tested with vllm-ascend again, it works

@vllm-bot vllm-bot merged commit 6597d7a into vllm-project:main Aug 29, 2025
35 of 38 checks passed
eicherseiji pushed a commit to eicherseiji/vllm that referenced this pull request Sep 9, 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.

5 participants