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
pt_safe_loader-0.1.0.tar.gz
(5.0 MB
view details)
Built Distribution
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.0.tar.gz.
File metadata
- Download URL: pt_safe_loader-0.1.0.tar.gz
- Upload date:
- Size: 5.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c610ac27e37cdca26b8f2a07054c5cc04df825d3bdc56c69989b8a0aeb9664e8
|
|
| MD5 |
884e687a888f8ef2a2f76a6ef6a4477c
|
|
| BLAKE2b-256 |
5ea7213cefde7796f02da54d41e9f394fe8005050ec37a65530a2c3b01be5b34
|
File details
Details for the file pt_safe_loader-0.1.0-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: pt_safe_loader-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 501.6 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69350eb9596f74926628b05681cae260856856da586d6052cd0fdc74b5665a51
|
|
| MD5 |
72fe969efa321ff87e89bcde637c7094
|
|
| BLAKE2b-256 |
8a460d7c9921efd4f24bc17ef8d45ec9c3ff33961f7dbe52046711cb21d044ec
|