Skip to content

[inductor] Fix bugs in emulate_precision_casts#163520

Closed
jansel wants to merge 4 commits intogh/jansel/546/basefrom
gh/jansel/546/head
Closed

[inductor] Fix bugs in emulate_precision_casts#163520
jansel wants to merge 4 commits intogh/jansel/546/basefrom
gh/jansel/546/head

Conversation

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Sep 22, 2025

🔗 Helpful Links

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

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

✅ No Failures

As of commit 49b28d4 with merge base 51152ef (image):
💚 Looks good so far! There are no failures yet. 💚

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

[ghstack-poisoned]
@jansel jansel requested a review from eellison September 22, 2025 15:13
[ghstack-poisoned]
Copy link
Contributor

@eellison eellison left a comment

Choose a reason for hiding this comment

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

nice!

Comment on lines -806 to -809
if (
not isinstance(func, torch._ops.OpOverload)
or torch.Tag.pointwise not in func.tags
):
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Comment on lines +816 to +821
if not output_low_precision:
for input_node in last_node.all_input_nodes:
val = input_node.meta.get("val") if hasattr(input_node, "meta") else None
if isinstance(val, torch.Tensor) and val.dtype in low_pr_fp:
output_low_precision = True
break
Copy link
Contributor

Choose a reason for hiding this comment

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

Thinking out loud:

For something like

x: bfloat16
y = x.to(float32)

This would set low_precision_pointwise_barrier on the x.to(float32) output. I guess this is okay because its actual dtype later in lowering will be float32, so we'll ignore it.

And the decomps themselves should be upcasting intermediaries to be fp32, so those will also get ignored, e.g. gelu here.

[ghstack-poisoned]
@pytorchmergebot
Copy link
Collaborator

Starting merge as part of PR stack under #163482

pytorchmergebot pushed a commit that referenced this pull request Sep 24, 2025
pytorchmergebot pushed a commit that referenced this pull request Sep 24, 2025
This reverts commit a8cd437.

See #163481 (comment)

This PR might also cause issues with cudagraphs.

Pull Request resolved: #163737
Approved by: https://github.com/ezyang
ghstack dependencies: #163386, #163398, #163387, #163414, #163415, #163419, #163434, #163393, #163412, #163422, #163481, #163520, #163482
dsashidh pushed a commit to dsashidh/pytorch that referenced this pull request Sep 26, 2025
jainapurva pushed a commit that referenced this pull request Sep 29, 2025
jainapurva pushed a commit that referenced this pull request Sep 29, 2025
jainapurva pushed a commit that referenced this pull request Sep 29, 2025
This reverts commit a8cd437.

See #163481 (comment)

This PR might also cause issues with cudagraphs.

Pull Request resolved: #163737
Approved by: https://github.com/ezyang
ghstack dependencies: #163386, #163398, #163387, #163414, #163415, #163419, #163434, #163393, #163412, #163422, #163481, #163520, #163482
@github-actions github-actions bot deleted the gh/jansel/546/head branch October 25, 2025 02:12
Khanaksahu pushed a commit to Khanaksahu/pytorch that referenced this pull request Nov 17, 2025
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.

4 participants