Skip to content

Fix SDPA decomp problem #4851

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
Aug 22, 2024
Merged

Fix SDPA decomp problem #4851

merged 1 commit into from
Aug 22, 2024

Conversation

mcremon-meta
Copy link
Contributor

Summary:
As titled. The new _safe_softmax function is meant to avoid NaN issues mostly in training. For inference, we shouldn't need it so we swap with the regular softmax, which will prevent the decomposition that introduces the unsupported ops (eq, logical_not and any). See https://www.internalfb.com/code/fbsource/fbcode/caffe2/torch/_decomp/decompositions.py?lines=425.

Note that it needed some changes to run_and_verify since we now need some aten IR changes. I will fix it in another diff, where run_and_verify will use a nop quantizer instead. This way the code path will be the same for fp32 and quantized. But let's make CI green first!

We will also need to formalize better how to apply passes on the initial graph module (aten IR passes as opposed to edge IR passes). Seems like lifted constants and other things like that can create issues, but unless we see errors, let's wait until the IR changes from PT/ET are in first.

Reviewed By: hsharma35

Differential Revision: D61639074

Copy link

pytorch-bot bot commented Aug 22, 2024

🔗 Helpful Links

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

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

✅ No Failures

As of commit 66c39b4 with merge base 87b38cf (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 Aug 22, 2024
@facebook-github-bot
Copy link
Contributor

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

Summary: As titled. The new `_safe_softmax` function is meant to avoid NaN issues mostly in training. For inference, we shouldn't need it so we swap with the regular softmax, which will prevent the decomposition that introduces the unsupported ops (`eq`, `logical_not` and `any`). See https://www.internalfb.com/code/fbsource/fbcode/caffe2/torch/_decomp/decompositions.py?lines=425.

Reviewed By: hsharma35

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

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

@facebook-github-bot facebook-github-bot merged commit d7c069f into main Aug 22, 2024
35 of 37 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants