From 3b4fe65e1cc1e7f8172cb957dcb01b207df373d8 Mon Sep 17 00:00:00 2001 From: Iwan Kawrakow Date: Wed, 28 Aug 2024 18:31:27 +0300 Subject: [PATCH] Minor --- ggml/src/ggml.c | 1 - src/llama.cpp | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ggml/src/ggml.c b/ggml/src/ggml.c index e1cf168b..939f5215 100644 --- a/ggml/src/ggml.c +++ b/ggml/src/ggml.c @@ -2181,7 +2181,6 @@ static inline float ggml_vec_add_f32_f32(const int n, const float * x, float * y return max; } #else -// TODO add AVX2 static inline float ggml_vec_add_f32_f16(const int n, const ggml_half * x, float * y, float slope) { float max = -INFINITY; for (int i = 0; i < n; ++i) { diff --git a/src/llama.cpp b/src/llama.cpp index 59370600..ad3febef 100644 --- a/src/llama.cpp +++ b/src/llama.cpp @@ -8692,8 +8692,9 @@ struct llm_build_context { struct ggml_tensor * build_inp_KQ_mask(bool causal = true) { auto nx = causal ? n_kv : n_tokens; // Note: we only use a binary mask when nx%32 == 0 because otherwise the CUDA implementation becomes way more messy + //bool can_be_binary = binary_kq && !lctx.is_encoding && !flash_attn && !hparams.use_alibi && nx%32 == 0; + //auto type = can_be_binary ? GGML_TYPE_I32 : flash_attn ? GGML_TYPE_F16 : GGML_TYPE_F32; auto type = !lctx.is_encoding ? !binary_kq || flash_attn || hparams.use_alibi || (nx%32 != 0) ? GGML_TYPE_F16 : GGML_TYPE_I32 : GGML_TYPE_F32; - //auto type = flash_attn || hparams.use_alibi || (nx%32 != 0) ? GGML_TYPE_F16 : GGML_TYPE_I32; if (type == GGML_TYPE_I32) nx /= 32; lctx.inp_KQ_mask = ggml_new_tensor_2d(ctx0, type, nx, GGML_PAD(n_tokens, GGML_KQ_MASK_PAD)); cb(lctx.inp_KQ_mask, "KQ_mask", -1); @@ -8705,6 +8706,8 @@ struct llm_build_context { GGML_ASSERT(hparams.n_swa > 0); auto nx = causal ? n_kv : n_tokens; // Note: we only use a binary mask when nx%32 == 0 because otherwise the CUDA implementation becomes way more messy + //bool can_be_binary = binary_kq && !lctx.is_encoding && !flash_attn && !hparams.use_alibi && nx%32 == 0; + //auto type = can_be_binary ? GGML_TYPE_I32 : flash_attn ? GGML_TYPE_F16 : GGML_TYPE_F32; auto type = !lctx.is_encoding ? !binary_kq || flash_attn || hparams.use_alibi || (nx%32 != 0) ? GGML_TYPE_F16 : GGML_TYPE_I32 : GGML_TYPE_F32; if (type == GGML_TYPE_I32) nx /= 32; lctx.inp_KQ_mask_swa = ggml_new_tensor_2d(ctx0, type, nx, GGML_PAD(n_tokens, GGML_KQ_MASK_PAD));