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

catch python buffer unsupported types #3701

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

shivadbhavsar
Copy link
Contributor

Issue:
New datatypes (fp8 and bf16) are not natively supported by the python buffer protocol. See https://docs.python.org/3/library/struct.html#format-characters

This can lead to some silly behavior since all unsupported types seem to give format string "z". Example:

import migraphx
p = migraphx.program()
mm = p.get_main_module()
s = migraphx.shape(type="bf16_type", lens=[16])
a = migraphx.generate_argument(s) 
l = mm.add_literal(a)
print(a.get_shape()) # bf16_type, {16}, {1}
print(l.shape()) # fp8e5m2fnuz_type, {16}, {2} ??????????

Fix:

  1. explicitly error out if the python buffer format string is "z".
  2. add add_literal_from_argument method that allows the user to directly add an argument to some module they may or may not be a recognized type by py buffer protocol.

@shivadbhavsar shivadbhavsar self-assigned this Dec 11, 2024
@shivadbhavsar shivadbhavsar added the bugfix Fixes a bug found in the code. label Dec 11, 2024
Copy link

codecov bot commented Dec 11, 2024

Codecov Report

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

Project coverage is 92.23%. Comparing base (2e59073) to head (9053020).

Files with missing lines Patch % Lines
src/module.cpp 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #3701   +/-   ##
========================================
  Coverage    92.23%   92.23%           
========================================
  Files          514      514           
  Lines        21746    21746           
========================================
  Hits         20057    20057           
  Misses        1689     1689           

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

@migraphx-bot
Copy link
Collaborator

Test Batch Rate new
905302
Rate old
64fe0c
Diff Compare
torchvision-resnet50 64 3,256.98 3,254.94 0.06%
torchvision-resnet50_fp16 64 6,988.80 6,977.96 0.16%
torchvision-densenet121 32 2,435.96 2,436.55 -0.02%
torchvision-densenet121_fp16 32 4,047.38 4,076.26 -0.71%
torchvision-inceptionv3 32 1,628.13 1,627.46 0.04%
torchvision-inceptionv3_fp16 32 2,742.76 2,741.58 0.04%
cadene-inceptionv4 16 764.62 764.31 0.04%
cadene-resnext64x4 16 812.65 813.14 -0.06%
slim-mobilenet 64 7,455.82 7,466.83 -0.15%
slim-nasnetalarge 64 209.05 209.03 0.01%
slim-resnet50v2 64 3,440.47 3,443.32 -0.08%
bert-mrpc-onnx 8 1,143.33 1,144.17 -0.07%
bert-mrpc-tf 1 477.19 474.21 0.63%
pytorch-examples-wlang-gru 1 428.28 416.53 2.82%
pytorch-examples-wlang-lstm 1 392.94 384.23 2.27%
torchvision-resnet50_1 1 812.98 783.29 3.79% 🔆
cadene-dpn92_1 1 400.25 398.94 0.33%
cadene-resnext101_1 1 382.55 383.46 -0.24%
onnx-taau-downsample 1 345.37 345.52 -0.04%
dlrm-criteoterabyte 1 33.35 33.33 0.08%
dlrm-criteoterabyte_fp16 1 52.72 52.73 -0.02%
agentmodel 1 8,083.36 8,127.83 -0.55%
unet_fp16 2 58.95 58.89 0.10%
resnet50v1_fp16 1 908.92 938.63 -3.17% 🔴
resnet50v1_int8 1 989.67 984.73 0.50%
bert_base_cased_fp16 64 1,170.70 1,170.23 0.04%
bert_large_uncased_fp16 32 362.77 362.94 -0.05%
bert_large_fp16 1 200.22 200.28 -0.03%
distilgpt2_fp16 16 2,200.08 2,198.50 0.07%
yolov5s 1 534.63 531.33 0.62%
tinyllama 1 43.35 43.34 0.03%
vicuna-fastchat 1 172.69 172.03 0.38%
whisper-tiny-encoder 1 417.68 418.00 -0.08%
whisper-tiny-decoder 1 429.22 428.83 0.09%

This build is not recommended to 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Fixes a bug found in the code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants