Useful tools for working with pytorch checkpoints and popular machine learning libraries.
Project description
Checkpoint Tools
A small collection of helpful command-line tools for working with PyTorch checkpoints.
Installation
pip install checkpoint-tools
Available Commands
See all with checkpoint-tools --help
metadata
Usage: checkpoint-tools metadata [OPTIONS] INPUT_FILE
Print metadata of a SafeTensors checkpoint.
Options:
--help Show this message and exit.
convert
Usage: checkpoint-tools convert [OPTIONS] INPUT_FILE
Convert a PyTorch/SafeTensors checkpoint to SafeTensors format, optionally
changing the precision of the (floating point) tensors.
Writes the file with a suffix appropriate for the precision of the tensors
in the state dictionary.
Options:
--float8-e5m2-fn-uz Convert all floating point tensors to
float8-e5m2-fn-uz (5 exponent bits, 2 mantissa
bits, finite numbers only, no negative zero)
--float8-e5m2 Convert all floating point tensors to
float8-e5m2 (5 exponent bits, 2 mantissa bits)
--float8-e4m3-fn-uz Convert all floating point tensors to
float8-e4m3-fn-uz (4 exponent bits, 3 mantissa
bits, finite numbers only, no negative zero)
--float8-e4m3-fn Convert all floating point tensors to
float8-e4m3-fn (4 exponent bits, 3 mantissa
bits, finite numbers only)
--bfloat16 Convert all floating point tensors to bfloat16
--float16 Convert all floating point tensors to float16
--full Leave all tensors as full precision
--replace-key TEXT Keys to replace, use `:` to separate old and
new key parts
--ignore-key TEXT Keys to ignore
--overwrite / --no-overwrite Overwrite output file if it exists
--name TEXT Output file name
--help Show this message and exit.
convert-to-diffusers
Usage: checkpoint-tools convert-to-diffusers [OPTIONS] INPUT_FILE
Convert a non-diffusers PyTorch/SafeTensors checkpoint to Diffusers format
in SafeTensors.
Writes the file with a suffix appropriate for the precision of the tensors
in the state dictionary.
Supported model types:
Stable Diffusion 1.5
Stable Diffusion XL
Stable Diffusion 3.5
FLUX.Dev
FLUX.Schnell
Options:
--name TEXT Output file name
--model-type TEXT Model type, default inferred from state
dictionary
--int8 Quantize all floating point tensors to 8-bit
integer using bitsandbytes
--nf4 Quantize all floating point tensors to
normalized float4 using bitsandbytes
--float8-e5m2-fn-uz Convert all floating point tensors to
float8-e5m2-fn-uz (5 exponent bits, 2 mantissa
bits, finite numbers only, no negative zero)
--float8-e5m2 Convert all floating point tensors to
float8-e5m2 (5 exponent bits, 2 mantissa bits)
--float8-e4m3-fn-uz Convert all floating point tensors to
float8-e4m3-fn-uz (4 exponent bits, 3 mantissa
bits, finite numbers only, no negative zero)
--float8-e4m3-fn Convert all floating point tensors to
float8-e4m3-fn (4 exponent bits, 3 mantissa
bits, finite numbers only)
--bfloat16 Convert all floating point tensors to bfloat16
--float16 Convert all floating point tensors to float16
--full Leave all tensors as full precision
--replace-key TEXT Keys to replace, use `:` to separate old and
new key parts
--ignore-key TEXT Keys to ignore
--overwrite / --no-overwrite Overwrite output file if it exists
--name TEXT Output file name
--help Show this message and exit.
combine
Usage: checkpoint-tools combine [OPTIONS] [INPUT_FILES]...
Combine multiple checkpoints into a single checkpoint.
Options:
--float8-e5m2-fn-uz Convert all floating point tensors to
float8-e5m2-fn-uz (5 exponent bits, 2 mantissa
bits, finite numbers only, no negative zero)
--float8-e5m2 Convert all floating point tensors to
float8-e5m2 (5 exponent bits, 2 mantissa bits)
--float8-e4m3-fn-uz Convert all floating point tensors to
float8-e4m3-fn-uz (4 exponent bits, 3 mantissa
bits, finite numbers only, no negative zero)
--float8-e4m3-fn Convert all floating point tensors to
float8-e4m3-fn (4 exponent bits, 3 mantissa
bits, finite numbers only)
--bfloat16 Convert all floating point tensors to bfloat16
--float16 Convert all floating point tensors to float16
--full Leave all tensors as full precision
--replace-key TEXT Keys to replace, use `:` to separate old and
new key parts
--ignore-key TEXT Keys to ignore
--overwrite / --no-overwrite Overwrite output file if it exists
--name TEXT Output file name
--help Show this message and exit.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
checkpoint_tools-0.2.0.tar.gz
(15.6 kB
view details)
File details
Details for the file checkpoint_tools-0.2.0.tar.gz.
File metadata
- Download URL: checkpoint_tools-0.2.0.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d68f5290761d2da62d435f5c5d9eaf99cb46ef1e1fccb40d867b1de3cb26721
|
|
| MD5 |
ccbe3874cf70215966aa5acc917b2d43
|
|
| BLAKE2b-256 |
9982366ffedfb84684a4ae4210bcc308dd86ab537942776551f432a348ae813f
|