Skip to content

ENH: Adding MLX - #1008

Open
prady0t wants to merge 8 commits into
data-apis:mainfrom
prady0t:mlx-support
Open

prady0t wants to merge 8 commits into
data-apis:mainfrom
prady0t:mlx-support

Conversation

@prady0t

@prady0t prady0t commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Reference issue

Closes #1006

What does this implement/fix?

Additional information

AI Generation Disclosure

GitHub Copilot was used to generate changes in _compat.py file

Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Comment thread src/array_api_extra/_lib/_compat.py Outdated
Comment on lines +78 to +87
class _MLXNamespaceInfo:
def __init__(self, info: object) -> None:
self._info = info

def __getattr__(self, name: str) -> object:
return getattr(self._info, name)

def default_dtypes(self, *, device: object = None) -> object:
_ = device
return self._info.default_dtypes() # type: ignore[attr-defined]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Most of the changes in these files should be in array-api-compat

Comment thread pixi.toml Outdated
jax = ">=0.10.2" # waiting for conda-forge/jaxlib-feedstock#326
jax = ">=0.10.2"

[feature.mlx.target.osx-arm64.pypi-dependencies]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

0.32.3 is not yet available on conda-forge. See

prady0t and others added 7 commits October 4, 2026 17:16
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@prady0t
prady0t marked this pull request as ready for review October 21, 2026 08:26
@prady0t

prady0t commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

@lucascolley @ev-br Would love some reviews. The gigantic diff is mostly from the pixi lock file.

@ev-br

ev-br commented Oct 21, 2026

Copy link
Copy Markdown
Member

For me, a description would be helpful. What is the goal and what is the plan towards it?

@lucascolley lucascolley added this to the 0.12.1 milestone Oct 25, 2026
@prady0t

prady0t commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Hi, sorry for the delay. Here's the info:

We want MLX support for the extra library. To do that, we need the tests inside tests/main to pass for MLX. Adding MLX to the list of supported backends causes 900+ failures, most of which are known MLX limitations. Here's a list of all such failures:

# Failure category Occurrences Underlying reason
1 Device support 497 failures + 49 errors mlx.core.array does not expose .device.
2 astype(copy=...) 97 MLX astype() does not accept the copy keyword.
3 Boolean indexing 56 MLX does not support boolean array indexing.
4 Missing bool attribute 47 MLX exposes bool_, not bool.
5 arange(device=...) 30 MLX arange() does not accept the device keyword.
6 Missing complex128 29 MLX does not expose complex128; it suggests complex64.
7 Zero-dimensional indexing 21 Too many indices are used on a 0-D array.
8 Missing unique_values 14 Function is absent from mlx.core.
9 Missing signbit 11 Function is absent from mlx.core.
10 Sorting API incompatibility 14 MLX sort() and argsort() reject stable and/or axis combinations.
11 Assertion mismatches 14 Dtype, namespace, or expected error-message mismatches.
12 Other missing APIs 2 unique_inverse and __array_api_version__ are missing.

To increase support, I asked AI to create a compatibility layer; that code exists in src/array_api_extra/_lib/_compat.py. Most of these should be an addition to array-api-compat.

Some of the tests (Such as boolean indexing, complex128 dtype tests) are skipped as they are not supported by MLX.

This branch has not been deployed

No deployments
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.

ENH, TST: Add support for MLX as array backend

3 participants