[AMD] Support AMD MXFP4 Qwen3.5-397B-A17B model (#21234)
This commit is contained in:
@@ -88,6 +88,7 @@ from sglang.srt.utils import (
|
|||||||
cpu_has_amx_support,
|
cpu_has_amx_support,
|
||||||
is_cpu,
|
is_cpu,
|
||||||
is_cuda,
|
is_cuda,
|
||||||
|
is_gfx95_supported,
|
||||||
is_npu,
|
is_npu,
|
||||||
make_layers,
|
make_layers,
|
||||||
set_weight_attrs,
|
set_weight_attrs,
|
||||||
@@ -98,6 +99,7 @@ logger = logging.getLogger(__name__)
|
|||||||
_is_cuda = is_cuda()
|
_is_cuda = is_cuda()
|
||||||
_is_npu = is_npu()
|
_is_npu = is_npu()
|
||||||
_is_cpu = is_cpu()
|
_is_cpu = is_cpu()
|
||||||
|
_is_gfx95 = is_gfx95_supported()
|
||||||
_is_amx_available = cpu_has_amx_support()
|
_is_amx_available = cpu_has_amx_support()
|
||||||
|
|
||||||
|
|
||||||
@@ -879,6 +881,14 @@ ALL_DECODER_LAYER_TYPES = {
|
|||||||
class Qwen3_5ForCausalLM(nn.Module):
|
class Qwen3_5ForCausalLM(nn.Module):
|
||||||
"""Qwen3.5 Model with support for dense variant."""
|
"""Qwen3.5 Model with support for dense variant."""
|
||||||
|
|
||||||
|
if _is_gfx95:
|
||||||
|
packed_modules_mapping = {
|
||||||
|
"qkv_proj": ["q_proj", "k_proj", "v_proj"],
|
||||||
|
"gate_up_proj": ["gate_proj", "up_proj"],
|
||||||
|
"in_proj_qkvz": ["in_proj_qkv", "in_proj_z"],
|
||||||
|
"in_proj_ba": ["in_proj_b", "in_proj_a"],
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config: Qwen3_5TextConfig,
|
config: Qwen3_5TextConfig,
|
||||||
@@ -1300,6 +1310,10 @@ class Qwen3_5MoeForCausalLM(Qwen3_5ForCausalLM):
|
|||||||
|
|
||||||
|
|
||||||
class Qwen3_5ForConditionalGeneration(Qwen3VLForConditionalGeneration):
|
class Qwen3_5ForConditionalGeneration(Qwen3VLForConditionalGeneration):
|
||||||
|
if _is_gfx95:
|
||||||
|
packed_modules_mapping = Qwen3_5ForCausalLM.packed_modules_mapping
|
||||||
|
hf_to_sglang_mapper = None
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config: Qwen3_5Config,
|
config: Qwen3_5Config,
|
||||||
@@ -1422,6 +1436,10 @@ class Qwen3_5ForConditionalGeneration(Qwen3VLForConditionalGeneration):
|
|||||||
class Qwen3_5MoeForConditionalGeneration(Qwen3VLForConditionalGeneration):
|
class Qwen3_5MoeForConditionalGeneration(Qwen3VLForConditionalGeneration):
|
||||||
"""Qwen3.5 MoE Vision-Language Model."""
|
"""Qwen3.5 MoE Vision-Language Model."""
|
||||||
|
|
||||||
|
if _is_gfx95:
|
||||||
|
packed_modules_mapping = Qwen3_5ForCausalLM.packed_modules_mapping
|
||||||
|
hf_to_sglang_mapper = None
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
config: Qwen3_5MoeConfig,
|
config: Qwen3_5MoeConfig,
|
||||||
|
|||||||
Reference in New Issue
Block a user