From 87b7af6ceef2b4d96374dbff5070b41b17d3f138 Mon Sep 17 00:00:00 2001 From: Jesse Gross Date: Thu, 19 Jun 2025 14:39:20 -0700 Subject: [PATCH] ggml: Check return status for computation. We don't check the return status after computing the graph, which can silently lead to bad outputs if we try to keep going and future computation succeeds. This appears to happens in certain cases on Apple M2 devices. Fixes #11070 --- ml/backend/ggml/ggml.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ml/backend/ggml/ggml.go b/ml/backend/ggml/ggml.go index 5a9fe67e5..8aadad864 100644 --- a/ml/backend/ggml/ggml.go +++ b/ml/backend/ggml/ggml.go @@ -602,7 +602,9 @@ func (c *Context) Forward(tensors ...ml.Tensor) ml.Context { } func (c *Context) Compute(tensors ...ml.Tensor) { - C.ggml_backend_sched_graph_compute_async(c.b.sched, c.graph) + if status := C.ggml_backend_sched_graph_compute_async(c.b.sched, c.graph); status != C.GGML_STATUS_SUCCESS { + panic(fmt.Errorf("error computing ggml graph: %v", status)) + } C.ggml_backend_sched_reset(c.b.sched) needSync := true