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

Quantizelinear nearbyint fix #3819

Merged
merged 5 commits into from
Feb 18, 2025
Merged

Quantizelinear nearbyint fix #3819

merged 5 commits into from
Feb 18, 2025

Conversation

CharlieL7
Copy link
Collaborator

@CharlieL7 CharlieL7 commented Feb 14, 2025

Fixes #2661.

For floating point types do not use the nearbyint operation.
Updates tests to catch this error and fixes gold values.

I tested and it fixes the issue seen on https://github.com/ROCm/rocMLIR-internal/issues/1718

@CharlieL7 CharlieL7 self-assigned this Feb 14, 2025
@CharlieL7 CharlieL7 requested a review from causten as a code owner February 14, 2025 22:33
@migraphx-bot
Copy link
Collaborator

Test Batch Rate new
5a3918
Rate old
bfc14e
Diff Compare
torchvision-resnet50 64 3,233.96 3,233.96 0.00%
torchvision-resnet50_fp16 64 6,874.33 6,874.33 0.00%
torchvision-densenet121 32 2,438.02 2,436.94 0.04%
torchvision-densenet121_fp16 32 4,175.33 4,181.18 -0.14%
torchvision-inceptionv3 32 1,613.72 1,612.90 0.05%
torchvision-inceptionv3_fp16 32 2,675.59 2,677.82 -0.08%
cadene-inceptionv4 16 750.12 750.47 -0.05%
cadene-resnext64x4 16 808.90 809.72 -0.10%
slim-mobilenet 64 6,660.48 6,659.15 0.02%
slim-nasnetalarge 64 196.81 196.77 0.02%
slim-resnet50v2 64 3,429.83 3,430.42 -0.02%
bert-mrpc-onnx 8 1,133.14 1,133.14 0.00%
bert-mrpc-tf 1 502.51 500.00 0.50%
pytorch-examples-wlang-gru 1 477.31 470.97 1.35%
pytorch-examples-wlang-lstm 1 440.19 437.32 0.66%
torchvision-resnet50_1 1 800.00 793.65 0.80%
cadene-dpn92_1 1 427.94 430.36 -0.56%
cadene-resnext101_1 1 389.11 389.11 0.00%
onnx-taau-downsample 1 370.94 371.31 -0.10%
dlrm-criteoterabyte 1 31.83 31.79 0.11%
dlrm-criteoterabyte_fp16 1 51.04 51.06 -0.03%
agentmodel 1 8,412.69 8,658.38 -2.84%
unet_fp16 2 58.34 58.36 -0.03%
resnet50v1_fp16 1 1,063.83 1,075.27 -1.06%
resnet50v1_int8 1 806.45 800.00 0.81%
bert_base_cased_fp16 64 1,158.58 1,159.42 -0.07%
bert_large_uncased_fp16 32 359.83 359.96 -0.03%
bert_large_fp16 1 215.98 215.98 0.00%
distilgpt2_fp16 16 2,185.79 2,188.78 -0.14%
yolov5s 1 521.16 531.08 -1.87%
tinyllama 1 49.07 49.12 -0.10%
vicuna-fastchat 1 43.59 43.55 0.10%
whisper-tiny-encoder 1 436.68 436.68 0.00%
whisper-tiny-decoder 1 450.45 448.43 0.45%

This build is OK for 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

Copy link

codecov bot commented Feb 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.35%. Comparing base (bfc14e5) to head (5a39189).
Report is 2 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #3819   +/-   ##
========================================
  Coverage    92.35%   92.35%           
========================================
  Files          519      519           
  Lines        22307    22311    +4     
========================================
+ Hits         20601    20606    +5     
+ Misses        1706     1705    -1     

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

Copy link
Contributor

@ahsan-ca ahsan-ca left a comment

Choose a reason for hiding this comment

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

Besides a typo, looks good to me. Thanks for doing this.

@@ -1,7 +1,7 @@
/*
/*rby
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo

@causten causten merged commit c8b73b1 into develop Feb 18, 2025
41 of 45 checks passed
@causten causten deleted the quantizelinear_nearbyint_fix branch February 18, 2025 03:17
for(int i = 0; i < xv.size(); ++i)
{
double quantized = xv.at(i) / sv.at(i);
quantized = std::max(static_cast<double>(min_value),
Copy link
Contributor

@lakhinderwalia lakhinderwalia Feb 18, 2025

Choose a reason for hiding this comment

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

Perhaps you should saturate quantized + zero_pts. Else that sum will overflow in the next line.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll make a followup PR with this

@CharlieL7 CharlieL7 mentioned this pull request Feb 18, 2025
ahsan-ca pushed a commit that referenced this pull request Feb 19, 2025
causten pushed a commit that referenced this pull request Feb 19, 2025
Fixes for issues that weren't addressed in #3819
ahsan-ca pushed a commit that referenced this pull request Feb 19, 2025
Fixes for issues that weren't addressed in #3819
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.

[Q] Is nearbyint necessary for the FP8 quantizelinar ?
5 participants