Update load_fsdp_to_hf.py

This commit is contained in:
joesharratt1229 2025-07-28 15:56:16 +01:00 committed by GitHub
parent 3393d22611
commit 62887ad1fc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -32,27 +32,6 @@ def main(fsdp_checkpoint_path, huggingface_model_path, output_path, push_to_hub=
tokenizer = AutoTokenizer.from_pretrained(huggingface_model_path)
tokenizer.save_pretrained(output_path)
# Push to hub if requested
if push_to_hub:
if not output_path:
raise ValueError("output path must be provided when push_to_hub=True")
print(f"Pushing model to Hugging Face Hub: {output_path}")
# Create repository if it doesn't exist
api = HfApi(token=hub_token)
try:
create_repo(repo_id=output_path, private=private, exist_ok=True, token=hub_token)
print(f"Repository {output_path} created or already exists")
except Exception as e:
print(f"Repository creation info: {e}")
# Push model and tokenizer to hub
model.push_to_hub(output_path, token=hub_token, private=private)
tokenizer.push_to_hub(output_path, token=hub_token, private=private)
print(f"✅ Model successfully pushed to https://huggingface.co/{output_path}")
if __name__ == "__main__":
fire.Fire(main)