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

Add fused_mlp to glm4v models #12378

Merged
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
5 changes: 4 additions & 1 deletion python/llm/src/ipex_llm/transformers/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -1056,13 +1056,14 @@ def _optimize_pre(model, qtype=None):
from ipex_llm.transformers.models.chatglm2 import split_mlp
model.apply(split_mlp)
elif isinstance(model.config.eos_token_id, list):
from ipex_llm.transformers.models.chatglm2 import split_mlp
# glm4 family
if hasattr(model.transformer, "vision"):
if model.config.num_layers != 40:
from ipex_llm.transformers.models.chatglm4v import merge_qkv
model.apply(merge_qkv)
model.apply(split_mlp)
elif model.config.num_layers in [40, 28]:
from ipex_llm.transformers.models.chatglm2 import split_mlp
model.apply(split_mlp)

return model
Expand Down Expand Up @@ -1459,6 +1460,8 @@ def _optimize_post(model, lightweight_bmm=False):
convert_forward(model, SiglipAttention, siglip_attention_forward)
from ipex_llm.transformers.models.chatglm4v import vision_model_forward
convert_forward(model, vision_module.VisionModel, vision_model_forward)
from ipex_llm.transformers.models.chatglm2 import mlp_forward
convert_forward(model, module.MLP, mlp_forward)

elif model.config.num_layers in [40, 28]:
# glm-4-9b
Expand Down
Loading