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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs] export #162

Merged
merged 2 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,20 @@ 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 username/mymodel /path/to/save/converted_model . --private
```
The repo will be created if `repo_id` does not exist. The `--private` will create the repo as a private repo and cab ne ommited to create a publicly accessible repo.
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