(input_dir_or_checkpoint: str, output_file: str)
| 63 | |
| 64 | |
| 65 | def convert_weights(input_dir_or_checkpoint: str, output_file: str) -> None: |
| 66 | pt_path = os.path.join(input_dir_or_checkpoint, "pytorch_model.bin") |
| 67 | print("Loading checkpoint from file...") |
| 68 | sd = torch.load(pt_path, map_location="cpu", weights_only=True) |
| 69 | print("Converting checkpoint...") |
| 70 | sd = codegen_hf_to_meta(sd) |
| 71 | |
| 72 | print("Saving checkpoint...") |
| 73 | torch.save(sd, output_file) |
| 74 | print("Done.") |
| 75 | |
| 76 | |
| 77 | def main(): |
no test coverage detected