Skip to content

Add Apple Accelerate backend for macOS#188

Merged
bodono merged 7 commits intomasterfrom
apple-accelerate-python
Apr 9, 2026
Merged

Add Apple Accelerate backend for macOS#188
bodono merged 7 commits intomasterfrom
apple-accelerate-python

Conversation

@bodono
Copy link
Copy Markdown
Owner

@bodono bodono commented Apr 9, 2026

Summary

  • Build _scs_accelerate extension module automatically on macOS using the Accelerate framework's sparse LDLt solver
  • Users select it at runtime with apple_ldl=True (e.g., scs.SCS(data, cone, apple_ldl=True))
  • The module uses 32-bit integers since Accelerate does not support DLONG
  • macOS wheels on PyPI will include the accelerate backend automatically
  • CI tests Python 3.10–3.14 on macOS

Files changed

  • meson.build — auto-detect macOS, build _scs_accelerate with DLONG filtered from c_args
  • scs/scsmodule.h — add PY_ACCELERATE to preprocessor chain
  • scs/py/__init__.py — add apple_ldl kwarg to _select_scs_module()
  • test/test_solve_random_cone_prob_accelerate.py — feasible/infeasible/unbounded tests
  • .github/workflows/build.ymlbuild_accelerate job (macOS, Python 3.10–3.14)
  • README.md — document accelerate usage
  • scs_source — update submodule to include accelerate backend

Test plan

  • Local build and test pass on macOS (conda python312)
  • Wheel contains _scs_accelerate.cpython-312-darwin.so
  • CI passes on macOS for Python 3.10–3.14

🤖 Generated with Claude Code

bodono and others added 7 commits April 9, 2026 11:13
Build the _scs_accelerate extension module automatically on macOS using
the Accelerate framework's sparse LDLt solver. Users select it at
runtime with apple_ldl=True. The module uses 32-bit integers (Accelerate
does not support DLONG).

- Add _scs_accelerate to meson.build with DLONG filtered from c_args
- Add PY_ACCELERATE to scsmodule.h preprocessor chain
- Add apple_ldl kwarg to _select_scs_module() in __init__.py
- Add test_solve_random_cone_prob_accelerate.py
- Add build_accelerate CI job (macOS, Python 3.10-3.14)
- Update README with accelerate usage
- Update scs_source submodule to include accelerate backend

Co-Authored-By: Claude Opus 4.6 <[email protected]>
The build_accelerate CI job runs on macos-latest (ARM) but pixi.toml
only listed linux-64, causing pixi to fail on macOS runners.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Adding osx-arm64 globally to pixi.toml broke MKL jobs because pixi
tried to solve MKL deps for osx-arm64 where they don't exist. Instead,
the accelerate job adds the platform at runtime.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add osx-arm64 to pixi.toml platforms so setup-pixi works on macOS.
Use --platform linux-64 in Linux jobs and --platform osx-arm64 in the
accelerate job so pixi doesn't try to solve platform-specific packages
(like MKL) for the wrong platform.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Use pytest.skip on non-macOS instead of try/except ImportError. This
ensures the macOS wheel build fails if _scs_accelerate is not included.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Skip on macOS and Linux aarch64 where MKL is not included. On Linux
x86_64 and Windows, fail if _scs_mkl import is missing to catch wheel
packaging regressions.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Skip on macOS and non-x86_64 Linux. On x86_64 Linux, use try/except
for the import to handle musllinux (openblas) vs manylinux (MKL).
On Windows, fail hard if _scs_mkl is missing.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@bodono bodono merged commit 724e151 into master Apr 9, 2026
25 checks passed
@bodono bodono deleted the apple-accelerate-python branch April 9, 2026 11:13
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.

1 participant