Skip to content

None dtype comparison not supported in MLX #447

Closed

Description

@aaishwarymishra

In reporting.py we have

def to_json_serializable(o):
    if o in dtype_to_name:
        return dtype_to_name[o]

While running tests all the test failed because this method was being called at each test and the main problem is if the o is of the type None

MlLX throws an exception for equality like

if None == mlx.core.float16:
    print("success")

We either have to modify the method to something like

def to_json_serializable(o):
    if o is not None and o in dtype_to_name:
        return dtype_to_name[o]

I think it's a minor problem and can be fixed in test itself not sure though.

Activity

  1. ev-br commented on Aug 4, 2026

    @ev-br
    Member

    PR welcome, I'd say. A minimal workaround to unblock running the test suite with MLX would be best.

  2. prady0t commented on Aug 5, 2026

    @prady0t
    Contributor

    MLX is missing __array_namespace_info__, this prevents pytest from collecting tests. Is this being tackled in the compat layer?

    I tried running tests by skipping the __array_namespace_info__ attribute.

    if not hasattr(xp, "__array_namespace_info__"):
        pytest.skip(
            "__array_namespace_info__ is not defined in the array module",
            allow_module_level=True,
        )

    But there were a few more blockers:

    • Calls to xp.__array_namespace_info__().devices() were put inside try block, returning None when exception (our MLX case)

    • We should put this line inside the try block too to avoid test suite failures when the device is not an accepted argument (our MLX case):

    x = xp.empty(2, device=device)

    After these changes, I ran with ARRAY_API_TESTS_SKIP_DTYPES=float64 (since float64 is not supported), and the tests are running now.

    409 failed, 312 passed, 7 skipped, 64 warnings, 716 errors in 191.65s (0:03:11)
    
  3. ev-br commented on Aug 5, 2026

    @ev-br
    Member

    Great! Not sure you saw it @prady0t , there's an MLX tracker at data-apis/array-api-compat#450, which links several sub-issues.
    I think it'd be best to use this tracker, and follow a similar style: run tests and note failures per group of functions (ideally, with repro examples from the test suite), then sort triage the failures into roughly three buckets: "submit fixes to MLX itself", "test suite needs improving", and "hard, leave to the end".

  4. ev-br commented on Aug 5, 2026

    @ev-br
    Member

    It'd be great to do a breadth-first kind of summary of what are these 409 failures, similar to data-apis/array-api-compat#452

    For deciding what to submit upstream and in which order, the general guidance is data-apis/array-api-compat#452 (comment)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions