]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
Add LLAMA_DEFAULT_RMS_EPS so we can change the default (#2384)
authorKawrakow <redacted>
Tue, 25 Jul 2023 15:35:53 +0000 (18:35 +0300)
committerGitHub <redacted>
Tue, 25 Jul 2023 15:35:53 +0000 (18:35 +0300)
Co-authored-by: Iwan Kawrakow <redacted>
examples/baby-llama/baby-llama.cpp
examples/common.h
examples/train-text-from-scratch/train-text-from-scratch.cpp
llama.cpp
llama.h

index f9dc0aaa61ed17a932c20534c33fcb2fd1146b84..6fa55b3194676ca0d126842859b96ba846daba07 100644 (file)
@@ -8,7 +8,11 @@
 #pragma warning(disable: 4244 4267) // possible loss of data
 #endif
 
-static const float rms_norm_eps = 1e-6f;
+#ifdef LLAMA_DEFAULT_RMS_EPS
+static const float rms_norm_eps = LLAMA_DEFAULT_RMS_EPS;
+#else
+static const float rms_norm_eps = 5e-6f;
+#endif
 
 float frand() {
     return (float)rand()/(float)RAND_MAX;
index 2d87c923b43f05866a215c503513e5ecef095f92..672dcf77c8f992166ebeba2b5a7e630ac59172b9 100644 (file)
@@ -34,7 +34,7 @@ struct gpt_params {
     int32_t main_gpu                        = 0;    // the GPU that is used for scratch and small tensors
     float   tensor_split[LLAMA_MAX_DEVICES] = {0};  // how split tensors should be distributed across GPUs
     int32_t n_probs                         = 0;    // if greater than 0, output the probabilities of top n_probs tokens.
-    float   rms_norm_eps                    = 1e-6; // rms norm epsilon
+    float   rms_norm_eps                    = LLAMA_DEFAULT_RMS_EPS; // rms norm epsilon
     float   rope_freq_base                  = 10000.0f; // RoPE base frequency
     float   rope_freq_scale                 = 1.0f;     // RoPE frequency scaling factor
 
index 4bbf6b7826c62205324febcca1bda8e1165aefb1..54dc2beed00809793613989767f01232ee31391c 100644 (file)
@@ -16,7 +16,7 @@
 #pragma warning(disable: 4244 4267) // possible loss of data
 #endif
 
-static const float rms_norm_eps = 1e-6f;
+static const float rms_norm_eps = LLAMA_DEFAULT_RMS_EPS;
 
 struct random_normal_distribution {
     std::mt19937 gen;
index febefbacf313a0023bd4b40346d9a108f4b028a1..30d4b0a6e6c7c8c79e3b1ee3beef3106bd040946 100644 (file)
--- a/llama.cpp
+++ b/llama.cpp
@@ -186,7 +186,7 @@ struct llama_hparams {
     // LLaMAv2
     // TODO: load from model data hparams
     float f_ffn_mult = 1.0f;
-    float f_rms_norm_eps = 1e-6f;
+    float f_rms_norm_eps = LLAMA_DEFAULT_RMS_EPS;
 
     float rope_freq_base  = 10000.0f;
     float rope_freq_scale = 1.0f;
@@ -870,7 +870,7 @@ struct llama_context_params llama_context_default_params() {
         /*.n_ctx                       =*/ 512,
         /*.n_batch                     =*/ 512,
         /*.n_gqa                       =*/ 1,
-        /*.rms_norm_eps                =*/ 1e-6f,
+        /*.rms_norm_eps                =*/ LLAMA_DEFAULT_RMS_EPS,
         /*.gpu_layers                  =*/ 0,
         /*.main_gpu                    =*/ 0,
         /*.tensor_split                =*/ nullptr,
diff --git a/llama.h b/llama.h
index 843b0bf5f7f5a5bdc34d6f6e0a8217b0f483ff36..df46f9b9cfa311ea78906e5d4eb1f7c8a651e055 100644 (file)
--- a/llama.h
+++ b/llama.h
 #define LLAMA_SUPPORTS_GPU_OFFLOAD
 #endif
 
+#ifndef LLAMA_DEFAULT_RMS_EPS
+#define LLAMA_DEFAULT_RMS_EPS 5e-6f
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif