Download export_hf.py from Gentraxyz/RecursiveComplete: direct link, hf CLI and curl.
- Browser
- Download file 588 Bytes
-
https://huggingface.co/Gentraxyz/RecursiveComplete/resolve/main/export_hf.py
- Command line
-
hf download hf://Gentraxyz/RecursiveComplete/export_hf.py
-
curl -L -o export_hf.py https://huggingface.co/Gentraxyz/RecursiveComplete/resolve/main/export_hf.py
588 Bytes
| """Run this once before uploading. Strips optimizer state and saves a clean | |
| safetensors file + config.json for Hugging Face.""" | |
| import json, torch | |
| from safetensors.torch import save_file | |
| ck = torch.load('big.pt', map_location='cpu') | |
| sd = ck['model'] | |
| # safetensors needs contiguous tensors and no shared storage (untie weights) | |
| sd = {k: v.clone().contiguous() for k, v in sd.items()} | |
| save_file(sd, 'model.safetensors') | |
| json.dump(ck['cfg'], open('config.json', 'w'), indent=2) | |
| print("wrote model.safetensors + config.json") | |
| print("config:", ck['cfg'], "| trained to iter", ck.get('iter')) | |