Skip to content

BUG: wrong errors e.g. "divide by zero encountered in matmul" on MacOS M4 #28687

@malciin

Description

@malciin

Current status

Apple is aware of this issue, see this comment below. Hopefully an OS update will have a fix soon. If you are experiencing this issue on a Mac with an M4 CPU it is not necessary to comment on this thread about it.

Describe the issue:

I guess its self explanatory. Following code:

np.identity(n=784) @ np.identity(n=784)

produces many wrong runtime warnings.

For small matrices is works as expected, for eg. np.identity(14) @ np.identity(14) doesn't produce warning but np.identity(15) @ np.identity(15) and bigger does.

Reproduce the code example:

import numpy as np
np.identity(n=15) @ np.identity(n=15) # produces warning
np.identity(n=14) @ np.identity(n=14) # no warning

# same result for
import numpy as np
np.ones(shape=(1, 2)) @ np.ones(shape=(2, 784))

Error message:

../test.py:3: RuntimeWarning: divide by zero encountered in matmul
  np.identity(n=784) @ np.identity(n=784)
../test.py:3: RuntimeWarning: overflow encountered in matmul
  np.identity(n=784) @ np.identity(n=784)
../test.py:3: RuntimeWarning: invalid value encountered in matmul
  np.identity(n=784) @ np.identity(n=784)

Python and NumPy Versions:

2.2.4
3.13.2 | packaged by Anaconda, Inc. | (main, Feb 6 2025, 12:55:35) [Clang 14.0.6 ]

I've checked also 3.11 & 3.9 but same result.

Runtime Environment:

No response

Context for the issue:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy