Skip to content

Matrix multiply with blis+numpy from conda-forge crashes #937

Open

Description

@cbu-work

In a Python codebase, I encountered mysterious crashes deep within matplotlib when I switch my BLAS to blis, and traced them back to a suspiciously simple numpy.dot multiplication of two identity matrices crashing the interpreter. MWE using Python via miniforge on

  • Windows 11 with Powershell (edited - I mistakenly wrote "10" before)
  • Python 3.13
  • blis 2.0
  • numpy 2.5.1
> conda create -n blis-bug python=3.13 "libblas=*=*_blis" numpy
Channels:
 - conda-forge
Platform: win-64
Collecting package metadata (repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: C:\Users\myuser\AppData\Local\miniforge3\envs\blis-bug

  added / updated specs:
    - libblas[build=*_blis]
    - numpy
    - python=3.13


The following NEW packages will be INSTALLED:

  blis               conda-forge/win-64::blis-2.0-pthreads_h02eceb6_4
  bzip2              conda-forge/win-64::bzip2-1.0.8-h0ad9c76_9
  ca-certificates    conda-forge/noarch::ca-certificates-2026.6.17-h4c7d964_0
  libblas            conda-forge/win-64::libblas-3.11.0-8_h281ba03_blis
  libcblas           conda-forge/win-64::libcblas-3.11.0-8_h8e9ec6c_blis
  libexpat           conda-forge/win-64::libexpat-2.8.1-hac47afa_1
  libffi             conda-forge/win-64::libffi-3.5.2-h3d046cb_0
  liblapack          conda-forge/win-64::liblapack-3.11.0-8_h018ca30_netlib
  liblzma            conda-forge/win-64::liblzma-5.8.3-hfd05255_0
  libmpdec           conda-forge/win-64::libmpdec-4.0.0-hfd05255_1
  libsqlite          conda-forge/win-64::libsqlite-3.53.3-hf5d6505_0
  libzlib            conda-forge/win-64::libzlib-1.3.2-hfd05255_2
  numpy              conda-forge/win-64::numpy-2.5.1-py313ha8dc839_0
  openssl            conda-forge/win-64::openssl-3.6.3-hf411b9b_0
  pip                conda-forge/noarch::pip-26.1.2-pyh145f28c_0
  python             conda-forge/win-64::python-3.13.14-h09917c8_100_cp313
  python_abi         conda-forge/noarch::python_abi-3.13-8_cp313
  tk                 conda-forge/win-64::tk-8.6.13-h6ed50ae_3
  tzdata             conda-forge/noarch::tzdata-2025c-hc9c84f9_1
  ucrt               conda-forge/win-64::ucrt-10.0.26100.0-h57928b3_0
  vc                 conda-forge/win-64::vc-14.5-h1b7c187_39
  vc14_runtime       conda-forge/win-64::vc14_runtime-14.51.36231-h1b9f54f_39
  vcomp14            conda-forge/win-64::vcomp14-14.51.36231-h1b9f54f_39


Proceed ([y]/n)?


Downloading and Extracting Packages:

Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate blis-bug
#
# To deactivate an active environment, use
#
#     $ conda deactivate

WARNING conda.conda_pypi.main:notify_externally_managed_future(209):
  This environment has pip installed. A future conda release will
  protect conda environments from accidental 'pip install' usage.
  Try the beta to install PyPI packages natively with conda:
    conda config --set solver rattler
    conda config --append channels conda-pypi
    conda install <package>
  More info: https://docs.conda.io/projects/conda/en/stable/new-features.html
  
> conda activate blis-bug
> python -c "import numpy as np;A = np.array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]);B = np.array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]);print(np.dot(A, B))"
> $LastExitCode
-1073741819
> python -c "import numpy as np; np._pytesttester._show_numpy_info()"
NumPy version 2.5.1
NumPy CPU features:  X86_V2 X86_V3*

Expected result observed with openblas:

> conda install "libblas=*=*_openblas"
...
    package                    |            build
    ---------------------------|-----------------
    libblas-3.11.0             |8_h0adab6e_openblas          66 KB  conda-forge
    libcblas-3.11.0            |8_h2a8eebe_openblas          67 KB  conda-forge
    liblapack-3.11.0           |8_hd232482_openblas          79 KB  conda-forge
    libopenblas-0.3.33         |pthreads_h877e47f_0         3.9 MB  conda-forge
    ------------------------------------------------------------
                                           Total:         4.1 MB

The following NEW packages will be INSTALLED:

  libopenblas        conda-forge/win-64::libopenblas-0.3.33-pthreads_h877e47f_0

The following packages will be REMOVED:

  blis-2.0-pthreads_h02eceb6_4

The following packages will be REVISED:

  libblas                            3.11.0-8_h281ba03_blis --> 3.11.0-8_h0adab6e_openblas
  libcblas                           3.11.0-8_h8e9ec6c_blis --> 3.11.0-8_h2a8eebe_openblas
  liblapack                        3.11.0-8_h018ca30_netlib --> 3.11.0-8_hd232482_openblas
...
> python -c "import numpy as np;A = np.array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]);B = np.array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]);print(np.dot(A, B))"
[[1. 0. 0.]
 [0. 1. 0.]
 [0. 0. 1.]]

This is on a laptop with an Intel(R) Core(TM) Ultra 7 265U (2.10 GHz). I already did a memcheck and processor check to confirm that the hardware is ok.

Do you need any more information to analyze?
Can anybody reproduce? I feel kinda silly, as I would not expect such a simple repro to have slipped through testing cracks...hence the hardware check 😅

As this touches conda-forge, I hope it's ok to ping @h-vetinari as an FYI, too.

I'm seeing the same crash on Python 3.14 (3.13 was just closest to my original setup).

Activity

  1. devinamatthews commented on Jul 24, 2026

    @devinamatthews
    Member

    Unfortunately I can't reproduce on Win11 with Core Ultra 9 285H.

    (base) PS C:\Users\46774035> conda create -n blis-bug -c conda-forge python=3.13 "libblas=*=*_blis" numpy
    3 channel Terms of Service accepted
    Retrieving notices: done
    Channels:
     - conda-forge
     - defaults
    Platform: win-64
    Collecting package metadata (repodata.json): done
    Solving environment: done
    
    ## Package Plan ##
    
      environment location: C:\Users\46774035\AppData\Local\miniconda3\envs\blis-bug
    
      added / updated specs:
        - libblas[build=*_blis]
        - numpy
        - python=3.13
    
    
    The following packages will be downloaded:
    
        package                    |            build
        ---------------------------|-----------------
        blis-2.0                   |pthreads_h02eceb6_4         5.1 MB  conda-forge
        bzip2-1.0.8                |       h0ad9c76_9          55 KB  conda-forge
        ca-certificates-2026.7.22  |       h4c7d964_0         129 KB  conda-forge
        libblas-3.11.0             |  8_h281ba03_blis          66 KB  conda-forge
        libcblas-3.11.0            |  8_h8e9ec6c_blis          67 KB  conda-forge
        libexpat-2.8.1             |       hac47afa_1          70 KB  conda-forge
        libffi-3.5.2               |       h3d046cb_0          45 KB  conda-forge
        liblapack-3.11.0           |8_h018ca30_netlib         2.0 MB  conda-forge
        liblzma-5.8.3              |       hfd05255_0         104 KB  conda-forge
        libmpdec-4.0.0             |       hfd05255_1          87 KB  conda-forge
        libsqlite-3.53.3           |       hf5d6505_0         1.3 MB  conda-forge
        libzlib-1.3.2              |       hfd05255_2          57 KB  conda-forge
        numpy-2.5.1                |  py313ha8dc839_0         7.0 MB  conda-forge
        openssl-3.6.3              |       hf411b9b_0         9.0 MB  conda-forge
        pip-26.1.2                 |     pyh145f28c_0         1.1 MB  conda-forge
        python-3.13.14             |h09917c8_100_cp313        16.0 MB  conda-forge
        python_abi-3.13            |          8_cp313           7 KB  conda-forge
        tk-8.6.13                  |       h967ab96_3         3.6 MB  conda-forge
        tzdata-2026c               |       h151e31d_0         116 KB  conda-forge
        ucrt-10.0.26100.0          |       h57928b3_0         678 KB  conda-forge
        vc-14.5                    |      h1b7c187_39          20 KB  conda-forge
        vc14_runtime-14.51.36231   |      h1b9f54f_39         720 KB  conda-forge
        vcomp14-14.51.36231        |      h1b9f54f_39         118 KB  conda-forge
        ------------------------------------------------------------
                                               Total:        47.5 MB
    
    The following NEW packages will be INSTALLED:
    
      blis               conda-forge/win-64::blis-2.0-pthreads_h02eceb6_4
      bzip2              conda-forge/win-64::bzip2-1.0.8-h0ad9c76_9
      ca-certificates    conda-forge/noarch::ca-certificates-2026.7.22-h4c7d964_0
      libblas            conda-forge/win-64::libblas-3.11.0-8_h281ba03_blis
      libcblas           conda-forge/win-64::libcblas-3.11.0-8_h8e9ec6c_blis
      libexpat           conda-forge/win-64::libexpat-2.8.1-hac47afa_1
      libffi             conda-forge/win-64::libffi-3.5.2-h3d046cb_0
      liblapack          conda-forge/win-64::liblapack-3.11.0-8_h018ca30_netlib
      liblzma            conda-forge/win-64::liblzma-5.8.3-hfd05255_0
      libmpdec           conda-forge/win-64::libmpdec-4.0.0-hfd05255_1
      libsqlite          conda-forge/win-64::libsqlite-3.53.3-hf5d6505_0
      libzlib            conda-forge/win-64::libzlib-1.3.2-hfd05255_2
      numpy              conda-forge/win-64::numpy-2.5.1-py313ha8dc839_0
      openssl            conda-forge/win-64::openssl-3.6.3-hf411b9b_0
      pip                conda-forge/noarch::pip-26.1.2-pyh145f28c_0
      python             conda-forge/win-64::python-3.13.14-h09917c8_100_cp313
      python_abi         conda-forge/noarch::python_abi-3.13-8_cp313
      tk                 conda-forge/win-64::tk-8.6.13-h967ab96_3
      tzdata             conda-forge/noarch::tzdata-2026c-h151e31d_0
      ucrt               conda-forge/win-64::ucrt-10.0.26100.0-h57928b3_0
      vc                 conda-forge/win-64::vc-14.5-h1b7c187_39
      vc14_runtime       conda-forge/win-64::vc14_runtime-14.51.36231-h1b9f54f_39
      vcomp14            conda-forge/win-64::vcomp14-14.51.36231-h1b9f54f_39
    
    
    Proceed ([y]/n)?
    
    
    Downloading and Extracting Packages:
    
    Preparing transaction: done
    Verifying transaction: done
    Executing transaction: done
    #
    # To activate this environment, use
    #
    #     $ conda activate blis-bug
    #
    # To deactivate an active environment, use
    #
    #     $ conda deactivate
    
    
    Channel "defaults" has the following notices:
      [info] -- Tue Jun  9 00:00:00 2026
      PyTorch 2.12 with CUDA support is now available to install with your current channel (Anaconda Main). Learn more: https://anacondas
    
    WARNING conda.conda_pypi.main:notify_externally_managed_future(156):
      Did you know? You can install many PyPI packages with conda
      using the conda-pypi beta. Get started:
        https://docs.conda.io/projects/conda/en/stable/new-features.html
    
    (base) PS C:\Users\46774035> conda activate blis-bug
    (blis-bug) PS C:\Users\46774035> python -c "import numpy as np;A = np.array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]);B = np.array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]);print(np.dot(A, B))"
    [[1. 0. 0.]
     [0. 1. 0.]
     [0. 0. 1.]]
    (blis-bug) PS C:\Users\46774035> $LastExitCode
    0
    
  2. cbu-work commented on Aug 3, 2026

    @cbu-work
    Author

    Thank you for trying to repro! I did some more digging. I tried on other machines, and could not reproduce there, either.
    The closest I could get to w.r.t. CPU is a Intel(R) Core(TM) Ultra 7 265HX (2.60 GHz) (Intel64 Family 6 Model 198 Stepping 2, GenuineIntel), which is on a more powerful version of my laptop (265HX instead of 265U). This also does not show the problem.

    Interestingly, I found out that forcing single-threading makes the issue disappear!

    $env:BLIS_NUM_THREADS=1;python -c "import numpy as np; A=np.eye(3); print(np.dot(A,A))"
    [[1. 0. 0.]
     [0. 1. 0.]
     [0. 0. 1.]]​‌
    

    works​‌! Any thread count >1 consistently crashes.

    Going to dgemm directly crashes with BLIS_NUM_THREADS>1

    $env:BLIS_NUM_THREADS=2;python -c "import scipy.linalg.blas as blas;import numpy as np;A = np.eye(3);print(blas.dgemm(alpha=1.0, a=A, b=A))"
    

    Matrix size does not seem to play a role:

    $env:BLIS_NUM_THREADS=1;python -c "import numpy as np; A=np.random.rand(500,500); print((A@A)[0,0])"
    123.17867102205722
    

    works

    $env:BLIS_NUM_THREADS=2;python -c "import numpy as np; A=np.random.rand(500,500); print((A@A)[0,0])"
    

    crashes.

    Could it be that the problem is in BLIS multithreading/runtime management rather than the DGEMM kernel itself?

    This is a CPU with a maybe unexpected core setup (2 performance, 8 efficient, 2 low-power efficient cores)?

    Get-CimInstance Win32_Processor | Format-List *
    
    
    Availability                            : 3
    CpuStatus                               : 1
    CurrentVoltage                          : 12
    DeviceID                                : CPU0
    ErrorCleared                            :
    ErrorDescription                        :
    LastErrorCode                           :
    LoadPercentage                          : 39
    Status                                  : OK
    StatusInfo                              : 3
    AddressWidth                            : 64
    DataWidth                               : 64
    ExtClock                                : 100
    L2CacheSize                             : 10240
    L2CacheSpeed                            :
    MaxClockSpeed                           : 2100
    PowerManagementSupported                : False
    ProcessorType                           : 3
    Revision                                :
    SocketDesignation                       : U3E1
    Version                                 :
    VoltageCaps                             :
    Caption                                 : Intel64 Family 6 Model 181 Stepping 0
    Description                             : Intel64 Family 6 Model 181 Stepping 0
    InstallDate                             :
    Name                                    : Intel(R) Core(TM) Ultra 7 265U
    ConfigManagerErrorCode                  :
    ConfigManagerUserConfig                 :
    CreationClassName                       : Win32_Processor
    PNPDeviceID                             :
    PowerManagementCapabilities             :
    SystemCreationClassName                 : Win32_ComputerSystem
    SystemName                              : XXXXXXX
    CurrentClockSpeed                       : 2100
    Family                                  : 774
    OtherFamilyDescription                  :
    Role                                    : CPU
    Stepping                                :
    UniqueId                                :
    UpgradeMethod                           : 83
    Architecture                            : 9
    AssetTag                                :
    Characteristics                         : 252
    L3CacheSize                             : 12288
    L3CacheSpeed                            : 0
    Level                                   : 6
    Manufacturer                            : GenuineIntel
    NumberOfCores                           : 12
    NumberOfEnabledCore                     : 12
    NumberOfLogicalProcessors               : 14
    PartNumber                              :
    ProcessorId                             : BFEBFBFF000B0650
    SecondLevelAddressTranslationExtensions : False
    SerialNumber                            :
    ThreadCount                             : 14
    VirtualizationFirmwareEnabled           : False
    VMMonitorModeExtensions                 : False
    PSComputerName                          :
    CimClass                                : root/cimv2:Win32_Processor
    CimInstanceProperties                   : {Caption, Description, InstallDate, Name...}
    CimSystemProperties                     : Microsoft.Management.Infrastructure.CimSystemProperties
    

    What can I do to help analysis?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions