Repository navigation
Guard mixed-precision skip RMS normalization fusion - #3163
Open
Justin Chu (justinchuby) with Copilot wants to merge 3 commits into
Open
Justin Chu (justinchuby) with Copilot wants to merge 3 commits into
Justin Chu (justinchuby) with Copilot wants to merge 3 commits into
Conversation
Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix float16 residual fusion with float32 scale in norm
Guard mixed-precision skip RMS normalization fusion
Nov 5, 2026
Justin Chu (justinchuby)
marked this pull request as ready for review
November 5, 2026 21:23
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The fusion can silently replace an overridable graph-input scale with a fixed constant, ignoring runtime values, and abort when external scale data is unavailable.
2 open issues
What changed in this PR
This PR addresses #3155 by guarding skip RMS normalization fusion against mixed dtypes that ONNX Runtime rejects, while preserving fusion for eligible float32 scales.
Changes:
- Require matching input, skip, and optional bias dtypes.
- Narrow exactly representable constant scales to float16 when normalization exclusively feeds a cast back to float16.
- Add regression coverage for safe and unsafe scales, shared outputs, bias variants, and Gemma-style optimization.
| File | Description |
|---|---|
onnxscript/rewriter/ort_fusions/skip_normalization.py |
Adds dtype guards and cast-back fusion rules with scale narrowing. |
onnxscript/rewriter/ort_fusions/skip_normalization_unit_test.py |
Tests mixed-precision fusion eligibility and numerical equivalence. |
Review effort: Balanced
Comment on lines
+84
to
+85
| if gamma.const_value is None: | ||
| return check_result.fail("Scale narrowing requires a constant scale.", gamma) |
| ) | ||
| if gamma.const_value is None: | ||
| return check_result.fail("Scale narrowing requires a constant scale.", gamma) | ||
| scale = gamma.const_value.numpy() |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3163 +/- ##
==========================================
+ Coverage 73.34% 73.42% +0.07%
==========================================
Files 269 269
Lines 33564 33668 +104
Branches 3210 3226 +16
==========================================
+ Hits 24618 24720 +102
- Misses 7876 7879 +3
+ Partials 1070 1069 -1 ☔ View full report in Codecov by Harness. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Skip RMS fusion can combine float16 residual inputs with a float32 scale, producing a graph ONNX Runtime rejects.
fuse_skip_rms_normalizationfuses a float16 residual into a norm whose scale is float32, which ONNX Runtime rejects #3155