From 9f97e01fbbfb24fc1f0964bb53703ecd2b2345ed Mon Sep 17 00:00:00 2001 From: Jack-Khuu Date: Wed, 18 Sep 2024 16:44:20 -0700 Subject: [PATCH 1/2] Remove unnecessary __dict__ access from ModelArgs.transformer_args --- torchchat/cli/convert_hf_checkpoint.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torchchat/cli/convert_hf_checkpoint.py b/torchchat/cli/convert_hf_checkpoint.py index adf27885d..70dda316f 100644 --- a/torchchat/cli/convert_hf_checkpoint.py +++ b/torchchat/cli/convert_hf_checkpoint.py @@ -33,7 +33,7 @@ def convert_hf_checkpoint( model_name = model_dir.name config = ModelArgs.from_name(model_name).transformer_args['text'] - print(f"Model config {config.__dict__}") + print(f"Model config {config}") # Load the json file containing weight mapping model_map_json = model_dir / "pytorch_model.bin.index.json" From e6ed31a714265be151134f1a65896a578426c254 Mon Sep 17 00:00:00 2001 From: Jack-Khuu Date: Wed, 18 Sep 2024 17:07:26 -0700 Subject: [PATCH 2/2] Refix by casting to TransformerArgs --- torchchat/cli/convert_hf_checkpoint.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/torchchat/cli/convert_hf_checkpoint.py b/torchchat/cli/convert_hf_checkpoint.py index 70dda316f..f90b59c25 100644 --- a/torchchat/cli/convert_hf_checkpoint.py +++ b/torchchat/cli/convert_hf_checkpoint.py @@ -12,6 +12,8 @@ import torch +from torchchat.model import TransformerArgs + # support running without installing as a package wd = Path(__file__).parent.parent sys.path.append(str(wd.resolve())) @@ -32,8 +34,9 @@ def convert_hf_checkpoint( if model_name is None: model_name = model_dir.name - config = ModelArgs.from_name(model_name).transformer_args['text'] - print(f"Model config {config}") + config_args = ModelArgs.from_name(model_name).transformer_args['text'] + config = TransformerArgs.from_params(config_args) + print(f"Model config {config.__dict__}") # Load the json file containing weight mapping model_map_json = model_dir / "pytorch_model.bin.index.json"