Skip to content

ggml-openvino: honour the -1 skip id in MUL_MAT_ID - #363

Merged
ravi9 merged 1 commit into
dev_backend_openvinofrom
ov-fix-mul-mat-id-skip
Oct 26, 2026
Merged

ravi9 merged 1 commit into
dev_backend_openvinofrom
ov-fix-mul-mat-id-skip

Conversation

@ravi9

@ravi9 ravi9 commented Oct 26, 2026

Copy link
Copy Markdown
Owner

ggml-org#26631 made an id of -1 in MUL_MAT_ID skip the slot and zero its row of the result. It updated the OpenVINO ADD_ID translator but not MUL_MAT_ID, so -1 reached GatherMatmul and Gather as an expert index, and 169 of the 743 MUL_MAT_ID op tests on CPU (all skip=1) failed.

  • A skipped slot looks up a valid expert, and the result is multiplied by a 0/1 mask of the kept slots.
  • In the packed MXFP4 path (Gather and MatMul), clamping the id to expert 0 is enough.
  • GatherMatmul computes a wrong row when a token names the same expert twice, so the general path gives each skipped slot an expert that no other slot of that token uses.
  • ids that come from TopK are never -1. Model graphs take their ids from the router's TopK, so they skip this handling, stay unchanged, and still match the GPU MoE fusion.

Upstream made an id of -1 in MUL_MAT_ID skip the slot and zero its row of
the result. The translator passed -1 straight to GatherMatmul or Gather,
so 169 of the 743 MUL_MAT_ID op tests on CPU (all skip=1) failed.

A skipped slot now looks up a valid expert, and the result is multiplied
by a 0/1 mask of the kept slots. For the packed MXFP4 path (Gather and
MatMul), clamping the id to expert 0 is enough. GatherMatmul computes a
wrong row when a token names the same expert twice, so the general path
gives each skipped slot an expert that no other slot of the token uses.

TopK indices are never -1, and model graphs take the ids from the
router's TopK. Those graphs skip the handling and stay unchanged, so the
GPU MoE fusion still matches them.
@ravi9
ravi9 merged commit 508e30b into dev_backend_openvino Oct 26, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant