Skip to main content

Safe parser-based PyTorch checkpoint converter to safetensors

Project description

pt-loader

CI Crates.io docs.rs PyPI Python Versions License: MIT

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 .pt checkpoints 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.

Installation

Python

Install from PyPI:

pip install pt-safe-loader

Install from source (local repo):

uv sync --group dev
uv run maturin develop --features pyo3

Rust

Add dependency:

[dependencies]
pt-loader = "0.1"

Python Usage

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

pt_safe_loader-0.1.4.tar.gz (39.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pt_safe_loader-0.1.4-cp38-abi3-win_amd64.whl (506.9 kB view details)

Uploaded CPython 3.8+Windows x86-64

pt_safe_loader-0.1.4-cp38-abi3-manylinux_2_34_x86_64.whl (599.9 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.34+ x86-64

pt_safe_loader-0.1.4-cp38-abi3-macosx_11_0_arm64.whl (530.1 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

File details

Details for the file pt_safe_loader-0.1.4.tar.gz.

File metadata

  • Download URL: pt_safe_loader-0.1.4.tar.gz
  • Upload date:
  • Size: 39.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pt_safe_loader-0.1.4.tar.gz
Algorithm Hash digest
SHA256 f0e252d6d5606122b66d4764232b5898818a4c5d9f3bc5987d1bc14cc8d85eee
MD5 5fbea89aa2b7cd94625a3f7d46d3d4eb
BLAKE2b-256 3e896d22d7036ce04e2d8a30ae45e6638d4d90041b39aac619ca920855cacec6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pt_safe_loader-0.1.4.tar.gz:

Publisher: release.yml on a-gradient/pt-loader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pt_safe_loader-0.1.4-cp38-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for pt_safe_loader-0.1.4-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 69370080c617ea0d381dd42732d577c8856c87c222245634b55156493440326a
MD5 004e49d0bc194cc6b946d6dfbdaff2e3
BLAKE2b-256 f2b21687291bb341fc4590dfd9e2be271bc04760dfd89680ef07fbc675c33f89

See more details on using hashes here.

Provenance

The following attestation bundles were made for pt_safe_loader-0.1.4-cp38-abi3-win_amd64.whl:

Publisher: release.yml on a-gradient/pt-loader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pt_safe_loader-0.1.4-cp38-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pt_safe_loader-0.1.4-cp38-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 36147db57bb2cd7bbdf84db46e23a4d823f201d5fa5fd6964c6f0e6f5fa40e45
MD5 3e86ad07678d2ce01aeecff96a47462b
BLAKE2b-256 8c3f19bb3a14bfc31f84eb7c7e85c43eaf2b1cf9336bc438b4e41bc5024e8a07

See more details on using hashes here.

Provenance

The following attestation bundles were made for pt_safe_loader-0.1.4-cp38-abi3-manylinux_2_34_x86_64.whl:

Publisher: release.yml on a-gradient/pt-loader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pt_safe_loader-0.1.4-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pt_safe_loader-0.1.4-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 58004dbf27f349e064ae726ea8587ab34722721a0bf17311382cbd97a303bd72
MD5 ca959d132e27a77d46798c0e7145708a
BLAKE2b-256 f8f8979020e15b0b7a0a11ed95d790b70733a2bfee46761dd35e916dc26389b2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pt_safe_loader-0.1.4-cp38-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on a-gradient/pt-loader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page