#124124th of 206 in ML frameworks and libraries

safetensors

Tensor file format and library that avoids pickle, with zero-copy lazy loading

Stars
4k
License
Apache-2.0
Last commit
Nov 2026
Last release
Jun 2026
Language
Rust
Stars, last 29 weeks+277
22 Apr 2026: 3,686 stars29 Apr 2026: 3,700 stars6 May 2026: 3,705 stars13 May 2026: 3,714 stars20 May 2026: 3,724 stars27 May 2026: 3,734 stars3 Jun 2026: 3,741 stars10 Jun 2026: 3,748 stars17 Jun 2026: 3,761 stars24 Jun 2026: 3,771 stars1 Jul 2026: 3,780 stars8 Jul 2026: 3,789 stars15 Jul 2026: 3,797 stars22 Jul 2026: 3,802 stars29 Jul 2026: 3,824 stars5 Aug 2026: 3,833 stars12 Aug 2026: 3,840 stars19 Aug 2026: 3,851 stars26 Aug 2026: 3,865 stars2 Sept 2026: 3,875 stars9 Sept 2026: 3,883 stars16 Sept 2026: 3,890 stars23 Sept 2026: 3,895 stars30 Sept 2026: 3,902 stars7 Oct 2026: 3,908 stars14 Oct 2026: 3,918 stars21 Oct 2026: 3,930 stars28 Oct 2026: 3,936 stars4 Nov 2026: 3,943 stars11 Nov 2026: 3,963 stars

3,686 on 22 Apr 20263,963 on 11 Nov 2026

From GitHub's daily star counts.

Checked on GitHub.

Overview

Safetensors defines a simple file layout for tensors: an 8-byte little-endian header size, a JSON header with dtype, shape and offsets, then a raw byte buffer. The Rust core ships with Python bindings (pip install safetensors) that save and load tensors via safe_open and save_file, including PyTorch. Loading never executes code, the header is capped at 100MB, and tensors can be read individually without scanning the whole file.

Who it is for: Engineers saving, sharing or loading model weights safely and quickly

Strengths

  • Loading a file cannot run arbitrary code, unlike pickle-based PyTorch checkpoints
  • Lazy loading of single tensors; README reports BLOOM on 8 GPUs dropping from 10 min to 45 s
  • Native bfloat16 and fp8 dtypes, and no file size limit
  • Format is small and documented; Rust crate plus Python bindings on PyPI and crates.io

Weaknesses

  • Stores only tensors and string metadata, no custom code or arbitrary structures
  • No strided tensors; everything must be packed before serialization
  • Sub-byte dtypes error out on unaligned reads
  • Not fully zero-copy: header is JSON and GPU loads still copy from disk

What it needs

  • no GPU
  • Docker
  • Needs Rust toolchain (build from source only), setuptools_rust (build from source only)
  • Models: PyTorch, TensorFlow, Flax, NumPy

What changed

  1. “The serialize and serializefile functions now release the GIL during writes, enabling true multithreaded saves from Python. Their input contract has also changed: tensor metadata is now passed via a …”

From the release notes. No flag means the note does not say so, not that the upgrade is safe.

Also in ML frameworks and libraries

See all 206
Also in ML frameworks and libraries
RankProjectScore
1transformersPython library defining open models for text, vision, audio and multimodal tasks168.9k stars+1,573 (+0.9%) in 30 daysApache-2.094 out of 100
2ultralyticsPython library and CLI for training and running YOLO vision models63.3k stars+1,004 (+1.6%) in 30 daysAGPL-3.094 out of 100
3pytorchPython tensor library with GPU support and tape-based autograd105.5k stars+1,036 (+1.0%) in 30 dayscustom license93 out of 100
#4pytorch-image-modelsPyTorch library of image models, pretrained weights and training scripts37.3k stars+107 (+0.3%) in 30 daysApache-2.093 out of 100
#5supervisionPython toolkit for loading, annotating and counting computer vision detections Live demo ↗ (opens in a new tab)51.6k stars+521 (+1.0%) in 30 daysMIT92 out of 100