[ROCm][Bugfix][Perf] enable shared expert fusion for Qwen3.5 (#44434)
Signed-off-by: Nico Holmberg <nico.holmberg@amd.com>
This commit is contained in:
@@ -30,6 +30,7 @@ from collections.abc import Callable, Iterable
|
||||
import torch
|
||||
from torch import nn
|
||||
|
||||
from vllm._aiter_ops import rocm_aiter_ops
|
||||
from vllm.compilation.decorators import support_torch_compile
|
||||
from vllm.config import VllmConfig
|
||||
from vllm.distributed import (
|
||||
@@ -314,6 +315,15 @@ class Qwen3_5Model(Qwen3NextModel):
|
||||
num_experts = (
|
||||
self.config.num_experts if hasattr(self.config, "num_experts") else 0
|
||||
)
|
||||
from vllm.config import get_current_vllm_config
|
||||
|
||||
from .qwen3_next import _is_shared_expert_fse_compatible
|
||||
|
||||
is_fse = (
|
||||
rocm_aiter_ops.is_fusion_moe_shared_experts_enabled()
|
||||
and _is_shared_expert_fse_compatible(get_current_vllm_config().quant_config)
|
||||
)
|
||||
|
||||
for name, loaded_weight in weights:
|
||||
if "rotary_emb.inv_freq" in name:
|
||||
continue
|
||||
@@ -327,6 +337,15 @@ class Qwen3_5Model(Qwen3NextModel):
|
||||
if name is None:
|
||||
continue
|
||||
|
||||
# FSE: remap shared_expert weights to fused expert slot
|
||||
if is_fse and "mlp.shared_expert." in name:
|
||||
name = name.replace(
|
||||
"mlp.shared_expert.",
|
||||
f"mlp.experts.{num_experts}.",
|
||||
)
|
||||
is_fused_expert = False
|
||||
expert_params_mapping = self.get_expert_mapping()
|
||||
|
||||
for param_name, weight_name, shard_id in stacked_params_mapping:
|
||||
if "experts.gate_up_proj" in name or "experts.down_proj" in name:
|
||||
is_fused_expert = True
|
||||
|
||||
Reference in New Issue
Block a user