Skip to content

Fix metal error escaping handler - #4174

Open
zcbenz wants to merge 1 commit into
ml-explore:mainfrom
zcbenz:metal-error-disappear
Open

Fix metal error escaping handler#4174
zcbenz wants to merge 1 commit into
ml-explore:mainfrom
zcbenz:metal-error-disappear

Conversation

@zcbenz

@zcbenz zcbenz commented Aug 11, 2026

Copy link
Copy Markdown
Member

When a kernel is committed separately from event signaling, the event would be signaled even when the kernel failed, and it is possible that the waiter of the event would be signaled before the completion handler sets the error, ends up with the error getting silently ignored.

Using the example from #4134:

import mlx.core as mx, numpy as np

a = mx.full((3100, 1048576), 3.0)
b = mx.full((3100, 1048576), 4.0)
mx.eval(a, b)
c = a + b
mx.eval(c)

While a+b failed due to OOM, the synchronizer event would not get the error when eval ends.

This PR makes the error persistent in command encoder, until it is thrown either by event, or when users tries to use the stream.

Using the above example, with this PR while eval(c) still does not throw, following calls will eventually receive the error.

c = a + b
mx.eval(c) # do not throw
mx.arange(10) # throws

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant