pytorch - 💡(How to fix) Fix Inductor CPU returns wrong argmax after sin_() and transpose [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
pytorch/pytorch#183082Fetched 2026-05-11 03:12:55
View on GitHub
Comments
0
Participants
1
Timeline
55
Reactions
0
Participants
Timeline (top)
mentioned ×24subscribed ×24labeled ×7

Root Cause

The input tensor is fixed, so the mismatch is not caused by randomness.

Code Example

import torch

def f(x):
    x = x.clone()
    x.sin_()
    return x.t().argmax()

x = torch.tensor([
    [-1.5256, -0.7502, -0.6540, -1.6095, -0.1002, -0.6092, -0.9798],
    [-1.6091, -0.7121,  0.3037, -0.7773, -0.2515, -0.2223,  1.6871],
    [ 0.2284,  0.4676, -0.6970, -1.1608,  0.6995,  0.1991,  0.8657],
    [ 0.2444, -0.6629,  0.8073,  1.1017, -0.1759, -2.2456, -1.4465],
    [ 0.0612, -0.6177, -0.7981, -0.1316, -0.7984,  0.3357,  0.2753],
])

eager = f(x)
compiled = torch.compile(f, backend="inductor")(x)

print("eager =", eager.item())
print("compiled =", compiled.item())

---

eager = 31
compiled = 13
RAW_BUFFERClick to expand / collapse

🐛 Describe the bug

torch.compile with the Inductor CPU backend returns a different result from eager mode when argmax() is applied after an in-place sin_() and a transposed view.

The input tensor is fixed, so the mismatch is not caused by randomness.

Reproducer

import torch

def f(x):
    x = x.clone()
    x.sin_()
    return x.t().argmax()

x = torch.tensor([
    [-1.5256, -0.7502, -0.6540, -1.6095, -0.1002, -0.6092, -0.9798],
    [-1.6091, -0.7121,  0.3037, -0.7773, -0.2515, -0.2223,  1.6871],
    [ 0.2284,  0.4676, -0.6970, -1.1608,  0.6995,  0.1991,  0.8657],
    [ 0.2444, -0.6629,  0.8073,  1.1017, -0.1759, -2.2456, -1.4465],
    [ 0.0612, -0.6177, -0.7981, -0.1316, -0.7984,  0.3357,  0.2753],
])

eager = f(x)
compiled = torch.compile(f, backend="inductor")(x)

print("eager =", eager.item())
print("compiled =", compiled.item())

Result

eager = 31
compiled = 13

Versions

PyTorch version: 2.10.0+cpu

cc @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10 @jerryzh168 @aditew01 @chauhang @penguinwu @voznesenskym @EikanWang @Guobing-Chen @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @aakhundov @coconutruben @jataylo

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

pytorch - 💡(How to fix) Fix Inductor CPU returns wrong argmax after sin_() and transpose [1 participants]