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.1.dev0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distributions

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

Uploaded CPython 3.10 Windows x86-64

safetensors-0.2.1.dev0-cp310-cp310-win32.whl (228.4 kB view details)

Uploaded CPython 3.10 Windows x86

safetensors-0.2.1.dev0-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.1.dev0-cp310-cp310-macosx_12_0_arm64.whl (345.1 kB view details)

Uploaded CPython 3.10 macOS 12.0+ ARM64

safetensors-0.2.1.dev0-cp310-cp310-macosx_10_11_x86_64.whl (360.2 kB view details)

Uploaded CPython 3.10 macOS 10.11+ x86-64

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

Uploaded CPython 3.9 Windows x86-64

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

Uploaded CPython 3.9 Windows x86

safetensors-0.2.1.dev0-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.1.dev0-cp39-cp39-macosx_12_0_arm64.whl (345.6 kB view details)

Uploaded CPython 3.9 macOS 12.0+ ARM64

safetensors-0.2.1.dev0-cp39-cp39-macosx_10_11_x86_64.whl (360.7 kB view details)

Uploaded CPython 3.9 macOS 10.11+ x86-64

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

Uploaded CPython 3.8 Windows x86-64

safetensors-0.2.1.dev0-cp38-cp38-win32.whl (228.5 kB view details)

Uploaded CPython 3.8 Windows x86

safetensors-0.2.1.dev0-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.1.dev0-cp38-cp38-macosx_10_11_x86_64.whl (360.8 kB view details)

Uploaded CPython 3.8 macOS 10.11+ x86-64

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

Uploaded CPython 3.7m Windows x86-64

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

Uploaded CPython 3.7m Windows x86

safetensors-0.2.1.dev0-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.1.dev0-cp37-cp37m-macosx_10_11_x86_64.whl (360.8 kB view details)

Uploaded CPython 3.7m macOS 10.11+ x86-64

File details

Details for the file safetensors-0.2.1.dev0.tar.gz.

File metadata

  • Download URL: safetensors-0.2.1.dev0.tar.gz
  • Upload date:
  • Size: 4.6 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.1.dev0.tar.gz
Algorithm Hash digest
SHA256 9f48c3a97e73f973986e007e65700b864a0aee8b606225b1a0cb16a264d0e56b
MD5 bf13fccc90473a9b52de15c9719a428e
BLAKE2b-256 a32c848172cc3c72e975972d859c01b6f3247f65b5f0a402356c6962fe942575

See more details on using hashes here.

File details

Details for the file safetensors-0.2.1.dev0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for safetensors-0.2.1.dev0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a6bc556b6aa09727df167a80f5727520e4c062d59ea38eab1296f2f8d32a9cfd
MD5 4a4e0e6deda39d6f35ea429cce016f19
BLAKE2b-256 175526a8e0be04f0b6d6b0cd103f5b361917db9e0ff88ef8ac5c65e40db2e1ac

See more details on using hashes here.

File details

Details for the file safetensors-0.2.1.dev0-cp310-cp310-win32.whl.

File metadata

File hashes

Hashes for safetensors-0.2.1.dev0-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 e7778c79e06071ba278a3a8b07341a05701041df6e579bbe863d6326d0966812
MD5 3b9970941db5ce2fa7bd3e7a792a7695
BLAKE2b-256 7a223011d644f7e88836254f8428d143f647e6064377309937536b7be5a8a4fb

See more details on using hashes here.

File details

Details for the file safetensors-0.2.1.dev0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for safetensors-0.2.1.dev0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 241d87371048033f4f1e04651560ecd345485e94cedd449fc6474456b2454783
MD5 6380b2ee430ead6638b1a564540c4247
BLAKE2b-256 081061f408fc43fc05c967a2921d59437af763c5ebb8a0ec73d572c9a974bff3

See more details on using hashes here.

File details

Details for the file safetensors-0.2.1.dev0-cp310-cp310-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for safetensors-0.2.1.dev0-cp310-cp310-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 3daedffbc39fad49ed0f4de9937737bb01cd726d4c2a6fc67715a6cf12f67f96
MD5 c6dec37a5f52720aa41cc72871c18e3f
BLAKE2b-256 784ddcf932ce6c01ba310213dc808731b52f0c45131dea4f010498d224f7df86

See more details on using hashes here.

File details

Details for the file safetensors-0.2.1.dev0-cp310-cp310-macosx_10_11_x86_64.whl.

File metadata

File hashes

Hashes for safetensors-0.2.1.dev0-cp310-cp310-macosx_10_11_x86_64.whl
Algorithm Hash digest
SHA256 4c9e9b755e84f3c58b915e5c1588eaab69b2ed1e9db5ed3a4016f85a689880d0
MD5 2ec7b7d9dc92dd0e30970ea4a72879fd
BLAKE2b-256 b4d84a697020d32d7069bf60df58f3d1be5ab7cbc70c2535cdc6c91cc2a79922

See more details on using hashes here.

File details

Details for the file safetensors-0.2.1.dev0-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for safetensors-0.2.1.dev0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 6461670870b770da4ba343aee709622984889437f8f236dadbcc6ecaa78eb1e5
MD5 b108039d09ddfed770c30a4606d06089
BLAKE2b-256 c87986c4f078ce46c42b64393e1ef3df4892cb7554aaa5786e9fd48c3a7247dd

See more details on using hashes here.

File details

Details for the file safetensors-0.2.1.dev0-cp39-cp39-win32.whl.

File metadata

File hashes

Hashes for safetensors-0.2.1.dev0-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 49c3950b683894b0b7f1e4fc764d92d5402a415626a0133479ea373f52c89f88
MD5 872ef0cfff5f7aad5a3f6efe06df709e
BLAKE2b-256 f23b7b59a25d47121f4f2a46a023d6cb1352bc9ccf0731eb833a90dbadfdcd6e

