Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix checkpoint converter to use arguments before default behavior of checking yaml #392

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 19 additions & 18 deletions src/llama_recipes/inference/checkpoint_converter_fsdp_hf.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,26 @@ def main(
HF_model_path_or_name="" # Path/ name of the HF model that include config.json and tokenizer_config.json (e.g. meta-llama/Llama-2-7b-chat-hf)
):

try:
file_name = 'train_params.yaml'
# Combine the directory and file name to create the full path
train_params_path = os.path.join(fsdp_checkpoint_path, file_name)
# Open the file
with open(train_params_path, 'r') as file:
# Load the YAML data
data = yaml.safe_load(file)

# Access the 'model_name' field
HF_model_path_or_name = data.get('model_name')

if not HF_model_path_or_name:
try:
file_name = 'train_params.yaml'
# Combine the directory and file name to create the full path
train_params_path = os.path.join(fsdp_checkpoint_path, file_name)
# Open the file
with open(train_params_path, 'r') as file:
# Load the YAML data
data = yaml.safe_load(file)

# Access the 'model_name' field
HF_model_path_or_name = data.get('model_name')

print(f"Model name: {HF_model_path_or_name}")
except FileNotFoundError:
print(f"The file {train_params_path} does not exist.")
HF_model_path_or_name = input("Please enter the model name: ")
print(f"Model name: {HF_model_path_or_name}")
except FileNotFoundError:
print(f"The file {train_params_path} does not exist.")
HF_model_path_or_name = input("Please enter the model name: ")
print(f"Model name: {HF_model_path_or_name}")
except Exception as e:
print(f"An error occurred: {e}")
except Exception as e:
print(f"An error occurred: {e}")


#load the HF model definition from config
Expand Down