Commit 6288d94
committed
ggml-openvino: add Gemma-4 26B MoE support
Adds support for the Gemma-4 26B-A4B hybrid-FFN MoE model on the OpenVINO
backend (dense shared FFN + 128-expert top-8 MoE per layer, interleaved
SWA/global attention, QK-norm, sandwich norms, logit soft-cap).
Backend changes (all under ggml/src/ggml-openvino/):
- 3D quantized expert weights: rank-2 GatherCompressed-matchable dequant
(Q4_K gate/up, Q5_1 down), f16 zero-point (zp = -bias/scale) so the
fusable Subtract form stays algebraically w*s + min without OOM; extracted
in-place into the backend buffer (use_bias sizing).
- Per-expert VIEW slicing on the non-static path + unique VIEW output names
so the 8 same-named expert views no longer collide in the tensor_map.
- MoE token dim kept dynamic through SUM_ROWS/DIV/CLAMP routing-norm ops and
the per-expert scale, so all RoPE concats stay dynamic (fixes decode
Broadcast mismatch and the GPU in-place-concat KV-cache corruption).
- GET_ROWS batched-gather index broadcast tied to the data batch dim.
- Full-MoE path: keep the whole MoE (routing gather/softmax/normalization +
expert matmuls) on one OV submodel instead of fragmenting at every MoE
node. Auto-enabled for MoE models on the dynamic-shape devices (CPU/GPU),
latched on MUL_MAT_ID at placement; NPU keeps the fragmented static path.
The un-fragmented graph is numerically correct on both CPU and GPU and
avoids the cross-submodel index corruption the fragmented path hit.
- op gating: exclude fused TOPK_MOE (uses ARGSORT routing), i64 CONCAT,
borderline q4_1/q5_1 n=256 GET_ROWS, and oversized non-expert MUL_MAT_ID.
- Guard is_kvcache() against a null view_src on SCALE ops (gemma4 inp_scaled),
which otherwise segfaults compute_llm_params.
Verified against ravi9/dev_backend_openvino: gemma4 26B MoE CPU greedy
"Paris is the capital of France"; gemma4 E2B on CPU/GPU; dense Llama-3.2-1B
on CPU+GPU byte-identical to baseline; test-backend-ops OPENVINO CPU
2622/2622 and GPU 2576/2576.1 parent 396adc3 commit 6288d94
10 files changed
Lines changed: 554 additions & 75 deletions
File tree
- ggml/src/ggml-openvino
- openvino
- op
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
565 | 565 | | |
566 | 566 | | |
567 | 567 | | |
568 | | - | |
| 568 | + | |
569 | 569 | | |
570 | 570 | | |
571 | 571 | | |
| |||
958 | 958 | | |
959 | 959 | | |
960 | 960 | | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
961 | 985 | | |
962 | 986 | | |
963 | 987 | | |
| |||
1673 | 1697 | | |
1674 | 1698 | | |
1675 | 1699 | | |
| 1700 | + | |
| 1701 | + | |
| 1702 | + | |
| 1703 | + | |
| 1704 | + | |
| 1705 | + | |
| 1706 | + | |
| 1707 | + | |
1676 | 1708 | | |
1677 | 1709 | | |
| 1710 | + | |
| 1711 | + | |
| 1712 | + | |
| 1713 | + | |
| 1714 | + | |
| 1715 | + | |
1678 | 1716 | | |
1679 | 1717 | | |
1680 | 1718 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
176 | 198 | | |
177 | 199 | | |
178 | 200 | | |
| |||
252 | 274 | | |
253 | 275 | | |
254 | 276 | | |
255 | | - | |
256 | | - | |
257 | | - | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
258 | 283 | | |
259 | 284 | | |
260 | 285 | | |
| |||
390 | 415 | | |
391 | 416 | | |
392 | 417 | | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
393 | 422 | | |
394 | 423 | | |
395 | 424 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
102 | 120 | | |
103 | 121 | | |
104 | 122 | | |
| |||
0 commit comments