Skip to content

[BUG] Missing array-api methods #3484

Closed

Description

@ilan-gold

Describe the bug
The current array-api implementation is currently missing a few methods

To Reproduce

from_dlpack:

import mlx.core as mx

mx.array([[0, 1], [2, 3]]).__array_namespace__().from_dlpack

as_array(..., copy=...):

import mlx.core as mx

mx.array([[0, 1], [2, 3]]).__array_namespace__().asarray(mx.array([[0, 1], [2, 3]]), copy=True)

Expected behavior
I would expect the above to work. I assume there are others as well.

Desktop (please complete the following information):

  • OS Version: 15.1 (24B83)
  • Version: 0.31.2

Additional context

Activity

  1. Sahith59 commented on Jun 22, 2026

    @Sahith59

    Hey folks! I was taking a look at the remaining missing methods here and just put together a PR that adds from_dlpack to the array namespace. It looks like asarray(..., copy=True) was already handled recently. Let me know if you want me to tackle any of the other missing array-api methods!

  2. zcbenz commented on Jun 26, 2026

    @zcbenz
    Member

    Note that the array-api defines some ops that have dynamic output shape (for example nonzero and the set functions), which are not implementable with MLX at the moment, and we do not plan to include them.

    There are also ops defined some optional parameters that would require new kernels to implement efficiently, which we also prefer to omit for now until there are real requests for them.

    Having said this it seems that the open pull requests have already covered most of the missing ones, and I will close this issue once they are merged.

  3. rgommers commented on Jun 26, 2026

    @rgommers

    That all sounds very reasonable. Awesome to see DLPack support just landed (gh-3531), and asarray is present too now. With those, I suspect MLX will be supportable by SciPy, scikit-learn et al. without too much trouble. Dynamic shape-using functions like nonzero and unique_* are clearly marked in the array API standard, and optional (e.g., jax.jit also doesn't support them).

  4. zcbenz commented on Jul 1, 2026

    @zcbenz
    Member

    Closing since we should have all the implementable ops included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions