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.2.tar.gz (4.5 kB view details)

Uploaded Source

Built Distributions

safetensors-0.2.2-cp310-cp310-win_amd64.whl (236.7 kB view details)

Uploaded CPython 3.10 Windows x86-64

safetensors-0.2.2-cp310-cp310-win32.whl (228.3 kB view details)

Uploaded CPython 3.10 Windows x86

safetensors-0.2.2-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.2-cp310-cp310-macosx_12_0_arm64.whl (345.0 kB view details)

Uploaded CPython 3.10 macOS 12.0+ ARM64

safetensors-0.2.2-cp310-cp310-macosx_10_11_x86_64.whl (360.1 kB view details)

Uploaded CPython 3.10 macOS 10.11+ x86-64

safetensors-0.2.2-cp39-cp39-win_amd64.whl (237.1 kB view details)

Uploaded CPython 3.9 Windows x86-64

safetensors-0.2.2-cp39-cp39-win32.whl (228.6 kB view details)

Uploaded CPython 3.9 Windows x86

safetensors-0.2.2-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.2-cp39-cp39-macosx_12_0_arm64.whl (345.5 kB view details)

Uploaded CPython 3.9 macOS 12.0+ ARM64

safetensors-0.2.2-cp39-cp39-macosx_10_11_x86_64.whl (360.5 kB view details)

Uploaded CPython 3.9 macOS 10.11+ x86-64

safetensors-0.2.2-cp38-cp38-win_amd64.whl (237.1 kB view details)

Uploaded CPython 3.8 Windows x86-64

safetensors-0.2.2-cp38-cp38-win32.whl (228.4 kB view details)

Uploaded CPython 3.8 Windows x86

safetensors-0.2.2-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.2-cp38-cp38-macosx_10_11_x86_64.whl (360.7 kB view details)

Uploaded CPython 3.8 macOS 10.11+ x86-64

safetensors-0.2.2-cp37-cp37m-win_amd64.whl (237.1 kB view details)

Uploaded CPython 3.7m Windows x86-64

safetensors-0.2.2-cp37-cp37m-win32.whl (228.5 kB view details)

Uploaded CPython 3.7m Windows x86

safetensors-0.2.2-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.2-cp37-cp37m-macosx_10_11_x86_64.whl (360.7 kB view details)

Uploaded CPython 3.7m macOS 10.11+ x86-64

File details

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

File metadata

  • Download URL: safetensors-0.2.2.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.2.tar.gz
Algorithm Hash digest
SHA256 00910e89eeb8f1a6d6e97794564d32fd7a4e90df10172625fdf6b5f48f91880e
MD5 d80cbb213cca3660351e614a70bf4951
BLAKE2b-256 baf9bd9f04aaebca4c87e8dcf86dc3e1742df507da94c1423c2f6ba5c275f8d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for safetensors-0.2.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 9e142746adba15d700fdda84f3bf59a5dc150d283bd8b5db4ae66dd0818fe53e
MD5 6683677be5a2d102853b5e2365af24bf
BLAKE2b-256 5d0947c28b4153e771fdb711f1cbd3842116a5af9d584f3460fa9981c4bd0472

See more details on using hashes here.

File details

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

File metadata

  • Download URL: safetensors-0.2.2-cp310-cp310-win32.whl
  • Upload date:
  • Size: 228.3 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.2-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 b656a8c76dd579383f5f4f9776ccaf6fda5bdb195a469d0445d21da3a17ed0b8
MD5 45a8c184c168ca3f2c66cfc372e6f2d3
BLAKE2b-256 9963a6f2326e73daf951f0f59601b873c10a9fa54db901213c266462a73500b1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for safetensors-0.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d220ba37516ed2ee75fdc7d46101e5f56ac21c133dad63b1aeef172b7a3914a9
MD5 6c5b63af7f420ea6b82a67446e55fa55
BLAKE2b-256 b276fd9a4217f375d86041f681c2f019a751e58f63b12ac40d528e695e5d1c6d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for safetensors-0.2.2-cp310-cp310-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 3053e0f2bc2df3336a0ccaf5687c81543ee655ca7adb56705a53204b7d47ad24
MD5 95534fdc9c74f8268b314c5325331d00
BLAKE2b-256 95e84f5fd61612040838e67bedaeec007896f50d850311dd2b7034804166e184

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for safetensors-0.2.2-cp310-cp310-macosx_10_11_x86_64.whl
Algorithm Hash digest
SHA256 a6d1ebcbd07d4c89a3ddfdf7b8573c003f19d6e2e403b9d536d9c3fcc5c13aec
MD5 ced303b3cec3c574f52638447782548f
BLAKE2b-256 c62dd8474a70d044e029a5d67d74abc394f233c1a8879acb6acf3783eea7a441

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for safetensors-0.2.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 e7fe28b2a8563e10c9dacd8e4b95702dd194eb8a71cc442993d56806b1e95184
MD5 f9dae40b0a6cdf0d70c7b3ebec915976
BLAKE2b-256 0502164096591b3205e32ad6d22a2c3e002f030f2c4000add980110a4edd94d3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: safetensors-0.2.2-cp39-cp39-win32.whl
  • Upload date:
  • Size: 228.6 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.2-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 5fadf5a8d5083d477ccc1a4ad0b96a0c1a235158d11bf4e905cef5a2b2f59a19
