Skip to content

Support whole-number float exponents in ReplacePowWithMulPass (#18851)#18851

Open
khazaei wants to merge 1 commit intopytorch:mainfrom
khazaei:export-D100695654
Open

Support whole-number float exponents in ReplacePowWithMulPass (#18851)#18851
khazaei wants to merge 1 commit intopytorch:mainfrom
khazaei:export-D100695654

Conversation

@khazaei
Copy link
Copy Markdown
Contributor

@khazaei khazaei commented Apr 13, 2026

Summary:

Extend ReplacePowWithMulPass to accept float exponents that are whole numbers
(e.g., 2.0, 3.0, 4.0) in addition to integer exponents. Previously the pass only
matched int typed exponents, causing it to miss valid optimization opportunities
when the exponent was a float with no fractional part.

Changes:

  • Broaden the type check from isinstance(_, int) to isinstance(_, (int, float))
  • Add a guard to reject non-whole-number floats (e.g., 1.5, 0.5)
  • Convert validated float exponents to int before proceeding
  • Update docstring to document the new behavior

Reviewed By: hsharma35, mcremon-meta

Differential Revision: D100695654

@pytorch-bot
Copy link
Copy Markdown

pytorch-bot bot commented Apr 13, 2026

🔗 Helpful Links

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

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

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

⏳ 2 Pending, 2 Unrelated Failures

As of commit db78fae with merge base 75c677f (image):

FLAKY - The following jobs failed but were 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 Apr 13, 2026
@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync bot commented Apr 13, 2026

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

@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.

@meta-codesync meta-codesync bot changed the title Support whole-number float exponents in ReplacePowWithMulPass Support whole-number float exponents in ReplacePowWithMulPass (#18851) Apr 14, 2026
@khazaei khazaei force-pushed the export-D100695654 branch from cc464b5 to 9b8346e Compare April 14, 2026 21:08
khazaei pushed a commit to khazaei/executorch that referenced this pull request Apr 14, 2026
…h#18851)

Summary:

Extend `ReplacePowWithMulPass` to accept float exponents that are whole numbers
(e.g., 2.0, 3.0, 4.0) in addition to integer exponents. Previously the pass only
matched `int` typed exponents, causing it to miss valid optimization opportunities
when the exponent was a float with no fractional part.

Changes:
- Broaden the type check from `isinstance(_, int)` to `isinstance(_, (int, float))`
- Add a guard to reject non-whole-number floats (e.g., 1.5, 0.5)
- Convert validated float exponents to `int` before proceeding
- Update docstring to document the new behavior

Reviewed By: hsharma35, mcremon-meta

Differential Revision: D100695654
khazaei pushed a commit to khazaei/executorch that referenced this pull request Apr 14, 2026
…h#18851)

Summary:

Extend `ReplacePowWithMulPass` to accept float exponents that are whole numbers
(e.g., 2.0, 3.0, 4.0) in addition to integer exponents. Previously the pass only
matched `int` typed exponents, causing it to miss valid optimization opportunities
when the exponent was a float with no fractional part.

Changes:
- Broaden the type check from `isinstance(_, int)` to `isinstance(_, (int, float))`
- Add a guard to reject non-whole-number floats (e.g., 1.5, 0.5)
- Convert validated float exponents to `int` before proceeding
- Update docstring to document the new behavior

Reviewed By: hsharma35, mcremon-meta

Differential Revision: D100695654
@khazaei khazaei force-pushed the export-D100695654 branch from 9b8346e to e6267b1 Compare April 14, 2026 21:10
khazaei pushed a commit to khazaei/executorch that referenced this pull request Apr 14, 2026
…h#18851)

Summary:
Pull Request resolved: pytorch#18851

Extend `ReplacePowWithMulPass` to accept float exponents that are whole numbers
(e.g., 2.0, 3.0, 4.0) in addition to integer exponents. Previously the pass only
matched `int` typed exponents, causing it to miss valid optimization opportunities
when the exponent was a float with no fractional part.

Changes:
- Broaden the type check from `isinstance(_, int)` to `isinstance(_, (int, float))`
- Add a guard to reject non-whole-number floats (e.g., 1.5, 0.5)
- Convert validated float exponents to `int` before proceeding
- Update docstring to document the new behavior

Reviewed By: hsharma35, mcremon-meta

Differential Revision: D100695654
@khazaei khazaei force-pushed the export-D100695654 branch from e6267b1 to 6b1da40 Compare April 14, 2026 21:12
…h#18851)

Summary:
Pull Request resolved: pytorch#18851

Extend `ReplacePowWithMulPass` to accept float exponents that are whole numbers
(e.g., 2.0, 3.0, 4.0) in addition to integer exponents. Previously the pass only
matched `int` typed exponents, causing it to miss valid optimization opportunities
when the exponent was a float with no fractional part.

Changes:
- Broaden the type check from `isinstance(_, int)` to `isinstance(_, (int, float))`
- Add a guard to reject non-whole-number floats (e.g., 1.5, 0.5)
- Convert validated float exponents to `int` before proceeding
- Update docstring to document the new behavior

Reviewed By: hsharma35, mcremon-meta

Differential Revision: D100695654
@khazaei khazaei force-pushed the export-D100695654 branch from 6b1da40 to db78fae Compare April 14, 2026 21:22
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 meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants