Skip to content

Commit

Permalink
reduce diffs with master
Browse files Browse the repository at this point in the history
  • Loading branch information
christianazinn committed Jun 5, 2024
1 parent bb5ee02 commit 5ad397d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 2 additions & 3 deletions convert-hf-to-gguf.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,8 @@ def __init__(self, dir_model: Path, ftype: gguf.LlamaFileType, fname_out: Path,
self.lazy = not eager
self.part_names = Model.get_model_part_names(self.dir_model, ".safetensors")
self.is_safetensors = len(self.part_names) > 0

if not self.is_safetensors:
self.part_names = Model.get_model_part_names(self.dir_model, ".bin")

self.hparams = Model.load_hparams(self.dir_model)
self.block_count = self.find_hparam(["n_layers", "num_hidden_layers", "n_layer"])
self.tensor_map = gguf.get_tensor_name_map(self.model_arch, self.block_count)
Expand Down Expand Up @@ -331,7 +329,7 @@ def write(self):
self.write_tensors()
self.gguf_writer.write_header_to_file()
self.gguf_writer.write_kv_data_to_file()
self.gguf_writer.write_tensors_to_file()
self.gguf_writer.write_tensors_to_file(progress=True)
self.gguf_writer.close()

def write_vocab(self):
Expand Down Expand Up @@ -1568,6 +1566,7 @@ def modify_tensors(self, data_torch: Tensor, name: str, bid: int | None) -> Iter

return [(self.map_tensor_name(name), data_torch)]


@Model.register("QWenLMHeadModel")
class QwenModel(Model):
model_arch = gguf.MODEL_ARCH.QWEN
Expand Down
5 changes: 3 additions & 2 deletions gguf-py/gguf/gguf_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ def format_n_bytes_to_str(num: int) -> str:
num /= 1024.0
return f"{num:.1f}T - over 1TB, --split recommended"


class GGUFManager(GGUFWriter):
kv_data: KVTempData
tensors: list[TensorTempData]
Expand Down Expand Up @@ -204,7 +205,7 @@ def write_kv_data_to_file(self) -> None:

self.state = WriterState.KV_DATA

def write_tensors_to_file(self) -> None:
def write_tensors_to_file(self, progress: bool = False) -> None:
if self.split_arguments.dry_run:
return

Expand All @@ -227,7 +228,7 @@ def write_tensors_to_file(self) -> None:
# need to write everything down here
writer.write_header_to_file()
writer.write_kv_data_to_file()
writer.write_tensors_to_file(progress=True)
writer.write_tensors_to_file(progress=progress)
del tensors

self.state = WriterState.TI_DATA
Expand Down

0 comments on commit 5ad397d

Please sign in to comment.