scipy: BUG: complex determinants broken with openblas 0.3.22

Describe your issue.

scipy.linalg.det is broken when scipy is built from source with the just-released openblas 0.3.22.

Tested on macOS x86_64.

Ref: https://github.com/sagemath/sage/pull/35371

Reproducing Code Example

>>> import numpy, scipy
>>> A = numpy.array([[1,2,4],[5,3,9],[7,8,6]], dtype='complex')
>>> A
array([[1.+0.j, 2.+0.j, 4.+0.j],
       [5.+0.j, 3.+0.j, 9.+0.j],
       [7.+0.j, 8.+0.j, 6.+0.j]])
>>> scipy.linalg.det(A)
0j      # wrong
>>> Ar = numpy.array([[1,2,4],[5,3,9],[7,8,6]], dtype='float')
>>> scipy.linalg.det(Ar)
88.0

Error message

N/A

SciPy/NumPy/Python version and system information

>>> import sys, scipy, numpy; print(scipy.__version__, numpy.__version__, sys.version_info); scipy.show_config()
1.10.1 1.24.2 sys.version_info(major=3, minor=11, micro=2, releaselevel='final', serial=0)
/Users/mkoeppe/s/sage/sage-rebasing/worktree-algebraic-2018-spring/local/var/lib/sage/venv-python3.11/lib/python3.11/site-packages/scipy/__config__.py:140: UserWarning: Install `pyyaml` for better output
  warnings.warn("Install `pyyaml` for better output", stacklevel=1)
{
  "Compilers": {
    "c": {
      "name": "clang",
      "linker": "ld64",
      "version": "14.0.0",
      "commands": "gcc"
    },
    "cython": {
      "name": "cython",
      "linker": "cython",
      "version": "0.29.32",
      "commands": "cython"
    },
    "c++": {
      "name": "clang",
      "linker": "ld64",
      "version": "14.0.0",
      "commands": "g++"
    },
    "fortran": {
      "name": "gcc",
      "linker": "ld64",
      "version": "12.2.0",
      "commands": "gfortran"
    },
    "pythran": {
      "version": "0.12.1",
      "include directory": "/Users/mkoeppe/s/sage/sage-rebasing/worktree-algebraic-2018-spring/local/var/lib/sage/venv-python3.11/lib/python3.11/site-packages/pythran"
    }
  },
  "Machine Information": {
    "host": {
      "cpu": "x86_64",
      "family": "x86_64",
      "endian": "little",
      "system": "darwin"
    },
    "build": {
      "cpu": "x86_64",
      "family": "x86_64",
      "endian": "little",
      "system": "darwin"
    },
    "cross-compiled": false
  },
  "Build Dependencies": {
    "blas": {
      "name": "openblas",
      "found": true,
      "version": "0.3.22",
      "detection method": "pkgconfig",
      "include directory": "/usr/local/Cellar/openblas/0.3.22/include",
      "lib directory": "/usr/local/Cellar/openblas/0.3.22/lib",
      "openblas configuration": "USE_64BITINT= DYNAMIC_ARCH=1 DYNAMIC_OLDER= NO_CBLAS= NO_LAPACK= NO_LAPACKE= NO_AFFINITY=1 USE_OPENMP=1 NEHALEM MAX_THREADS=56",
      "pc file directory": "/usr/local/opt/openblas/lib/pkgconfig"
    },
    "lapack": {
      "name": "openblas",
      "found": true,
      "version": "0.3.22",
      "detection method": "pkgconfig",
      "include directory": "/usr/local/Cellar/openblas/0.3.22/include",
      "lib directory": "/usr/local/Cellar/openblas/0.3.22/lib",
      "openblas configuration": "USE_64BITINT= DYNAMIC_ARCH=1 DYNAMIC_OLDER= NO_CBLAS= NO_LAPACK= NO_LAPACKE= NO_AFFINITY=1 USE_OPENMP=1 NEHALEM MAX_THREADS=56",
      "pc file directory": "/usr/local/opt/openblas/lib/pkgconfig"
    }
  },
  "Python Information": {
    "path": "/Users/mkoeppe/s/sage/sage-rebasing/worktree-algebraic-2018-spring/local/var/lib/sage/venv-python3.11/bin/python3",
    "version": "3.11"
  }
}

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 16 (16 by maintainers)

