Skip to main content

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

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

pt_safe_loader-0.1.2.tar.gz (29.8 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.2-cp38-abi3-win_amd64.whl (463.0 kB view details)

Uploaded CPython 3.8+Windows x86-64

pt_safe_loader-0.1.2-cp38-abi3-manylinux_2_34_x86_64.whl (556.6 kB view details)

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

pt_safe_loader-0.1.2-cp38-abi3-macosx_11_0_arm64.whl (489.3 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

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

Hashes for pt_safe_loader-0.1.2.tar.gz
Algorithm Hash digest
SHA256 614907a216f14c20d0c4bb8a1d1f30b4176d7e85474b552bdc5b40d473646be0
MD5 0839f08ac65e1765c257761b2f65e26e
BLAKE2b-256 712d6cdc7ffe111721876ff05e9b74e27793cfa861d6816d05b1cc99dfffde5a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pt_safe_loader-0.1.2.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.2-cp38-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for pt_safe_loader-0.1.2-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 cebce871fca315d32d14ffa139a3ee4f0d43d3a30b147de48bfab1b97d76f08c
MD5 05657a9dd1f04945dfda02e4329fa8e0
BLAKE2b-256 df96d160cfc5b138b6f75edc4bc752d03f34cd680a9b5e9e5b364ed4d436850d

See more details on using hashes here.

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

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.2-cp38-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pt_safe_loader-0.1.2-cp38-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 90cc6a424d2fb4b25d19cf85abe1da26dd0c169d33d52dc105bad4fcf3425353
MD5 5c74ff16ed02d7abee456dcfffac5674
BLAKE2b-256 728d12eac261da0bde15d072e9f718634871055470ffee8cdde6230dee7cdb04

See more details on using hashes here.

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

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.2-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pt_safe_loader-0.1.2-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f249cc99c2a6bccb334321975344c7d0b91fde39660c868883c12e5b9284a099
MD5 95bf5dba3972884b9d109769afdcc145
BLAKE2b-256 bd157c87787ad6ae1f4f47b0c2c7236d6719d290b29c53ee4d8e9fbbea3b82ee

See more details on using hashes here.

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

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