Skip to content

[XPU] Remove stale expectedFailure for linalg.tensorinv test_numpy_ref float64 - #197547

Closed
pponikox wants to merge 1 commit into
pytorch:mainfrom
pponikox:stale_expect_linalg-tensorinv
Closed

pponikox wants to merge 1 commit into
pytorch:mainfrom
pponikox:stale_expect_linalg-tensorinv

Conversation

@pponikox

@pponikox pponikox commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #200245
Fixes: intel/torch-xpu-ops#5074
Related: intel/torch-xpu-ops#4313
Related: intel/torch-xpu-ops#2618

Removes the XPU expectedFailure for TestCommon.test_numpy_ref (linalg.tensorinv, float64) from the OpInfo in torch/testing/_internal/opinfo/definitions/linalg.py.

No linalg.tensorinv or XPU kernel code is changed. The XPU result was always correct. The expectedFailure was hiding a wrong NumPy reference in the PyTorch XPU CI environment, and that environment was fixed by #199535.

Root cause

Validation

Intel BMG:

python test_ops_xpu.py TestCommonXPU.test_numpy_ref_linalg_tensorinv_xpu_float64 -v
  • before: FAILED (unexpected success)
  • after: OK (complex128 variant also passes)

PyTorch XPU CI: rebased onto viable/strict 5de236d which includes #199535.

@pytorch-bot

pytorch-bot Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ You can merge normally! (1 Unrelated Failure)

As of commit c380a78 with merge base 5de236d (image):

FLAKY - The following job failed but was likely due to flakiness present on trunk:

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

@pponikox

Copy link
Copy Markdown
Contributor Author

@pytorchbot label "topic: not user facing"

@dvrogozh dvrogozh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

linalg.tensorinv now computes correctly on XPU

Nothing in PR description or linked intel/torch-xpu-ops#5074 issue tells what was actually changed to fix the problem. Without that this looks a random change. Please update PR with clear details.

@chuanqi129 chuanqi129 added the ciflow/xpu Run XPU CI tasks label Oct 5, 2026
@pytorch-bot

pytorch-bot Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Workflows were awaiting approval. CI has now been triggered for the ciflow labels on this PR.

