Skip to content

Warn when NumPy links Accelerate; document the OpenBLAS wheel - #574

Open
meandmytram wants to merge 3 commits into
mainfrom
blas-accelerate-warning
Open

Warn when NumPy links Accelerate; document the OpenBLAS wheel#574
meandmytram wants to merge 3 commits into
mainfrom
blas-accelerate-warning

Conversation

@meandmytram

Copy link
Copy Markdown
Member

On the macOS arm64 wheels of NumPy 2.x, which link Apple's Accelerate framework, mdopt's matrices (rank-deficient, singular values spanning many orders of magnitude) made numpy.linalg.qr die with SIGBUS and numpy.linalg.svd trip malloc's heap-corruption check inside dgesdd (crash reports from the [[72,12,6]] investigation on PR #543), and a chi_max=400 bivariate-bicycle decode returned wrong verdicts while every unit test and benchmark fingerprint passed. Both the NumPy and the SciPy macOS wheels in that environment link Accelerate.

The OpenBLAS build of the same NumPy version (the macosx_11_0_arm64 wheel) runs the same reproducers clean: the 200-call QR loop that died with SIGBUS every time exits normally with zero wrong factorisations, three runs out of three.

Changes:

  • mdopt.backend.array warns once at import when Accelerate is found behind NumPy (MDOPT_ALLOW_ACCELERATE=1 silences it); a test covers the three cases (Accelerate, another vendor, silenced).
  • The README documents the two commands that install the OpenBLAS wheel and the per-process thread setting for worker pools.

🤖 Generated with Claude Code

https://claude.ai/code/session_01S6mbxc9eJDQMVx7tjvYwud

…enBLAS wheel

On the macOS arm64 NumPy 2.x wheels, which link Apple's Accelerate
framework, the decoders' rank-deficient, wide-spectrum matrices made
numpy.linalg.qr die with SIGBUS and numpy.linalg.svd trip malloc's
heap-corruption check inside dgesdd (five crash reports from the
[[72,12,6]] investigation), and a chi_max=400 decode returned wrong
verdicts while every unit test passed. The OpenBLAS build of the same
NumPy version (the macosx_11_0_arm64 wheel) runs the same reproducers
clean. The backend now warns once at import when Accelerate is found
behind NumPy (MDOPT_ALLOW_ACCELERATE=1 silences it) and the README gives
the two commands that install the OpenBLAS wheel.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S6mbxc9eJDQMVx7tjvYwud
@codecov

codecov Bot commented Sep 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.20%. Comparing base (519b7a8) to head (365c91d).

Files with missing lines Patch % Lines
mdopt/backend/array.py 84.84% 5 Missing ⚠️
tests/backend/test_array.py 95.45% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #574      +/-   ##
==========================================
- Coverage   97.29%   97.20%   -0.10%     
==========================================
  Files          26       26              
  Lines        5259     5336      +77     
==========================================
+ Hits         5117     5187      +70     
- Misses        142      149       +7     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…AS wheels

The SVD helpers call SciPy's LAPACK too, and the SciPy macOS arm64 wheels
link Accelerate like NumPy's; with only NumPy switched to OpenBLAS the
reduced SVD path still returned a wrong factorisation (reconstruction
error 0.15) or crashed, and with both switched it passes repeatedly.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S6mbxc9eJDQMVx7tjvYwud

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

SciPy vendor detection uses an incompatible configuration API, preventing its warning from firing.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds runtime warnings and installation guidance to avoid unstable Apple Accelerate LAPACK builds.

Changes:

  • Detects Accelerate-backed NumPy and SciPy installations.
  • Supports warning suppression via MDOPT_ALLOW_ACCELERATE.
  • Documents OpenBLAS wheel installation and thread settings.
File summaries
File Description
mdopt/backend/array.py Adds LAPACK vendor detection and warnings.
tests/backend/test_array.py Tests NumPy warning and suppression behavior.
README.md Documents the issue and OpenBLAS alternatives.
Review details

Suppressed comments (1)

README.md:42

  • This likewise overgeneralizes all SciPy macOS wheels even though the next sentence identifies an OpenBLAS arm64 wheel. Name the Accelerate variant explicitly so users on the OpenBLAS wheel are not told their installation is affected.
The SciPy macOS wheels link Accelerate as well, and mdopt's SVD helpers
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread mdopt/backend/array.py
Comment thread README.md Outdated
…rate

SciPy 1.10 and later report their LAPACK through show_config(mode="dicts"),
but SciPy 1.9, which the dependency floor allows, has show() without a mode
argument, so the SciPy check silently reported an unknown vendor there. The
helper now falls back to __config__.get_info("lapack_opt") in that case, and
two SciPy-shaped test doubles cover both APIs.

The README said the macOS arm64 wheels link Accelerate; only the
macosx_14_0_arm64 wheels do (checked NumPy 2.4.6, SciPy 1.15.3 and 1.18.1),
which pip picks on macOS 14 and later, while the macosx_11_0_arm64 NumPy
and macosx_12_0_arm64 SciPy wheels bundle OpenBLAS.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S6mbxc9eJDQMVx7tjvYwud
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants