EXAONE-Deep-7.8B-GGUF / exaone-gguf-fallback.patch
Calvin806's picture
Add files using upload-large-folder tool
4771568 verified
diff --git a/src/llama-model-loader.cpp b/src/llama-model-loader.cpp
index bd9e6da88..5a120d69a 100644
--- a/src/llama-model-loader.cpp
+++ b/src/llama-model-loader.cpp
@@ -1,4 +1,26 @@
#include "llama-model-loader.h"
+#include <cstring>
+
+// EXAONE_GGUF_FIND_KEY_MACRO_HOOK
+// Hook gguf_find_key() inside this translation unit to handle EPS/RMS key mismatch for EXAONE.
+static auto gguf_find_key_orig = &gguf_find_key;
+
+static int gguf_find_key_exaone_fallback(const gguf_context * ctx, const char * key) {
+ int kid = gguf_find_key_orig(ctx, key);
+ if (kid >= 0) return kid;
+
+ if (strcmp(key, "exaone.attention.layer_norm_epsilon") == 0) {
+ return gguf_find_key_orig(ctx, "exaone.attention.layer_norm_rms_epsilon");
+ }
+ if (strcmp(key, "exaone.attention.layer_norm_rms_epsilon") == 0) {
+ return gguf_find_key_orig(ctx, "exaone.attention.layer_norm_epsilon");
+ }
+ return -1;
+}
+
+// Redirect all gguf_find_key calls in this file
+#define gguf_find_key(ctx, key) gguf_find_key_exaone_fallback((ctx), (key))
+
#include "ggml.h"