[Mypy] Fix typing for R/S models (#54157)
Signed-off-by: Taneem Ibrahim <taneem.ibrahim@gmail.com>
This commit is contained in:
@@ -10,7 +10,7 @@ import torch
|
||||
from torch import nn
|
||||
|
||||
from vllm.compilation.decorators import support_torch_compile
|
||||
from vllm.config import CacheConfig, ModelConfig, VllmConfig
|
||||
from vllm.config import CacheConfig, VllmConfig
|
||||
from vllm.distributed import (
|
||||
get_pp_group,
|
||||
get_tensor_model_parallel_world_size,
|
||||
@@ -55,7 +55,7 @@ logger = init_logger(__name__)
|
||||
class FusedMoEBlock(nn.Module):
|
||||
def __init__(
|
||||
self,
|
||||
config: ModelConfig,
|
||||
config: Step3TextConfig,
|
||||
quant_config: QuantizationConfig | None = None,
|
||||
prefix: str = "",
|
||||
):
|
||||
@@ -384,7 +384,7 @@ class Step3TextModel(nn.Module):
|
||||
return hidden_states
|
||||
|
||||
def load_weights(self, weights: Iterable[tuple[str, torch.Tensor]]) -> set[str]:
|
||||
qkv_params_mapping = [
|
||||
qkv_params_mapping: list[tuple[str, str, float, float]] = [
|
||||
# (param_name, shard_name, relative_start_idx, relative_end_idx)
|
||||
(
|
||||
".qkv_proj",
|
||||
@@ -410,7 +410,7 @@ class Step3TextModel(nn.Module):
|
||||
/ (self.config.share_q_dim + self.config.head_dim * 2),
|
||||
),
|
||||
]
|
||||
stacked_params_mapping = [
|
||||
stacked_params_mapping: list[tuple[str, str, int]] = [
|
||||
# (param_name, shard_name, shard_id)
|
||||
(".gate_up_proj", ".gate_proj", 0),
|
||||
(".gate_up_proj", ".up_proj", 1),
|
||||
@@ -421,7 +421,7 @@ class Step3TextModel(nn.Module):
|
||||
"base_layer." if any(".base_layer." in name for name in params_dict) else ""
|
||||
)
|
||||
|
||||
expert_params_mapping = [
|
||||
expert_params_mapping: list[tuple[str, str, str]] = [
|
||||
(
|
||||
f".moe.experts.routed_experts.{base_layer}w13_weight",
|
||||
".moe.gate_proj.weight",
|
||||
@@ -460,7 +460,7 @@ class Step3TextModel(nn.Module):
|
||||
break
|
||||
else:
|
||||
for mapping in expert_params_mapping:
|
||||
param_name, weight_name, shard_id = mapping
|
||||
param_name, weight_name, expert_shard_id = mapping
|
||||
if weight_name not in name:
|
||||
continue
|
||||
name = name.replace(weight_name, param_name)
|
||||
@@ -480,7 +480,7 @@ class Step3TextModel(nn.Module):
|
||||
param,
|
||||
loaded_weight_expert,
|
||||
name,
|
||||
shard_id=shard_id,
|
||||
shard_id=expert_shard_id,
|
||||
expert_id=expert_id,
|
||||
)
|
||||
loaded_params.add(name)
|
||||
|
||||
Reference in New Issue
Block a user