@BBBela BBBela left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am not sure if removing the expectedFailure is good solution here - at least in this moment. There is an older issue that lists affected test case as failing, but PVC-specific (intel/torch-xpu-ops#4313). This expectedFailure that is being removed by this PR was added about month ago when generalizing upstream test files.

In short - from the issues it looks like the test_numpy_ref_linalg_tensorinv_xpu_float64 without any decorators fails on PVC with numerical errors and passes on BMG. After adding expectedFailure decorator it passes on PVC with XFAIL but fails on BMG with Unexpected Success. The problem is that most of PyTorch XPU CI runs on PVC, while torch-xpu-ops CI runs on BMG. I launched XPU CI on this PR to confirm this, but if the above is correct, then test_numpy_ref_linalg_tensorinv_xpu_float64 will fail on this PR with numerical problems.

I believe it needs to be checked and verified on PVC platform.

@BBBela

BBBela commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

The CI results are as expected - the test_numpy_ref_linalg_tensorinv_xpu_float64 fails with numerical issues, but the PR base is from 17 days ago. Interesting part is that my recent PRs show the same test case in PyTorch CI as failing with Unexpected Success, so on current viable/strict the test_numpy_ref_linalg_tensorinv_xpu_float64 is numerically passing also on PVC.
That indicates that there must have changed something in PyTorch code or PyTorch XPU CI runners that changed the results of test_numpy_ref_linalg_tensorinv_xpu_float64. I will investigate it and come back when I find something.

@pponikox

pponikox commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

Nothing in PR description or linked intel/torch-xpu-ops#5074 issue tells what was actually changed to fix the problem. Without that this looks a random change. Please update PR with clear details.

Thanks @dvrogozh, you're right. That sentence was misleading.

Nothing was changed in the code to "fix" linalg.tensorinv. The test always passed on BMG, which is what torch-xpu-ops CI uses. The expectedFailure was added in #178849 because of a numerical failure on PVC (intel/torch-xpu-ops#4313), and PVC is what PyTorch XPU CI mainly uses. I wasn't aware of this - thanks @BBBela for explaining this in greater detail.

So this PR only changes the test expectation, and that is valid only if the test also passes on PVC.
I've rewritten the PR description with the history of both issues, links, and the current status. The PR stays in draft until @BBBela's PVC investigation in intel/torch-xpu-ops#4313 is concluded.

@pponikox

pponikox commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

@BBBela thanks a lot for the timeline and for running XPU CI. This explains pretty much the whole picture that I was not aware of. That intel/torch-xpu-ops#4313 task completely slipped through my radar.

In short - from the issues it looks like the test_numpy_ref_linalg_tensorinv_xpu_float64 without any decorators fails on PVC with numerical errors and passes on BMG.

Agreed. My validation was done on BMG only, so I only saw the Unexpected success side. I didn't had access to PVC, so I'll rely on CI and your verification there.

The CI results are as expected - the test_numpy_ref_linalg_tensorinv_xpu_float64 fails with numerical issues, but the PR base is from 17 days ago. [...] on current viable/strict the test_numpy_ref_linalg_tensorinv_xpu_float64 is numerically passing also on PVC.

This one is Interesting. A few things that might help narrow it down:

  • Maybe it would be useful to rebase this PR onto the latest viable/strict and re-run XPU CI? Since the diff is the same, an old-base fail / new-base pass on the same PR would confirm the change and give us a commit range between cfaca3b and the new base.
  • The bot analysis in [Bug Skip]: test_numpy_ref_linalg_tensorinv_xpu_float64 — Mismatched elements (66.7%) vs NumPy reference on PVC intel/torch-xpu-ops#4313 raised a lead it couldn't confirm on BMG: the oneMKL getrf/getrs scratchpads in src/ATen/native/xpu/mkl/BatchLinearAlgebra.cpp are allocated with at::empty (uninitialized), while orgqr/ungqr use at::zeros. If that matters on PVC, the result could change with allocator state rather than with code changes, which might also explain the different results.

I've updated the PR description to reflect all this, and I'm keeping the PR in draft until your PVC investigation is done.
Let me know if you'd like me to do the rebase.

@BBBela

BBBela commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

The result of investigation is that the root cause of numerical problem with test_numpy_ref_linalg_tensorinv_xpu_float64 has been removed from PyTorch main just recently. Current PyTorch CI state is that test_numpy_ref_linalg_tensorinv_xpu_float64 numerically passes, so in CI it fails with Unexpected Success.

I put more detailed problem and investigation description in the linked issue intel/torch-xpu-ops#5074.

Saying that, we can proceed with merging this PR as the problem is clear now and resolved on main.

@BBBela

BBBela commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

@pytorchbot rebase

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Successfully rebased stale_expect_linalg-tensorinv onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via git checkout stale_expect_linalg-tensorinv && git pull --rebase)

@pytorchmergebot
pytorchmergebot force-pushed the stale_expect_linalg-tensorinv branch from 3a6616e to c380a78 Compare October 6, 2026 12:53

@BBBela BBBela left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's wait for CI results, but after recent finding this PR looks good to me and a right solution.

One thing - after investigation showed the real problem and the exact commit that made this expectedFailure redundant, I believe that this PR description needs to be again adjusted, sorry

Once CI is green, you have my approval 😉

@dvrogozh

dvrogozh commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

One thing - after investigation showed the real problem and the exact commit that made this expectedFailure redundant, I believe that this PR description needs to be again adjusted

@pponikox, I believe you did that, right? Please, reply for a clarity.

Fixes intel/torch-xpu-ops#5074. Related: intel/torch-xpu-ops#4313, intel/torch-xpu-ops#2618.

I recommend to use the following form referencing other stuff:

<Key-Word>: <Link>

I.e. in our particular case:

Fixes: https://github.com/intel/torch-xpu-ops/issues/5074
Related: https://github.com/intel/torch-xpu-ops/issues/4313
Related: https://github.com/intel/torch-xpu-ops/issues/2618

In this form git log can be more easily parsed and searched if needed.

@BBBela BBBela left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CI passed, thanks for patience during investigating the problem 😉

@pponikox

pponikox commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

@pponikox, I believe you did that, right? Please, reply for a clarity.

Yes, the description was updated yesterday.

I recommend to use the following form referencing other stuff:

<Key-Word>: <Link>

I.e. in our particular case:

Fixes: https://github.com/intel/torch-xpu-ops/issues/5074
Related: https://github.com/intel/torch-xpu-ops/issues/4313
Related: https://github.com/intel/torch-xpu-ops/issues/2618

In this form git log can be more easily parsed and searched if needed.

Just for clarification:
Under the hood I'm using the full links like you've mentioned:
image

However when I save or go to preview the links are shortened into this
image

I'm not 100% sure how this description is visible in the history, but scanning through other logs I think that full links URLs are used 😉

