Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ONNX parsing for SimplifiedLayerNormalization #3129

Merged
merged 13 commits into from
Aug 8, 2024

Conversation

turneram
Copy link
Contributor

No description provided.

@turneram turneram requested a review from causten as a code owner May 29, 2024 17:55
Copy link

codecov bot commented May 29, 2024

Codecov Report

Attention: Patch coverage is 92.85714% with 2 lines in your changes missing coverage. Please review.

Project coverage is 92.26%. Comparing base (e0a2325) to head (6f98953).
Report is 151 commits behind head on develop.

Files with missing lines Patch % Lines
src/onnx/parse_simplified_layer_normalization.cpp 92.85% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #3129   +/-   ##
========================================
  Coverage    92.26%   92.26%           
========================================
  Files          499      500    +1     
  Lines        20020    20048   +28     
========================================
+ Hits         18471    18497   +26     
- Misses        1549     1551    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@turneram turneram linked an issue May 29, 2024 that may be closed by this pull request
@migraphx-bot
Copy link
Collaborator

migraphx-bot commented May 29, 2024

Test Batch Rate new
8f10e7
Rate old
b9cce0
Diff Compare
torchvision-resnet50 64 1,713.97 1,713.09 0.05%
torchvision-resnet50_fp16 64 3,810.29 3,810.54 -0.01%
torchvision-densenet121 32 1,455.43 1,453.33 0.14%
torchvision-densenet121_fp16 32 2,431.94 2,431.93 0.00%
torchvision-inceptionv3 32 882.48 883.38 -0.10%
torchvision-inceptionv3_fp16 32 1,416.07 1,414.61 0.10%
cadene-inceptionv4 16 407.52 407.58 -0.01%
cadene-resnext64x4 16 413.54 413.72 -0.05%
slim-mobilenet 64 3,822.77 3,822.77 0.00%
slim-nasnetalarge 64 97.03 97.02 0.00%
slim-resnet50v2 64 1,650.65 1,651.90 -0.08%
bert-mrpc-onnx 8 589.47 591.41 -0.33%
bert-mrpc-tf 1 289.00 289.91 -0.31%
pytorch-examples-wlang-gru 1 335.15 332.28 0.86%
pytorch-examples-wlang-lstm 1 298.82 298.17 0.22%
torchvision-resnet50_1 1 452.70 453.96 -0.28%
cadene-dpn92_1 1 244.70 244.78 -0.03%
cadene-resnext101_1 1 189.07 189.18 -0.05%
onnx-taau-downsample 1 204.13 203.94 0.09%
dlrm-criteoterabyte 1 22.28 22.27 0.03%
dlrm-criteoterabyte_fp16 1 41.65 41.62 0.07%
agentmodel 1 6,115.91 5,896.57 3.72% 🔆
unet_fp16 2 33.73 33.73 0.01%
resnet50v1_fp16 1 561.82 564.20 -0.42%
resnet50v1_int8 1 463.79 462.59 0.26%
bert_base_cased_fp16 64 620.74 620.70 0.01%
bert_large_uncased_fp16 32 193.75 193.75 0.00%
bert_large_fp16 1 103.89 103.85 0.05%
distilgpt2_fp16 16 1,189.19 1,187.89 0.11%
yolov5s 1 297.21 298.42 -0.41%
tinyllama 1 23.32 23.34 -0.07%
vicuna-fastchat 1 132.70 134.00 -0.98%
whisper-tiny-encoder 1 241.38 241.32 0.02%
whisper-tiny-decoder 1 245.53 245.93 -0.16%

Check results before merge 🔆