MD5 3f0163eab8a5f82ace83382dcd2e03a7
BLAKE2b-256 eefc708bae3dc7c89ac45f70428c52f44783464fa54b69e13b9cec1ecb3e1896

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for safetensors-0.2.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1b47917ffbb462e9505a10f47c0c563efdeeae3c59438fe5502fbe642011b8bf
MD5 00c31cc04ba8595e09229e90432cbabf
BLAKE2b-256 2e3708023bf03e32f8ed2af53445fa6f8d249822d7f65904c5eb7699ec21915a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for safetensors-0.2.2-cp39-cp39-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 8cba61bfb33603fe37f5af127a8b543ec40648292bffb2b10d92980f2dc0eea1
MD5 c606cbaaf7c186bd3dc6cbae22510543
BLAKE2b-256 161f452569df9187feea4410b2342cfd5c333121bf186ff1156c8433bafe82d8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for safetensors-0.2.2-cp39-cp39-macosx_10_11_x86_64.whl
Algorithm Hash digest
SHA256 0f8a4fa0cdf255f4d1932f46035cfdb7002ed25a713c41cc0c5be7231c82c8fe
MD5 d0dffe4a52337788bd25f7f8a59e2973
BLAKE2b-256 759f89fdcf725408bad2a556210e314449130f28cf9ec06d12938726eed5e550

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for safetensors-0.2.2-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 35969365ce3493fc0e99659f899bba72bee9d97805597799bfbb514befb6a6ab
MD5 fc20c3560a194727b5c56eef74cd731f
BLAKE2b-256 dcc5da1f05744cb615a03d4b5c22bb44296efd74b0dc90c7d983c5e0bdf30fff

See more details on using hashes here.

File details

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

File metadata

  • Download URL: safetensors-0.2.2-cp38-cp38-win32.whl
  • Upload date:
  • Size: 228.4 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.2-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 bf2cd76497c5165705b661ab5e219781996f8a400644380f80ba9d9e8aa4c586
MD5 0bee1b2eb20601b0332f52958a711ed3
BLAKE2b-256 089f1ba9498e351dac9bddc4b1a539daffa8d2dbcf260514b64f30d6b04a7ba1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for safetensors-0.2.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2157afe9906cb2eff8fb7fa08756b5322a33e1c07efe46a137e10872e4b5ebb1
MD5 4d9528136f66d750572777209a3f6347
BLAKE2b-256 21db9d0aa824701097fa32b4b5d607328a1cb8ac4c694e1334833675f42bb47d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for safetensors-0.2.2-cp38-cp38-macosx_10_11_x86_64.whl
Algorithm Hash digest
SHA256 6977ff904829c407e64e805befd7284b37a4c4c7cca4d702a8daff7e764945e7
MD5 b21ebcdb875b815b1fc7451bcad1f627
BLAKE2b-256 589ad0f96705242b822eaa96c373cc551406f6eae02ea6bad5cb0058cb8ccce6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for safetensors-0.2.2-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 1eed30b73a309d743db53121abb3be738c1f314d09a0ca282fbdc97c7f36d793
MD5 a40affd0e00d3157cba12cb075100903
BLAKE2b-256 060f3b361791aa0924194d90cbf6f138d55633f0a0c14f988e3553764af3df75

See more details on using hashes here.

File details

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

File metadata

  • Download URL: safetensors-0.2.2-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 228.5 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.2-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 458d32fa11855560f15dcee6108370b95cd3e02f1bf17a9a0888421ed0a97b71
MD5 40ad43e2c7382dc7d35e8912a78d2e04
BLAKE2b-256 eabe6914379d89744edf182610d9e36166faebd00ea765600e5d112d93b10a1a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for safetensors-0.2.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 951e44e7cb3c7a28c025bd673beb260585570b68c2fe9f484552133b7f7889a7
MD5 223e53d6ba7967de716e2eb6156c3cd9
BLAKE2b-256 c62506d120878718b47f5c43ef1f13489878e03efd52bdb7b7631445fbb0ae03

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for safetensors-0.2.2-cp37-cp37m-macosx_10_11_x86_64.whl
Algorithm Hash digest
SHA256 55d3432c5b949279b765af7f0328ee338afc68f99645b1d3772399f307242a30
MD5 d39e6be68c96f080f54b1ac33899b89f
BLAKE2b-256 3760eb44c48b42fbc6478096f78d4254445ddfd76d0ce63f000bbb7c7ec3abca

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