See more details on using hashes here.

File details

Details for the file safetensors-0.2.1.dev0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for safetensors-0.2.1.dev0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d7565fb64d546cf1750e88875e8e0d5337760bdfa5bafbc2be8e61d205cf7d81
MD5 4670c90bde9a06e332ebf56cedab12c1
BLAKE2b-256 4b6587fe7b37dbeb8efeffd0bca7f7c0f3e3649dc6c406f9bf2b3d715c0788b5

See more details on using hashes here.

File details

Details for the file safetensors-0.2.1.dev0-cp39-cp39-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for safetensors-0.2.1.dev0-cp39-cp39-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 d185cfaa0b342abfb6b4c9160d1e60ef174a9f3d27bc292cc2963469503e254a
MD5 eb9e1d1d70ca5b44ce77c6bbbe9c53c6
BLAKE2b-256 2309165dc5decfb7b18ff53f46f495e0807e71b51b47c5a833b7849ba80ffa3e

See more details on using hashes here.

File details

Details for the file safetensors-0.2.1.dev0-cp39-cp39-macosx_10_11_x86_64.whl.

File metadata

File hashes

Hashes for safetensors-0.2.1.dev0-cp39-cp39-macosx_10_11_x86_64.whl
Algorithm Hash digest
SHA256 61a3940a16e0c6d79d55fa9fd865c963aa45b83d919e88dc9de23c699d382175
MD5 6cc618696a5701bf656ae9517ed5bd84
BLAKE2b-256 a3dfc485255951c3c411c19d9bfc4082664c66a11a01415cec4bec8a471a202f

See more details on using hashes here.

File details

Details for the file safetensors-0.2.1.dev0-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for safetensors-0.2.1.dev0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 6a15fd1323b128bb6535f6ab65968510a96cfa2f28510dff551a9f640135da44
MD5 bf5c5b3f23d7fc334965d8819a812e8d
BLAKE2b-256 7836b4eaebe75156b353b5e226586a8b56ca3777ab1a35692254c4c67bb194ea

See more details on using hashes here.

File details

Details for the file safetensors-0.2.1.dev0-cp38-cp38-win32.whl.

File metadata

File hashes

Hashes for safetensors-0.2.1.dev0-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 a87f39995341bff20e91e0be4100b390e142c7d5371884958fb0159671ddb20e
MD5 88989b14305626cf663351b7e05f871c
BLAKE2b-256 0569dc524f5fae089188fe9a976aaadbf5f562b1b4f9c6273437e72b81f3e115

See more details on using hashes here.

File details

Details for the file safetensors-0.2.1.dev0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for safetensors-0.2.1.dev0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1c62d77fe8fe4c6ac1ecfefa68f5f585fdd96dbd4597e6849178c33d35c94dd0
MD5 c86c2f11c0f5288c90d4ccc8bbc3c66a
BLAKE2b-256 4deb9d6f9ffb25f8288b812fefbbf8a7a9459a4dda3308e61b95eb7ba1efa52f

See more details on using hashes here.

File details

Details for the file safetensors-0.2.1.dev0-cp38-cp38-macosx_10_11_x86_64.whl.

File metadata

File hashes

Hashes for safetensors-0.2.1.dev0-cp38-cp38-macosx_10_11_x86_64.whl
Algorithm Hash digest
SHA256 3a2a93857b4aae88568dfe6cb562b5bbe17d1f5d0f43a41aaef357dcff5b8ecd
MD5 aa225bf45cfdacc5a21290dd226610f8
BLAKE2b-256 3ccb4fcb8d22467e6da61233fce57f679cafe84bbf9260846d9854a082208d32

See more details on using hashes here.

File details

Details for the file safetensors-0.2.1.dev0-cp37-cp37m-win_amd64.whl.

File metadata

File hashes

Hashes for safetensors-0.2.1.dev0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 f0a3e10c9338e7c336a08af369d079d66d7224b2e6a09fa4394cbe3635932d00
MD5 f2fbc65bffc9d3d9697e4d2957024863
BLAKE2b-256 d177dbc3fd144a43981931b291b91559fd0ea6723ebd053ac72f9b71228a612a

See more details on using hashes here.

File details

Details for the file safetensors-0.2.1.dev0-cp37-cp37m-win32.whl.

File metadata

File hashes

Hashes for safetensors-0.2.1.dev0-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 4e9e5dcb9fc0dcf55ac9b5a36f951dc8472eb47828c8885191cab16d5767db08
MD5 a7b89a0ccb4adf504bf11738c5ddce32
BLAKE2b-256 f5eaa2a86b26035a01500617ba1e5454a48703668c9eb8d65877d05da94ae6e4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for safetensors-0.2.1.dev0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5886d5b1baace98eaa1979636e2c997587020f4417822144aa8ff0fa17e307b6
MD5 10aa956b52e20681b0980fa5c5e29847
BLAKE2b-256 b03d433a0cc706118dcad73d68803c4919e627bddfa38689a27dee5f404833b7

See more details on using hashes here.

File details

Details for the file safetensors-0.2.1.dev0-cp37-cp37m-macosx_10_11_x86_64.whl.

File metadata

File hashes

Hashes for safetensors-0.2.1.dev0-cp37-cp37m-macosx_10_11_x86_64.whl
Algorithm Hash digest
SHA256 27ad6120f37dd9fee9cd135a45e81528ec17e93d1b91d08987a364f0862d8332
MD5 dbac23088be6af20413a0b046047a376
BLAKE2b-256 60adbd99d552dc70baa665683dd8b92917ae939c8fc2e68eb4ac52bce34ac386

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