From f22da417f060a614be3e41fa3f99816bda1eaee5 Mon Sep 17 00:00:00 2001 From: Molly Sophia Date: Tue, 6 Aug 2024 23:51:17 +0800 Subject: [PATCH 1/2] Fix build with CUDA under linux Signed-off-by: Molly Sophia --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 90ae23b..56c057c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -172,7 +172,6 @@ elseif() set(GGML_STANDALONE ON) endif() -set(BUILD_SHARED_LIBS OFF) if (NOT TARGET ggml) add_subdirectory(ggml) # ... otherwise assume ggml is added by a parent CMakeLists.txt From 15ce960da46993bdbe385e4f331fe32ae744dad9 Mon Sep 17 00:00:00 2001 From: Molly Sophia Date: Wed, 7 Aug 2024 11:55:27 +0800 Subject: [PATCH 2/2] Workaround for a case when ggml sched incorrectly assigns buffer type Signed-off-by: Molly Sophia --- rwkv_graph.inc | 6 +++--- rwkv_operators.inc | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rwkv_graph.inc b/rwkv_graph.inc index fd24555..0dc417e 100644 --- a/rwkv_graph.inc +++ b/rwkv_graph.inc @@ -548,7 +548,7 @@ static struct ggml_tensor * rwkv_att_v6( ggml_reshape_1d(ctx, layer.att_time_decay, n_embed) ); - w = rwkv_exp(ctx, ggml_neg_inplace(ctx, rwkv_exp(ctx, w))); + w = rwkv_exp(ctx, ggml_neg(ctx, rwkv_exp(ctx, w))); w = ggml_reshape_4d(ctx, w, 1, head_size, head_count, sequence_length); // dup is not strictly required; doing it just in case. @@ -576,9 +576,9 @@ static struct ggml_tensor * rwkv_att_v6( x = rwkv_group_norm_eps_64e_minus5(ctx, x, head_count); // Convert back to a regular vector. x = ggml_reshape_2d(ctx, x, n_embed, sequence_length); - x = ggml_add_inplace( + x = ggml_add( ctx, - ggml_mul_inplace( + ggml_mul( ctx, x, layer.att_ln_x_weight diff --git a/rwkv_operators.inc b/rwkv_operators.inc index 0f87bc5..182a128 100644 --- a/rwkv_operators.inc +++ b/rwkv_operators.inc @@ -158,7 +158,7 @@ static void rwkv_groupnorm_impl( // Element-wise exp(x) struct ggml_tensor * rwkv_exp(struct ggml_context * ctx, struct ggml_tensor * x) { - return ggml_map_custom1_inplace(ctx, x, rwkv_exp_impl, 1, NULL); + return ggml_map_custom1(ctx, x, rwkv_exp_impl, 1, NULL); } // Element-wise 1 - x