Add initial MLX support with the creation wrappers - #453
Conversation
|
After adding temporary compatibility wrappers and rerunning
With: ARRAY_API_TESTS_SKIP_DTYPES=float64,complex64,int64,uint64the suite reports 14 passed, 2 failed:
NOTE: MLX does not implement eq for comparing None with datatype, also we skipped complex completely due to problem with |
|
Thanks! Going forward, it would be helpful to list reproducible examples from the test suite failures, which the test suite prints on a failure.
Please open an issue in the test suite, with an MRE. If it's a test suite problem, it should be reproducible with numpy or array-api-strict, I suppose.
This is one of things to propose adding to MLX; even if they decline, we'll have an answer. |
ev-br
left a comment
There was a problem hiding this comment.
Given that the upstream work in MLX is proceeding at a high pace, the majority of workarounds here are no longer needed.
One other feature of this PR, the device=stream trick needs more analysis: it's a clever trick which might turn out to be bad idea in the end.
All in all, I think it's best to park this PR and concentrate on improving the compatibility upstream.
Of course, if this sort of WIP PR is useful to you as a testbed for your MLX work, feel free to keep using it @aaishwarymishra. If you do this, it'd be best to keep it current and remove things which are already upstream. This way, it would be easier for everybody to assess the compatibility status.
| dtype: None | DType = None, | ||
| device: None | Device = None, | ||
| ): | ||
| return mx.ones(x.shape, dtype=x.dtype if dtype is None else dtype, stream=device) |
There was a problem hiding this comment.
stream=device is a clever trick indeed.
At this stage I'm not sure what the consequences are, and whether we should do it across the board, or instead keep accepting the stream argument as a fall-through via **kwargs, as done for other arguments beyond the array API spec.
|
Yeah i will make it draft for now :) |
This pull request introduces initial support for the MLX backend in the
array_api_compatpackage. The main changes add MLX-specific modules, implement compatibility wrappers for core array functions, and update the build and development configuration to include MLX. Below are the most important changes:For #452
MLX Backend Implementation:
array_api_compat/mlxbackend with__init__.py,_aliases.py, and_typing.pyto support MLX arrays and provide compatibility wrappers for common array operations.arange,asarray,empty_like,eye,meshgrid,ones_like, andzeros_likein_aliases.py, handling MLX-specific quirks and edge cases.Array,DType,Device) in_typing.pyfor consistent type handling.__init__.pyto expose all relevant symbols and ensure proper module structure for the MLX backend.Build and Development Environment:
meson.buildandpyproject.tomlto include MLX sources and conditionally require themlxpackage on macOS (sys_platform == 'darwin'). [1] [2]