Repository navigation
openvino: match the MoE fusion on the rank-3 stateful graph - #335
Merged
ravi9 merged 1 commit intoOct 5, 2026
Merged
Conversation
cavusmustafa
force-pushed
the
moe_fusion_rank3_stateful
branch
from
October 3, 2026 16:36
7e45125 to
e6100fc
Compare
ravi9
force-pushed
the
dev_backend_openvino
branch
from
October 3, 2026 19:48
308ccd8 to
836d571
Compare
cavusmustafa
force-pushed
the
moe_fusion_rank3_stateful
branch
from
October 5, 2026 19:00
e6100fc to
b68dc9e
Compare
ravi9
force-pushed
the
moe_fusion_rank3_stateful
branch
from
October 5, 2026 21:40
b68dc9e to
324a0c5
Compare
ravi9
marked this pull request as ready for review
October 5, 2026 22:32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
FuseMoeCompressedFusedGateUp only matched the rank-4 graph, so under GGML_OPENVINO_STATEFUL_EXECUTION=1 gemma-4 26B-A4B silently ran the unfused MoE path: pp512 dropped from ~1600 t/s to 66 t/s while decode kept its gain.
The pattern did not bind at all (the callback was never invoked), because the rank-3 graph differs in node structure, not only in rank:
rank-4: GatherMatmul -> Transpose -> Unsqueeze -> [Convert] -> Slice
rank-3: GatherMatmul -> Convert -> Transpose -> Slice
The rank-3 graph never drops to a batch dim, so it has no Unsqueeze after the expert GEMM - that Unsqueeze sits between the GEGLU and the down projection instead - and its Convert is on the other side of the Transpose. Wrap both in optional<>, which matches either form, in the gate/up and down branches.
With the pattern binding, the routing guard is reached and rejects rank 3. Routing arrives as [n_tokens, top_k, 1] there versus [1, n_tokens, top_k, 1] on the rank-4 graph, so normalise it up to the rank-4 form, keep the op config that the stateless path already validates, and squeeze the batch dim back off the result. Guard that the replacement shape matches the ReduceSum it replaces.
26B-A4B on Arc B390, GPU, GGML_OPENVINO_REQUANT_KQUANT=q4_asym64_all: stateful pp512 66 -> 1585 t/s, tg128 30.2; prefill now at parity with stateless (1609) instead of 24x behind it.
The stateless path is unchanged: 26B perplexity is bit-identical before and after (7990.0534 +/- 1274.45692), and test-backend-ops -o MUL_MAT_ID on OPENVINO0 goes from 575/577 to 577/577.
Overview
Additional information
Requirements