LLM inference in C/C++
C++ ggml
tests: actually exercise `test-recurrent-state-rollback` (#25758)
Aman Gupta32e789fdfd59
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txtindex 855295c152..7a93b19a07 100644--- a/tests/CMakeLists.txt+++ b/tests/CMakeLists.txt@@ -148,6 +148,8 @@ if (LLAMA_LLGUIDANCE)llama_build_and_test(test-grammar-llguidance.cpp ARGS ${PROJECT_SOURCE_DIR}/models/ggml-vocab-llama-bpe.gguf)endif ()+llama_build(test-recurrent-state-rollback.cpp get-model.cpp)+if (NOT WIN32 OR NOT BUILD_SHARED_LIBS)# these tests are disabled on Windows because they use internal functions not exported with LLAMA_API (when building with shared libraries)llama_build_and_test(test-sampling.cpp)@@ -193,6 +195,28 @@ if (NOT WIN32 OR NOT BUILD_SHARED_LIBS)# llama_build_and_test(test-double-float.cpp) # SLOWllama_build_and_test(test-llama-archs.cpp)++ set(MODEL_DIR "${CMAKE_CURRENT_BINARY_DIR}/test-models/")+ file(MAKE_DIRECTORY "${MODEL_DIR}")++ llama_test(+ test-llama-archs+ NAME test-generate-models+ LABEL main+ ARGS -o "${MODEL_DIR}"+ )+ set_tests_properties(test-generate-models PROPERTIES+ FIXTURES_SETUP generate-models+ )++ llama_test(+ test-recurrent-state-rollback+ LABEL main+ ARGS -m "${MODEL_DIR}/qwen35-dense.gguf"+ )+ set_tests_properties(test-recurrent-state-rollback PROPERTIES+ FIXTURES_REQUIRED generate-models+ )endif()llama_build_and_test(test-chat-peg-parser.cpp peg-parser/simple-tokenize.cpp)@@ -250,9 +274,6 @@ llama_build_and_test(test-backend-sampler.cpp LABEL "model")llama_build_and_test(test-state-restore-fragmented.cpp LABEL "model" ARGS -m "${MODEL_DEST}")set_tests_properties(test-state-restore-fragmented PROPERTIES FIXTURES_REQUIRED test-download-model)-llama_build_and_test(test-recurrent-state-rollback.cpp LABEL "model" ARGS -m "${MODEL_DEST}")-set_tests_properties(test-recurrent-state-rollback PROPERTIES FIXTURES_REQUIRED test-download-model)-# Test state save/load functionalityllama_build_and_test(test-save-load-state.cpp LABEL "model" ARGS -m "${MODEL_DEST}")set_tests_properties(test-save-load-state PROPERTIES FIXTURES_REQUIRED test-download-model)diff --git a/tests/test-llama-archs.cpp b/tests/test-llama-archs.cppindex 2cdf357398..796d490749 100644--- a/tests/test-llama-archs.cpp+++ b/tests/test-llama-archs.cpp@@ -465,7 +465,7 @@ static int save_models(const llm_arch target_arch, const size_t seed, const ggmlif (!moe && moe_mandatory(arch)) {continue;}- if (!llama_model_saver_supports_arch(arch)) {+ if (!llama_model_saver_supports_arch(arch) || !arch_supported(arch)) {LOG_INF("%s: %s model (%s) is unsupported, skipping\n", __func__, llm_arch_name(arch), moe ? "MoE" : "dense");continue;}diff --git a/tests/test-recurrent-state-rollback.cpp b/tests/test-recurrent-state-rollback.cppindex be19316db8..8e2eace6a1 100644--- a/tests/test-recurrent-state-rollback.cpp+++ b/tests/test-recurrent-state-rollback.cpp@@ -20,7 +20,7 @@ static llama_context * make_ctx(const common_params & params, llama_model * modestatic bool decode_tokens(llama_context * ctx, const std::vector<llama_token> & tokens, uint32_t count) {llama_batch batch = llama_batch_init(count, 0, 1);for (uint32_t pos = 0; pos < count; ++pos) {- common_batch_add(batch, tokens[pos], pos, { 0 }, false);+ common_batch_add(batch, tokens[pos], pos, { 0 }, pos + 1 == count);}const bool ok = llama_decode(ctx, batch) == 0;llama_batch_free(batch);@@ -79,7 +79,12 @@ int main(int argc, char ** argv) {return 0;}- std::vector<llama_token> tokens = common_tokenize(ctx_src, "The quick brown fox jumps", true);+ std::vector<llama_token> tokens;+ if (llama_vocab_type(vocab) == LLAMA_VOCAB_TYPE_NONE) {+ tokens = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };+ } else {+ tokens = common_tokenize(ctx_src, "The quick brown fox jumps", true);+ }const uint32_t n_rs_seq = llama_n_rs_seq(ctx_src);if (tokens.size() > n_rs_seq + 1) {tokens.resize(n_rs_seq + 1);