Skip to content

Comments

vulkan: fuse mul_mat_id + mul#17095

Merged
0cc4m merged 2 commits intoggml-org:masterfrom
jeffbolznv:mul_mat_id_mul
Nov 9, 2025
Merged

vulkan: fuse mul_mat_id + mul#17095
0cc4m merged 2 commits intoggml-org:masterfrom
jeffbolznv:mul_mat_id_mul

Conversation

@jeffbolznv
Copy link
Collaborator

This comes up in qwen3 moe. Worth 1-2% on Qwen3 MoE.

I'd eventually like to generalize this, to be able to handle things like MUL_MAT_ID + ADD_ID + MUL (which comes up in gpt-oss).

@github-actions github-actions bot added testing Everything test related Vulkan Issues specific to the Vulkan backend ggml changes relating to the ggml tensor library for machine learning labels Nov 8, 2025
@0cc4m
Copy link
Collaborator

0cc4m commented Nov 8, 2025

Please fix the conflict.

This comes up in qwen3 moe.
@jeffbolznv
Copy link
Collaborator Author

Rebased.

Comment on lines +3619 to +3624
if (mul) {
std::array<int64_t, 4> ne { 1, out->ne[1], out->ne[2], out->ne[3] };
ne[0] = 1;
ggml_tensor * m = ggml_new_tensor(ctx, out->type, 4, ne.data());
out = ggml_mul(ctx, out, m);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't like how we keep making the basic, single op test cases more complex by adding flags to change the behavior completely. Can you move the fusion cases to a different class?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, done.

Copy link
Collaborator

@0cc4m 0cc4m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@0cc4m 0cc4m merged commit 80a6cf6 into ggml-org:master Nov 9, 2025
71 checks passed
Anico2 added a commit to Anico2/llama.cpp that referenced this pull request Jan 15, 2026
* vulkan: fuse mul_mat_id + mul

This comes up in qwen3 moe.

* split mul_mat_id fusion tests into a separate class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ggml changes relating to the ggml tensor library for machine learning testing Everything test related Vulkan Issues specific to the Vulkan backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants