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.
Active Development Notice
pt-loader is under active development. During v0.1.x, we may introduce breaking API and behavior changes in both Rust and Python interfaces without backward-compatibility guarantees.
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:
from pt_loader import PtCheckpoint
ckpt = PtCheckpoint.load("samples/yolo26n.pt")
print(ckpt.metadata()["tensor_count"])
result = ckpt.export(format="safetensors", dir="out")
print(result["weights_path"])
tensors = ckpt.state_dict(backend="numpy")
print(next(iter(tensors.values())).shape)
Rust Usage
use pt_loader::{ExportFormat, ExportOptions, LoadOptions, PtCheckpoint};
use std::path::Path;
let input = "samples/yolo26n.pt";
let ckpt = PtCheckpoint::load(input, LoadOptions::default())?;
let result = ckpt.export("out", ExportOptions::new(ExportFormat::Safetensors, Some(Path::new(input))))?;
println!("{}", result.weights_path.display());
Development
cargo test
cargo check --features pyo3
uv run pytest -q
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.2.tar.gz.
File metadata
- Download URL: pt_safe_loader-0.1.2.tar.gz
- Upload date:
- Size: 29.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
614907a216f14c20d0c4bb8a1d1f30b4176d7e85474b552bdc5b40d473646be0
|
|
| MD5 |
0839f08ac65e1765c257761b2f65e26e
|
|
| BLAKE2b-256 |
712d6cdc7ffe111721876ff05e9b74e27793cfa861d6816d05b1cc99dfffde5a
|
Provenance
The following attestation bundles were made for pt_safe_loader-0.1.2.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.2.tar.gz -
Subject digest:
614907a216f14c20d0c4bb8a1d1f30b4176d7e85474b552bdc5b40d473646be0 - Sigstore transparency entry: 1340065265
- Sigstore integration time:
-
Permalink:
a-gradient/pt-loader@95c428cf08f5c01a5b31fb54c40c9dc7d4e58267 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/a-gradient
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@95c428cf08f5c01a5b31fb54c40c9dc7d4e58267 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pt_safe_loader-0.1.2-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: pt_safe_loader-0.1.2-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 463.0 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 |
cebce871fca315d32d14ffa139a3ee4f0d43d3a30b147de48bfab1b97d76f08c
|
|
| MD5 |
05657a9dd1f04945dfda02e4329fa8e0
|
|
| BLAKE2b-256 |
df96d160cfc5b138b6f75edc4bc752d03f34cd680a9b5e9e5b364ed4d436850d
|
Provenance
The following attestation bundles were made for pt_safe_loader-0.1.2-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.2-cp38-abi3-win_amd64.whl -
Subject digest:
cebce871fca315d32d14ffa139a3ee4f0d43d3a30b147de48bfab1b97d76f08c - Sigstore transparency entry: 1340065304
- Sigstore integration time:
-
Permalink:
a-gradient/pt-loader@95c428cf08f5c01a5b31fb54c40c9dc7d4e58267 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/a-gradient
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@95c428cf08f5c01a5b31fb54c40c9dc7d4e58267 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pt_safe_loader-0.1.2-cp38-abi3-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: pt_safe_loader-0.1.2-cp38-abi3-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 556.6 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 |
90cc6a424d2fb4b25d19cf85abe1da26dd0c169d33d52dc105bad4fcf3425353
|
|
| MD5 |
5c74ff16ed02d7abee456dcfffac5674
|
|
| BLAKE2b-256 |
728d12eac261da0bde15d072e9f718634871055470ffee8cdde6230dee7cdb04
|
Provenance
The following attestation bundles were made for pt_safe_loader-0.1.2-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.2-cp38-abi3-manylinux_2_34_x86_64.whl -
Subject digest:
90cc6a424d2fb4b25d19cf85abe1da26dd0c169d33d52dc105bad4fcf3425353 - Sigstore transparency entry: 1340065274
- Sigstore integration time:
-
Permalink:
a-gradient/pt-loader@95c428cf08f5c01a5b31fb54c40c9dc7d4e58267 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/a-gradient
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@95c428cf08f5c01a5b31fb54c40c9dc7d4e58267 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pt_safe_loader-0.1.2-cp38-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: pt_safe_loader-0.1.2-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 489.3 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 |
f249cc99c2a6bccb334321975344c7d0b91fde39660c868883c12e5b9284a099
|
|
| MD5 |
95bf5dba3972884b9d109769afdcc145
|
|
| BLAKE2b-256 |
bd157c87787ad6ae1f4f47b0c2c7236d6719d290b29c53ee4d8e9fbbea3b82ee
|
Provenance
The following attestation bundles were made for pt_safe_loader-0.1.2-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.2-cp38-abi3-macosx_11_0_arm64.whl -
Subject digest:
f249cc99c2a6bccb334321975344c7d0b91fde39660c868883c12e5b9284a099 - Sigstore transparency entry: 1340065283
- Sigstore integration time:
-
Permalink:
a-gradient/pt-loader@95c428cf08f5c01a5b31fb54c40c9dc7d4e58267 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/a-gradient
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@95c428cf08f5c01a5b31fb54c40c9dc7d4e58267 -
Trigger Event:
push
-
Statement type: