]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
nit: more informative crash when grammar sampler fails (#11593)
authorOlivier Chafik <redacted>
Sun, 2 Feb 2025 19:58:34 +0000 (19:58 +0000)
committerGitHub <redacted>
Sun, 2 Feb 2025 19:58:34 +0000 (19:58 +0000)
src/llama-grammar.cpp

index 6be5cbe0e76fdf0518def0eab7eb169ed7020b3d..9b518d1ac64a5cc74dac012350d48548e12ba406 100644 (file)
@@ -1213,5 +1213,7 @@ void llama_grammar_accept_str(struct llama_grammar & grammar, const std::string
     }
 
     grammar.partial_utf8 = decoded.second;
-    GGML_ASSERT(!grammar.stacks.empty());
+    if (grammar.stacks.empty()) {
+        throw std::runtime_error("Unexpected empty grammar stack after accepting piece: " + piece);
+    }
 }