Skip to content

[PyTorch] Fix inductor CPU masked() body codegen when result dtype is bool and operator is where #138486

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

Closed
wants to merge 5 commits into from

Conversation

swolchok
Copy link
Contributor

@swolchok swolchok commented Oct 21, 2024

Stack from ghstack (oldest at bottom):

In this case, it looks like we expect the body to be a VecMask (unify_mask_base_type is called by where()), but we didn't make it a VecMask. Now we do.

Differential Revision: D64702918

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @yf225 @chenyang78 @kadeng @muchulee8 @ColinPeppler @amjames @desertfire @chauhang @aakhundov

… bool and operator is where

In this case, it looks like we expect the body to be a VecMask (unify_mask_base_type is called by where()), but we don't make it a VecMask.

Differential Revision: [D64702918](https://our.internmc.facebook.com/intern/diff/D64702918/)

[ghstack-poisoned]
Copy link

pytorch-bot bot commented Oct 21, 2024

🔗 Helpful Links

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

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

✅ No Failures

As of commit 83b08e8 with merge base fb0da32 (image):
💚 Looks good so far! There are no failures yet. 💚

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

swolchok added a commit that referenced this pull request Oct 21, 2024
… bool and operator is where

In this case, it looks like we expect the body to be a VecMask (unify_mask_base_type is called by where()), but we don't make it a VecMask.

Differential Revision: [D64702918](https://our.internmc.facebook.com/intern/diff/D64702918/)

ghstack-source-id: 249157267
Pull Request resolved: #138486
@facebook-github-bot
Copy link
Contributor

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

@swolchok
Copy link
Contributor Author

this should fix one of the inductor failures on #137426 . I need to figure out how to repro this issue without that PR and add a regression test.

…lt dtype is bool and operator is where"

In this case, it looks like we expect the body to be a VecMask (unify_mask_base_type is called by where()), but we don't make it a VecMask.

Differential Revision: [D64702918](https://our.internmc.facebook.com/intern/diff/D64702918/)

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy yf225 chenyang78 kadeng muchulee8 ColinPeppler amjames desertfire chauhang aakhundov

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

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

swolchok added a commit that referenced this pull request Oct 21, 2024
… bool and operator is where

Pull Request resolved: #138486

In this case, it looks like we expect the body to be a VecMask (unify_mask_base_type is called by where()), but we don't make it a VecMask.
ghstack-source-id: 249215767
@exported-using-ghexport

Differential Revision: [D64702918](https://our.internmc.facebook.com/intern/diff/D64702918/)
@swolchok
Copy link
Contributor Author

swolchok commented Oct 21, 2024

figure out how to repro this issue without that PR and add a regression test.

I could use help adding a test here. The failing input to constant_pad_nd on #137426 is tensor size (0, 3, 3) and pad=(1, 1, 1, 1, 1, 1). I brute-forced all sizes in range(3, 10) for dim 1 and 2 on main without finding a repro.

@swolchok swolchok requested review from jgong5 and leslie-fang-intel and removed request for jgong5 October 21, 2024 22:31
Copy link
Collaborator

@leslie-fang-intel leslie-fang-intel 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 fix. I think the changes in this PR looks good to me. But would like to study more about the failure.
It looks like body code generates a scalar var with bool dtype, and we mistake it as at::vec::Vectorized instead of at::vec::VecMask. It will be great to have a test case.

…lt dtype is bool and operator is where"


In this case, it looks like we expect the body to be a VecMask (unify_mask_base_type is called by where()), but we didn't make it a VecMask. Now we do.

Differential Revision: [D64702918](https://our.internmc.facebook.com/intern/diff/D64702918/)

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy yf225 chenyang78 kadeng muchulee8 ColinPeppler amjames desertfire chauhang aakhundov

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

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

@swolchok
Copy link
Contributor Author

It will be great to have a test case.

done!

@swolchok swolchok added the topic: not user facing topic category label Oct 22, 2024
…lt dtype is bool and operator is where"


In this case, it looks like we expect the body to be a VecMask (unify_mask_base_type is called by where()), but we didn't make it a VecMask. Now we do.

Differential Revision: [D64702918](https://our.internmc.facebook.com/intern/diff/D64702918/)

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy yf225 chenyang78 kadeng muchulee8 ColinPeppler amjames desertfire chauhang aakhundov

[ghstack-poisoned]
swolchok added a commit that referenced this pull request Oct 22, 2024
… bool and operator is where

Pull Request resolved: #138486

In this case, it looks like we expect the body to be a VecMask (unify_mask_base_type is called by where()), but we don't make it a VecMask.
ghstack-source-id: 249288078
@exported-using-ghexport

Differential Revision: [D64702918](https://our.internmc.facebook.com/intern/diff/D64702918/)
@facebook-github-bot
Copy link
Contributor

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

Copy link
Collaborator

@leslie-fang-intel leslie-fang-intel left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the fix.

…lt dtype is bool and operator is where"


In this case, it looks like we expect the body to be a VecMask (unify_mask_base_type is called by where()), but we didn't make it a VecMask. Now we do.

Differential Revision: [D64702918](https://our.internmc.facebook.com/intern/diff/D64702918/)

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy yf225 chenyang78 kadeng muchulee8 ColinPeppler amjames desertfire chauhang aakhundov

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

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

pytorchmergebot pushed a commit that referenced this pull request Oct 24, 2024
This issue is one of two inductor bugs blocking land of #137426. Turned out to be simple

Differential Revision: [D64734116](https://our.internmc.facebook.com/intern/diff/D64734116/)

Pull Request resolved: #138542
Approved by: https://github.com/jgong5, https://github.com/malfet
ghstack dependencies: #138486

Co-authored-by: leslie-fang-intel <leslie.fang@intel.com>
pytorchmergebot pushed a commit that referenced this pull request Oct 24, 2024
These are ternary ops, not binary ops.

Differential Revision: [D64794253](https://our.internmc.facebook.com/intern/diff/D64794253/)

Pull Request resolved: #138655
Approved by: https://github.com/jgong5, https://github.com/malfet
ghstack dependencies: #138486, #138542
pytorchmergebot pushed a commit that referenced this pull request Oct 24, 2024
The size of the destination array was too small.

Differential Revision: [D64843491](https://our.internmc.facebook.com/intern/diff/D64843491/)
Pull Request resolved: #138716
Approved by: https://github.com/jgong5, https://github.com/malfet
ghstack dependencies: #138486, #138542, #138655
pytorchmergebot pushed a commit that referenced this pull request Oct 24, 2024
There is no guarantee that `len` here is enough for a full vector. This was causing at least one test failure on #137426.

Differential Revision: [D64857786](https://our.internmc.facebook.com/intern/diff/D64857786/)

Pull Request resolved: #138744
Approved by: https://github.com/jgong5, https://github.com/malfet
ghstack dependencies: #138486, #138542, #138655, #138716
pytorchmergebot pushed a commit that referenced this pull request Oct 26, 2024
The correct vector length for ARM64 is 128 bits (16
bytes). We were previously using double this, apparently just because
that would be the same length as AVX2.

Differential Revision: [D63984039](https://our.internmc.facebook.com/intern/diff/D63984039/)

Pull Request resolved: #137426
Approved by: https://github.com/jgong5, https://github.com/malfet
ghstack dependencies: #138486, #138542, #138655, #138716, #138744
@github-actions github-actions bot deleted the gh/swolchok/671/head branch November 24, 2024 02:13
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.

5 participants