@pponikox
pponikox requested a review from dvrogozh October 7, 2026 06:42
@dvrogozh

dvrogozh commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Under the hood I'm using the full links like you've mentioned. However when I save or go to preview the links are shortened into this.

3 things to clarify:

  1. Yes, that's true for whenever you mention a full link in the PR description, comments or Github issues - Github rendering system takes care of that and shortens links. If PR description will be used for the commit message no shortening will be done - it will use the raw text without any rendering magic.

  2. If you use shortened link in the PR description Github still understands that and renders a nice link for you. However, as above - this will go as is in the raw PR description to commit message, i.e. in shortened form. This makes it 1) a little difficult to click on the link from, for example, raw terminal git log as there is no link, just row #555 number, 2) gives a discrepancy whenever such commit appears in a fork since Github magic will attempt to reconstruct the link against the fork and the object might not exist there. That's why I personally prefer to always refer to the full links for issues in PR descriptions.

  3. When I was talking about full links, I was commenting on the in-the-source .cpp comments. That's where I found using shortened gihtub convention form annoying as that is not typically handled by the editor's renderers.

UPDATE:

When I was talking about full links, I was commenting on the in-the-source .cpp comments.

This might have been in the other PR review :).

@dvrogozh dvrogozh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@chuanqi129
chuanqi129 marked this pull request as ready for review October 8, 2026 05:45
@chuanqi129 chuanqi129 added the ciflow/trunk Trigger trunk jobs on your pull request label Oct 8, 2026
@pponikox

pponikox commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

I double checked that the latests CI failure is NOT related to my changes (problem is with test/inductor/test_torchinductor.py::GPUTests::test_mutate_realized_buffer_in_make_fx_graph_case_foreach_reads_sibling_target_xpu which also failed in the previous CI run).

@chuanqi129

Copy link
Copy Markdown
Collaborator

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

cyyever pushed a commit to BakeLab/pytorch that referenced this pull request Oct 11, 2026
…f float64 (pytorch#197547)

### Summary

Fixes pytorch#200245
Fixes: intel/torch-xpu-ops#5074
Related: intel/torch-xpu-ops#4313
Related: intel/torch-xpu-ops#2618

Removes the XPU `expectedFailure` for `TestCommon.test_numpy_ref` (`linalg.tensorinv`, `float64`) from the OpInfo in `torch/testing/_internal/opinfo/definitions/linalg.py`.

No `linalg.tensorinv` or XPU kernel code is changed. The XPU result was always correct. The `expectedFailure` was hiding a wrong **NumPy reference** in the PyTorch XPU CI environment, and that environment was fixed by pytorch#199535.

### Root cause

- `test_numpy_ref` compares `torch.linalg.tensorinv` on XPU against `np.linalg.tensorinv` computed on the CPU host.
- NumPy <= 1.23.x bundles OpenBLAS <= 0.3.20, which returns wrong results for LU-based routines (inv/solve/det) on Intel Xeon Sapphire Rapids and Granite Rapids CPUs (numpy/numpy#22502, fixed in OpenBLAS 0.3.21 / NumPy 1.24.0 via numpy/numpy#22525). Detailed analysis: intel/torch-xpu-ops#2618.
- PyTorch XPU CI images used Python 3.10, for which `.ci/docker/requirements-ci.txt` pins `numpy==1.23.2`, on affected host CPUs. As a result the reference was wrong and the test failed.
- The failure was originally attributed to PVC / oneMKL. That turned out to be incorrect: the deciding factor was the host CPU + NumPy/OpenBLAS version, not the GPU.

### Validation

Intel BMG:
```
python test_ops_xpu.py TestCommonXPU.test_numpy_ref_linalg_tensorinv_xpu_float64 -v
```
- before: FAILED (unexpected success)
- after: OK (complex128 variant also passes)

PyTorch XPU CI: rebased onto `viable/strict` 5de236d which includes pytorch#199535.

Pull Request resolved: pytorch#197547
Approved by: https://github.com/dvrogozh, https://github.com/BBBela, https://github.com/chuanqi129, https://github.com/atalman

This branch was previously deployed

1 inactive deployment
bedrock — c380a78c Deployed Oct 8, 2026 by chuanqi129
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request ciflow/xpu Run XPU CI tasks Merged open source topic: not user facing topic category

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

DISABLED test_numpy_ref_linalg_tensorinv_xpu_float64 (__main__.TestCommonXPU) UT failure Unexpected success in test_ops_xpu.py

7 participants