Skip to content

when it crashed in the background, can not catch the exception #2670

Description

@taocheng-njfu
Image why it can not catch the exception below, how can I catch the exception when run in the background Image

Activity

  1. davidkoski commented on Sep 29, 2025

    @davidkoski
    Member

    This is thrown on the metal worker thread -- it is possible that this is not set up to deliver this back to the calling thread (the one calling eval).

  2. davidkoski commented on Sep 29, 2025

    @davidkoski
    Member

    I think this is the same as ml-explore/mlx-swift#274 -- the suggestion to try and catch the error didn't work because the error wasn't surfaced there.

  3. taocheng-njfu commented on Sep 30, 2025

    @taocheng-njfu
    Author

    This is thrown on the metal worker thread -- it is possible that this is not set up to deliver this back to the calling thread (the one calling eval).

    I think so too. Is there any way to catch this abnormality? I've been blocked for 3 or 4 days, and I don't have any ideas.

  4. taocheng-njfu commented on Sep 30, 2025

    @taocheng-njfu
    Author

    I think this is the same as #274 -- the suggestion to try and catch the error didn't work because the error wasn't surfaced there.

    Image Image

    it can not catch the exception

  5. davidkoski commented on Sep 30, 2025

    @davidkoski
    Member

    It would have to be a change on the mx::core side (mlx project).

  6. davidkoski commented on Sep 30, 2025

    @davidkoski
    Member

    Let me see about transferring this issue.

  7. davidkoski commented on Sep 30, 2025

    @davidkoski
    Member

    Specifically the request is:

    • if there is an uncaught exception on the worker thread, surface that or a proxy back in the eval
  8. taocheng-njfu commented on Oct 13, 2025

    @taocheng-njfu
    Author

    Any updates, boss?

  9. davidkoski commented on Oct 13, 2025

    @davidkoski
    Member

    @awni I think this requires a change on the mlx (core) side -- do you agree? Can you move it to the mlx repo? Thanks!

  10. awni commented on Oct 13, 2025

    @awni
    Member

    Yea I can move it... but it's not likely we are going to add this feature in the near future. The reason is that we don't have guarantees on the state being in a reasonable condition if there is an exception during eval.

    It's better to treat eval as something which shouldn't crash in your application. If it is crashing, then we should fix that (if it's an MLX issue) or you should fix it in the calling code if it's an issue there.

  11. transferred this issue fromml-explore/mlx-swifton Oct 13, 2025
  12. davidkoski commented on Oct 13, 2025

    @davidkoski
    Member

    I think this might be a race -- the GPU could become unavailable after eval is called, e.g. if an app goes into the background on iOS.

  13. taocheng-njfu commented on Oct 14, 2025

    @taocheng-njfu
    Author

    My model is quite time-consuming when performing eval, probably taking about 5 seconds. If I switch to the background while eval is in progress, it crashes, and currently, I have no way to prevent it.

  14. zcbenz commented on Nov 23, 2025

    @zcbenz
    Member

    Related: #2106, #1231, #1363 . We should probably merge them into one issue.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions