]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
memory : fix broken batch splits for recurrent cache (#14575)
authorcompilade <redacted>
Tue, 8 Jul 2025 15:37:47 +0000 (11:37 -0400)
committerGitHub <redacted>
Tue, 8 Jul 2025 15:37:47 +0000 (18:37 +0300)
Splits producing more than one ubatch per batch for recurrent models
were broken with #14512.

This fixes it by moving the completeness check after the ubatch split loop.

src/llama-memory-recurrent.cpp

index 4b90dac7a327cf4a0c29396b3a3215a1e2ad84d0..a1b5b1a272cc09d02db4ecd7f5aa0686640f38ed 100644 (file)
@@ -377,14 +377,18 @@ llama_memory_context_ptr llama_memory_recurrent::init_batch(llama_batch_allocr &
                 ubatch = balloc.split_equal(n_ubatch, false);
             }
 
-            if (balloc.get_n_used() < balloc.get_n_tokens()) {
-                // failed to find a suitable split
+            if (ubatch.n_tokens == 0) {
                 break;
             }
 
             ubatches.push_back(std::move(ubatch)); // NOLINT
         }
 
+        if (balloc.get_n_used() < balloc.get_n_tokens()) {
+            // failed to find a suitable split
+            break;
+        }
+
         if (!prepare(ubatches)) {
             break;
         }