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

Skip to content

mul: remove opmath cast sequence#9663

Merged
ysiraichi merged 1 commit intopytorch:masterfrom
tenstorrent:sshon/mul-op-mathop-remove
Oct 3, 2025
Merged

mul: remove opmath cast sequence#9663
ysiraichi merged 1 commit intopytorch:masterfrom
tenstorrent:sshon/mul-op-mathop-remove

Conversation

@sshonTT
Copy link
Contributor

@sshonTT sshonTT commented Oct 1, 2025

Remove the explicit opmath-driven cast chain (bf16→f32→bf16, etc.) from mul. The op now executes in the dtype chosen by standard dtype promotion, without inserting unconditional upcast/downcast steps. But leave its functionality for future usage.

@sshonTT
Copy link
Contributor Author

sshonTT commented Oct 1, 2025

Fixes issue #9662

@sshonTT
Copy link
Contributor Author

sshonTT commented Oct 2, 2025

@ysiraichi Hi, could you take a look when you have a chance?

@ysiraichi
Copy link
Collaborator

Could you add a test to verify whether that does what we expect?

@sshonTT
Copy link
Contributor Author

sshonTT commented Oct 2, 2025

Could you add a test to verify whether that does what we expect?

I could add a test for the mul op, but as you know, this patch affects the intermediate type casting, so it’s tricky to capture the cast → op → cast-back sequence. Do you have any ideas on how to validate this?

@ysiraichi
Copy link
Collaborator

You can use expecttest!
See test_ops_error_message.py for reference.

Remove the explicit opmath-driven cast chain (bf16→f32→bf16, etc.) from `mul`. The op now executes in the dtype chosen by standard dtype promotion, without inserting unconditional upcast/downcast steps. But leave its functionality for future usage.
@sshonTT sshonTT force-pushed the sshon/mul-op-mathop-remove branch from f22abe8 to 55c07ed Compare October 2, 2025 14:20
@sshonTT
Copy link
Contributor Author

sshonTT commented Oct 2, 2025

@ysiraichi ,I was going to try the expecttest module you suggested, but I found that test_operations_hlo.py already provides a more effective way to check the behavior I wanted. So I added the test there instead.

Copy link
Collaborator

@ysiraichi ysiraichi left a comment

Choose a reason for hiding this comment

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

Thank you for the PR.

@ysiraichi ysiraichi merged commit 2a9138a into pytorch:master Oct 3, 2025
24 checks passed
@sshonTT sshonTT deleted the sshon/mul-op-mathop-remove branch October 3, 2025 18:22
@jeffhataws
Copy link
Collaborator

@sshonTT @mmanzoorTT looks like we may need to revert this change due to #9699 .

rajkthakur added a commit to rajkthakur/xla that referenced this pull request Nov 4, 2025
rajkthakur added a commit to rajkthakur/xla that referenced this pull request Nov 10, 2025
rajkthakur added a commit to rajkthakur/xla that referenced this pull request Nov 11, 2025
jeffhataws pushed a commit that referenced this pull request Nov 12, 2025
Commit 2a9138a removed `.use_opmathtype_for_compute()` from element-wise
'mul' operation, this breaks mixed-precision accumulation behavior
expected by the Neuron compiler that traces/compile on CPU and later
execute the binary on neuron hardwares, causing accuracy
degradation transformer models using mixed-precision compilation

Reverts: commit 2a9138a, other changes are result of rebase from r2.9
Fixes: Model accuracy failures with mixed-precision accumulation
#9699
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments