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.3.tar.gz (33.2 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.3-cp38-abi3-win_amd64.whl (498.0 kB view details)

Uploaded CPython 3.8+Windows x86-64

pt_safe_loader-0.1.3-cp38-abi3-manylinux_2_34_x86_64.whl (590.3 kB view details)

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

pt_safe_loader-0.1.3-cp38-abi3-macosx_11_0_arm64.whl (520.5 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: pt_safe_loader-0.1.3.tar.gz
  • Upload date:
  • Size: 33.2 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.3.tar.gz
Algorithm Hash digest
SHA256 2f5af3860a0f5da23c4c854ee58050f2d849c791c52a91a407a7a5fab92e330b
MD5 0802bc6509ef99162cf4f1b58456acbb
BLAKE2b-256 baa7cf79d37f8b230bcf591d4d20211a87aa8f23ff1fa39895062ca207197cff

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pt_safe_loader-0.1.3-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 04fe2b5585150f47630304eece92f81dc22006242facbb0e1edd7c51cfaca2d5
MD5 a3311c1d436701894915922abf05838f
BLAKE2b-256 6bfeabb0c39ea94d59221a015cf1021b6d3c57d7d2c4f3577e083722f2031690

See more details on using hashes here.

Provenance

The following attestation bundles were made for pt_safe_loader-0.1.3-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.3-cp38-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pt_safe_loader-0.1.3-cp38-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 fbb36f43e5cbc0ff3c18ead8430c9f59c303591f0a60f97ffc20909562546c24
MD5 f9427e34f950bcd6a4094960c84e667c
BLAKE2b-256 617df7f05d089dae2f61e6c3f432c9531c7a966d999ce89f69f90d3c22973192

See more details on using hashes here.

Provenance

The following attestation bundles were made for pt_safe_loader-0.1.3-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.3-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pt_safe_loader-0.1.3-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 571b4b0689f9e6ed65458fd7e5a08e1cf986e296f8d926fb117719edd763767c
MD5 d3025e75fc9e6acc5c6ef9c2ba59b399
BLAKE2b-256 a5bfb1cec6f1fea7dfa693f4c6d6d8e742e90e3760f6e82ced8bf16212aaa4a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pt_safe_loader-0.1.3-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