Skip to content

Add nanobind 3.0 split-mode support - #4359

Draft
XXXXRT666 wants to merge 8 commits into
ml-explore:mainfrom
XXXXRT666:nanobind-3.0-support
Draft

Add nanobind 3.0 split-mode support#4359
XXXXRT666 wants to merge 8 commits into
ml-explore:mainfrom
XXXXRT666:nanobind-3.0-support

Conversation

@XXXXRT666

Copy link
Copy Markdown
Contributor

Proposed changes

Note

This is a draft for nanobind 3.0 prerelease testing and builds on #4337. I will rebase this branch after #4337 lands and update the version pins to the final nanobind 3.0 releases before marking the PR ready for review.

Update nanobind to 3.0.0 and adopt nanobind split mode for regular python builds, using the nanobind-backend package.

This change:

  • builds the regular python frontend against the Python 3.10 Stable ABI, producing an abi3 frontend wheel per platform
  • keeps Python 3.13t and 3.14t in linked FREE_THREADED mode and produces specific cp313t and cp314t wheels, since those python releases do not provide a free-threaded Stable ABI so the official backend does not publish wheels for them
  • adapts the Python buffer and some low level call paths required by the Python 3.10 Limited API

The public Python API and the existing mlx-cpu, mlx-cuda, and mlx-metal package split remain unchanged.

For context, see wjakob/nanobind discussion #1416.

Checklist

Put an x in the boxes that apply.

  • I have read the CONTRIBUTING document
  • I have run pre-commit run --all-files to format my code / installed pre-commit prior to committing changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the necessary documentation (if needed)

@XXXXRT666

Copy link
Copy Markdown
Contributor Author

Wheel release matrix

Platform Architecture Regular CPython frontend (split mode) Python 3.13t frontend (linked mode) Python 3.14t frontend (linked mode) MLX backend wheels
Linux x86_64 cp310-abi3 cp313-cp313t cp314-cp314t mlx-cpu, mlx-cuda-12, mlx-cuda-13
Linux aarch64 cp310-abi3 cp313-cp313t cp314-cp314t mlx-cpu, mlx-cuda-12, mlx-cuda-13
Windows x86_64 cp310-abi3 cp313-cp313t cp314-cp314t mlx-cpu, mlx-cuda-12, mlx-cuda-13
Windows arm64 cp311-abi3 cp313-cp313t cp314-cp314t mlx-cpu
macOS arm64 cp310-abi3 for each OS cp313-cp313t for each OS cp314-cp314t for each OS mlx-metal for each OS

The abi3 wheel covers all supported GIL python versions from python 3.10, while 3.13t and 3.14t require specific wheels. The previous release matrix built 48 frontend wheels: 27 for Linux and Windows, and 21 for macOS across 3 OS versions. The new matrix builds 21 frontend wheels: 12 for Linux and Windows, and 9 for macOS. This reduces the frontend wheel count from 48 to 21.

The 13 existing mlx-cpu, mlx-cuda, and mlx-metal backend wheels remain unchanged. Including those backend wheels, the complete MLX release matrix is reduced from 61 wheels to 34.

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