Skip to content

Commit 38e7dbc

Browse files
authored
Support kunlunxin backend (#268)
### PR Category Others ### PR Type New Features ### Description Based on vLLM 0.20.2 (empty), adapted for vllm-plugin-FL with support for the Kunlunxin backend.The Qwen3.6-35B-A3B and Qwen3.6-27B models have been verified, the test includes high-concurrency input of text and images. Test command: export FLAGCX_PATH=/workspace/FlagCX export USE_RESHAPE_AND_CACHE_FLASH=1 vllm serve /workspace/models/Qwen3.6-27B \ --served-model-name qwen3 \ --tensor-parallel-size 4 \ --max-model-len 16384\ --reasoning-parser qwen3 \ --block-size 128 \ --gpu-memory-utilization 0.8 \ --enforce-eager \ --port 8100 Verified results: <img width="609" height="285" alt="image" src="https://github.com/user-attachments/assets/be79815f-a7ce-45bd-a079-15f115d107b6" /> ### Changes Add Kunlunxin backend support.
1 parent d599e5e commit 38e7dbc

26 files changed

Lines changed: 3682 additions & 53 deletions

vllm_fl/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,18 @@ def _patch_custom_ops():
9494
register_op_schemas()
9595

9696

97+
def _init_vendor_device():
98+
"""Vendor-specific device initialization patches."""
99+
from vllm_fl.utils import DeviceInfo
100+
if DeviceInfo().vendor_name == "kunlunxin":
101+
from vllm_fl.dispatch.backends.vendor.kunlunxin.patches.patch_fla_utils import _patch_xpu_get_device
102+
_patch_xpu_get_device()
103+
104+
97105
def register():
98106
"""Register the FL platform."""
107+
_init_vendor_device()
108+
99109
_patch_custom_ops()
100110
_patch_flash_attn_import()
101111
_patch_transformers_compat()
@@ -167,7 +177,6 @@ def register_model():
167177
except Exception as e:
168178
logger.error(f"Register DeepseekV4 model error: {str(e)}")
169179

170-
171180
# Register DeepseekV4 model
172181
try:
173182
ModelRegistry.register_model(
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (c) 2026 Kunlunxin, Inc. All rights reserved.
2+
3+
"""
4+
Kunlunxin backend for vllm-plugin-FL dispatch.
5+
"""
6+
7+
from .kunlunxin import KunlunxinBackend
8+
9+
__all__ = ["KunlunxinBackend"]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Kunlunxin implementation modules
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright (c) 2026 Kunlunxin, Inc. All rights reserved.
2+
3+
"""
4+
Kunlunxin activation operator implementations.
5+
"""
6+
7+
from __future__ import annotations
8+
9+
import torch
10+
11+
12+
def silu_and_mul_kunlunxin(obj, x: torch.Tensor) -> torch.Tensor:
13+
"""
14+
SiLU activation followed by element-wise multiplication.
15+
16+
Args:
17+
obj: The calling obj (for interface consistency)
18+
x: Input tensor of shape [..., 2*d]
19+
20+
Returns:
21+
Output tensor of shape [..., d]
22+
"""
23+
import xtorch_ops
24+
25+
d = x.shape[-1] // 2
26+
out = torch.empty(
27+
*x.shape[:-1], d, dtype=x.dtype, device=x.device
28+
)
29+
xtorch_ops.swiglu(x, out)
30+
return out

0 commit comments

Comments
 (0)