]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
fix: crash when calling `llama_state_get_size` on a context without a KV cache (...
authorGilad S. <redacted>
Wed, 14 May 2025 16:18:18 +0000 (19:18 +0300)
committerGitHub <redacted>
Wed, 14 May 2025 16:18:18 +0000 (19:18 +0300)
src/llama-context.cpp

index 62246c10dab089f4583f0174492792eb27e7c543..1b76317da0ec9f81a5e637b723b75150b777f977 100644 (file)
@@ -1704,10 +1704,12 @@ size_t llama_context::state_write_data(llama_io_write_i & io) {
         }
     }
 
-    LLAMA_LOG_DEBUG("%s: - writing KV self\n", __func__);
     llama_kv_cache * kv_self = static_cast<llama_kv_cache *>(memory.get());
-
-    kv_self->state_write(io);
+    
+    if (kv_self != nullptr) {
+        LLAMA_LOG_DEBUG("%s: - writing KV self\n", __func__);
+        kv_self->state_write(io);
+    }
 
     return io.n_bytes();
 }