Skip to content

Support Half/BFloat16 in gelu #7888

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

Merged
merged 1 commit into from
Jan 23, 2025
Merged

Support Half/BFloat16 in gelu #7888

merged 1 commit into from
Jan 23, 2025

Conversation

swolchok
Copy link
Contributor

Partial fix for #7748.

[ghstack-poisoned]
@swolchok
Copy link
Contributor Author

swolchok commented Jan 23, 2025

Stack from ghstack (oldest at bottom):

Copy link

pytorch-bot bot commented Jan 23, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/7888

Note: Links to docs will display an error until the docs builds have been completed.

⏳ No Failures, 8 Pending

As of commit 9162daa with merge base 26665f3 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 23, 2025
swolchok added a commit that referenced this pull request Jan 23, 2025
Partial fix for #7748.

ghstack-source-id: becd2a0
ghstack-comment-id: 2610629831
Pull Request resolved: #7888
@swolchok swolchok added the release notes: ops & kernels Changes to the opset and any new / changed kernel implementations label Jan 23, 2025
@swolchok
Copy link
Contributor Author

manually ran Mac unittests locally , should be good to land.

@swolchok swolchok merged commit 73dce90 into main Jan 23, 2025
43 of 46 checks passed
@swolchok swolchok deleted the gh/swolchok/189/head branch January 23, 2025 18:44
@zingo
Copy link
Collaborator

zingo commented Jan 24, 2025

Hi @swolchok there might be a problem in this change or the Arm tools used.

From this patch (on main) we see this fails on the Arm Backend testing. It don't seem to happen on other targets, I wonder if it is a compiler version kind of thing, but would expect it to show up on other backends compiling for Arm in that case, but maybe out embedded Arm gcc version differ or are more picky.

/pytorch/executorch/kernels/portable/cpu/op_gelu.cpp: In lambda function:
/pytorch/executorch/kernels/portable/cpu/op_gelu.cpp:54:44: error: ambiguous overload for 'operator+' (operand types are 'int' and 'executorch::runtime::etensor::Half')
   54 |             const CTYPE ret = 0.5 * x * (1 + std::tanh(inner));
      |                                          ~ ^ ~~~~~~~~~~~~~~~~
      |                                          |            |
      |                                          int          executorch::runtime::etensor::Half

I thing we are using gcc 13.3 when building the Arm code e.g.
arm-gnu-toolchain-13.3.rel1-aarch64-arm-none-eabi

Add tried to add the label trunk in this patch to verify if it start causing the problem but it seem I can't after it is merged.

@zingo
Copy link
Collaborator

zingo commented Jan 24, 2025

Using 1.0 in
const CTYPE ret = 0.5 * x * (1.0 + std::tanh(inner));
fixed it
I do not know if static_cast(1.0) would be preferred but as other constants in the code used float notation directly I tried to go for more easy to read :)

@zingo
Copy link
Collaborator

zingo commented Jan 24, 2025

Possible fix here #7937

@swolchok
Copy link
Contributor Author

tried to add the label trunk

you can check hud.pytorch.org instead. This did break the ARM builds: https://hud.pytorch.org/hud/pytorch/executorch/main/1?per_page=50&name_filter=test-arm&mergeLF=true

YIWENX14 pushed a commit that referenced this pull request Jan 28, 2025
zonglinpeng pushed a commit to zonglinpeng/executorch that referenced this pull request Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. release notes: ops & kernels Changes to the opset and any new / changed kernel implementations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants