]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
eval-callback : stop on first NaN (#15320)
authorGeorgi Gerganov <redacted>
Thu, 14 Aug 2025 19:10:51 +0000 (22:10 +0300)
committerGitHub <redacted>
Thu, 14 Aug 2025 19:10:51 +0000 (22:10 +0300)
* eval-callback : stop on first NaN

* cont : log error

examples/eval-callback/eval-callback.cpp

index 4afd80eb454ad8624665a22b864ee403bf0698e5..61eefc7248a7e8a57c138d30f8e03db9a448f756 100644 (file)
@@ -7,6 +7,7 @@
 #include <cstdio>
 #include <string>
 #include <vector>
+#include <numeric>
 
 /**
  * This the arbitrary data which will be passed to each callback.
@@ -77,6 +78,12 @@ static void ggml_print_tensor(uint8_t * data, ggml_type type, const int64_t * ne
         LOG("                                     ]\n");
         LOG("                                     sum = %f\n", sum);
     }
+
+    // TODO: make this abort configurable/optional?
+    if (std::isnan(sum)) {
+        LOG_ERR("encountered NaN - aborting\n");
+        exit(0);
+    }
 }
 
 /**