Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Inductor] Skip nonfinite preservation for safe scaled softmax#186211

Draft
Yuxingwang-intel wants to merge 1 commit into
pytorch:mainfrom
Yuxingwang-intel:scaled-softmax
Draft

[Inductor] Skip nonfinite preservation for safe scaled softmax#186211
Yuxingwang-intel wants to merge 1 commit into
pytorch:mainfrom
Yuxingwang-intel:scaled-softmax

Conversation

@Yuxingwang-intel
Copy link
Copy Markdown
Contributor

@Yuxingwang-intel Yuxingwang-intel commented Jun 4, 2026

Skip the scaled softmax nonfinite-semantics preservation logic for static safe scale factors.

PR #184046 added logic in Inductor to preserve the original scaled subtraction behavior for nonfinite scaled-softmax inputs, so that Inductor does not turn eager NaNs into finite softmax results. However, for static positive scales <= 1, multiplying finite inputs by the scale will not introduce overflow. In those cases, the additional preservation logic is unnecessary overhead and can also block downstream fusion patterns or cause performance regressions on benchmarks.
This PR keeps the existing nonfinite-semantics preserving path for unsafe or dynamic scales but directly returns the stable scaled-softmax form for compile-time safe scales.

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo

@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Jun 4, 2026

🔗 Helpful Links

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

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

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

@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Jun 4, 2026

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.

@Yuxingwang-intel Yuxingwang-intel marked this pull request as draft June 4, 2026 09:00
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Jun 4, 2026

The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:

  • ciflow/inductor
  • ciflow/torchtitan

Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows.

1 similar comment
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Jun 4, 2026

The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:

  • ciflow/inductor
  • ciflow/torchtitan

Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows.

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.

2 participants