Skip to content

Commit

Permalink
nit: more informative crash when grammar sampler fails (#11593)
Browse files Browse the repository at this point in the history
  • Loading branch information
ochafik authored Feb 2, 2025
1 parent 864a0b6 commit 90f9b88
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/llama-grammar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 90f9b88

Please sign in to comment.