Skip to content

BUG: np.dot (with OpenBLAS specifically) on float32 matrices returns all 0s but works as expected for float64 #29393

@KarthikL1729

Description

@KarthikL1729

Describe the issue:

I am using Numpy for profiling GEMM on a Macbook (Apple Silicon), and I installed two separate configurations of Numpy for the same: one using pip which defaults to using the Accelerate implementation for BLAS; and one using Homebrew, which defaults to using OpenBLAS (version 0.3.30). Both the installations themselves are Numpy v2.3.1.

On running np.dot on 2 randomly generated float32 matrices using the Accelerate configuration, everything works as expected. However when I run the exact same code with the OpenBLAS configuration, it returns all 0s. Changing the dtype to float64 fixes it, but I was unsure of why it does not work for float32 specifically.

I also tested the same code with older versions of Numpy (v2.2.6, v2.3.0) that use OpenBLAS, and they showed the same unexpected behaviour (they use slightly older versions of OpenBLAS too).

Am I missing something? I could ideally just continue using the Accelerate implementations since everything works expected on it, but I have not been able to fix the OpenBLAS np.dot behaviour, and wanted to bring this up.

Reproduce the code example:

import numpy as np

A = np.random.randn(8,8).astype(np.float32)
B = np.random.randn(8,8).astype(np.float32)
res = np.dot(A,B)

# Accelerate works fine, OpenBLAS returns an 8x8 matrix of 0s.

Python and NumPy Versions:

Python version: 3.13.5
Numpy versions: 2.3.1, 2.3.0, 2.2.6
OpenBLAS versions: 0.3.30, 0.3.29

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