]> git.djapps.eu Git - pkg/ggml/sources/ggml/commit
metal: handle command buffer failures gracefully in synchronize (llama/20306)
authorJulian Pscheid <redacted>
Tue, 10 Mar 2026 06:32:24 +0000 (23:32 -0700)
committerGeorgi Gerganov <redacted>
Sun, 15 Mar 2026 19:50:13 +0000 (21:50 +0200)
commitbc0adc4d1a6748ea43ff608a0d4bd5905c04c32b
treef240f3b69ddceeddce30fb83a7cd6ca9ec338798
parenta18fa2a2dc887ff1520228e5c8e7b8b87f605c4a
metal: handle command buffer failures gracefully in synchronize (llama/20306)

Replace GGML_ABORT("fatal error") in ggml_metal_synchronize() with
error flag + return. This aligns synchronize error handling with
graph_compute, which already returns GGML_STATUS_FAILED for the same
condition.

When a command buffer fails (e.g., iOS GPU access revocation during
backgrounding, macOS eGPU disconnect, OOM), the backend enters an
error state instead of killing the host process. Subsequent
graph_compute calls return GGML_STATUS_FAILED immediately. Recovery
requires recreating the backend.

Failed extra command buffers are properly released on the error path
to avoid Metal object leaks.
src/ggml-metal/ggml-metal-context.m