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.

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:

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.yml will:
    • publish to crates.io using CRATES_IO_TOKEN
    • build and publish to PyPI via trusted publishing

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.1.tar.gz (25.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.1-cp38-abi3-win_amd64.whl (428.5 kB view details)

Uploaded CPython 3.8+Windows x86-64

pt_safe_loader-0.1.1-cp38-abi3-manylinux_2_34_x86_64.whl (524.8 kB view details)

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

pt_safe_loader-0.1.1-cp38-abi3-macosx_11_0_arm64.whl (459.2 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: pt_safe_loader-0.1.1.tar.gz
  • Upload date:
  • Size: 25.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.1.tar.gz
Algorithm Hash digest
SHA256 1e06026726ff9831752f0fc0f53d49b2b269c42e963cea0cb69e78f9bb0ef99c
MD5 b62445cc9bfb22858882cbe0936adf36
BLAKE2b-256 fcc21880e5c85c37a7119bb0575a833724fc721954f1826bca541351fadbcd06

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pt_safe_loader-0.1.1-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 4587f9385064572f71c8e73b19a08f06bd7f1bc60c013f03a441468a5e09f486
MD5 72c8efd3814b078084392f537c9ae7b0
BLAKE2b-256 7ddc91e720aafde49334edd1525151dd249487a53b7770edd88a1e96a960be54

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pt_safe_loader-0.1.1-cp38-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 2cebccad30455dd27a4efa2bed6e3bff3ef337fd877a63dacbb884545e91c237
MD5 317619c6cd41c6612a00b372eb4cf1ca
BLAKE2b-256 3243e307aff6cace9f34d4dbe9d01f600d478769bbb5d6240cedfbca2026d3e0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pt_safe_loader-0.1.1-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bd3f4c235f9106205abdde1b15066864f9b11b4361f41668ec452937d8d5d9cf
MD5 d1c36946c03ee5eccf961e35efc842e4
BLAKE2b-256 0ae38613773873f79590c95c2dee18042c5fd71829ceda5fc69f276cfc1f9d2a

See more details on using hashes here.

Provenance

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