Add portable CPU longhaul support
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
// TODO: replace with #include "llama-ext.h" in the future
|
||||
#include "../src/llama-arch.h"
|
||||
#include "../src/llama-model.h"
|
||||
#include "../src/llama-model-saver.h"
|
||||
|
||||
#include <cinttypes>
|
||||
@@ -476,7 +477,9 @@ static int save_models(const llm_arch target_arch, const size_t seed, const ggml
|
||||
if (!moe && moe_mandatory(arch)) {
|
||||
continue;
|
||||
}
|
||||
if (!llama_model_saver_supports_arch(arch) || !arch_supported(arch)) {
|
||||
const bool can_save_fixture =
|
||||
llama_model_saver_supports_arch(arch) || arch == LLM_ARCH_LAGUNA;
|
||||
if (!can_save_fixture || !arch_supported(arch)) {
|
||||
LOG_INF("%s: %s model (%s) is unsupported, skipping\n", __func__, llm_arch_name(arch), moe ? "MoE" : "dense");
|
||||
continue;
|
||||
}
|
||||
@@ -484,7 +487,20 @@ static int save_models(const llm_arch target_arch, const size_t seed, const ggml
|
||||
auto model_and_ctx = get_model_and_ctx(gguf_ctx.get(), nullptr, seed, {});
|
||||
const std::string path = dir + "/" + llm_arch_name(arch) + (moe ? "-moe.gguf" : "-dense.gguf");
|
||||
LOG_INF("%s: Saving %s model (%s) to %s...\n", __func__, llm_arch_name(arch), moe ? "MoE" : "dense", path.c_str());
|
||||
llama_model_save_to_file(model_and_ctx.first.get(), path.c_str());
|
||||
if (llama_model_saver_supports_arch(arch)) {
|
||||
llama_model_save_to_file(model_and_ctx.first.get(), path.c_str());
|
||||
} else {
|
||||
// Laguna is not supported by the production model saver yet.
|
||||
// Preserve the exact synthetic fixture metadata and attach the
|
||||
// initialized model tensors so longhaul can be tested from a
|
||||
// real file without broadening the saver API.
|
||||
gguf_context_ptr fixture(gguf_init_empty());
|
||||
gguf_set_kv(fixture.get(), gguf_ctx.get());
|
||||
for (const auto & item : llama_internal_get_tensor_map(model_and_ctx.first.get())) {
|
||||
gguf_add_tensor(fixture.get(), item.second);
|
||||
}
|
||||
gguf_write_to_file(fixture.get(), path.c_str(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
llama_log_set(ud.original_logger.callback, ud.original_logger.user_data);
|
||||
|
||||
Reference in New Issue
Block a user