Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions paddlenlp/experimental/transformers/fused_transformer_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1299,8 +1299,12 @@ def init_weight_shape(self, config):
self.moe_ffn2_weight_shape = [self.config.moe_config.num_experts, self.dim_feedforward, self.embed_dim]

if config.quant_type == "weight_only_int4":
self.moe_ffn1_weight_shape[2] //= 2
self.moe_ffn2_weight_shape[2] //= 2
if config.moe_config.has_shared_expert():
self.moe_ffn1_weight_shape[2] //= 2
self.moe_ffn2_weight_shape[1] //= 2
else:
self.moe_ffn1_weight_shape[2] //= 2
self.moe_ffn2_weight_shape[2] //= 2

if self.config.moe_config.has_shared_expert():
self.shared_expert_ffn1_weight_shape = [
Expand All @@ -1315,6 +1319,9 @@ def init_weight_shape(self, config):
self.embed_dim,
1,
]
if config.quant_type == "weight_only_int4":
self.shared_expert_ffn1_weight_shape[0] //= 2
self.shared_expert_ffn2_weight_shape[0] //= 2

def compute_qkv_linear(self, ln_out, i):
return weight_only_linear(
Expand Down