Skip to content

Use __cpp_aligned_new instead of hand-rolling the implementation#11293

Merged
facebook-github-bot merged 1 commit intopytorch:mainfrom
tamird:export-D75806635
Jun 4, 2025
Merged

Use __cpp_aligned_new instead of hand-rolling the implementation#11293
facebook-github-bot merged 1 commit intopytorch:mainfrom
tamird:export-D75806635

Conversation

@tamird
Copy link
Contributor

@tamird tamird commented Jun 2, 2025

The current feature detection seems to be incorrect, resulting in fallback to
the manual implementation, which in turn returns untagged pointers under
hwasan.
Use new expressions instead to delegate the work to the C++ compiler.

Differential Revision: D75806635

@pytorch-bot
Copy link

pytorch-bot bot commented Jun 2, 2025

🔗 Helpful Links

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

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

✅ No Failures

As of commit f7fbffe with merge base bca2cf5 (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 CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported labels Jun 2, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75806635

@tamird
Copy link
Contributor Author

tamird commented Jun 2, 2025

@pytorchbot label "release notes: none"

@pytorch-bot pytorch-bot bot added the release notes: none Do not include this in the release notes label Jun 2, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75806635

11 similar comments
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75806635

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75806635

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75806635

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75806635

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75806635

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75806635

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75806635

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75806635

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75806635

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75806635

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75806635

@tamird tamird changed the title Use posix_memalign on all non-CRT platforms Use __cpp_aligned_new instead of hand-rolling the implementation Jun 3, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75806635

Copy link
Contributor

@swolchok swolchok left a comment

Choose a reason for hiding this comment

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

Do we know whether this actually works on Apple platforms? #10660 (the PR that added the previous implementation) cited some concerns about aligned_alloc.

I'm inclined to accept this on the grounds that we should presume that standard library functions that exist on a platform actually work until proven otherwise, but I'd like to let @lucylq chime in.

@tamird
Copy link
Contributor Author

tamird commented Jun 3, 2025

Do we know whether this actually works on Apple platforms? #10660 (the PR that added the previous implementation) cited some concerns about aligned_alloc.

I'm inclined to accept this on the grounds that we should presume that standard library functions that exist on a platform actually work until proven otherwise, but I'd like to let @lucylq chime in.

We have tests on apple platforms, so that should be sufficient to prove that it works. Yes?

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75806635

1 similar comment
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75806635

Copy link
Contributor

@lucylq lucylq left a comment

Choose a reason for hiding this comment

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

thanks for the changes!

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75806635

1 similar comment
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75806635

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75806635

2 similar comments
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75806635

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75806635

@tamird
Copy link
Contributor Author

tamird commented Jun 4, 2025

@swolchok this keeps failing to land with:

The following GitHub Pull Request(s) are not mergeable on GitHub: #11293. This Diff cannot land if the Pull Request cannot be merged. Please rebase the diff and re-export it to GitHub or resolve the merge conflict on GitHub and import the changes.

Yet this PR shows no merge conflicts. This has persisted through several rebases. Do you know what's going on?

@tamird
Copy link
Contributor Author

tamird commented Jun 4, 2025

The problem seems to be:

$ curl -sfSL https://api.github.com/repos/pytorch/executorch/pulls/11293 | jq .mergeable_state
"unstable"

which is an undocumented field. Why is that used to determine whether it is mergeable or not?

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75806635

1 similar comment
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75806635

@swolchok
Copy link
Contributor

swolchok commented Jun 4, 2025

@swolchok this keeps failing to land with:

The following GitHub Pull Request(s) are not mergeable on GitHub: #11293. This Diff cannot land if the Pull Request cannot be merged. Please rebase the diff and re-export it to GitHub or resolve the merge conflict on GitHub and import the changes.

Yet this PR shows no merge conflicts. This has persisted through several rebases. Do you know what's going on?

how are you updating the PR? if you sent it out internally, you need to update the internal diff and export that diff to github; I see force pushes which looks like maybe you are updating the PR through some separate mechanism like working with github directly.

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75806635

@tamird
Copy link
Contributor Author

tamird commented Jun 4, 2025

@swolchok this keeps failing to land with:

The following GitHub Pull Request(s) are not mergeable on GitHub: #11293. This Diff cannot land if the Pull Request cannot be merged. Please rebase the diff and re-export it to GitHub or resolve the merge conflict on GitHub and import the changes.

Yet this PR shows no merge conflicts. This has persisted through several rebases. Do you know what's going on?

how are you updating the PR? if you sent it out internally, you need to update the internal diff and export that diff to github; I see force pushes which looks like maybe you are updating the PR through some separate mechanism like working with github directly.

No, those force pushes are done by phabricator.

It seems that PRs that have both internal and external changes are broken because the mergeable_state is always "unstable".

…11293)

Summary:
Pull Request resolved: #11293

The current feature detection seems to be incorrect, resulting in fallback to
the manual implementation, which in turn returns untagged pointers under
hwasan.

Use new expressions instead to delegate the work to the C++ compiler.

Reviewed By: lucylq

Differential Revision: D75806635
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75806635

@facebook-github-bot facebook-github-bot merged commit aa67f08 into pytorch:main Jun 4, 2025
169 of 171 checks passed
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. fb-exported release notes: none Do not include this in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants