Skip to content

ENH: Check for buggy Accelerate on MacOS #15647

@vrakesh

Description

@vrakesh

I recently began, digging deep into numpy, with the intention of contributing to the project. On my Mac development machine, I encountered test failures when I ran tests, on the master commit build (Note: The build had succeeded). The same commit was fine on a linux machine, and the azure pipeline mac build indicated it was passing, digging through issues and PR found two related issues #14644 and #15154

Machine/Environment Information

Operating System: MacOS Mojave (10.14.6)
C Compiler : Apple LLVM (clang-1001.0.46.4)
Python Version : 3.7.4
Accelerate  and OpenBLAS available on Mac OS

Reproducing code example:

$ git clone https://github.com/<numpy-fork>/numpy
$ pip install -r test_requirements.txt
$ pip install . <or> python setup.py install
$ python runtests.py -v -m full 
# The build picks up Acclerate API for LAPACK and BLAS

Error message:

The failing tests include, the following

numpy/lib/tests/test_mixins.py ...........                                                                                                                                                             [ 56%]
numpy/lib/tests/test_nanfunctions.py ...........................................................................................                                                                       [ 56%]
numpy/lib/tests/test_packbits.py ..................................................................................................................................................................... [ 58%]
...................................................................................................................                                                                                    [ 59%]
numpy/lib/tests/test_polynomial.py ........F........                                                                                                                                                   [ 59%]
numpy/lib/tests/test_recfunctions.py .........................................x........                                                                                                                [ 60%]
numpy/lib/tests/test_regression.py ............F..............                                                                                                                                         [ 60%]
numpy/lib/tests/test_shape_base.py ..................................................................                                                                                                  [ 60%]
numpy/lib/tests/test_stride_tricks.py ................                                                                                                                                                 [ 61%]
numpy/lib/tests/test_twodim_base.py ..................................                                                                                                                                 [ 61%]
numpy/lib/tests/test_type_check.py ....................................................                                                                                                                [ 61%]
numpy/lib/tests/test_ufunclike.py ......                                                                                                                                                               [ 61%]
numpy/lib/tests/test_utils.py ............                                                                                                                                                             [ 62%]
numpy/linalg/tests/test_build.py s                                                                                                                                                                     [ 62%]
numpy/linalg/tests/test_deprecations.py .                                                                                                                                                              [ 62%]
numpy/linalg/tests/test_linalg.py ....................................................................................FFFFFF..FFF..................................................................... [ 63%]
........................................................................................................................................s.................xx                                           [ 65%]
numpy/linalg/tests/test_regression.py .........                                                                                                                                                        [ 65%]
numpy/ma/tests/test_core.py .......................................................................................................................................................................... [ 66%]
...................................................................................................................................................................................................... [ 68%]
...................................................................................................................................................................................................... [ 70%]
...................................................................................................................................................................................................... [ 72%]
...................................................................................................................................................................................................... [ 73%]
...................................................................................................................................................................................................... [ 75%]
...................................................................................................................................................................................................... [ 77%]
.....................................................................xx............................................................................................................................... [ 79%]
..............................................................................................................................................................................                         [ 81%]
numpy/ma/tests/test_deprecations.py ......                                                                                                                                                             [ 81%]
numpy/ma/tests/test_extras.py ..............................................................FF.....................                                                                                    [ 81%]
numpy/ma/tests/test_mrecords.py ........................                                                                                                                                               [ 82%]
numpy/ma/tests/test_old_ma.py ......................................                                                                                                                                   [ 82%]
numpy/ma/tests/test_regression.py .............                                                                                                                                                        [ 82%]
numpy/ma/tests/test_subclassing.py ............                                                                                                                                                        [ 82%]
numpy/matrixlib/tests/test_defmatrix.py ...........................................                                                                                                                    [ 83%]
numpy/matrixlib/tests/test_interaction.py .......................                                                                                                                                      [ 83%]
numpy/matrixlib/tests/test_masked_matrix.py ..............                                                                                                                                             [ 83%]
numpy/matrixlib/tests/test_matrix_linalg.py ....................................FF......................                                                                                               [ 83%]
numpy/matrixlib/tests/test_multiarray.py ..                                                                                                                                                            [ 83%]
numpy/matrixlib/tests/test_numeric.py ..                                                                                                                                                               [ 84%]
numpy/matrixlib/tests/test_regression.py ....                                                                                                                                                          [ 84%]
numpy/polynomial/tests/test_chebyshev.py ........................F................                                                                                                                     [ 84%]
numpy/polynomial/tests/test_classes.py ................................................................................................FFFFFF......................................................... [ 85%]
.................................................................................                                                                                                                      [ 86%]
numpy/polynomial/tests/test_hermite.py ......................F...........                                                                                                                              [ 86%]
numpy/polynomial/tests/test_hermite_e.py ......................F...........                                                                                                                            [ 87%]
numpy/polynomial/tests/test_laguerre.py ......................F...........                                                                                                                             [ 87%]
numpy/polynomial/tests/test_legendre.py ......................F...........                                                                                                                             [ 87%]
numpy/polynomial/tests/test_polynomial.py ............................F..                                                                                                                              [ 88%]
numpy/polynomial/tests/test_polyutils.py ......                                                                                                                                                        [ 88%]
numpy/polynomial/tests/test_printing.py ............                                                                                                                                                   [ 88%]
numpy/random/tests/test_direct.py .......................................................................                                                                                              [ 88%]
numpy/random/tests/test_extending.py .s.                                                                                                                                                               [ 89%]
numpy/random/tests/test_generator_mt19937.py ......................................................................................................................................................... [ 90%]
..................................................................                                                                                                                                     [ 91%]
numpy/random/tests/test_generator_mt19937_regressions.py .............                                                                                                                                 [ 91%]
numpy/random/tests/test_random.py ................................................................................................................................                                     [ 92%]
numpy/random/tests/test_randomstate.py ............................................................................................................................................................... [ 93%]
......                                                                                                                                                                                                 [ 93%]
numpy/random/tests/test_randomstate_regression.py ..................                                                                                                                                   [ 94%]
numpy/random/tests/test_regression.py ............                                                                                                                                                     [ 94%]
numpy/random/tests/test_seed_sequence.py .                                                                                                                                                             [ 94%]
numpy/random/tests/test_smoke.py .s................................................................................................................................................................... [ 95%]
....................................................................................................ss................................................................................................ [ 97%]
..............................................................................................                                                                                                         [ 98%]
numpy/testing/tests/test_decorators.py ........                                                                                                                                                        [ 98%]
numpy/testing/tests/test_utils.py ..................................................................................sss........................................                                        [ 99%]
numpy/tests/test_ctypeslib.py .......................                                                                                                                                                  [ 99%]
numpy/tests/test_matlib.py ........                                                                                                                                                                    [ 99%]
numpy/tests/test_numpy_version.py .                                                                                                                                                                    [ 99%]
numpy/tests/test_public_api.py ..........                                                                                                                                                              [ 99%]
numpy/tests/test_reloading.py ..                                                                                                                                                                       [ 99%]
numpy/tests/test_scripts.py XXX.                                                                                                                                                                       [ 99%]
numpy/tests/test_warnings.py .                                                                                                                                                                         [100%]

================================================================================================== FAILURES ============

Some test errors include

numpy/lib/polynomial.py:635: RankWarning
E           numpy.RankWarning: Polyfit may be poorly conditioned
numpy/testing/_private/utils.py:839: AssertionError
>               raise AssertionError(msg)
E               AssertionError: 
E               Arrays are not almost equal to 6 decimals
E               
E               Mismatched elements: 2 / 2 (100%)
E               Max absolute difference: 2.
E               Max relative difference: inf
E                x: array([2., 1.], dtype=float32)
E                y: array([-0., -0.], dtype=float32)

Commit at the time of filing this issue

3cdc3ff

What resolved this issue

As suggested in #14644 , forcing use of openblas via site.cfg resolves the test failures.
Mac does not provide openblas under /usr/local/lib/, instead it is under /usr/local/opt/openblas/lib

We need to update docs to reflect this issue, or by default look for openblas under additional locations in Mac

Installation document briefly mentions, Accelerate being buggy. However, Building from Source provides no insight into this.

I am ready and willing to contribute back by adding a document warning , or mac build improvement (look for openblas in additional locations), as per the feedback from the members of the community. Long term, I feel dropping Accelerate support for Macs, seems the right way forward(#14880 ).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions