Skip to content

[BUG] Metal scatter does not support 64bit dtype #4300

Description

@aaishwarymishra

Describe the bug
mx.eye fails on the Metal GPU when an 8-byte dtype such as mx.int64 or mx.uint64 is requested. This happens because eye uses scatter internally, and Metal scatter does not support 8-byte output types.

To Reproduce

import mlx.core as mx

x = mx.eye(3, dtype=mx.int64)
mx.eval(x)

The operation fails with an error similar to:

[Scatter::eval_gpu] Does not support int64

The same issue occurs with mx.uint64.

Expected behavior
mx.eye should return an identity matrix with the requested dtype:

mx.array(
    [[1, 0, 0],
     [0, 1, 0],
     [0, 0, 1]],
    dtype=mx.int64,
)

Since eye only produces zeros and ones, it could safely construct the matrix using a scatter-supported dtype such as int32, then cast the result to the requested dtype without data loss.

Desktop (please complete the following information):

  • OS Version: macOS 26.6.1
  • MLX Version: 0.32.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions