Przeglądaj źródła

scripts : Use mmap in torch load (#4202)

* Use mmap in torch load, prefer .bin files when loading

* Revert .bin > .safetensors preference
Galunid 2 lat temu
rodzic
commit
1ddb52ec38
1 zmienionych plików z 1 dodań i 1 usunięć
  1. 1 1
      convert-hf-to-gguf.py

+ 1 - 1
convert-hf-to-gguf.py

@@ -59,7 +59,7 @@ class Model:
                 from safetensors import safe_open
                 from safetensors import safe_open
                 ctx = cast(ContextManager[Any], safe_open(self.dir_model / part_name, framework="pt", device="cpu"))
                 ctx = cast(ContextManager[Any], safe_open(self.dir_model / part_name, framework="pt", device="cpu"))
             else:
             else:
-                ctx = contextlib.nullcontext(torch.load(self.dir_model / part_name, map_location="cpu"))
+                ctx = contextlib.nullcontext(torch.load(str(self.dir_model / part_name), map_location="cpu", mmap=True, weights_only=True))
 
 
             with ctx as model_part:
             with ctx as model_part:
                 for name in model_part.keys():
                 for name in model_part.keys():