[GPU] Fix MoE fusion accuracy for flattened PagedAttention inputs #38631
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 552 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.378
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #38631"
general
weight: 0.35
v-Golubev
Description of the issue (symptom, root cause, and resolution)
[tokens, hidden]. However, the fusion could select[tokens, 1, hidden]as the fused MoE input.[tokens, 1, hidden]to the shared-expert output[tokens, hidden]caused unintended broadcasting to[tokens, tokens, hidden].hidden_states_mwhen it matches the final unfused output shape; otherwise, they use the input before the matchedUnsqueeze.Reshapeis cloned after the fused MoE. This preserves both the optimization and the original output-shape semantics.has_batch_dimis derived locally from the selected input rank: rank 3 indicates a batch dimension, while rank 2 indicates flattened input. Fusion is skipped only for dynamic or unsupported input ranks.Relevant code
src/common/transformations/src/transformations/common_optimizations/moe_op_fusion.cpp-
Convert3GatherMatmulMoeBlockToMoeOp-
Convert2GatherMatmulMoeBlockToMoeOpsrc/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp- Registers
MoeOpFusionwithout a model-globalhas_batch_dimvalue.src/plugins/intel_gpu/src/plugin/transformations/fuse_moe_router.cpp-
FuseMoESoftmaxRouter-
FuseMoESigmoidRouterReproduction and validation
Problematic graph
The original unfused graph restores the flattened
[tokens, hidden]shape before combining the routed and shared-expert branches.Before the fix, the fusion could use the tensor containing the singleton dimension as input 0. The routed branch therefore produced
[tokens, 1, hidden], causing unintended broadcasting when combined with[tokens, hidden].The fix first compares
hidden_states_mwith the final unfused output shape. If they differ, it selects the input before the matchedUnsqueeze, which is the actual flattened BGM input.When the selected input matches the original output, as in the MiniCPM topology, the fused MoE directly preserves
[tokens, hidden]. If it still differs, the transformation remains enabled and clones the original finalReshapeafter the fused MoE.Tickets