Skip to content

ggml-zendnn : group matmul direct API for mul_mat_id - #25918

Merged
ggerganov merged 2 commits into
ggml-org:masterfrom
z-sachin:ggml-zendnn/refactor-mul-mat-id
Jul 31, 2026
Merged

ggerganov merged 2 commits into
ggml-org:masterfrom
z-sachin:ggml-zendnn/refactor-mul-mat-id

Conversation

@z-sachin

Copy link
Copy Markdown
Contributor

Overview

This PR updates the vendored ZenDNN dependency to the latest WW28 release and switches the ZenDNN mul_mat_id implementation to use grouped GEMM, allowing all active experts to be processed in a single backend call.

Changes

  • Add ggml_zendnn_group_matmul() and ggml_zendnn_group_gemm() wrappers that batch all active experts' GEMMs into a single ZenDNN grouped GEMM call instead of issuing one call per expert.

  • Rework ggml_zendnn_compute_forward_mul_mat_id() to support grouped execution:

    • Resize the gather/scatter buffer based on total_rows instead of max_rows, since data for all active experts must coexist for a single grouped GEMM.
    • Precompute each expert's offset into the shared buffer.
    • Fold the src1 → vec_dot_type conversion into the gather step, eliminating the separate conversion pass.
  • Restructure the execution flow from for each expert: gather → GEMM → scatter to gather all experts → one grouped GEMM → scatter all experts.

  • Remove the outdated comment in device_supports_op() that described grouped GEMM as future work. The existing 32-expert limit remains unchanged.

Requirements

@github-actions github-actions Bot added ggml changes relating to the ggml tensor library for machine learning AMD ZenDNN Issues related to the AMD ZenDNN backend labels Jul 20, 2026
@taronaeo

Copy link
Copy Markdown
Member

cc: @z-vishal

@z-manoj

z-manoj commented Jul 21, 2026

Copy link
Copy Markdown

CC @avinashcpandey @Jiten1parmar

@Jiten1parmar Jiten1parmar left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

@taronaeo taronaeo added the merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge. label Jul 30, 2026
@ggerganov
ggerganov merged commit 1e22599 into ggml-org:master Jul 31, 2026
19 of 25 checks passed
huaxel pushed a commit to huaxel/strix-llama.cpp that referenced this pull request Aug 2, 2026
* ggml-zendnn : group matmul API for mul_mat_id

* ggml-zendnn : scale MUL_MAT_ID fallback threshold by expert count
satindergrewal pushed a commit to satindergrewal/llama.cpp that referenced this pull request Aug 12, 2026
* ggml-zendnn : group matmul API for mul_mat_id

* ggml-zendnn : scale MUL_MAT_ID fallback threshold by expert count
thecodacus pushed a commit to thecodacus/llama.cpp that referenced this pull request Sep 7, 2026
* ggml-zendnn : group matmul API for mul_mat_id

* ggml-zendnn : scale MUL_MAT_ID fallback threshold by expert count
zbrad pushed a commit to zbrad/llama.cpp that referenced this pull request Sep 10, 2026
* ggml-zendnn : group matmul API for mul_mat_id

* ggml-zendnn : scale MUL_MAT_ID fallback threshold by expert count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AMD ZenDNN Issues related to the AMD ZenDNN backend ggml changes relating to the ggml tensor library for machine learning merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants