Pure-Python safetensors
Project description
pure_safetensors
Safetensors library but in pure clean Python. Run it on PyPy or IronPython or wherever.
Dependencies
We try to keep dependencies light:
- attrs dataclass library (2881 LoC)
- marshmallow serialization and validation library (2647 LoC)
- sortedcollections tiny sorted collections library (339 LoC) built on top of sortedcontainers (1493 LoC)
- (optional) sparsefile sparse file library (191 LoC)
Optionally, this library integrates with NumPy (if available). PyTorch integration is planned.
To run the tests, you'll need pytest
, numpy
, and optionally hypothesis
.
Examples
TODO
Bugs
The space allocator is a greedy algorithm based on first-fit-decreasing bin packing. So if you add/remove tensors to an existing file, it may leave too much empty space behind.
Alternatives
pure_safetensors | safetensors | pure_torch.py | safetensors.cpp | |
---|---|---|---|---|
Written in pure Python? | ✅ | ❌ | ✅ | — |
Supports NumPy directly (no PyTorch)? | ✅ | ✅ | ❌ | — |
Can write safetensors files? | ✅ | ✅ | ❌ | ❌ |
Can add/delete tensors in-place (no copying)? | ✅ | ❌ | ❌ | ❌ |
Has unit tests? | ✅ | ✅ | ❌ | ❌ |
Stable API? | 🤷 | ✅ | ❔ | ❔ |
Automatically make files sparse to save space? | ✅ | ❌ | ❌ | ❌ |
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
pure_safetensors-0.1.0.tar.gz
(10.8 kB
view hashes)
Built Distribution
Close
Hashes for pure_safetensors-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7aba79bbfbe551f55344d5ce81151a21bbe8b8078ddb64c71560c0b31c918911 |
|
MD5 | 4e784114b4a6df2253d9850595f82dc8 |
|
BLAKE2b-256 | 0a7d7d09d0367c4523c5f1dd861715ba04b1bf09adeed3dec5f5ec46d1651027 |