From 389d2e6b9e109abbafafb0b19039c11d532819d4 Mon Sep 17 00:00:00 2001 From: Cebtenzzre Date: Sun, 1 Oct 2023 21:42:42 -0400 Subject: [PATCH] gguf : free tensors as they are written --- gguf-py/gguf/gguf.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gguf-py/gguf/gguf.py b/gguf-py/gguf/gguf.py index 7a54b5dcf..6cce3dbb0 100644 --- a/gguf-py/gguf/gguf.py +++ b/gguf-py/gguf/gguf.py @@ -863,7 +863,11 @@ class GGUFWriter: self.write_padding(self.fout, self.fout.tell()) if self.temp_file is None: - for tensor in self.tensors: + while True: + try: + tensor = self.tensors.pop(0) + except IndexError: + break tensor.tofile(self.fout) self.write_padding(self.fout, tensor.nbytes) return