Skip to main content

Fast and Safe Tensor serialization

Project description

Installation

pip install safetensors

Usage

Numpy

from safetensors.numpy import save_file, load_file
import numpy as np

tensors = {
   "a": np.zeros((2, 2)),
   "b": np.zeros((2, 3), dtype=np.uint8)
}

save_file(tensors, "./model.safetensors")


# Now loading
loaded = load_file("./model.safetensors")

Torch

from safetensors.torch import save_file, load_file
import torch

tensors = {
   "a": torch.zeros((2, 2)),
   "b": torch.zeros((2, 3), dtype=torch.uint8)
}

save_file(tensors, "./model.safetensors")


# Now loading
loaded = load_file("./model.safetensors")

Developing

pip install setuptools_rust
python setup.py develop

Should be enough to install this library locally.

Testing

pip install pytest   # We don't require pytest, but it's a common library used across HF.
pytest -sv tests/

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

safetensors-0.2.3.tar.gz (4.5 kB view details)

Uploaded Source

Built Distributions

safetensors-0.2.3-cp310-cp310-win_amd64.whl (235.8 kB view details)

Uploaded CPython 3.10 Windows x86-64

safetensors-0.2.3-cp310-cp310-win32.whl (227.6 kB view details)

Uploaded CPython 3.10 Windows x86

safetensors-0.2.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

safetensors-0.2.3-cp310-cp310-macosx_12_0_arm64.whl (344.3 kB view details)

Uploaded CPython 3.10 macOS 12.0+ ARM64

safetensors-0.2.3-cp310-cp310-macosx_10_11_x86_64.whl (359.4 kB view details)

Uploaded CPython 3.10 macOS 10.11+ x86-64

safetensors-0.2.3-cp39-cp39-win_amd64.whl (236.1 kB view details)

Uploaded CPython 3.9 Windows x86-64

safetensors-0.2.3-cp39-cp39-win32.whl (228.0 kB view details)

Uploaded CPython 3.9 Windows x86

safetensors-0.2.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

safetensors-0.2.3-cp39-cp39-macosx_12_0_arm64.whl (344.7 kB view details)

Uploaded CPython 3.9 macOS 12.0+ ARM64

safetensors-0.2.3-cp39-cp39-macosx_10_11_x86_64.whl (359.6 kB view details)

Uploaded CPython 3.9 macOS 10.11+ x86-64

safetensors-0.2.3-cp38-cp38-win_amd64.whl (236.1 kB view details)

Uploaded CPython 3.8 Windows x86-64

safetensors-0.2.3-cp38-cp38-win32.whl (227.8 kB view details)

Uploaded CPython 3.8 Windows x86

safetensors-0.2.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

safetensors-0.2.3-cp38-cp38-macosx_10_11_x86_64.whl (359.9 kB view details)

Uploaded CPython 3.8 macOS 10.11+ x86-64

safetensors-0.2.3-cp37-cp37m-win_amd64.whl (236.2 kB view details)

Uploaded CPython 3.7m Windows x86-64

safetensors-0.2.3-cp37-cp37m-win32.whl (227.9 kB view details)

Uploaded CPython 3.7m Windows x86

safetensors-0.2.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

safetensors-0.2.3-cp37-cp37m-macosx_10_11_x86_64.whl (359.9 kB view details)

Uploaded CPython 3.7m macOS 10.11+ x86-64

File details

Details for the file safetensors-0.2.3.tar.gz.

File metadata

  • Download URL: safetensors-0.2.3.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for safetensors-0.2.3.tar.gz
Algorithm Hash digest
SHA256 bfa5b564ed20d8c9018853f679e66163f26c3329234ec7b95a566e35f38603cd
MD5 c9ca586ad282df0fa9af4990131a9d56
BLAKE2b-256 bafd3f72a926fd8cceb9fe62eacc01cb43dde29eb380000d969c05dc8284a471

See more details on using hashes here.

File details

Details for the file safetensors-0.2.3-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for safetensors-0.2.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 fb6ec1460f721982f564c2ee31e4978943713e6fd9d02df6b750f4c3ec2057c7
MD5 00629c1dcb1dd6771522f22c9b1c7963
BLAKE2b-256 793ddc7f458c8d25df9f6b5f668c624950edcb9146d1406d67d65e2901d74c7d

See more details on using hashes here.

File details

Details for the file safetensors-0.2.3-cp310-cp310-win32.whl.

