|
43 | 43 | from vllm.distributed import utils as dist_utils |
44 | 44 | from vllm.logger import init_logger |
45 | 45 | from vllm.model_executor import SamplingMetadata |
46 | | -from vllm.model_executor.layers.activation import _ACTIVATION_REGISTRY |
| 46 | +from vllm.model_executor.layers.activation import _ACTIVATION_REGISTRY, SiluAndMul |
47 | 47 | from vllm.model_executor.layers.layernorm import RMSNorm |
48 | 48 | from vllm.model_executor.layers.linear import (ColumnParallelLinear, |
| 49 | + MergedColumnParallelLinear, |
49 | 50 | QKVParallelLinear, |
50 | 51 | RowParallelLinear) |
51 | 52 | from vllm.model_executor.layers.quantization import QuantizationConfig |
@@ -171,28 +172,23 @@ def __init__(self, |
171 | 172 | quant_config: Optional[QuantizationConfig] = None, |
172 | 173 | prefix: str = ""): |
173 | 174 | super().__init__() |
174 | | - self.gate_proj = ColumnParallelLinear(in_features, |
175 | | - hidden_features, |
176 | | - bias=bias, |
177 | | - quant_config=quant_config, |
178 | | - prefix=f"{prefix}.gate_proj") |
179 | | - self.up_proj = ColumnParallelLinear(in_features, |
180 | | - hidden_features, |
181 | | - bias=bias, |
182 | | - quant_config=quant_config, |
183 | | - prefix=f"{prefix}.up_proj") |
| 175 | + self.gate_up_proj = MergedColumnParallelLinear( |
| 176 | + input_size=in_features, |
| 177 | + output_sizes=[hidden_features] * 2, # [gate_proj, up_proj] |
| 178 | + bias=bias, |
| 179 | + quant_config=quant_config, |
| 180 | + prefix=f"{prefix}.gate_up_proj") |
184 | 181 | self.down_proj = RowParallelLinear(hidden_features, |
185 | 182 | in_features, |
186 | 183 | bias=bias, |
187 | 184 | quant_config=quant_config, |
188 | 185 | prefix=f"{prefix}.down_proj") |
189 | | - self.act_fn = act_fn |
| 186 | + self.act_fn = SiluAndMul() |
190 | 187 |
|
191 | 188 | def forward(self, x: torch.Tensor): |
192 | | - x_gate, _ = self.gate_proj(x) |
193 | | - x_gate = self.act_fn(x_gate) |
194 | | - x_up, _ = self.up_proj(x) |
195 | | - x_down, _ = self.down_proj(x_gate * x_up) |
| 189 | + gate_up, _ = self.gate_up_proj(x) |
| 190 | + x = self.act_fn(gate_up) |
| 191 | + x_down, _ = self.down_proj(x) |
196 | 192 | return x_down |
197 | 193 |
|
198 | 194 |
|
@@ -539,6 +535,10 @@ def __init__( |
539 | 535 | head_dim = self.hidden_size // self.num_heads |
540 | 536 | self.rotary_pos_emb = Qwen2_5_VisionRotaryEmbedding(head_dim // 2) |
541 | 537 |
|
| 538 | + if vision_config.hidden_act != "silu": |
| 539 | + raise ValueError(f"Unsupported activation: {vision_config.hidden_act}. " |
| 540 | + "Only silu is supported for now.") |
| 541 | + |
542 | 542 | self.blocks = nn.ModuleList([ |
543 | 543 | Qwen2_5_VisionBlock( |
544 | 544 | dim=self.hidden_size, |
@@ -752,6 +752,8 @@ def load_weights(self, weights: Iterable[tuple[str, |
752 | 752 | ("attn.qkv.", "attn.q.", "q"), |
753 | 753 | ("attn.qkv.", "attn.k.", "k"), |
754 | 754 | ("attn.qkv.", "attn.v.", "v"), |
| 755 | + ("mlp.gate_up_proj.", "mlp.gate_proj.", 0), |
| 756 | + ("mlp.gate_up_proj.", "mlp.up_proj.", 1), |
755 | 757 | ] |
756 | 758 | params_dict = dict(self.named_parameters(remove_duplicate=False)) |
757 | 759 | loaded_params: set[str] = set() |
|
0 commit comments