MLX compatibility: Creation functions

Open
#452 25 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
30/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python

Research direction

Start with the listed Array API test nodes, especially test_arange, test_asarray_arrays, test_eye, test_linspace, test_meshgrid, and test_dlpack.py::test_from_dlpack, then compare each signature and behavior with its MLX analog. The issue tracks multiple incompatibilities, upstream dependencies, and an open draft PR, so completion requires resolving the remaining applicable failures and updating the table.

Written by the indexing model from the issue text.

Description

Array API MLX Analog Status Blame / Notes Upstream Test Node Result
arange(start, /, stop=None, step=1, *, dtype=None, device=None) arange(start, stop, step, dtype=None, *, stream=None) partial stop=None now accepted. Remaining failure: integer args larger than signed 32-bit (e.g. step=2**31) — the nanobind binding uses C++ int, so xp.arange(n-1, n+3) with n = iinfo(int32).max raises TypeError. Still no device. ml-explore/mlx#3982 (merged); int32 limit fixed ml-explore/mlx#4255 test_arange Passed
asarray(obj, /, *, dtype=None, device=None, copy=None) asarray(a, dtype=None, *, copy=None) partial — won't fix copy=False raises even for an MLX array already of the requested dtype. Fix was proposed and closed unmerged. No device; dtype not keyword-only. ml-explore/mlx#4036 (closed, not merged) test_asarray_arrays Failed
empty(shape, *, dtype=None, device=None) empty(shape, dtype=float32, *, stream=None) undocumented Implemented (pure alias) but still absent from MLX docs. No device. ml-explore/mlx#3729 (merged) test_empty Passed
empty_like(x, /, *, dtype=None, device=None) empty_like(a, /, *, dtype=None, stream=None) undocumented dtype now accepted — empty_like aliases zeros_like, so it inherited the fix. Still undocumented; no device. ml-explore/mlx#4028 (merged); #4037 (closed, superseded) test_empty_like Passed
eye(n_rows, n_cols=None, /, *, k=0, dtype=None, device=None) eye(n, m=None, k=0, dtype=float32, *, stream=None) partial eye(0) fixed upstream; the too-large-k failure was a test-suite issue, fixed at the tip of array-api-tests. Remaining failure: GPU scatter does not support uint64 MLX limitation, so identity creation fails for that dtype. ml-explore/mlx#3952 (merged); uint64 case cant be supported due to mlx limitation ml-explore/mlx#4300 test_eye Failed
from_dlpack(x, /, *, device=None, copy=None) from_dlpack(x, /, *, copy=None) Incompatible Test fails before reaching from_dlpack: MLX has no x.device and does not have device parameter in the signature - test_dlpack.py::test_from_dlpack Failed
full(shape, fill_value, *, dtype=None, device=None) full(shape, vals, dtype=None, *, stream=None) signature mismatch fill_value is named vals; dtype not keyword-only; no device. test_full Passed
full_like(x, /, fill_value, *, dtype=None, device=None) full_like(a, vals, dtype=None, *, stream=None) signature mismatch fill_value is named vals; dtype not keyword-only; no device. test_full_like Passed
linspace(start, stop, /, num, *, dtype=None, device=None, endpoint=True) linspace(start, stop, num=50, dtype=float32, stream=None) partial — in progress endpoint still unsupported, so endpoint=False fails. Draft PR open. No device. ml-explore/mlx#4152 (issue, open), #4184 (draft PR, open) test_linspace Passed
meshgrid(*arrays, indexing="xy") meshgrid(*arrays, sparse=False, indexing="xy", stream=None) return mismatch — in progress MLX returns a list; Array API 2025.12 requires a tuple. ml-explore/mlx#4034 (issue, open) test_meshgrid Passed
ones(shape, *, dtype=None, device=None) ones(shape, dtype=float32, *, stream=None) signature mismatch dtype not keyword-only; no device. Behavior passes. test_ones Passed
ones_like(x, /, *, dtype=None, device=None) ones_like(a, /, *, dtype=None, stream=None) signature mismatch dtype added upstream as a keyword-only arg. No device. ml-explore/mlx#4001 (issue, closed) → #4028 (merged) test_ones_like Passed
tril(x, /, *, k=0) tril(x, k, *, stream=None) signature mismatch k accepted positionally; spec makes it keyword-only. Behavior passes. test_tril Passed
triu(x, /, *, k=0) triu(x, k, *, stream=None) signature mismatch k accepted positionally; spec makes it keyword-only. Behavior passes. test_triu Passed
zeros(shape, *, dtype=None, device=None) zeros(shape, dtype=float32, *, stream=None) signature mismatch dtype not keyword-only; no device. Behavior passes. test_zeros Passed
zeros_like(x, /, *, dtype=None, device=None) zeros_like(a, /, *, dtype=None, stream=None) signature mismatch dtype added upstream as a keyword-only arg. No device. ml-explore/mlx#4001 (issue, closed) → #4028 (merged) test_zeros_like Passed

Planned x-fails

  • test_asarray_arrays
  • test_eye
  • test_from_dlpack depends on #459
Dominant language
Python
Stars
131
Forks
49
Avg merge
2d 8h
Merged PRs (30d)
6

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from data-apis/array-api-compat

All issues in data-apis/array-api-compat

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.