Skip to content

SDPA: use exp_u20 for the softmax exponential (#22082) - #22082

Open
pssrawat wants to merge 1 commit into
pytorch:mainfrom
pssrawat:export-D117198987
Open

SDPA: use exp_u20 for the softmax exponential (#22082)#22082
pssrawat wants to merge 1 commit into
pytorch:mainfrom
pssrawat:export-D117198987

Conversation

@pssrawat

@pssrawat pssrawat commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary:

Switch the softmax exponential in the flash-attention custom SDPA
kernel (op_sdpa_impl.h) from Vectorized::exp() to
Vectorized::exp_u20(). The file already carried this as a TODO.

This is not bit-exact. exp_u20 is a ULP-20 approximation, so it differs
from exp outright, and fourteen autoregressive layers on that is enough
to flip a near-tie argmax.

Differential Revision: D117198987

@pytorch-bot

pytorch-bot Bot commented Aug 24, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 1 New Failure, 1 Cancelled Job, 1 Unrelated Failure, 13 Unclassified Failures

As of commit a8cac3c with merge base 2287a8b (image):

NEW FAILURE - The following job has failed:

  • Cadence Build & Test / hifi-build / hifi4 (gh)
    ##[error]Refusing to check out fork pull request code from a 'pull_request_target' workflow. This workflow runs with the base repository's GITHUB_TOKEN, secrets, default-branch cache scope, and runner access. Fetching and executing a fork's code in that trusted context commonly leads to "pwn request" vulnerabilities. To opt in, review the risks at https://gh.io/securely-using-pull_request_target and set 'allow-unsafe-pr-checkout: true' on the actions/checkout step.

UNCLASSIFIED FAILURES - DrCI could not classify the following jobs because the workflow did not run on the merge base. The failures may be pre-existing on trunk or introduced by this PR:

CANCELLED JOB - The following job was cancelled. Please retry:

FLAKY - The following job failed but was likely due to flakiness present on trunk:

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

@meta-cla meta-cla 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 24, 2026
@meta-codesync

meta-codesync Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

@pssrawat has exported this pull request. If you are a Meta employee, you can view the originating Diff in D117198987.

Summary:

Switch the softmax exponential in the flash-attention custom SDPA
kernel (`op_sdpa_impl.h`) from `Vectorized::exp()` to
`Vectorized::exp_u20()`. The file already carried this as a TODO.


This is not bit-exact. `exp_u20` is a ULP-20 approximation, so it differs
from `exp` outright, and fourteen autoregressive layers on that is enough
to flip a near-tie argmax.

Differential Revision: D117198987
@meta-codesync meta-codesync Bot changed the title SDPA: use exp_u20 for the softmax exponential SDPA: use exp_u20 for the softmax exponential (#22082) Aug 24, 2026
@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

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

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. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant