Skip to content

Commit 7f7ddd5

Browse files
authored
Fix ggml to gguf conversion on Windows (#2733)
This fixes `RuntimeWarning: overflow encountered in long_scalars` Credit: anon (not mine)
1 parent b8ad1b6 commit 7f7ddd5

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

convert-llama-ggmlv3-to-gguf.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import sys, struct, math, argparse, warnings
1+
import sys, struct, math, argparse
22
from pathlib import Path
33

44
import numpy as np
55

66
import gguf
77

8-
warnings.filterwarnings('error')
9-
108
# Note: Does not support GGML_QKK_64
119
QK_K = 256
1210
# Items here are (block size, type size)
@@ -95,7 +93,7 @@ def load(self, data, offset):
9593
pad = ((offset + 31) & ~31) - offset
9694
offset += pad
9795
n_elems = np.prod(self.dims)
98-
n_bytes = (n_elems * tysize) // blksize
96+
n_bytes = np.int64(np.int64(n_elems) * np.int64(tysize)) // np.int64(blksize)
9997
self.start_offset = offset
10098
self.len_bytes = n_bytes
10199
offset += n_bytes
@@ -327,11 +325,7 @@ def main():
327325
data = np.memmap(cfg.input, mode = 'r')
328326
model = GGMLV3Model()
329327
print('* Scanning GGML input file')
330-
try:
331-
offset = model.load(data, 0)
332-
except OverflowError:
333-
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)
334-
raise
328+
offset = model.load(data, 0)
335329
print(f'* GGML model hyperparameters: {model.hyperparameters}')
336330
vocab_override = None
337331
params_override = None

0 commit comments

Comments
 (0)