You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Two coupled changes that make gemma4 26B MoE run correctly on the GPU device
with no manual flag.
1. Auto-detect MoE and stop fragmenting the GPU graph. The per-node "force this
MoE op to CPU on GPU" gates fragment the graph into dozens of submodels with
cross-boundary copies (which mis-handle e.g. the layer-5 argsort indices and
crash). GGML_OPENVINO_GPU_FULL_MOE kept the whole MoE on one OV submodel but
had to be set by hand. Now ggml_openvino_gpu_full_moe_enabled() auto-enables
it when running a MoE model on GPU: a GGML_OP_MUL_MAT_ID op (the expert-routed
matmul, the defining op of a MoE model) latches a process-global flag from
supports_op() at op-placement time. The scheduler queries placement before the
expert weights are streamed in and makes several placement passes, so the first
pass that sees MUL_MAT_ID sets the flag and later passes converge on the
full-MoE layout. The GGML_OPENVINO_GPU_FULL_MOE env var still overrides
(non-zero forces on, "0" forces off as an escape hatch). CPU/NPU behavior is
unchanged: the gates are GPU-guarded, and the auto path only fires on GPU.
2. Dodge the GPU rms_fusion bug on that path. OpenVINO's rms_fusion folds
Power(x, 2) -> ... into the internal RMS op; on the GPU plugin that fused RMS
primitive's dynamic multi-token kernel writes only token 0 (tokens 1..N read
back as 0). For gemma4 this collapsed the per-layer router RMSNorm (~7x summed
over the prefill tokens), flattening the router softmax and flipping the top-8
expert selection, so the GPU output drifted ("France" -> " only"). On the GPU
full-MoE path only, compute the square as Multiply(x, x): algebraically
identical, but it does not match the fusion pattern, so the GPU runs the
unfused primitives and writes every token. Every other configuration keeps the
fused fast path (CPU, NPU, and non-MoE GPU models such as Llama-3.2-1B).
Verified: gemma4 26B MoE on GPU with NO flag now matches CPU byte-for-byte on
prefill and multi-token decode; the GGML_OPENVINO_GPU_FULL_MOE=0 escape hatch
restores the old (fragmented) path; gemma4 CPU output unchanged; dense
Llama-3.2-1B on GPU still correct with rms_fusion active.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments