]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
Fix ggml to gguf conversion on Windows (#2733)
authorIgnacioFDM <redacted>
Wed, 23 Aug 2023 09:31:09 +0000 (06:31 -0300)
committerGitHub <redacted>
Wed, 23 Aug 2023 09:31:09 +0000 (03:31 -0600)
This fixes `RuntimeWarning: overflow encountered in long_scalars`

Credit: anon (not mine)

convert-llama-ggmlv3-to-gguf.py

index 5b038fc0a3baf320d7bd4c5ba3832fae701d7219..86d4596804d61411e8bccec1b4be42fb07ea152a 100644 (file)
@@ -1,12 +1,10 @@
-import sys, struct, math, argparse, warnings
+import sys, struct, math, argparse
 from pathlib import Path
 
 import numpy as np
 
 import gguf
 
-warnings.filterwarnings('error')
-
 # Note: Does not support GGML_QKK_64
 QK_K = 256
 # Items here are (block size, type size)
@@ -95,7 +93,7 @@ class Tensor:
         pad = ((offset + 31) & ~31) - offset
         offset += pad
         n_elems = np.prod(self.dims)
-        n_bytes = (n_elems * tysize) // blksize
+        n_bytes = np.int64(np.int64(n_elems) * np.int64(tysize)) // np.int64(blksize)
         self.start_offset = offset
         self.len_bytes = n_bytes
         offset += n_bytes
@@ -327,11 +325,7 @@ def main():
     data = np.memmap(cfg.input, mode = 'r')
     model = GGMLV3Model()
     print('* Scanning GGML input file')
-    try:
-        offset = model.load(data, 0)
-    except OverflowError:
-        print(f'!!! Caught overflow loading tensors. The most likely issue is running on Windows but not in WSL. Try running in WSL if possible.', file = sys.stderr)
-        raise
+    offset = model.load(data, 0)
     print(f'* GGML model hyperparameters: {model.hyperparameters}')
     vocab_override = None
     params_override = None