Skip to content

Commit

Permalink
add export readme and change default dtype
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackmin801 authored and samsja committed Nov 19, 2024
1 parent 21a3543 commit e04a9d5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,19 @@ For info about the arguments to the script, do:
```bash
python3 scripts/subset_data.py --help
```

# Exporting checkpoints to huggingface compatible model
You can convert the checkpoints saved by the training script to a model that can be run with any huggingface-compatible inference engine (e.g. transformers, vLLM) using our export script.
The export script takes the training config as a positional argument and 2 keyword arguments, `ckpt.resume` which is the path to the checkpoint, `ckpt.path` which is the path you wish to save the converted model.
You may also pass the `torch_dtype` argument to either `float32` or `bfloat16` to specify the precision of the exported model weights. The default `torch_dtype` is `float32`.

Example export command:
```bash
python scripts/export_dcp.py @configs/10B/H100.toml --ckpt.path /path/to/save/converted_model --ckpt.resume /path/to/ckpt/step_84000 --torch_dtype bfloat16
```

You can then upload the model to huggingface using huggingface-cli:
```bash
# Usage: huggingface-cli upload [repo_id] [local_path] [path_in_repo]
huggingface-cli upload mymodel /path/to/save/converted_model . --private
```
2 changes: 1 addition & 1 deletion scripts/export_dcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

class ExportConfig(Config):
save_format: Literal["pt", "safetensors"] = "safetensors"
torch_dtype: Literal["float32", "bfloat16"] = "bfloat16"
torch_dtype: Literal["float32", "bfloat16"] = "float32"
with_debug_automap: bool = False


Expand Down

0 comments on commit e04a9d5

Please sign in to comment.