Most upvoted comments

linalg.det function is also worked out and more tests are added accordingly. Since we identified this problem as an upstream issue, we can close it. But thanks everyone for the heads up and contributions.

real: image complex: image

In [4]: import sys, scipy, numpy; print(scipy.__version__, numpy.__version__, sys.version_info); scipy.show_config()
1.11.0.dev0+1761.02fb953 1.23.5 sys.version_info(major=3, minor=10, micro=8, releaselevel='final', serial=0)
/home/jakeb/development/scipy/build-install/lib/python3.10/site-packages/scipy/__config__.py:140: UserWarning: Install `pyyaml` for better output
  warnings.warn("Install `pyyaml` for better output", stacklevel=1)
{
  "Compilers": {
    "c": {
      "name": "gcc",
      "linker": "ld.bfd",
      "version": "11.3.0",
      "commands": "/home/jakeb/miniconda3/envs/scipy-dev/bin/x86_64-conda-linux-gnu-cc"
    },
    "cython": {
      "name": "cython",
      "linker": "cython",
      "version": "0.29.33",
      "commands": "cython"
    },
    "c++": {
      "name": "gcc",
      "linker": "ld.bfd",
      "version": "11.3.0",
      "commands": "/home/jakeb/miniconda3/envs/scipy-dev/bin/x86_64-conda-linux-gnu-c++"
    },
    "fortran": {
      "name": "gcc",
      "linker": "ld.bfd",
      "version": "11.3.0",
      "commands": "/home/jakeb/miniconda3/envs/scipy-dev/bin/x86_64-conda-linux-gnu-gfortran"
    },
    "pythran": {
      "version": "0.12.1",
      "include directory": "../../../miniconda3/envs/scipy-dev/lib/python3.10/site-packages/pythran"
    }
  },
  "Machine Information": {
    "host": {
      "cpu": "x86_64",
      "family": "x86_64",
      "endian": "little",
      "system": "linux"
    },
    "build": {
      "cpu": "x86_64",
      "family": "x86_64",
      "endian": "little",
      "system": "linux"
    },
    "cross-compiled": false
  },
  "Build Dependencies": {
    "blas": {
      "name": "openblas",
      "found": true,
      "version": "0.3.21",
      "detection method": "pkgconfig",
      "include directory": "/home/jakeb/miniconda3/envs/scipy-dev/include",
      "lib directory": "/home/jakeb/miniconda3/envs/scipy-dev/lib",
      "openblas configuration": "USE_64BITINT= DYNAMIC_ARCH=1 DYNAMIC_OLDER= NO_CBLAS= NO_LAPACK= NO_LAPACKE= NO_AFFINITY=1 USE_OPENMP=0 PRESCOTT MAX_THREADS=2",
      "pc file directory": "/home/jakeb/miniconda3/envs/scipy-dev/lib/pkgconfig"
    },
    "lapack": {
      "name": "openblas",
      "found": true,
      "version": "0.3.21",
      "detection method": "pkgconfig",
      "include directory": "/home/jakeb/miniconda3/envs/scipy-dev/include",
      "lib directory": "/home/jakeb/miniconda3/envs/scipy-dev/lib",
      "openblas configuration": "USE_64BITINT= DYNAMIC_ARCH=1 DYNAMIC_OLDER= NO_CBLAS= NO_LAPACK= NO_LAPACKE= NO_AFFINITY=1 USE_OPENMP=0 PRESCOTT MAX_THREADS=2",
      "pc file directory": "/home/jakeb/miniconda3/envs/scipy-dev/lib/pkgconfig"
    }
  },
  "Python Information": {
    "path": "/home/jakeb/miniconda3/envs/scipy-dev/bin/python3.10",
    "version": "3.10"
  }
}

I’ll fix that today or tomorrow evening and get rid of the custom fortran files and call ?getrf directly… They are not doing anything substantial. Complex tests are also wrong it seems so I can add those fixes too.