fix(metax): avoid vllm._C dependency in activation ops for empty builds - #325
fix(metax): avoid vllm._C dependency in activation ops for empty builds#325tengqm wants to merge 1 commit into
Conversation
When vllm is built with VLLM_TARGET_DEVICE=empty, vllm._C is not compiled and torch.ops._C.silu_and_mul does not exist. The MetaX activation functions instantiating SiluAndMul/GeluAndMul crash at model load time because their __init__ accesses torch.ops._C. Replace SiluAndMul/GeluAndMul with pure PyTorch F.silu/F.gelu. This is functionally identical and works on both empty and full vllm builds — the CUDA kernel path was a micro-optimization, not a correctness requirement. The dispatch layer (call_op) already routes these through the MetaX vendor backend. Co-Authored-By: ftgreat <ldwang@baai.ac.cn> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Error without this fixFull stack trace from MetaX C550 (MACA 3.7.2.0, vllm 0.20.2 built with vllm_fl/ops/activation.py,: cannot open Why dispatch doesn't help hereThe crash happens in The dispatch layer (
The fix replaces |
Error without this fixFull stack trace from MetaX C550 (MACA 3.7.2.0, vllm 0.20.2 built with Why dispatch doesn't help hereThe crash happens in The dispatch layer (
The fix replaces |
|
This PR is not ready. Need further investigation. |
|
This PR was generated based on an experiment using cpu version of vllm. So the conclusion and the proposed fixes are both wrong. |
Problem
When vllm is built with VLLM_TARGET_DEVICE=empty, vllm._C is not compiled and torch.ops._C.silu_and_mul / torch.ops._C.gelu_and_mul do not exist. The MetaX activation functions instantiate SiluAndMul() / GeluAndMul(), whose init accesses torch.ops._C.* — causing AttributeError at model load time.
Root cause
silu_and_mul_maca and gelu_and_mul_maca delegate to vllm's compiled CUDA kernel classes (SiluAndMul, GeluAndMul). These depend on vllm._C.abi3.so which is absent in empty builds.
Fix
Replace with pure PyTorch: F.silu / F.gelu — functionally identical and works on both empty and full vllm builds.
Credit
Originally authored by ftgreat ldwang@baai.ac.cn in commit 1357ddf (2026-07-21) on the MetaX CI node. This PR upstreams that fix.
Testing
Verified on MetaX C550 (MACA 3.7.2.0, torch 2.8.0+metax): vllm 0.20.2 empty + vllm-plugin-FL, Qwen3-4B, eager mode, flash attention, inference succeeds without _C stubs.