ml-explore / ml-explore/mlx

[BUG] crash on qr followed by diag

Open
#3,583 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
28.5k
Forks
2.3k
Avg merge
3d 8h
Merged PRs (30d)
62

Description

Describe the bug

mlx crashes on my M2 Macbook Air with the following code:

import mlx.core as mx

x = mx.random.normal((10000, 10000))
q, r = mx.linalg.qr(x, stream=mx.cpu)
mx.eval(mx.diag(r))

giving

libc++abi: terminating due to uncaught exception of type std::runtime_error: [METAL] Command buffer execution failed: Caused GPU Timeout Error (00000002:kIOGPUCommandBufferCallbackErrorTimeout)

The following variant does not crash:

import mlx.core as mx

x = mx.random.normal((10000, 10000))
q, r = mx.linalg.qr(x, stream=mx.cpu)
mx.eval(r)
mx.eval(mx.diag(r))

Expected behavior
I'd expect the operation not to fail, given that the intermediate evaluation lets it succeed. But if this is a simple oom error then sorry for the false report.

Desktop:

  • OS Version: Tahoe 26.4.1
  • Mlx Version: 0.31.1

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.

Research direction

Reproduce the reported Python snippet on an M2 Mac with MLX 0.31.1, comparing the failing qr-to-diag sequence with the variant that evaluates r first. Trace the QR, diag, and evaluation behavior to identify why the command buffer times out; done means the original sequence completes without a crash.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.