[TRANSFORMATIONS] Preserve bias output precision during activation scaling - #38089
Open
andrew-k-park wants to merge 1 commit into
Open
Conversation
andrew-k-park
requested review from
a team and
e-ddykim
and
a balanced review from Copilot
September 11, 2026 10:13
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The regression test must verify that the transformation actually executes.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Fixes activation scaling to preserve a type-relaxed bias Add’s output precision.
Changes:
- Uses the bias Add’s output type for scale restoration.
- Adds an FP32 regression scenario.
File summaries
| File | Description |
|---|---|
activations_scaling.cpp |
Preserves bias Add output precision. |
activations_scaling_test.cpp |
Adds TypeRelaxed Add coverage. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+145
to
+148
| EXPECT_NO_THROW(manager.run_passes(model)); | ||
| EXPECT_EQ(gelu->get_output_element_type(0), element::f32); | ||
| EXPECT_EQ(matmul1->get_input_element_type(0), element::f32); | ||
| EXPECT_EQ(matmul1->get_input_element_type(1), element::f32); |
…aling Use the original output precision of a fused bias Add when inserting the scale-up operation. Previously, ScaleDownSingleLayer restored the MatMul output precision even when a TypeRelaxed bias Add extended the scaled region. This could convert an FP32 Add output to FP16 and invalidate a downstream MatMul with FP32 decompressed weights. Add a GPU-independent regression test covering the FP16 MatMul, FP32 TypeRelaxed bias Add, GELU, and downstream FP32 MatMul sequence.
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.
Details:
ScaleDownSingleLayerincorrectly restoring the MatMul output precision when a supported biasAddextends the scaled region.flowchart LR A["MatMul<br/>output: FP16"] --> B["TypeRelaxed Add<br/>output contract: FP32"] Bias["Bias<br/>FP32"] --> B B --> C["GELU<br/>FP32"] C --> D["Downstream MatMul<br/>activation: FP32<br/>weights: FP32"] W["Decompressed weights<br/>FP32"] --> Dflowchart LR A["MatMul<br/>output: FP16"] --> B["TypeRelaxed Add<br/>output: FP32"] Bias["Scaled bias<br/>FP32"] --> B B --> X["Convert<br/>FP32 to FP16"] X --> S["Scale-up Multiply<br/>FP16"] S --> C["GELU<br/>FP16"] C --> D["Downstream MatMul<br/>INVALID"] W["Decompressed weights<br/>FP32"] --> D style C fill:#fff3cd,stroke:#b58105,color:#24292f style W fill:#fff3cd,stroke:#b58105,color:#24292f style D fill:#ffebe9,stroke:#cf222e,stroke-width:2px,color:#24292fScaleDownSingleLayercapturedoutput_precfrom the first MatMul before detecting that the bias Add extended the scaled region.flowchart LR A["MatMul<br/>output: FP16"] --> B["TypeRelaxed Add<br/>output: FP32"] Bias["Scaled bias<br/>FP32"] --> B B --> S["Scale-up Multiply<br/>FP32"] S --> C["GELU<br/>FP32"] C --> D["Downstream MatMul<br/>VALID"] W["Decompressed weights<br/>FP32"] --> D style S fill:#ddf4ff,stroke:#0969da,color:#24292f style D fill:#dafbe1,stroke:#1a7f37,stroke-width:2px,color:#24292fTickets:
AI Assistance: