Skip to content

[ATen-CPU] Use math.h for GeLU as well as cmath#153742

Closed
SS-JIA wants to merge 1 commit into
mainfrom
pr153742
Closed

[ATen-CPU] Use math.h for GeLU as well as cmath#153742
SS-JIA wants to merge 1 commit into
mainfrom
pr153742

Conversation

@SS-JIA

@SS-JIA SS-JIA commented May 16, 2025

Copy link
Copy Markdown
Contributor

Summary:

Context

See #149164 for more context.

Originally, this fix worked but more recently including cmath by itself no longer provides access to math constants on Windows platforms. I found that including math.h resolves this.

I'm not sure exactly what changed, but this PR updates the header to just use both includes fix the symbols not being found. It might be a bug with a recent Windows update perhaps?

Test Plan:
CI

cc @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10 @jerryzh168

Summary:
## Context

See #149164 for more context.

Originally, this fix worked but more recently including `cmath` by itself no longer provides access to math constants on Windows platforms. I found that including `math.h` resolves this.

I'm not sure exactly what changed, but this PR updates the header to just use both includes fix the symbols not being found. It might be a bug with a recent Windows update perhaps?

Test Plan:
CI
@pytorch-bot

pytorch-bot Bot commented May 16, 2025

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ You can merge normally! (1 Unrelated Failure)

As of commit 5c91450 with merge base cda572b (image):

UNSTABLE - The following job is marked as unstable, possibly due to flakiness on trunk:

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

@pytorch-bot pytorch-bot Bot added the module: cpu CPU specific problem (e.g., perf, algorithm) label May 16, 2025
@SS-JIA SS-JIA requested a review from swolchok May 16, 2025 18:07
@SS-JIA SS-JIA changed the title [ATen-CPU] Use math.h for GeLU instead of cmath [ATen-CPU] Use math.h for GeLU as well as cmath May 16, 2025

@swolchok swolchok 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.

which constants? all the M_FOO constants? https://learn.microsoft.com/en-us/cpp/c-runtime-library/math-constants?view=msvc-170 says that cmath should be sufficient.

note that as soon as we get C++20 (which I believe will be in June, since the drop-dead date for Ubuntu 20.04 LTS is May 31 per https://ubuntu.com/blog/ubuntu-20-04-lts-end-of-life-standard-support-is-coming-to-an-end-heres-how-to-prepare), we can just migrate to the standard library constants found in https://en.cppreference.com/w/cpp/numeric/constants .

Given that this is an ultratemporary workaround, we can just do this I suppose

@SS-JIA

SS-JIA commented May 17, 2025

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label May 17, 2025
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: This PR needs a release notes: label
If your changes are user facing and intended to be a part of release notes, please use a label starting with release notes:.

If not, please add the topic: not user facing label.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "topic: not user facing"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Details for Dev Infra team Raised by workflow job

@Skylion007 Skylion007 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

May want to add a note that some of these constants are in stdlib in C++20

@Skylion007 Skylion007 added the topic: not user facing topic category label May 18, 2025
@Skylion007

Copy link
Copy Markdown
Collaborator

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@github-actions github-actions Bot deleted the pr153742 branch June 19, 2025 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged module: cpu CPU specific problem (e.g., perf, algorithm) topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants