[ONNX FE] Use MAX bias mode for L2 norm to guard zero-vector inputs#36778
Open
gblong1 wants to merge 5 commits into
Open
[ONNX FE] Use MAX bias mode for L2 norm to guard zero-vector inputs#36778gblong1 wants to merge 5 commits into
gblong1 wants to merge 5 commits into
Conversation
zero-norm case (sqrt(max(sum, eps))). For any nonzero norm sum(x^2) >> eps, so the result is bit-identical to the unbiased computation and the guard does not perturb normal embeddings
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the ONNX Frontend’s internal lp_norm helper so that L2 norm uses a flooring epsilon bias (sqrt(max(sum(x^2), eps))) rather than an additive bias (sqrt(sum(x^2) + eps)), aiming to stabilize normalization behavior around zero-vector inputs.
Changes:
- Switch
lp_norm(..., p_norm==2)fromBiasMode::ADDtoBiasMode::MAXwhen computing the L2 denominator.
Author
|
@mvafin - any feedback on this one? it should be a simple review. |
mvafin
approved these changes
Jul 15, 2026
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
Tickets:
AI Assistance: