From 764eefd1bc3a7b65409dbd2e127d1c28b44c5cb8 Mon Sep 17 00:00:00 2001 From: Kawrakow Date: Sat, 11 Oct 2025 16:01:13 +0300 Subject: [PATCH] Enable and clean up compiler warnings in src (#824) * WIP: enable and clean up warnings in src * All warnings handled --------- Co-authored-by: Iwan Kawrakow --- src/CMakeLists.txt | 30 +++++- src/llama-build-context.cpp | 14 ++- src/llama-load-tensors.cpp | 34 +++---- src/llama-sampling.cpp | 23 +++-- src/llama-vocab.cpp | 184 ++---------------------------------- src/llama.cpp | 108 +-------------------- 6 files changed, 76 insertions(+), 317 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b86b0066..de898bb9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -11,6 +11,32 @@ endif() # llama +if (LLAMA_ALL_WARNINGS) + if (NOT MSVC) + list(APPEND WARNING_FLAGS -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wno-sign-compare) + if (APPLE) + # shut up c99 extensions warning I get on my system due to arm_neon.h + list(APPEND WARNING_FLAGS -Wno-c99-extensions) + endif() + list(APPEND C_FLAGS -Wshadow -Wstrict-prototypes -Wpointer-arith -Wmissing-prototypes + -Werror=implicit-int -Werror=implicit-function-declaration) + list(APPEND CXX_FLAGS -Wmissing-declarations -Wmissing-noreturn) + + list(APPEND C_FLAGS ${WARNING_FLAGS}) + list(APPEND CXX_FLAGS ${WARNING_FLAGS}) + + get_flags(${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}) + + add_compile_options("$<$:${C_FLAGS};${GF_C_FLAGS}>" + "$<$:${CXX_FLAGS};${GF_CXX_FLAGS}>") + else() + # todo : msvc + set(C_FLAGS "") + set(CXX_FLAGS "") + endif() +endif() + + add_library(llama ../include/llama.h llama.cpp @@ -34,9 +60,9 @@ add_library(llama unicode-data.cpp ) -target_include_directories(llama PUBLIC . ../include ../common) +target_include_directories(llama PUBLIC . ../include) target_include_directories(llama PRIVATE ../ggml/src) -target_compile_features (llama PUBLIC cxx_std_11) # don't bump +target_compile_features (llama PUBLIC cxx_std_17) target_link_libraries(llama PUBLIC ggml) diff --git a/src/llama-build-context.cpp b/src/llama-build-context.cpp index 46f5f19e..d8533f4f 100644 --- a/src/llama-build-context.cpp +++ b/src/llama-build-context.cpp @@ -455,13 +455,11 @@ void llm_build_context::llm_build_kv_store( int64_t il) { const int64_t n_ctx = cparams.n_ctx; - const int64_t n_embd_k_gqa = hparams.n_embd_k_gqa(il); + //const int64_t n_embd_k_gqa = hparams.n_embd_k_gqa(il); const int64_t n_embd_v_gqa = hparams.n_embd_v_gqa(il); - const int64_t n_head = hparams.n_head(il); const int64_t n_head_kv = hparams.n_head_kv(il); const int64_t n_embd_head_k = hparams.n_embd_head_k; - const int64_t n_embd_head_v = hparams.n_embd_head_v; GGML_ASSERT(kv.size == n_ctx); @@ -957,7 +955,7 @@ static ggml_tensor * llm_build_kqv( const int64_t n_head = hparams.n_head(il); const int64_t n_head_kv = hparams.n_head_kv(il); const int64_t n_embd_head_k = hparams.n_embd_head_k; - const int64_t n_embd_k_gqa = hparams.n_embd_k_gqa(il); + //const int64_t n_embd_k_gqa = hparams.n_embd_k_gqa(il); const int64_t n_embd_head_v = hparams.n_embd_head_v; const int64_t n_embd_v_gqa = hparams.n_embd_v_gqa(il); @@ -1082,7 +1080,7 @@ static ggml_tensor * llm_build_kqv( auto r2v = q->ne[2] / v->ne[2]; n_step = q->ne[2]; n_per_step = 1; - ggml_tensor * kqv; + ggml_tensor * kqv = nullptr; for (int i12 = 0; i12 < q->ne[2]; i12 += n_per_step) { int this_ne12 = i12 + n_per_step <= q->ne[2] ? n_per_step : q->ne[2] - i12; int i02 = i12/r2k; @@ -5889,7 +5887,7 @@ ggml_cgraph * llm_build_context::build_deepseek2() { if (lctx.cparams.mla_attn) { - ggml_tensor * kv_cache_trans; + ggml_tensor * kv_cache_trans = nullptr; if (lctx.cparams.mla_attn == 1 && !lctx.cparams.flash_attn) { ggml_tensor * kv_cache_trans_view = ggml_view_2d(ctx0, kv_self.v_l[il], n_tokens, kv_lora_rank, @@ -6018,9 +6016,9 @@ ggml_cgraph * llm_build_context::build_deepseek2() { } else { - ggml_tensor * kqv_compressed; + ggml_tensor * kqv_compressed = nullptr; - auto wkv_b = model.layers[il].wkv_b; + //auto wkv_b = model.layers[il].wkv_b; auto wk_b = model.layers[il].wk_b->ne[1] == kv_lora_rank ? model.layers[il].wk_b : ggml_reshape_3d(ctx0, model.layers[il].wk_b, n_embd_head_qk_nope, kv_lora_rank, n_head); diff --git a/src/llama-load-tensors.cpp b/src/llama-load-tensors.cpp index 1237054e..1dc4caf0 100644 --- a/src/llama-load-tensors.cpp +++ b/src/llama-load-tensors.cpp @@ -216,23 +216,23 @@ ggml_context * create_tensors_helper::ctx_for_layer_split(int i) const { } #define LOADING_PRELUDE \ - const auto & hparams = model.hparams; \ - const int64_t n_layer = hparams.n_layer; \ - const int64_t n_head = hparams.n_head(); \ - const int64_t n_head_kv = hparams.n_head_kv(); \ - const int64_t n_embd = hparams.n_embd; \ - const int64_t n_embd_k_gqa = hparams.n_embd_k_gqa(); \ - const int64_t n_embd_v_gqa = hparams.n_embd_v_gqa(); \ - const int64_t n_embd_head_k = hparams.n_embd_head_k; \ - const int64_t n_embd_head_v = hparams.n_embd_head_v; \ - const int64_t n_ff = hparams.n_ff(); \ - const int64_t n_embd_gqa = n_embd_v_gqa; \ - const int64_t n_vocab = hparams.n_vocab; \ - const int64_t n_vocab_type = hparams.n_vocab_type; \ - const int64_t n_rot = hparams.n_rot; \ - const int64_t n_expert = hparams.n_expert; \ - const int64_t n_expert_used = hparams.n_expert_used; \ - const int64_t n_ctx_train = hparams.n_ctx_train; \ + [[maybe_unused]] const auto & hparams = model.hparams; \ + [[maybe_unused]] const int64_t n_layer = hparams.n_layer; \ + [[maybe_unused]] const int64_t n_head = hparams.n_head(); \ + [[maybe_unused]] const int64_t n_head_kv = hparams.n_head_kv(); \ + [[maybe_unused]] const int64_t n_embd = hparams.n_embd; \ + [[maybe_unused]] const int64_t n_embd_k_gqa = hparams.n_embd_k_gqa(); \ + [[maybe_unused]] const int64_t n_embd_v_gqa = hparams.n_embd_v_gqa(); \ + [[maybe_unused]] const int64_t n_embd_head_k = hparams.n_embd_head_k; \ + [[maybe_unused]] const int64_t n_embd_head_v = hparams.n_embd_head_v; \ + [[maybe_unused]] const int64_t n_ff = hparams.n_ff(); \ + [[maybe_unused]] const int64_t n_embd_gqa = n_embd_v_gqa; \ + [[maybe_unused]] const int64_t n_vocab = hparams.n_vocab; \ + [[maybe_unused]] const int64_t n_vocab_type = hparams.n_vocab_type; \ + [[maybe_unused]] const int64_t n_rot = hparams.n_rot; \ + [[maybe_unused]] const int64_t n_expert = hparams.n_expert; \ + [[maybe_unused]] const int64_t n_expert_used = hparams.n_expert_used; \ + [[maybe_unused]] const int64_t n_ctx_train = hparams.n_ctx_train; \ if (n_expert > 0 && hparams.n_expert_used == 0) { \ throw std::runtime_error("model has expert layers but no expert layers are used"); \ } \ diff --git a/src/llama-sampling.cpp b/src/llama-sampling.cpp index ea809506..0d23e146 100644 --- a/src/llama-sampling.cpp +++ b/src/llama-sampling.cpp @@ -450,8 +450,6 @@ void llama_sample_xtc_impl(struct llama_sampling * smpl, llama_token_data_array llama_sample_softmax_impl(nullptr, candidates); - auto cur_size = candidates->size; - int pos_last = 0; for (size_t i = 0; i < candidates->size; ++i) { @@ -471,7 +469,7 @@ void llama_sample_xtc_impl(struct llama_sampling * smpl, llama_token_data_array } void llama_sample_top_n_sigma_impl(struct llama_sampling * smpl, llama_token_data_array * candidates, float top_n_sigma) { - + if (top_n_sigma <= 0.0f || candidates->size < 4) { // top_n_sigma <= 0: disabled // candidates->size < 4: no point in applying the transformation for fewer than 4 logits. @@ -1132,14 +1130,15 @@ static void llama_sampler_grammar_free(struct llama_sampler* smpl) { delete ctx; } -static struct llama_sampler_i llama_sampler_grammar_i = { - /* .name = */ llama_sampler_grammar_name, - /* .accept = */ llama_sampler_grammar_accept_impl, - /* .apply = */ llama_sampler_grammar_apply, - /* .reset = */ llama_sampler_grammar_reset, - /* .clone = */ NULL, - /* .free = */ llama_sampler_grammar_free, -}; +// ? +//static struct llama_sampler_i llama_sampler_grammar_i = { +// /* .name = */ llama_sampler_grammar_name, +// /* .accept = */ llama_sampler_grammar_accept_impl, +// /* .apply = */ llama_sampler_grammar_apply, +// /* .reset = */ llama_sampler_grammar_reset, +// /* .clone = */ NULL, +// /* .free = */ llama_sampler_grammar_free, +//}; struct llama_grammar* llama_sampler_init_grammar_impl( const struct llama_vocab* vocab, @@ -1152,7 +1151,7 @@ struct llama_grammar* llama_sampler_init_grammar_impl( size_t num_trigger_tokens, const char** trigger_patterns, size_t num_trigger_patterns) { - auto* ctx = new llama_sampler_grammar; + // Huh? this is not used and leaks. auto* ctx = new llama_sampler_grammar; struct llama_grammar* grammar; if (grammar_str != nullptr && grammar_str[0] != '\0') { // TODO: remove trigger_words support. diff --git a/src/llama-vocab.cpp b/src/llama-vocab.cpp index 271d4816..372407a0 100644 --- a/src/llama-vocab.cpp +++ b/src/llama-vocab.cpp @@ -3567,35 +3567,10 @@ int32_t llama_vocab_n_tokens(const struct llama_vocab * vocab) { return vocab->n_tokens(); } -// deprecated -int32_t llama_n_vocab(const struct llama_vocab * vocab) { - return llama_vocab_n_tokens(vocab); -} - -enum llama_vocab_type llama_vocab_type(const struct llama_vocab * vocab) { - return vocab->get_type(); -} - -const char * llama_vocab_get_text(const struct llama_vocab * vocab, llama_token token) { - return vocab->token_get_text(token); -} - -float llama_vocab_get_score(const struct llama_vocab * vocab, llama_token token) { - return vocab->token_get_score(token); -} - -enum llama_token_attr llama_vocab_get_attr(const struct llama_vocab * vocab, llama_token token) { - return vocab->token_get_attr(token); -} - bool llama_vocab_is_eog(const struct llama_vocab * vocab, llama_token token) { return vocab->is_eog(token); } -bool llama_vocab_is_control(const struct llama_vocab * vocab, llama_token token) { - return vocab->is_control(token); -} - llama_token llama_vocab_bos(const struct llama_vocab * vocab) { return vocab->token_bos(); } @@ -3604,27 +3579,6 @@ llama_token llama_vocab_eos(const struct llama_vocab * vocab) { return vocab->token_eos(); } -llama_token llama_vocab_eot(const struct llama_vocab * vocab) { - return vocab->token_eot(); -} - -// deprecated -llama_token llama_vocab_cls(const struct llama_vocab * vocab) { - return vocab->token_bos(); -} - -llama_token llama_vocab_sep(const struct llama_vocab * vocab) { - return vocab->token_sep(); -} - -llama_token llama_vocab_nl (const struct llama_vocab * vocab) { - return vocab->token_nl(); -} - -llama_token llama_vocab_pad(const struct llama_vocab * vocab) { - return vocab->token_pad(); -} - bool llama_vocab_get_add_bos(const struct llama_vocab * vocab) { return vocab->get_add_bos(); } @@ -3633,63 +3587,11 @@ bool llama_vocab_get_add_eos(const struct llama_vocab * vocab) { return vocab->get_add_eos(); } -bool llama_vocab_get_add_sep(const struct llama_vocab * vocab) { - return vocab->get_add_sep(); -} - -llama_token llama_vocab_fim_pre(const struct llama_vocab * vocab) { - return vocab->token_fim_pre(); -} - -llama_token llama_vocab_fim_suf(const struct llama_vocab * vocab) { - return vocab->token_fim_suf(); -} - -llama_token llama_vocab_fim_mid(const struct llama_vocab * vocab) { - return vocab->token_fim_mid(); -} - -llama_token llama_vocab_fim_pad(const struct llama_vocab * vocab) { - return vocab->token_fim_pad(); -} - -llama_token llama_vocab_fim_rep(const struct llama_vocab * vocab) { - return vocab->token_fim_rep(); -} - -llama_token llama_vocab_fim_sep(const struct llama_vocab * vocab) { - return vocab->token_fim_sep(); -} - -llama_token llama_vocab_mask(const struct llama_vocab* vocab) { - return vocab->token_mask(); -} - -// deprecated -const char * llama_token_get_text(const struct llama_vocab * vocab, llama_token token) { - return llama_vocab_get_text(vocab, token); -} - -// deprecated -float llama_token_get_score(const struct llama_vocab * vocab, llama_token token) { - return llama_vocab_get_score(vocab, token); -} - -// deprecated -enum llama_token_attr llama_token_get_attr(const struct llama_vocab * vocab, llama_token token) { - return llama_vocab_get_attr(vocab, token); -} - // deprecated bool llama_token_is_eog(const struct llama_vocab * vocab, llama_token token) { return llama_vocab_is_eog(vocab, token); } -// deprecated -bool llama_token_is_control(const struct llama_vocab * vocab, llama_token token) { - return llama_vocab_is_control(vocab, token); -} - // deprecated llama_token llama_token_bos(const struct llama_vocab * vocab) { return llama_vocab_bos(vocab); @@ -3700,72 +3602,6 @@ llama_token llama_token_eos(const struct llama_vocab * vocab) { return llama_vocab_eos(vocab); } -// deprecated -llama_token llama_token_eot(const struct llama_vocab * vocab) { - return llama_vocab_eot(vocab); -} - -// deprecated -llama_token llama_token_cls(const struct llama_vocab * vocab) { - //return llama_vocab_cls(vocab); - return llama_vocab_bos(vocab); // avoid deprecation warning -} - -// deprecated -llama_token llama_token_sep(const struct llama_vocab * vocab) { - return llama_vocab_sep(vocab); -} - -// deprecated -llama_token llama_token_nl (const struct llama_vocab * vocab) { - return llama_vocab_nl(vocab); -} - -// deprecated -llama_token llama_token_pad(const struct llama_vocab * vocab) { - return llama_vocab_pad(vocab); -} - -// deprecated -bool llama_add_bos_token(const struct llama_vocab * vocab) { - return llama_vocab_get_add_bos(vocab); -} - -// deprecated -bool llama_add_eos_token(const struct llama_vocab * vocab) { - return llama_vocab_get_add_eos(vocab); -} - -// deprecated -llama_token llama_token_fim_pre(const struct llama_vocab * vocab) { - return llama_vocab_fim_pre(vocab); -} - -// deprecated -llama_token llama_token_fim_suf(const struct llama_vocab * vocab) { - return llama_vocab_fim_suf(vocab); -} - -// deprecated -llama_token llama_token_fim_mid(const struct llama_vocab * vocab) { - return llama_vocab_fim_mid(vocab); -} - -// deprecated -llama_token llama_token_fim_pad(const struct llama_vocab * vocab) { - return llama_vocab_fim_pad(vocab); -} - -// deprecated -llama_token llama_token_fim_rep(const struct llama_vocab * vocab) { - return llama_vocab_fim_rep(vocab); -} - -// deprecated -llama_token llama_token_fim_sep(const struct llama_vocab * vocab) { - return llama_vocab_fim_sep(vocab); -} - // // tokenization // @@ -3791,13 +3627,13 @@ int32_t llama_vocab_token_to_piece( return vocab->token_to_piece(token, buf, length, lstrip, special); } -int32_t llama_detokenize( - const struct llama_vocab * vocab, - const llama_token * tokens, - int32_t n_tokens, - char * text, - int32_t text_len_max, - bool remove_special, - bool unparse_special) { - return vocab->detokenize(tokens, n_tokens, text, text_len_max, remove_special, unparse_special); -} +//int32_t llama_detokenize( +// const struct llama_vocab * vocab, +// const llama_token * tokens, +// int32_t n_tokens, +// char * text, +// int32_t text_len_max, +// bool remove_special, +// bool unparse_special) { +// return vocab->detokenize(tokens, n_tokens, text, text_len_max, remove_special, unparse_special); +//} diff --git a/src/llama.cpp b/src/llama.cpp index 5c06b3cc..7bc823a0 100644 --- a/src/llama.cpp +++ b/src/llama.cpp @@ -154,26 +154,6 @@ static std::string trim(const std::string & str) { return str.substr(start, end - start); } -static bool is_float_close(float a, float b, float abs_tol) { - // Check for non-negative tolerance - if (abs_tol < 0.0) { - throw std::invalid_argument("Tolerance must be non-negative"); - } - - // Exact equality check - if (a == b) { - return true; - } - - // Check for infinities - if (std::isinf(a) || std::isinf(b)) { - return false; - } - - // Regular comparison using the provided absolute tolerance - return std::fabs(b - a) <= abs_tol; -} - enum llm_chat_template { LLM_CHAT_TEMPLATE_CHATML, LLM_CHAT_TEMPLATE_LLAMA_2, @@ -320,23 +300,6 @@ std::string gguf_kv_to_str(const gguf_context * ctx_gguf, int i) { // llama helpers // -// NOTE: avoid ever using this except for building the token_to_piece caches -static std::string llama_token_to_piece(const struct llama_model * model, llama_token token, bool special) { - std::string piece; - piece.resize(piece.capacity()); // using string internal cache - const int n_chars = llama_token_to_piece(model, token, &piece[0], piece.size(), 0, special); - if (n_chars < 0) { - piece.resize(-n_chars); - int check = llama_token_to_piece(model, token, &piece[0], piece.size(), 0, special); - GGML_ASSERT(check == -n_chars); - } - else { - piece.resize(n_chars); - } - - return piece; -} - ggml_backend_buffer_type_t llama_default_buffer_type_cpu(bool host_buffer) { ggml_backend_buffer_type_t buft = nullptr; @@ -666,12 +629,9 @@ static bool llama_kv_cache_init( } if (needs_v_cache) cache.v_l.reserve(n_layer); - bool warn = true; int n_mla = 0; for (int i = 0; i < (int) n_layer; i++) { - const uint32_t n_embd_k_gqa = hparams.n_embd_k_gqa(i) + hparams.n_embd_k_s(); const uint32_t n_embd_v_gqa = hparams.n_embd_v_gqa(i) + hparams.n_embd_v_s(); - const uint32_t n_head = hparams.n_head(i); const uint32_t n_head_kv = hparams.n_head_kv(i); const uint32_t n_embd_head_k= hparams.n_embd_head_k; @@ -682,7 +642,6 @@ static bool llama_kv_cache_init( if (cparams.mla_attn) { // DeepSeek MLA const uint32_t n_embd_head_qk_rope = hparams.n_rot; - const uint32_t n_embd_head_qk_nope = hparams.n_embd_head_k - hparams.n_rot; const uint32_t kv_lora_rank = hparams.n_lora_kv; //LLAMA_LOG_INFO("%s: layer %d: n_embd_head_qk_rope = %d, kv_lora_rank = %d\n", __func__, i, n_embd_head_qk_rope, kv_lora_rank); if (cparams.flash_attn) { @@ -1090,17 +1049,6 @@ static uint32_t llama_kv_cache_get_padding(const struct llama_cparams & cparams) // load LLaMA models // -static const char * llama_model_vocab_type_name(enum llama_vocab_type type){ - switch (type) { - case LLAMA_VOCAB_TYPE_NONE: return "no vocab"; - case LLAMA_VOCAB_TYPE_SPM: return "SPM"; - case LLAMA_VOCAB_TYPE_BPE: return "BPE"; - case LLAMA_VOCAB_TYPE_WPM: return "WPM"; - case LLAMA_VOCAB_TYPE_UGM: return "UGM"; - default: return "unknown"; - } -} - void llm_load_arch(llama_model_loader & ml, llama_model & model) { model.arch = ml.get_arch(); if (model.arch == LLM_ARCH_UNKNOWN) { @@ -1277,7 +1225,6 @@ static void llm_prepare_mla(llama_model & model, int mla) { // is no MLA + FA for prompt processing, and MLA + FA for token generation, it would be useful // to change the MLA setting on the fly, depending on context. In that case, having prepared // the MLA tensors here is the right ting to do^TM. - const uint32_t n_embd_head_qk_rope = hparams.n_rot; const uint32_t n_embd_head_qk_nope = hparams.n_embd_head_k - hparams.n_rot; const uint32_t kv_lora_rank = hparams.n_lora_kv; const int32_t n_embd_head_v = hparams.n_embd_head_v; @@ -1288,9 +1235,8 @@ static void llm_prepare_mla(llama_model & model, int mla) { // Somehow the number of heads is being defined as being per layer. Not sure why this is the // case, but for now we do not support strange models that have different numbers of heads // in different model layers. - if (hparams.n_head(il) != n_head) throw std::runtime_error("Unsupported configuration"); + if ((int)hparams.n_head(il) != n_head) throw std::runtime_error("Unsupported configuration"); } - auto total_size_wkb = 0; size_t max_wkv_size = 0; size_t max_wk_size = 0; for (auto& l : model.layers) { @@ -1414,10 +1360,6 @@ static void llm_prepare_mla(llama_model & model, int mla) { // preparation of wkv_b impossible. It also has the benefit that wkv_b will get automatically // run-time repacked if the rtr option is set. // - const uint32_t n_embd_head_qk_rope = hparams.n_rot; - const uint32_t n_embd_head_qk_nope = hparams.n_embd_head_k - hparams.n_rot; - const uint32_t kv_lora_rank = hparams.n_lora_kv; - const int32_t n_embd_head_v = hparams.n_embd_head_v; const int32_t n_head = hparams.n_head(0); std::vector work_data; LLAMA_LOG_INFO("============ %s: need to compute %d wkv_b tensors\n", __func__, n_to_compute); @@ -1425,7 +1367,7 @@ static void llm_prepare_mla(llama_model & model, int mla) { // Somehow the number of heads is being defined as being per layer. Not sure why this is the // case, but for now we do not support strange models that have different numbers of heads // in different model layers. - if (hparams.n_head(il) != n_head) throw std::runtime_error("Unsupported configuration"); + if ((int)hparams.n_head(il) != n_head) throw std::runtime_error("Unsupported configuration"); } size_t context_size = ggml_tensor_overhead()*16*n_layer; @@ -1434,12 +1376,8 @@ static void llm_prepare_mla(llama_model & model, int mla) { auto ctx = ggml_init(params); auto graph = ggml_new_graph_custom(ctx, 8, false); - //layer.wk_b = create_tensor(ctx_split, tn(LLM_TENSOR_ATTN_K_B, "weight", i), {n_embd_head_qk_nope, kv_lora_rank, n_head}, 0); - //layer.wv_b = create_tensor(ctx_split, tn(LLM_TENSOR_ATTN_V_B, "weight", i), {kv_lora_rank, n_embd_head_v, n_head}, 0); - std::vector wk_buffer, wv_buffer; std::vector tmp_buffer; - //std::vector tensor_data(2*n_embd_head_qk_nope*kv_lora_rank*n_head*sizeof(float) + max_wk_size); for (int il = 0; il < n_layer; ++il) { auto& l = model.layers[il]; if (l.wkv_b || !l.wk_b || !l.wv_b) continue; @@ -3514,6 +3452,7 @@ struct llama_model_params llama_model_default_params() { /*.check_tensors =*/ false, /*.repack_tensors =*/ false, /*.use_thp =*/ false, + /*.validate_quants =*/ false, }; #ifdef GGML_USE_METAL @@ -4298,10 +4237,6 @@ int32_t llama_n_layer(const struct llama_model * model) { return model->hparams.n_layer; } -int32_t llama_n_head(const struct llama_model * model) { - return model->hparams.n_head(); -} - float llama_rope_freq_scale_train(const struct llama_model * model) { return model->hparams.rope_freq_scale_train; } @@ -5903,11 +5838,6 @@ llama_token llama_token_eos(const struct llama_model * model) { return model->vocab.token_eos(); } -// What is cls? -//llama_token llama_token_cls(const struct llama_model * model) { -// return llama_token_cls_impl(model->vocab); -//} - llama_token llama_token_sep(const struct llama_model * model) { return model->vocab.token_sep(); } @@ -5944,36 +5874,6 @@ llama_token llama_token_eot(const struct llama_model * model) { return model->vocab.token_eot(); } -// deprecated -llama_token llama_token_fim_pre(const struct llama_model * model) { - return model->vocab.token_fim_pre(); -} - -// deprecated -llama_token llama_token_fim_suf(const struct llama_model * model) { - return model->vocab.token_fim_suf(); -} - -// deprecated -llama_token llama_token_fim_mid(const struct llama_model * model) { - return model->vocab.token_fim_mid(); -} - -// deprecated -llama_token llama_token_fim_pad(const struct llama_model * model) { - return model->vocab.token_fim_pad(); -} - -// deprecated -llama_token llama_token_fim_rep(const struct llama_model * model) { - return model->vocab.token_fim_rep(); -} - -// deprecated -llama_token llama_token_fim_sep(const struct llama_model * model) { - return model->vocab.token_fim_sep(); -} - // // tokenization // @@ -6781,7 +6681,7 @@ void llama_sample_top_n_sigma(struct llama_context * ctx, llama_token_data_array } -void llama_sample_dry(struct llama_context* ctx, struct llama_sampler_dry* smpl, llama_token_data_array* candidates_p) { +void llama_sample_dry([[maybe_unused]] struct llama_context* ctx, struct llama_sampler_dry* smpl, llama_token_data_array* candidates_p) { llama_sampler_dry_apply(smpl, candidates_p); }