Safe parser-based PyTorch checkpoint converter to safetensors
Project description
pt-loader
Safe parser-based PyTorch checkpoint converter to safetensors with both Rust and Python APIs.
Features
- Parses torch zip
.ptcheckpoints with strict safety limits. - Converts checkpoints to
model.safetensors+model.yaml. - Inspects checkpoint metadata and tensor summaries.
- Loads tensors directly into Python as NumPy arrays.
Python Usage
Install from source (local repo):
uv sync --group dev
uv run pytest -q
Example:
import pt_loader
report = pt_loader.inspect("samples/yolo26n.pt")
print(report["tensor_count"])
result = pt_loader.convert("samples/yolo26n.pt", out_dir="out")
print(result["safetensors_path"])
tensors = pt_loader.load_pt("samples/yolo26n.pt")
print(next(iter(tensors.values())).shape)
Rust Usage
use pt_loader::{convert_pt_to_safetensors, inspect_pt, ConvertOptions};
use std::path::Path;
let report = inspect_pt(Path::new("samples/yolo26n.pt"))?;
let result = convert_pt_to_safetensors(
Path::new("samples/yolo26n.pt"),
Path::new("out"),
ConvertOptions::default(),
)?;
Development
cargo test
cargo check --features pyo3
uv run pytest -q
Releasing
- Tag a release as
vX.Y.Z. - GitHub Actions workflow
.github/workflows/release.ymlwill:- publish to crates.io using
CRATES_IO_TOKEN - build and publish to PyPI via trusted publishing
- publish to crates.io using
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pt_safe_loader-0.1.1.tar.gz.
File metadata
- Download URL: pt_safe_loader-0.1.1.tar.gz
- Upload date:
- Size: 25.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e06026726ff9831752f0fc0f53d49b2b269c42e963cea0cb69e78f9bb0ef99c
|
|
| MD5 |
b62445cc9bfb22858882cbe0936adf36
|
|
| BLAKE2b-256 |
fcc21880e5c85c37a7119bb0575a833724fc721954f1826bca541351fadbcd06
|
Provenance
The following attestation bundles were made for pt_safe_loader-0.1.1.tar.gz:
Publisher:
release.yml on a-gradient/pt-loader
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pt_safe_loader-0.1.1.tar.gz -
Subject digest:
1e06026726ff9831752f0fc0f53d49b2b269c42e963cea0cb69e78f9bb0ef99c - Sigstore transparency entry: 1330676535
- Sigstore integration time:
-
Permalink:
a-gradient/pt-loader@38b09c3a9109db47b5b9ea232a54c76023c12b0a -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/a-gradient
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@38b09c3a9109db47b5b9ea232a54c76023c12b0a -
Trigger Event:
push
-
Statement type:
File details
Details for the file pt_safe_loader-0.1.1-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: pt_safe_loader-0.1.1-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 428.5 kB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4587f9385064572f71c8e73b19a08f06bd7f1bc60c013f03a441468a5e09f486
|
|
| MD5 |
72c8efd3814b078084392f537c9ae7b0
|
|
| BLAKE2b-256 |
7ddc91e720aafde49334edd1525151dd249487a53b7770edd88a1e96a960be54
|
Provenance
The following attestation bundles were made for pt_safe_loader-0.1.1-cp38-abi3-win_amd64.whl:
Publisher:
release.yml on a-gradient/pt-loader
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pt_safe_loader-0.1.1-cp38-abi3-win_amd64.whl -
Subject digest:
4587f9385064572f71c8e73b19a08f06bd7f1bc60c013f03a441468a5e09f486 - Sigstore transparency entry: 1330676792
- Sigstore integration time:
-
Permalink:
a-gradient/pt-loader@38b09c3a9109db47b5b9ea232a54c76023c12b0a -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/a-gradient
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@38b09c3a9109db47b5b9ea232a54c76023c12b0a -
Trigger Event:
push
-
Statement type:
File details
Details for the file pt_safe_loader-0.1.1-cp38-abi3-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: pt_safe_loader-0.1.1-cp38-abi3-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 524.8 kB
- Tags: CPython 3.8+, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2cebccad30455dd27a4efa2bed6e3bff3ef337fd877a63dacbb884545e91c237
|
|
| MD5 |
317619c6cd41c6612a00b372eb4cf1ca
|
|
| BLAKE2b-256 |
3243e307aff6cace9f34d4dbe9d01f600d478769bbb5d6240cedfbca2026d3e0
|
Provenance
The following attestation bundles were made for pt_safe_loader-0.1.1-cp38-abi3-manylinux_2_34_x86_64.whl:
Publisher:
release.yml on a-gradient/pt-loader
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pt_safe_loader-0.1.1-cp38-abi3-manylinux_2_34_x86_64.whl -
Subject digest:
2cebccad30455dd27a4efa2bed6e3bff3ef337fd877a63dacbb884545e91c237 - Sigstore transparency entry: 1330676934
- Sigstore integration time:
-
Permalink:
a-gradient/pt-loader@38b09c3a9109db47b5b9ea232a54c76023c12b0a -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/a-gradient
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@38b09c3a9109db47b5b9ea232a54c76023c12b0a -
Trigger Event:
push
-
Statement type:
File details
Details for the file pt_safe_loader-0.1.1-cp38-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: pt_safe_loader-0.1.1-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 459.2 kB
- Tags: CPython 3.8+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd3f4c235f9106205abdde1b15066864f9b11b4361f41668ec452937d8d5d9cf
|
|
| MD5 |
d1c36946c03ee5eccf961e35efc842e4
|
|
| BLAKE2b-256 |
0ae38613773873f79590c95c2dee18042c5fd71829ceda5fc69f276cfc1f9d2a
|
Provenance
The following attestation bundles were made for pt_safe_loader-0.1.1-cp38-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on a-gradient/pt-loader
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pt_safe_loader-0.1.1-cp38-abi3-macosx_11_0_arm64.whl -
Subject digest:
bd3f4c235f9106205abdde1b15066864f9b11b4361f41668ec452937d8d5d9cf - Sigstore transparency entry: 1330676652
- Sigstore integration time:
-
Permalink:
a-gradient/pt-loader@38b09c3a9109db47b5b9ea232a54c76023c12b0a -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/a-gradient
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@38b09c3a9109db47b5b9ea232a54c76023c12b0a -
Trigger Event:
push
-
Statement type: