From a1968c2e6380c91b4a16ec805ca996a7edeaee35 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Wed, 27 Mar 2024 19:03:43 +0200 Subject: [PATCH] sync : ggml ggml-ci --- ggml-alloc.c | 9 +++++++-- ggml-cuda/common.cuh | 13 ++++++++++--- ggml-cuda/dmmv.cu | 4 ---- scripts/sync-ggml-am.sh | 2 ++ scripts/sync-ggml.sh | 1 + 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/ggml-alloc.c b/ggml-alloc.c index 643b2e55f..7ceafec30 100644 --- a/ggml-alloc.c +++ b/ggml-alloc.c @@ -705,8 +705,13 @@ bool ggml_gallocr_reserve_n(ggml_gallocr_t galloc, struct ggml_cgraph * graph, c struct ggml_tensor * leaf = graph->leafs[i]; struct hash_node * hn = ggml_gallocr_hash_get(galloc, leaf); galloc->leaf_allocs[i].buffer_id = hn->buffer_id; - galloc->leaf_allocs[i].leaf.offset = hn->offset; - galloc->leaf_allocs[i].leaf.size_max = ggml_backend_buft_get_alloc_size(galloc->bufts[hn->buffer_id], leaf); + if (leaf->view_src || leaf->data) { + galloc->leaf_allocs[i].leaf.offset = SIZE_MAX; + galloc->leaf_allocs[i].leaf.size_max = 0; + } else { + galloc->leaf_allocs[i].leaf.offset = hn->offset; + galloc->leaf_allocs[i].leaf.size_max = ggml_backend_buft_get_alloc_size(galloc->bufts[hn->buffer_id], leaf); + } } // reallocate buffers if needed diff --git a/ggml-cuda/common.cuh b/ggml-cuda/common.cuh index 33c8ed1da..79e1d5424 100644 --- a/ggml-cuda/common.cuh +++ b/ggml-cuda/common.cuh @@ -1,7 +1,8 @@ #pragma once -#include "../ggml.h" -#include "../ggml-cuda.h" +#include "ggml.h" +#include "ggml-cuda.h" + #include #if defined(GGML_USE_HIPBLAS) @@ -11,7 +12,7 @@ #define GGML_COMMON_DECL_CUDA #define GGML_COMMON_IMPL_CUDA #endif -#include "../ggml-common.h" +#include "ggml-common.h" #include #include @@ -230,6 +231,12 @@ typedef float dfloat; // dequantize float typedef float2 dfloat2; #endif //GGML_CUDA_F16 +// dmmv = dequantize_mul_mat_vec +// TODO: remove this? +#ifndef GGML_CUDA_DMMV_X +#define GGML_CUDA_DMMV_X 32 +#endif + [[noreturn]] static __device__ void no_device_code( const char * file_name, const int line, const char * function_name, const int arch, const char * arch_list) { diff --git a/ggml-cuda/dmmv.cu b/ggml-cuda/dmmv.cu index 7156c9219..ea2950f3d 100644 --- a/ggml-cuda/dmmv.cu +++ b/ggml-cuda/dmmv.cu @@ -2,10 +2,6 @@ #include "dequantize.cuh" #include "convert.cuh" -// dmmv = dequantize_mul_mat_vec -#ifndef GGML_CUDA_DMMV_X -#define GGML_CUDA_DMMV_X 32 -#endif #ifndef GGML_CUDA_MMV_Y #define GGML_CUDA_MMV_Y 1 #endif diff --git a/scripts/sync-ggml-am.sh b/scripts/sync-ggml-am.sh index 83e6359b1..3003290f6 100755 --- a/scripts/sync-ggml-am.sh +++ b/scripts/sync-ggml-am.sh @@ -95,6 +95,7 @@ if [ -f $SRC_LLAMA/ggml-src.patch ]; then # src/ggml-backend-impl.h -> ggml-backend-impl.h # src/ggml-backend.c -> ggml-backend.c # src/ggml-common.h -> ggml-common.h + # src/ggml-cuda/* -> ggml-cuda/ # src/ggml-cuda.cu -> ggml-cuda.cu # src/ggml-cuda.h -> ggml-cuda.h # src/ggml-impl.h -> ggml-impl.h @@ -128,6 +129,7 @@ if [ -f $SRC_LLAMA/ggml-src.patch ]; then -e 's/src\/ggml-backend-impl\.h/ggml-backend-impl.h/g' \ -e 's/src\/ggml-backend\.c/ggml-backend.c/g' \ -e 's/src\/ggml-common\.h/ggml-common.h/g' \ + -e 's/src\/ggml-cuda\//ggml-cuda\//g' \ -e 's/src\/ggml-cuda\.cu/ggml-cuda.cu/g' \ -e 's/src\/ggml-cuda\.h/ggml-cuda.h/g' \ -e 's/src\/ggml-impl\.h/ggml-impl.h/g' \ diff --git a/scripts/sync-ggml.sh b/scripts/sync-ggml.sh index f1e6f0e57..d8fdaadf7 100755 --- a/scripts/sync-ggml.sh +++ b/scripts/sync-ggml.sh @@ -5,6 +5,7 @@ cp -rpv ../ggml/src/ggml-alloc.c ./ggml-alloc.c cp -rpv ../ggml/src/ggml-backend-impl.h ./ggml-backend-impl.h cp -rpv ../ggml/src/ggml-backend.c ./ggml-backend.c cp -rpv ../ggml/src/ggml-common.h ./ggml-common.h +cp -rpv ../ggml/src/ggml-cuda/* ./ggml-cuda/ cp -rpv ../ggml/src/ggml-cuda.cu ./ggml-cuda.cu cp -rpv ../ggml/src/ggml-cuda.h ./ggml-cuda.h cp -rpv ../ggml/src/ggml-impl.h ./ggml-impl.h