[Bugfix][Model] Fix Aria expert weight names and layout (#57487)
Signed-off-by: Jiang Wu <245355730+JiangLLM@users.noreply.github.com> Co-authored-by: Jiang Wu <245355730+JiangLLM@users.noreply.github.com>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
from collections.abc import Iterable, Mapping, Sequence
|
||||
from typing import Annotated, Literal
|
||||
|
||||
import regex as re
|
||||
import torch
|
||||
import torch.nn as nn
|
||||
from transformers import AriaConfig, AriaTextConfig, BatchFeature
|
||||
@@ -222,6 +223,7 @@ class AriaTextMoELayer(nn.Module):
|
||||
intermediate_size=config.intermediate_size,
|
||||
quant_config=quant_config,
|
||||
prefix=f"{prefix}.experts",
|
||||
is_fused_checkpoint_transposed=True,
|
||||
)
|
||||
|
||||
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
|
||||
@@ -267,14 +269,17 @@ class AriaTextModel(LlamaModel, SupportsQuant):
|
||||
"gate_up_proj": ["gate_proj", "up_proj"],
|
||||
}
|
||||
|
||||
# Aria packs all experts into single (transposed) fc1/fc2 tensors, which is
|
||||
# exactly the pre-fused checkpoint layout FusedMoE self-loads once fc1/fc2
|
||||
# are renamed to the fused gate_up_proj/down_proj names.
|
||||
# The fused expert loader expects names without the .weight suffix.
|
||||
hf_to_vllm_mapper = LlamaModel.hf_to_vllm_mapper | WeightsMapper(
|
||||
orig_to_new_regex={
|
||||
re.compile(r"experts\.fc1\.weight$"): "experts.gate_up_proj",
|
||||
re.compile(r"experts\.fc2\.weight$"): "experts.down_proj",
|
||||
},
|
||||
# Quantization configs also use the expert module names.
|
||||
orig_to_new_substr={
|
||||
"experts.fc1": "experts.gate_up_proj",
|
||||
"experts.fc2": "experts.down_proj",
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
def __init__(self, *, vllm_config: VllmConfig, prefix: str = ""):
|
||||
|
||||
Reference in New Issue
Block a user