From a30c3ab02c8979f07c0de3ef18c2db8a4faa571e Mon Sep 17 00:00:00 2001 From: Herman Semenov Date: Mon, 13 May 2024 21:26:01 -0500 Subject: [PATCH] ggml-quants, llama: removed excess checks, it has already been checked before --- common/common.cpp | 2 +- ggml-quants.c | 2 +- llama.cpp | 8 ++------ 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/common/common.cpp b/common/common.cpp index ba1ecf0e5..f3694e4eb 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -2543,7 +2543,7 @@ void dump_string_yaml_multiline(FILE * stream, const char * prop_name, const cha size_t pos_start = 0; size_t pos_found = 0; - if (!data_str.empty() && (std::isspace(data_str[0]) || std::isspace(data_str.back()))) { + if (std::isspace(data_str[0]) || std::isspace(data_str.back())) { data_str = std::regex_replace(data_str, std::regex("\n"), "\\n"); data_str = std::regex_replace(data_str, std::regex("\""), "\\\""); data_str = std::regex_replace(data_str, std::regex(R"(\\[^n"])"), R"(\$&)"); diff --git a/ggml-quants.c b/ggml-quants.c index 00334c5fe..6a59201f0 100644 --- a/ggml-quants.c +++ b/ggml-quants.c @@ -1914,7 +1914,7 @@ static void quantize_row_q3_K_impl(const float * restrict x, block_q3_K * restri for (int j = 0; j < QK_K/16; ++j) { if (quant_weights) { - const float * qw = quant_weights ? quant_weights + QK_K * i + 16*j : NULL; + const float * qw = quant_weights + QK_K * i + 16*j; for (int l = 0; l < 16; ++l) weight[l] = qw[l] * sqrtf(sigma2 + x[16*j+l]*x[16*j+l]); } else { for (int l = 0; l < 16; ++l) weight[l] = x[16*j+l]*x[16*j+l]; diff --git a/llama.cpp b/llama.cpp index e91ad7285..aa3b04ac6 100644 --- a/llama.cpp +++ b/llama.cpp @@ -13809,9 +13809,7 @@ llama_token llama_sample_token_mirostat(struct llama_context * ctx, llama_token_ // Sample the next word X using top-k sampling llama_sample_top_k(nullptr, candidates, int(k), 1); - if (ctx) { - ctx->t_sample_us += ggml_time_us() - t_start_sample_us; - } + ctx->t_sample_us += ggml_time_us() - t_start_sample_us; llama_token X = llama_sample_token(ctx, candidates); t_start_sample_us = ggml_time_us(); @@ -13825,9 +13823,7 @@ llama_token llama_sample_token_mirostat(struct llama_context * ctx, llama_token_ // Update mu using the learning rate and error *mu = *mu - eta * e; - if (ctx) { - ctx->t_sample_us += ggml_time_us() - t_start_sample_us; - } + ctx->t_sample_us += ggml_time_us() - t_start_sample_us; return X; }