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

bit_cast operator #3655

Merged
merged 15 commits into from
Dec 4, 2024
Merged

bit_cast operator #3655

merged 15 commits into from
Dec 4, 2024

Conversation

CharlieL7
Copy link
Collaborator

  • Converts between types while keeping the data the same. Basically an extension of reinterpret_cast without undefined behavior
  • Needed for conversion pass between fp8e4m3fn to fp8e4m3fnuz.

@CharlieL7 CharlieL7 self-assigned this Nov 22, 2024
@CharlieL7 CharlieL7 requested a review from pfultz2 November 25, 2024 20:40
@CharlieL7 CharlieL7 marked this pull request as ready for review November 25, 2024 20:40
@CharlieL7 CharlieL7 requested a review from causten as a code owner November 25, 2024 20:40
Copy link

codecov bot commented Nov 25, 2024

Codecov Report

Attention: Patch coverage is 95.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 92.20%. Comparing base (6b886e3) to head (463379f).
Report is 4 commits behind head on develop.

Files with missing lines Patch % Lines
src/include/migraphx/op/bit_cast.hpp 95.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #3655   +/-   ##
========================================
  Coverage    92.20%   92.20%           
========================================
  Files          513      514    +1     
  Lines        21658    21678   +20     
========================================
+ Hits         19970    19989   +19     
- Misses        1688     1689    +1     

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

@pfultz2
Copy link
Collaborator

pfultz2 commented Nov 26, 2024

What is the exact error are you getting when doing only one overload for bit_cast like this?

template <typename To,
          typename From,
          MIGRAPHX_REQUIRES(is_trivially_copyable<To>{} and is_trivially_copyable<From>{})>
inline constexpr auto bit_cast(From fr) noexcept
{
    return vec_transform(fr)([](auto x) -> To {
        static_assert(sizeof(To) == sizeof(decltype(x)));
        return __builtin_bit_cast(To, x);
    });
}

Copy link
Collaborator

@TedThemistokleous TedThemistokleous left a comment

Choose a reason for hiding this comment

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

Looks good. Just add test cases for THROWs

@TedThemistokleous TedThemistokleous added roadmap Tasks to finish for a release FP8 issues related to FP8 implemenation labels Nov 28, 2024
@migraphx-bot
Copy link
Collaborator

Test Batch Rate new
0b6cae
Rate old
241e24
Diff Compare
torchvision-resnet50 64 3,259.55 3,256.24 0.10%
torchvision-resnet50_fp16 64 6,982.07 6,984.56 -0.04%
torchvision-densenet121 32 2,433.16 2,434.44 -0.05%
torchvision-densenet121_fp16 32 4,089.56 4,078.22 0.28%
torchvision-inceptionv3 32 1,629.02 1,629.38 -0.02%
torchvision-inceptionv3_fp16 32 2,746.05 2,742.92 0.11%
cadene-inceptionv4 16 764.56 764.47 0.01%
cadene-resnext64x4 16 809.45 812.01 -0.32%
slim-mobilenet 64 7,455.75 7,468.13 -0.17%
slim-nasnetalarge 64 208.44 208.51 -0.03%
slim-resnet50v2 64 3,440.92 3,440.29 0.02%
bert-mrpc-onnx 8 1,148.71 1,148.20 0.04%
bert-mrpc-tf 1 463.56 464.32 -0.16%
pytorch-examples-wlang-gru 1 418.64 426.54 -1.85%
pytorch-examples-wlang-lstm 1 377.99 380.15 -0.57%
torchvision-resnet50_1 1 784.01 775.13 1.14%
cadene-dpn92_1 1 435.23 403.98 7.73% 🔆
cadene-resnext101_1 1 384.63 383.04 0.42%
onnx-taau-downsample 1 345.21 345.85 -0.19%
dlrm-criteoterabyte 1 33.35 33.33 0.06%
dlrm-criteoterabyte_fp16 1 52.74 52.75 -0.03%
agentmodel 1 10,062.90 8,145.38 23.54% 🔆
unet_fp16 2 58.79 58.93 -0.23%
resnet50v1_fp16 1 948.11 935.00 1.40%
resnet50v1_int8 1 1,020.83 1,023.68 -0.28%
bert_base_cased_fp16 64 1,170.84 1,169.83 0.09%
bert_large_uncased_fp16 32 363.48 363.35 0.03%
bert_large_fp16 1 200.17 195.75 2.26%
distilgpt2_fp16 16 2,194.18 2,196.59 -0.11%
yolov5s 1 526.77 534.53 -1.45%
tinyllama 1 43.59 43.39 0.45%
vicuna-fastchat 1 168.51 171.47 -1.73%
whisper-tiny-encoder 1 418.00 417.49 0.12%
whisper-tiny-decoder 1 433.27 427.46 1.36%

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

@causten causten merged commit dde7986 into develop Dec 4, 2024
37 of 39 checks passed
shivadbhavsar pushed a commit that referenced this pull request Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FP8 issues related to FP8 implemenation roadmap Tasks to finish for a release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants