tests: actually exercise test-recurrent-state-rollback (#25758)

This commit is contained in:
Aman Gupta
2026-07-16 21:06:12 +08:00
committed by GitHub
parent a8dc0e3269
commit 32e789fdfd
3 changed files with 32 additions and 6 deletions
+24 -3
View File
@@ -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) llama_build_and_test(test-grammar-llguidance.cpp ARGS ${PROJECT_SOURCE_DIR}/models/ggml-vocab-llama-bpe.gguf)
endif () endif ()
llama_build(test-recurrent-state-rollback.cpp get-model.cpp)
if (NOT WIN32 OR NOT BUILD_SHARED_LIBS) 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) # 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) 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) # SLOW # llama_build_and_test(test-double-float.cpp) # SLOW
llama_build_and_test(test-llama-archs.cpp) llama_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() endif()
llama_build_and_test(test-chat-peg-parser.cpp peg-parser/simple-tokenize.cpp) 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}") 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) 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 functionality # Test state save/load functionality
llama_build_and_test(test-save-load-state.cpp LABEL "model" ARGS -m "${MODEL_DEST}") llama_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) set_tests_properties(test-save-load-state PROPERTIES FIXTURES_REQUIRED test-download-model)
+1 -1
View File
@@ -465,7 +465,7 @@ static int save_models(const llm_arch target_arch, const size_t seed, const ggml
if (!moe && moe_mandatory(arch)) { if (!moe && moe_mandatory(arch)) {
continue; 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"); LOG_INF("%s: %s model (%s) is unsupported, skipping\n", __func__, llm_arch_name(arch), moe ? "MoE" : "dense");
continue; continue;
} }
+7 -2
View File
@@ -20,7 +20,7 @@ static llama_context * make_ctx(const common_params & params, llama_model * mode
static bool decode_tokens(llama_context * ctx, const std::vector<llama_token> & tokens, uint32_t count) { static bool decode_tokens(llama_context * ctx, const std::vector<llama_token> & tokens, uint32_t count) {
llama_batch batch = llama_batch_init(count, 0, 1); llama_batch batch = llama_batch_init(count, 0, 1);
for (uint32_t pos = 0; pos < count; ++pos) { 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; const bool ok = llama_decode(ctx, batch) == 0;
llama_batch_free(batch); llama_batch_free(batch);
@@ -79,7 +79,12 @@ int main(int argc, char ** argv) {
return 0; 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); const uint32_t n_rs_seq = llama_n_rs_seq(ctx_src);
if (tokens.size() > n_rs_seq + 1) { if (tokens.size() > n_rs_seq + 1) {
tokens.resize(n_rs_seq + 1); tokens.resize(n_rs_seq + 1);