Commit 58edb88
Gemma 4 MoE: re-enable fused com.microsoft::MoE op
ORT main now plumbs the SwiGLU schema attributes
(`swiglu_fusion`, `activation_alpha`, `activation_beta`,
`swiglu_limit`) through to the kernel via microsoft/onnxruntime#28467
(QMoE CUDA EP + MoE GEMM Refactor), so the fused MoE op now correctly
implements standard SwiGLU (`y = silu(gate) * up`) rather than only
GPT-OSS-style SwiGLU. This was the original blocker tracked in
microsoft/onnxruntime-genai#2062.
Switch Gemma 4's MoE block back to `com.microsoft::MoE` when the EP
advertises `supports_fused_moe`, with the explicit attribute set
required by standard SwiGLU:
activation_type = 'swiglu'
activation_alpha = 1.0 (no GPT-OSS 1.702 multiplier)
activation_beta = 0.0 (no GPT-OSS "+1" bias on the up branch)
swiglu_limit = inf (no clipping)
swiglu_fusion = 1 (interleaved)
normalize_routing_weights = 1
k = top_k
The CPU MoE kernel still only supports interleaved layout
(`contrib_ops/cpu/moe/moe_cpu.cc:27`), and the new CUDA kernel
accepts either, so emit interleaved (`swiglu_fusion=1`) for maximum
portability. HuggingFace stores `experts.gate_up_proj` chunked as
`[E, 2*inter, H]` (first `inter` rows = gate, next `inter` = up).
Convert at graph-emit time via Reshape→Transpose→Reshape on the
initializer; ORT folds the chain to a single static tensor at session
load.
The static-unroll `_dispatch_moe_fallback` is kept verbatim for EPs
that don't expose the fused op.
Validation on H200 with ORT 1.27.0.dev20260511001 (which contains
#28467):
* fp16 build of google/gemma-4-26b-a4b-it: 30 MoE nodes emitted, all
with the expected attribute set.
* `InferenceSession` on CUDAExecutionProvider loads in 12.3s
(vs 959s with the previous fully-unrolled fallback, a ~78x speedup
on session creation alone).
* Prefill (B=1, S=4) runs in 0.65s; logits are well-behaved (no NaN
or Inf, top-k token IDs land in the valid Gemma 4 vocab range).
All 15 `gemma4` graph-construction tests pass, lintrunner clean.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchu@microsoft.com>1 parent 395f022 commit 58edb88
1 file changed
Lines changed: 70 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1099 | 1099 | | |
1100 | 1100 | | |
1101 | 1101 | | |
| 1102 | + | |
| 1103 | + | |
1102 | 1104 | | |
1103 | 1105 | | |
1104 | 1106 | | |
| |||
1175 | 1177 | | |
1176 | 1178 | | |
1177 | 1179 | | |
1178 | | - | |
1179 | | - | |
1180 | | - | |
1181 | | - | |
1182 | | - | |
1183 | | - | |
1184 | | - | |
1185 | | - | |
1186 | | - | |
1187 | | - | |
1188 | | - | |
1189 | | - | |
1190 | | - | |
1191 | | - | |
1192 | | - | |
1193 | | - | |
1194 | | - | |
1195 | | - | |
1196 | | - | |
1197 | | - | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
1198 | 1248 | | |
1199 | 1249 | | |
1200 | 1250 | | |
| |||
0 commit comments