File metadata

  • Download URL: safetensors-0.2.3-cp310-cp310-win32.whl
  • Upload date:
  • Size: 227.6 kB
  • Tags: CPython 3.10, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for safetensors-0.2.3-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 a60272cb671517eaf0c57e0919cbf7734ef9ce38ea07f0a570c2bfa5581fe092
MD5 86aa40102a2495d7312ff6003099f37f
BLAKE2b-256 a057ccd7f9aaf8c34754c1ecd83c7a3cbd54a91398a7c253c43d49f6413c7114

See more details on using hashes here.

File details

Details for the file safetensors-0.2.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for safetensors-0.2.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0171b95dac2124b125cbd7c670627e8cda5f32d1f3fa71bab85b29d1d3c7d56d
MD5 f7a7e90b7e1d474086aebe651d76b949
BLAKE2b-256 7b007111948dc484f8d648fc0cfcf516374954aea08eb60f62138b6188beb4ab

See more details on using hashes here.

File details

Details for the file safetensors-0.2.3-cp310-cp310-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for safetensors-0.2.3-cp310-cp310-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 20a008857da3aaeadd257364a9cad064107df20f3a49a5a474261ccdcf7badd0
MD5 e9c0535056ebcc0d9d4b7c775089c8a5
BLAKE2b-256 e2582174963cb535a604e5d09fceb04a6edaf9bda816a67fb54c746c4565f9a9

See more details on using hashes here.

File details

Details for the file safetensors-0.2.3-cp310-cp310-macosx_10_11_x86_64.whl.

File metadata

File hashes

Hashes for safetensors-0.2.3-cp310-cp310-macosx_10_11_x86_64.whl
Algorithm Hash digest
SHA256 5361638f587bde9ba32575b6a802751c6afd35e7ffddb2d171a186cf6dfb08c5
MD5 6d9fb874c7e29ab6f0f623e847b51d93
BLAKE2b-256 86c29e31c7f8d2def924c5a9d078c2401c5a673859ab90a543c7993e43d974b5

See more details on using hashes here.

File details

Details for the file safetensors-0.2.3-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for safetensors-0.2.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 46cf25239ebcabbcda8ae8764b82d483878555e40eec0b0fa9574de4ed5b04a9
MD5 df946cf2874b9f8d1c041c7cace27ec8
BLAKE2b-256 d8e454fe3fa4540409af62ceb5826ea91cbce4de1fc0e486c2c8f0704424e745

See more details on using hashes here.

File details

Details for the file safetensors-0.2.3-cp39-cp39-win32.whl.

File metadata

  • Download URL: safetensors-0.2.3-cp39-cp39-win32.whl
  • Upload date:
  • Size: 228.0 kB
  • Tags: CPython 3.9, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for safetensors-0.2.3-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 e14f3c51fdeb34ec692555277cbf9a2b20eac6f449facec48fff03112044ccac
MD5 9b713212716d300aa2ce26792a54a4e3
BLAKE2b-256 6bca714d6d9d1e58fad65f68f6ee8ef453cd0d3068d8becf4115de2bf3f9b87b

See more details on using hashes here.

File details

Details for the file safetensors-0.2.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for safetensors-0.2.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a7bcdcd2a2d05649fb5e87785dd129d0a0515a8c44c410589af72f2fead8602c
MD5 f8fa951801c58b5588035c095e809611
BLAKE2b-256 dc89e0a2db720de2fca4bb3a11f55f20801d4f472a2775e76e012b1382031042

See more details on using hashes here.

File details

Details for the file safetensors-0.2.3-cp39-cp39-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for safetensors-0.2.3-cp39-cp39-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 03204b5355b27966963995a0f4ad59f1cbd7c7519c99bc737e2f748ddaa05354
MD5 928ae761197ba21a58b229938076382f
BLAKE2b-256 e3bd6d33006d7b3eefeb1b9b784160019aa5c26cb3354fbb0ca79fd81f7c4a8f

See more details on using hashes here.

File details

Details for the file safetensors-0.2.3-cp39-cp39-macosx_10_11_x86_64.whl.

File metadata

File hashes

Hashes for safetensors-0.2.3-cp39-cp39-macosx_10_11_x86_64.whl
Algorithm Hash digest
SHA256 edc44adddda94ad21b140528276369610ffb0d4d6bf4720bf4bfc851d3576f1d
MD5 52931d5b79ecc5fa529492d9ea8d19d8
BLAKE2b-256 e9d982e73b1d0e6ed294f6784a255a8062f550b74a6deb180ee9a2a21bc91220

