Skip to content

Implement GLU - #3247

Merged
junliume merged 55 commits into
developfrom
impl_glu_merged
Sep 27, 2024
Merged

junliume merged 55 commits into
developfrom
impl_glu_merged

Conversation

@cognaiger9

@cognaiger9 cognaiger9 commented Sep 10, 2024 •

Copy link
Copy Markdown
Contributor
  • Add GLU operation with contiguous forward and contiguous backward kernels.
  • Add driver and gtest for kernels.
  • MIOpen performs better if:
    • Input and output tensors are contiguous
    • Split dimension is 0
    • Number of elements in input tensor are less than 400,000 (forward case) or less than 800,000 (backward case)

Average improvement over ROCm

type fwd bwd
float16 1.3 1.56
float 1.11 1.53
bfloat16 1.27 1.54

Detail Benchmark

float16
op_name dtype size dim direction ROCm MIOpen Improvement
GLU float16 [2 320 4 4 4] 0 fwd 6816 4889 1,39
GLU float16 [2 320 4 4 4] 0 bwd 7968 5066 1,57
GLU float16 [32 64 3 3 3] 0 fwd 6448 4889 1,32
GLU float16 [32 64 3 3 3] 0 bwd 7776 4836 1,61
GLU float16 [64 3 11 11] 0 fwd 6384 4747 1,34
GLU float16 [64 3 11 11] 0 bwd 7904 4853 1,63
GLU float16 [256 256 1 1] 0 fwd 6176 5031 1,23
GLU float16 [256 256 1 1] 0 bwd 8048 5066 1,59
GLU float16 [128 64 7 7] 0 fwd 7488 5777 1,30
GLU float16 [128 64 7 7] 0 bwd 9344 6382 1,46
GLU float16 [64 64 7 7] 0 fwd 6880 5600 1,23
GLU float16 [64 64 7 7] 0 bwd 8608 5778 1,49
GLU float16 [64 32 7 7] 0 fwd 6192 4995 1,24
GLU float16 [64 32 7 7] 0 bwd 7904 5262 1,50
GLU float16 [32 32 7 7] 0 fwd 6368 4907 1,30
GLU float16 [32 32 7 7] 0 bwd 7936 4995 1,59
float32
op_name dtype size dim direction ROCm MIOpen Improvement
GLU float32 [2 320 4 4 4] 0 fwd 5936 5013 1,18
GLU float32 [2 320 4 4 4] 0 bwd 7744 5013 1,54
GLU float32 [32 64 3 3 3] 0 fwd 5408 4942 1,09
GLU float32 [32 64 3 3 3] 0 bwd 7968 5262 1,51
GLU float32 [64 3 11 11] 0 fwd 5376 4960 1,08
GLU float32 [64 3 11 11] 0 bwd 7904 4889 1,62
GLU float32 [256 256 1 1] 0 fwd 5680 5191 1,09
GLU float32 [256 256 1 1] 0 bwd 8064 5386 1,50
GLU float32 [128 64 7 7] 0 fwd 7056 6524 1,08
GLU float32 [128 64 7 7] 0 bwd 10064 7182 1,40
GLU float32 [64 64 7 7] 0 fwd 6128 5635 1,09
GLU float32 [64 64 7 7] 0 bwd 8944 5902 1,52
GLU float32 [64 32 7 7] 0 fwd 5856 5155 1,14
GLU float32 [64 32 7 7] 0 bwd 8320 5351 1,55
GLU float32 [32 32 7 7] 0 fwd 5472 4942 1,11
GLU float32 [32 32 7 7] 0 bwd 8112 5031 1,61
bfloat16
op_name dtype size dim direction ROCm MIOpen Improvement
GLU bfloat16 [2 320 4 4 4] 0 fwd 6928 5226 1,33
GLU bfloat16 [2 320 4 4 4] 0 bwd 7776 5013 1,55
GLU bfloat16 [32 64 3 3 3] 0 fwd 6320 5031 1,26
GLU bfloat16 [32 64 3 3 3] 0 bwd 7904 4889 1,62
GLU bfloat16 [64 3 11 11] 0 fwd 6416 4871 1,32
GLU bfloat16 [64 3 11 11] 0 bwd 7792 4942 1,58
GLU bfloat16 [256 256 1 1] 0 fwd 6240 4960 1,26
GLU bfloat16 [256 256 1 1] 0 bwd 8016 5191 1,54
GLU bfloat16 [128 64 7 7] 0 fwd 7392 6365 1,16
GLU bfloat16 [128 64 7 7] 0 bwd 9344 6560 1,42
GLU bfloat16 [64 64 7 7] 0 fwd 7024 5369 1,31
GLU bfloat16 [64 64 7 7] 0 bwd 8576 5778 1,48
GLU bfloat16 [64 32 7 7] 0 fwd 6560 5031 1,30
GLU bfloat16 [64 32 7 7] 0 bwd 8096 5191 1,56
GLU bfloat16 [32 32 7 7] 0 fwd 6384 5049 1,26
GLU bfloat16 [32 32 7 7] 0 bwd 7968 5013 1,59

@averinevg

Copy link
Copy Markdown
Contributor

@cognaiger9 CI is failing for the PR because of bad code formatting. Please fix it.
How-to-format-code.

Comment thread driver/glu_driver.hpp Resolved
Comment thread driver/glu_driver.hpp Resolved
Comment thread src/solver/glu/backward_glu.cpp Resolved

@iq136boy iq136boy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The PR is blocked by the following errors caused by the CI issue we recently have. After the CI issue is resolved, this PR need to restart to run through the CI.

[2024-09-24T07:18:43.885Z] Exception occurred: org.kohsuke.github.HttpException: {"message":"API rate limit exceeded for user ID 49319081. If you reach out to GitHub Support for help, please include the request ID

@junliume
junliume requested a review from averinevg September 26, 2024 06:28
@junliume
junliume dismissed stale reviews from averinevg and CAHEK7 September 26, 2024 06:28

Re-request review

Comment thread src/solver/glu/backward_glu.cpp Resolved
Comment thread src/solver/glu/forward_glu.cpp Resolved
Comment thread driver/glu_driver.hpp Resolved
Comment thread src/glu/problem_description.cpp Resolved
Comment thread src/glu/problem_description.cpp Resolved
Comment thread test/gtest/glu.cpp Resolved
Comment thread test/gtest/glu.cpp Resolved
Comment thread test/gtest/glu.cpp Resolved
Comment thread test/gtest/glu.cpp Resolved
Comment thread test/gtest/glu.hpp

struct GLUTestCase
{
std::vector<size_t> dimsLength;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[R] You could reuse miopen::unit_tests::TensorDescriptorParams for that

@averinevg averinevg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good job!

@averinevg

Copy link
Copy Markdown
Contributor

@junliume TESTING_CI_PASSED

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants