Commit 602bd391 for whisper.cpp

commit 602bd391ab3b85412729c8495853b6dab766e55c
Author: Aman Gupta <amangupta052@gmail.com>
Date:   Thu Nov 12 17:24:40 2026 +0800

    ggml-backend : prefetch only inputs computed by earlier splits (llama/32100)

    * ggml-backend : prefetch only inputs computed by earlier splits

    The copy callback of a split runs after the prefetch and can write tensors that a later split reads, e.g. the MoE cache uploads missed experts into its bank. A prefetch of such a tensor reads it before the write.

    * llama : skip the MoE cache when its device cannot run the cached mul_mat_id

    Otherwise the scheduler runs the matmul on another backend and copies the whole bank every ubatch.

diff --git a/ggml/src/ggml-backend.cpp b/ggml/src/ggml-backend.cpp
index 961990f8..b70d0d87 100644
--- a/ggml/src/ggml-backend.cpp
+++ b/ggml/src/ggml-backend.cpp
@@ -2172,8 +2172,13 @@ static void ggml_backend_sched_prefetch_inputs(ggml_backend_sched_t sched, int s
             continue;
         }

-        // not if this split computes or writes the input
+        // only results of earlier splits, the copy callback of this split runs later and can write other tensors (e.g. the MoE cache)
         const struct ggml_tensor * base = input->view_src ? input->view_src : input;
+        if (base->buffer == NULL || ggml_backend_buffer_get_usage(base->buffer) != GGML_BACKEND_BUFFER_USAGE_COMPUTE) {
+            continue;
+        }
+
+        // not if this split computes or writes the input
         bool written = false;
         for (int j = 0; j < split->graph.n_nodes && !written; j++) {
             const struct ggml_tensor * node = split->graph.nodes[j];