@migraphx-bot
Copy link
Collaborator


     ✅ bert-mrpc-onnx: PASSED: MIGraphX meets tolerance

     ✅ bert-mrpc-tf: PASSED: MIGraphX meets tolerance

     ✅ pytorch-examples-wlang-gru: PASSED: MIGraphX meets tolerance

     ✅ pytorch-examples-wlang-lstm: PASSED: MIGraphX meets tolerance

     ✅ torchvision-resnet50_1: PASSED: MIGraphX meets tolerance

     ✅ cadene-dpn92_1: PASSED: MIGraphX meets tolerance

     ✅ cadene-resnext101_1: PASSED: MIGraphX meets tolerance

     ✅ dlrm-criteoterabyte: PASSED: MIGraphX meets tolerance

     ✅ agentmodel: PASSED: MIGraphX meets tolerance

     ✅ unet: PASSED: MIGraphX meets tolerance

     ✅ resnet50v1: PASSED: MIGraphX meets tolerance

     ✅ bert_base_cased_fp16: PASSED: MIGraphX meets tolerance

🔴bert_large_uncased_fp16: FAILED: MIGraphX is not within tolerance - check verbose output


     ✅ bert_large: PASSED: MIGraphX meets tolerance

     ✅ yolov5s: PASSED: MIGraphX meets tolerance

     ✅ tinyllama: PASSED: MIGraphX meets tolerance

     ✅ vicuna-fastchat: PASSED: MIGraphX meets tolerance

     ✅ whisper-tiny-encoder: PASSED: MIGraphX meets tolerance

     ✅ whisper-tiny-decoder: PASSED: MIGraphX meets tolerance

     ✅ distilgpt2_fp16: PASSED: MIGraphX meets tolerance

@turneram turneram requested review from umangyadav, TedThemistokleous and shivadbhavsar and removed request for TedThemistokleous May 30, 2024 15:32
@umangyadav umangyadav requested a review from CharlieL7 May 31, 2024 12:11
@CharlieL7
Copy link
Collaborator

Where is this spec for this operator?

Copy link
Collaborator

@CharlieL7 CharlieL7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine, minor comments. I would like to see the equation that it's supposed to be doing.

auto rms = info.add_instruction(make_op("reduce_mean", {{"axes", {axis}}}), x_sq);
auto mean = rms;
epsilon =
(x_dtype == migraphx::shape::half_type and std::abs(epsilon) < 1e-7) ? 1e-7 : epsilon;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we limiting the epsilon for half type? It looks like a user input

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is how we handle epsilon in our regular LayerNorm parser, so I did the same here.

@turneram
Copy link
Contributor Author

Where is this spec for this operator?

There isn't actually one for SimplifiedLayerNormalization, but this is the spec for SkipSimplifiedLayerNormalization, which is just add + SLN. That spec does include an optional bias input, but neither of the ORT implementations utilize it, so I omitted it from ours.

@turneram
Copy link
Contributor Author

Looks fine, minor comments. I would like to see the equation that it's supposed to be doing.

The equation is the same as RMS LayerNorm.

@TedThemistokleous TedThemistokleous added onnxruntime PR changes interaction between MIGraphX and Onnxruntime Onnx Operators Adding or modifying an Onnx Operator in the MIGraphX codebase labels Jun 21, 2024
Comment on lines +33 to +48
std::vector<half> x{half{0.8},
half{-0.5},
half{0.0},
half{1.0},
half{0.5},
half{0.2},
half{0.3},
half{-0.6},
half{10.0},
half{-1.0},
half{0.0},
half{1.0},
half{1.2},
half{3.2},
half{-4.1},
half{5.3}};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't require casting all the elements to half. Same applies to all other places.

auto result = info.add_common_op("mul", x, rrms);
result = info.add_common_op("mul", result, scale);

return {result, mean, rrms};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this being matched with LayerNorm kernel on the GPU target ?

@CharlieL7 CharlieL7 self-requested a review July 23, 2024 13:53
@umangyadav umangyadav merged commit 5510d75 into develop Aug 8, 2024
45 of 46 checks passed
@umangyadav umangyadav deleted the simplified-layernorm branch August 8, 2024 15:32
TedThemistokleous pushed a commit that referenced this pull request Aug 13, 2024
TedThemistokleous pushed a commit that referenced this pull request Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Onnx Operators Adding or modifying an Onnx Operator in the MIGraphX codebase onnxruntime PR changes interaction between MIGraphX and Onnxruntime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add onnx parser for SimplifiedLayerNormalization
5 participants