See more details on using hashes here.

File details

Details for the file safetensors-0.2.3-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for safetensors-0.2.3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 1befdcc36bc6ea9e9ad5c443f7751cc08a03ca64d200ff1b73401c5308589a42
MD5 c90904a34c9222b1f098252d61544a4d
BLAKE2b-256 7a2aeab44e450b5c9a50a78145d826294f843b6ac1f51eb7ec3f71e541857ccd

See more details on using hashes here.

File details

Details for the file safetensors-0.2.3-cp38-cp38-win32.whl.

File metadata

  • Download URL: safetensors-0.2.3-cp38-cp38-win32.whl
  • Upload date:
  • Size: 227.8 kB
  • Tags: CPython 3.8, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for safetensors-0.2.3-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 8038e576afe6fd525071f7405c151f959137035d34b35f8b67e7714e10adabc8
MD5 d444e866640a105db5723a70168de3d7
BLAKE2b-256 2718800d0153fd5080a2fdb0f4bdc52c6ff8c0fbf48875fac1bde5f6f13c0266

See more details on using hashes here.

File details

Details for the file safetensors-0.2.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for safetensors-0.2.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8e1716ccafb2011295f55fdba70fee5c60b368d3b78d21f873b4fd5dd2d018f5
MD5 52b95b29e5fd8747cad9a1aac599e2b2
BLAKE2b-256 ed6414ac5d498878e6d7cdb721b99ae8f7d57572053589b22c734af22e3d1f39

See more details on using hashes here.

File details

Details for the file safetensors-0.2.3-cp38-cp38-macosx_10_11_x86_64.whl.

File metadata

File hashes

Hashes for safetensors-0.2.3-cp38-cp38-macosx_10_11_x86_64.whl
Algorithm Hash digest
SHA256 18f30c6d40324a3e062a3f86821b2f6ecc062f7d606637eddddd26b574b140e3
MD5 1b699b59a1a0601b0db7e7f8e2061ca3
BLAKE2b-256 b13168adf689186aa8ede479420412a9b4523207b7e898f6ff627334a0fe314d

See more details on using hashes here.

File details

Details for the file safetensors-0.2.3-cp37-cp37m-win_amd64.whl.

File metadata

File hashes

Hashes for safetensors-0.2.3-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 d1b03e07e7f91fcb5a227111d3e8947a4202efae071f68eb7c29e0db6d6ccfa2
MD5 21b9e90cccf05e84ac9290c6488616a9
BLAKE2b-256 f8259ac58e582fd0855662cdd54ebf0345c647353fc95f8e11c2065e7c550cc9

See more details on using hashes here.

File details

Details for the file safetensors-0.2.3-cp37-cp37m-win32.whl.

File metadata

  • Download URL: safetensors-0.2.3-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 227.9 kB
  • Tags: CPython 3.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for safetensors-0.2.3-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 c7d8ede6f389e76020a6ac1f81f910649901cc8170cf5108a93e37469046227d
MD5 94e5cd22d203c9959f745cdb8c04dfe2
BLAKE2b-256 338221d148b086c1859d19cac9a4296b8b559a6987a954ebd9feaa000b273fdb

See more details on using hashes here.

File details

Details for the file safetensors-0.2.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for safetensors-0.2.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c26a7c304335c523cd7a4e1edc3bb66a4f49f615ab964ab0c594ba25426db9ce
MD5 9d58cd10ea396ac1d3f82e413fe16632
BLAKE2b-256 1854aea2c6e9d63036e32b8dce958f123b4ae9962904f2cc87c47e5cef5d59ad

See more details on using hashes here.

File details

Details for the file safetensors-0.2.3-cp37-cp37m-macosx_10_11_x86_64.whl.

File metadata

File hashes

Hashes for safetensors-0.2.3-cp37-cp37m-macosx_10_11_x86_64.whl
Algorithm Hash digest
SHA256 6eb71d4f17964c7438210c3d47491be6a8486b225176ee05fc03cd1345921a4f
MD5 d0c83c0f23e790c6c148dfbc8e2433ae
BLAKE2b-256 11596d40b6320556d1f90a2a28e33737742f7c8e4a12ae9e9449706f02a39906

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page