numpy / numpy/numpy

BUG: `linalg.inv` crashing on windows arm64

Open
#29,442 28 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

00 - Bug 27 - OpenBLAS component: numpy.linalg
Dominant language
Python
Stars
32.8k
Forks
12.8k
Avg merge
1d 7h
Merged PRs (30d)
197

Description

Describe the issue:

The linalg.inv function is showing consistent crashes with the numpy 2.3.1 and 2.3.2 wheels for win_arm64 (Windows on Arm, WoA) installed from PyPI with Windows fatal exception: access violation.

The traceback in SciPy CI points at this line:

https://github.com/numpy/numpy/blob/c6b5258508690f1ffd240c00170779b54cd917d7/numpy/linalg/_linalg.py#L669

Reproduce the code example:
Here is a reproducer:


@pytest.mark.parametrize('dtype', [np.complex64, np.complex128])
@pytest.mark.parametrize('mtype', ['symm', 'herm'])  # matrix type
def test_numpy_inv_crash_win_arm64(dtype, mtype):
    rng = np.random.default_rng(1723059677121834)
    n = 20
    A = rng.random((n, n)) + rng.random((n, n))*1j
    if np.issubdtype(dtype, np.floating):
        A = A.real
    A = A.astype(dtype)
    A = A + A.T if mtype == 'symm' else A + A.conj().T
    ref = np.linalg.inv(A)


It's crashing for all combinations of `complex64`/`complex128` and symmetric/hermitian matrices. `float32`/`float64` dtypes are working fine.
Error message:
This ran in SciPy CI with `pytest-xdist` with 2 workers.

Windows fatal exception: access violation
...

 Current thread 0x00001f34 (most recent call first):
  File "C:\hostedtoolcache\windows\Python\3.12.10\arm64\Lib\site-packages\numpy\linalg\_linalg.py", line 669 in inv
  File "C:\a\scipy\scipy\build-install\Lib\site-packages\scipy\linalg\tests\test_lapack.py", line 3527 in test_numpy_inv_crash_win_arm64
  File "C:\hostedtoolcache\windows\Python\3.12.10\arm64\Lib\site-packages\_pytest\python.py", line 157 in pytest_pyfunc_call
  File "C:\hostedtoolcache\windows\Python\3.12.10\arm64\Lib\site-packages\pluggy\_callers.py", line 121 in _multicall
...
Python and NumPy Versions:

Python 3.11/3.12
NumPy 2.3.1/2.3.2

Runtime Environment:

(can't easily provide this, I don't have local hardware)

Context for the issue:

The SciPy tests can be skipped for now, so it's not blocking.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with numpy/linalg/_linalg.py at line 669 and run the supplied reproducer on the affected Windows ARM64 setup. Compare the complex64 and complex128 symmetric or Hermitian cases with the working float cases, then use the SciPy test at scipy/linalg/tests/test_lapack.py:3527 to verify that the access violation no longer occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.