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 FLUX e2e example #3619

Open
wants to merge 34 commits into
base: develop
Choose a base branch
from
Open

Add FLUX e2e example #3619

wants to merge 34 commits into from

Conversation

shivadbhavsar
Copy link
Contributor

No description provided.

Copy link

codecov bot commented Nov 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.18%. Comparing base (ebf82f6) to head (f7908ea).
Report is 1 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #3619   +/-   ##
========================================
  Coverage    92.18%   92.18%           
========================================
  Files          514      514           
  Lines        21780    21780           
========================================
  Hits         20078    20078           
  Misses        1702     1702           

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

@shivadbhavsar shivadbhavsar self-assigned this Nov 14, 2024
@shivadbhavsar shivadbhavsar marked this pull request as ready for review November 14, 2024 00:44
@shivadbhavsar shivadbhavsar requested review from a team and causten as code owners November 14, 2024 00:44
@kahmed10
Copy link
Collaborator

Can we add a reference image to this PR? Using the same prompt in the README

@@ -0,0 +1,27 @@
## Setup

Make sure python interpreter can find migraphx. Default location:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add some instructions on setting up a python virtual environment?

@migraphx-bot
Copy link
Collaborator

Test Batch Rate new
fb2086
Rate old
0f36aa
Diff Compare
torchvision-resnet50 64 3,255.22 3,261.99 -0.21%
torchvision-resnet50_fp16 64 6,994.20 6,984.41 0.14%
torchvision-densenet121 32 2,434.53 2,434.46 0.00%
torchvision-densenet121_fp16 32 4,067.68 4,068.77 -0.03%
torchvision-inceptionv3 32 1,629.44 1,630.14 -0.04%
torchvision-inceptionv3_fp16 32 2,745.56 2,746.22 -0.02%
cadene-inceptionv4 16 765.51 765.59 -0.01%
cadene-resnext64x4 16 810.85 809.78 0.13%
slim-mobilenet 64 7,467.09 7,474.57 -0.10%
slim-nasnetalarge 64 208.52 208.58 -0.03%
slim-resnet50v2 64 3,440.60 3,441.49 -0.03%
bert-mrpc-onnx 8 1,148.56 1,150.80 -0.19%
bert-mrpc-tf 1 463.84 465.54 -0.37%
pytorch-examples-wlang-gru 1 423.77 420.06 0.88%
pytorch-examples-wlang-lstm 1 482.78 381.98 26.39% 🔆
torchvision-resnet50_1 1 801.36 750.44 6.79% 🔆
cadene-dpn92_1 1 399.50 398.35 0.29%
cadene-resnext101_1 1 383.29 382.96 0.09%
onnx-taau-downsample 1 345.95 346.08 -0.04%
dlrm-criteoterabyte 1 33.34 33.35 -0.03%
dlrm-criteoterabyte_fp16 1 52.72 52.68 0.07%
agentmodel 1 10,173.73 8,091.53 25.73% 🔆
unet_fp16 2 58.88 58.77 0.18%
resnet50v1_fp16 1 943.56 943.16 0.04%
resnet50v1_int8 1 1,018.66 1,012.12 0.65%
bert_base_cased_fp16 64 1,170.84 1,169.97 0.07%
bert_large_uncased_fp16 32 363.78 363.75 0.01%
bert_large_fp16 1 200.63 199.03 0.81%
distilgpt2_fp16 16 2,202.68 2,201.98 0.03%
yolov5s 1 529.66 539.79 -1.88%
tinyllama 1 43.36 43.42 -0.14%
vicuna-fastchat 1 171.63 175.75 -2.34%
whisper-tiny-encoder 1 418.15 418.02 0.03%
whisper-tiny-decoder 1 422.93 428.37 -1.27%

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

spolifroni-amd and others added 15 commits December 18, 2024 12:14
Although, this prevents simplifying as much, it does help preserve the permutation of the broadcasted axes.

So if we have a tensor of `{2, 16, 10240}` that goes into a reduction along the last axis it will output to `{2, 16, 1}`, which may be broadcasted back into `{2, 16, 10240}`, but there could be more shape transformations after the reduce but before an pointwise operator:

```
@1 = multibroadcast[out_lens={2, 16, 10240},out_dyn_dims={}](@0) -> int64_type, {2, 16, 10240}, {16, 1, 0}
@2 = reshape[dims={2, 160, 32, 32}](@1) -> int64_type, {2, 160, 32, 32}, {163840, 1024, 32, 1}
@3 = transpose[permutation={0, 2, 3, 1}](@2) -> int64_type, {2, 32, 32, 160}, {163840, 32, 1, 1024}
```

On develop this would be simplified to:

```
@1 = unsqueeze[axes={1, 2, 5},steps={}](@0) -> int64_type, {2, 1, 1, 16, 1, 1}, {16, 16, 16, 1, 1, 1}
@2 = multibroadcast[out_lens={2, 1, 1, 16, 1, 10},out_dyn_dims={}](@1) -> int64_type, {2, 1, 1, 16, 1, 10}, {16, 16, 16, 1, 1, 0}
@3 = reshape[dims={2, 1, 1, 160}](@2) -> int64_type, {2, 1, 1, 160}, {160, 160, 160, 1}
@4 = multibroadcast[out_lens={2, 32, 32, 160},out_dyn_dims={}](@3) -> int64_type, {2, 32, 32, 160}, {160, 0, 0, 1}
```

Ideally, we would want to apply these transformations without the broadcast before the reduction but if it simplified like above because the shape_transform_descriptor doesnt track the permutation of the the broadcasted axes. With this PR, it will simplify to:

```
@1 = unsqueeze[axes={3, 4},steps={}](@0) -> int64_type, {2, 16, 1, 1, 1}, {16, 1, 1, 1, 1}
@2 = transpose[permutation={0, 3, 4, 1, 2}](@1) -> int64_type, {2, 1, 1, 16, 1}, {16, 1, 1, 1, 1}
@3 = multibroadcast[out_lens={2, 1, 1, 16, 10},out_dyn_dims={}](@2) -> int64_type, {2, 1, 1, 16, 10}, {16, 1, 1, 1, 0}
@4 = reshape[dims={2, 1, 1, 160}](@3) -> int64_type, {2, 1, 1, 160}, {160, 160, 160, 1}
@5 = multibroadcast[out_lens={2, 32, 32, 160},out_dyn_dims={}](@4) -> int64_type, {2, 32, 32, 160}, {160, 0, 0, 1}
```

This has a transpose because the shape_transform_descriptor understands how it will output in NHWC, which means we can make the input to the reduction NHWC layout as well. This PR doesn't enable such rewriting, it only modifies the shape_transform descriptor to track such layouts.

Also, there is some updates to the tests as well:

- Validate that a simplified transformation produces the same result
- Check that the simplification cannot be simplified further
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.

9 participants