Skip to content

Fix LayerNorm fusion selecting the Div output as scale or bias - #31148

Open
Sammy-Dabbas wants to merge 1 commit into
microsoft:mainfrom
Sammy-Dabbas:fix/layernorm-fusion-scale-selection
Open

Fix LayerNorm fusion selecting the Div output as scale or bias#31148
Sammy-Dabbas wants to merge 1 commit into
microsoft:mainfrom
Sammy-Dabbas:fix/layernorm-fusion-scale-selection

Conversation

@Sammy-Dabbas

Copy link
Copy Markdown
Contributor

Fixes #31147.

The scale selection in LayerNormFusion and SimplifiedLayerNormFusion picks a Mul input by rank alone, so a rank-1 Div output can be chosen as scale. The fusion removes the Div and the fused node references a dangling input, failing session creation with "Node input 'nm' is not a graph input, initializer, or output of a previous node". The bias loop can pick the Mul output the same way. This reproduces with keepdims=1, so it is separate from #31144.

The fix excludes operands produced inside the matched subgraph from scale and bias candidacy; when none remain, the fusion is skipped. Valid fusions are unaffected because a real scale always comes from outside the chain. Two negative tests added, one per fusion class; both fail before the change. No local C++ build available, so CI is the executable check.

The fusion could pick an operand produced inside the matched subgraph,
then remove its producer, leaving a dangling input that failed graph
resolve (microsoft#30513). Exclude in-subgraph operands from scale/bias candidacy.
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LayerNorm fusion selects the Div output as scale, failing session creation even with keepdims=1

1 participant