Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LLM Inference] Qwen2_Moe Support wint4 #9129

Merged
merged 2 commits into from
Sep 14, 2024
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 @@
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

Check warning on line 1304 in paddlenlp/experimental/transformers/fused_transformer_layers.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/experimental/transformers/fused_transformer_layers.py#L1302-L1304

Added lines #L1302 - L1304 were not covered by tests
else:
self.moe_ffn1_weight_shape[2] //= 2
self.moe_ffn2_weight_shape[2] //= 2

Check warning on line 1307 in paddlenlp/experimental/transformers/fused_transformer_layers.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/experimental/transformers/fused_transformer_layers.py#L1306-L1307

Added lines #L1306 - L1307 were not covered by tests

if self.config.moe_config.has_shared_expert():
self.shared_expert_ffn1_weight_shape = [
Expand All @@ -1315,6 +1319,9 @@
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

Check warning on line 1324 in paddlenlp/experimental/transformers/fused_transformer_layers.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/experimental/transformers/fused_transformer_layers.py#L1322-L1324

Added lines #L1322 - L1324 were not covered by tests

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