Skip to content

[BUG] linalg.cholesky gives runtime error on empty matrices. #4032

Description

@prady0t

Describe the bug

Calling linalg.cholesky on an empty (0, 0) matrix aborts the process. Found here: data-apis/array-api-compat#450 (comment)

To Reproduce

import mlx.core as mx
a = mx.zeros((0, 0))
r = mx.linalg.cholesky(a)
mx.eval(r)   # process aborts here

Output:

** On entry to  POTRF, parameter number  4 had an illegal value
libc++abi: terminating due to uncaught exception of type std::runtime_error: [Cholesky::eval_cpu] Cholesky decomposition failed with error code -4
[1]    31154 abort  

Expected behavior

Return an empty (0, 0) array

Desktop (please complete the following information):

  • OS Version: MacOS 26.5.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