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.0.tar.gz (5.0 MB view details)

Uploaded Source

Built Distribution

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

pt_safe_loader-0.1.0-cp313-cp313-macosx_11_0_arm64.whl (501.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Hashes for pt_safe_loader-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c610ac27e37cdca26b8f2a07054c5cc04df825d3bdc56c69989b8a0aeb9664e8
MD5 884e687a888f8ef2a2f76a6ef6a4477c
BLAKE2b-256 5ea7213cefde7796f02da54d41e9f394fe8005050ec37a65530a2c3b01be5b34

See more details on using hashes here.

File details

Details for the file pt_safe_loader-0.1.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pt_safe_loader-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 69350eb9596f74926628b05681cae260856856da586d6052cd0fdc74b5665a51
MD5 72fe969efa321ff87e89bcde637c7094
BLAKE2b-256 8a460d7c9921efd4f24bc17ef8d45ec9c3ff33961f7dbe52046711cb21d044ec

See more details on using hashes here.

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