]>
khamidou — GitHub mirrors - safetensors.git/log
Mishig [Wed, 17 May 2023 12:59:32 +0000 (14:59 +0200)]
[doc] Improve metadata parsing doc (#245)
* hfjs link to parsesafetensorsmetadata
* Add conditional image
* better wording
* new images
* Add python example
* Add reference to range request
* capitalization
Julien Chaumond [Wed, 17 May 2023 09:16:40 +0000 (11:16 +0200)]
[doc] Add a doc page about (remote) Metadata parsing (#243)
Would close #44
Nicolas Patry [Wed, 17 May 2023 09:15:11 +0000 (11:15 +0200)]
Adding a banner to the README. (#244)
* Adding a banner to the README.
* Svg.
* Fix size.
Nicolas Patry [Tue, 25 Apr 2023 12:34:04 +0000 (14:34 +0200)]
Fixing conda workflow. (#240)
Nicolas Patry [Tue, 25 Apr 2023 08:24:04 +0000 (10:24 +0200)]
Prepare 0.3.2 (#239)
Nicolas Patry [Mon, 24 Apr 2023 14:21:09 +0000 (16:21 +0200)]
New release candidate. (#224)
Nicolas Patry [Mon, 24 Apr 2023 14:15:32 +0000 (16:15 +0200)]
Fixing shared detection logic. (#232)
* Fixing shared tensor logic.
* Fixing shared detection logic.
* torch 1.10 support.
* Rebase.
Nicolas Patry [Mon, 24 Apr 2023 10:37:00 +0000 (12:37 +0200)]
Adding `save_model` and `load_model` to help with shared tensors with PyTorch. (#236)
* Adding `save_model` and `load_model` to help with shared tensors
and non contiguous tensors.
* Tmp.
* Adding more docs more tests on the edge cases.
* Adding support for different `keep_name` on disk.
* Torch 1.10 support + save_model failure test.
* Fixes 1.10
* Debugging on remote..
* 1.
* 2.
* 3.
* 4.
* Trying to fix documentation builder version.
* PR documentation + route from error message to new methods.
* ..
* Revert ".."
This reverts commit
564b6863fc11407e19982944733de999c17c95ba .
* Fixing `.[dev]` ?
* Adding contiguous support.
* ?
* Fix.
Nicolas Patry [Fri, 21 Apr 2023 12:54:22 +0000 (14:54 +0200)]
Fixing alignment (#235)
* Alignment checking.
* Fix alignments.
* Updating python tests.
* Improve a bit readability.
Nicolas Patry [Wed, 19 Apr 2023 13:46:04 +0000 (15:46 +0200)]
Fixing the logic to determine if PR is up-to-date. (#230)
* Fixing the logic to determine if PR is up-to-date.
* Update bindings/python/convert.py
Nicolas Patry [Wed, 12 Apr 2023 14:18:58 +0000 (16:18 +0200)]
Committing Cargo.lock. (#233)
* Committing Cargo.lock.
* Update .gitignore
Co-authored-by: Mishig <dmishig@gmail.com>
---------
Co-authored-by: Mishig <dmishig@gmail.com>
Nicolas Patry [Thu, 6 Apr 2023 11:08:14 +0000 (13:08 +0200)]
Minor checks + proptest in python. (#228)
* Minor checks + proptest in python.
* Fix readme.
* Tf version.
* Fix.
* Jax version.
* Jaxlib.
* Jax.
* Cannot have jax version
- Python 3.7 is minimal version for which they don't have release
jax>0.4
- Our doc builder relies on jax>0.4
* wtf.
* .
* ...
* Wahtever.
Nicolas Patry [Thu, 6 Apr 2023 08:27:38 +0000 (10:27 +0200)]
Specify python versions. (#227)
Nicolas Patry [Thu, 6 Apr 2023 08:27:30 +0000 (10:27 +0200)]
0-sized tensors allowed. (#226)
Nicolas Patry [Thu, 6 Apr 2023 08:27:13 +0000 (10:27 +0200)]
Adding last missing test for validate. (#225)
Nicolas Patry [Thu, 30 Mar 2023 12:58:08 +0000 (14:58 +0200)]
Remove the breaking change of disallowing zero sized tensors. (#221)
* Remove the breaking change of disallowing zero sized tensors.
Some files out there might exist with this.
While being questionnable, it's not worth doing a breaking change
since there doesn't seem to be either a security implication
nor a performance hit.
* Full support for zero-sized tensor on torch==1.10
* Adding a nice comment.
Nicolas Patry [Wed, 29 Mar 2023 08:58:08 +0000 (10:58 +0200)]
Fixing empty shape test. (#218)
Nicolas Patry [Wed, 29 Mar 2023 08:57:32 +0000 (10:57 +0200)]
Add a safety warning in the convertion script. (#219)
* Add a safety warning in the convertion script.
* Fix test temporarily.
Nicolas Patry [Wed, 29 Mar 2023 08:57:14 +0000 (10:57 +0200)]
Adding arithmetic overflow checks (unchecked in release builds). (#207)
* Adding arithmetic overflow checks (unchecked in release builds).
* Fix rebase
Nicolas Patry [Tue, 28 Mar 2023 13:53:50 +0000 (15:53 +0200)]
Overspecify a bit the format. (#215)
* Updating the README to overspecify JSON.
* Overspecify a bit the format.
* Stop being annoying.
* Fixing python cache + gh action.
* Fix audit.
* Fixing rust cache for python directory ?
Nicolas Patry [Tue, 28 Mar 2023 13:47:23 +0000 (15:47 +0200)]
Disallow erroneous buffer. (#206)
Nicolas Patry [Tue, 28 Mar 2023 13:45:39 +0000 (15:45 +0200)]
Disallowing zero-width tensor. (#205)
* Disallowing zero-width tensor.
* Fix test.
Nicolas Patry [Tue, 28 Mar 2023 13:45:08 +0000 (15:45 +0200)]
Adding simple proptest. (#216)
Nicolas Patry [Tue, 28 Mar 2023 13:32:41 +0000 (15:32 +0200)]
Zero width shape are OK (0-rank tensors). They are simply a scalar. (#208)
* Zero width shape are OK (0-rank tensors). They are simply a scalar.
Reasosn for support is that both torch and numpy support them, and
they flow naturally from the definition that an empty product has
length 1.
* not allowed -> allowed
Nicolas Patry [Tue, 28 Mar 2023 13:20:39 +0000 (15:20 +0200)]
Deactivating codecov commenting. (#217)
Nicolas Patry [Tue, 28 Mar 2023 12:13:38 +0000 (14:13 +0200)]
Increase coverage on the error paths. (#214)
Nicolas Patry [Tue, 28 Mar 2023 10:46:09 +0000 (12:46 +0200)]
Fixing codecov rust tag. (#213)
Nicolas Patry [Tue, 28 Mar 2023 10:40:20 +0000 (12:40 +0200)]
Oops. (#212)
Nicolas Patry [Tue, 28 Mar 2023 10:33:56 +0000 (12:33 +0200)]
Upload codecov for main branch. (#211)
Nicolas Patry [Tue, 28 Mar 2023 10:26:19 +0000 (12:26 +0200)]
Remove unwrap in prod code. (#209)
Nicolas Patry [Tue, 28 Mar 2023 10:24:44 +0000 (12:24 +0200)]
More badges. (#210)
* More badges.
* Update action to create codecov.
* Update readmes.
* Fix doc link.
* Two lines for Python and Rust.
* Doc link.
* Fix badge label.
* Use simpler run to get default working-dir.
* Fix ?
* Audit.
* Ignore criterion issue.
* Better command line ?
* codecov token.
* Working dir.
* Specify file.
* Fixing upload only on ubuntu.
* Code coverage only on linux.
* Fix codecov link.
nickkolok [Tue, 28 Mar 2023 08:20:42 +0000 (11:20 +0300)]
Minor improvements for README (#201)
* Use `s for code
* Fix typos in README
* All readmes.
* Adding Rust cache and latest ubuntu for python tests.
---------
Co-authored-by: Nicolas Patry <patry.nicolas@protonmail.com>
Nicolas Patry [Mon, 27 Mar 2023 08:30:56 +0000 (10:30 +0200)]
Adding a minimal version for torch. (#204)
Nicolas Patry [Fri, 17 Mar 2023 14:56:06 +0000 (15:56 +0100)]
Python 2.0 added a warning on ByteStorage, so using UntypedStorage (#196)
* Python 2.0 added a warning on ByteStorage, so using UntypedStorage
directly for that version.
Small error in their docs, `size` got renamed `nbytes`.
* Remove unused work.
Nicolas Patry [Fri, 17 Mar 2023 09:42:34 +0000 (10:42 +0100)]
Adding commit description to convertion PR. (#198)
* Adding commit description to convertion PR.
* Update bindings/python/convert.py
Co-authored-by: Omar Sanseviero <osanseviero@gmail.com>
* Adding suggestion for reporting issues.
---------
Co-authored-by: Omar Sanseviero <osanseviero@gmail.com>
Nicolas Patry [Mon, 13 Mar 2023 10:35:40 +0000 (11:35 +0100)]
Nicer error when failed to find tensor in Rust. (#191)
Co-authored-by: Ubuntu <ubuntu@ip-172-31-34-94.eu-west-3.compute.internal>
Nicolas Patry [Mon, 13 Mar 2023 10:35:27 +0000 (11:35 +0100)]
Making sure the safetensors existing PR is up-to-date. (#192)
* Making sure the safetensors existing PR is up-to-date.
* Fixed `target_branch` exists only on details.
Nicolas Patry [Wed, 8 Mar 2023 12:01:26 +0000 (13:01 +0100)]
Adding memmap example to read from file. (#189)
Nicolas Patry [Wed, 8 Mar 2023 12:01:11 +0000 (13:01 +0100)]
Remove too many keywords. (#187)
Nicolas Patry [Fri, 3 Mar 2023 14:21:07 +0000 (15:21 +0100)]
Version 0.3.0 (#186)
Nicolas Patry [Wed, 1 Mar 2023 20:45:08 +0000 (21:45 +0100)]
Preparing for release 0.3rc1. (#185)
* Preparing for release 0.3rc1.
* Full version number.
Nicolas Patry [Tue, 28 Feb 2023 15:19:40 +0000 (16:19 +0100)]
Faster GPU Loads ?? (#184)
* Faster GPU Loads ??
Beats my expectations. I wonder what I did do to not see this perf
bottleneck/improvements.
* Pyslice still not fixed on PyO3.
* Upgrade PyO3.
* Using newer pyo3.
* Make benches Windows friendly.
Nicolas Patry [Fri, 24 Feb 2023 13:56:51 +0000 (14:56 +0100)]
Better Rust API (tch-rs) (#179)
* Implementing a trait API for the Rust (should make tch-rs interaction
easier).
* Companion type.
* Re-export major formats + 3rd example in the trait doc.
* Even clearer OpaqueGPU type.
* Moving to `Cow<[u8]>`. Feels simpler.
* Fixes.
Dwayne Robinson [Fri, 24 Feb 2023 10:12:57 +0000 (02:12 -0800)]
README.md proposed clarity (#181)
* README.md proposed clarity
I had to look via a hex editor at an existing .safetensors file to figure it out (maybe this will accelerate others slightly to adopt it 😅), because parentheses "(...)" are not legal JSON, and it wasn't clear to me whether the offsets were file relative or byte buffer relative.
* Update other readme.
---------
Co-authored-by: Nicolas Patry <patry.nicolas@protonmail.com>
Nicolas Patry [Tue, 21 Feb 2023 14:23:56 +0000 (15:23 +0100)]
[Major Change] Enforcing tensor alignment (#148)
* [Major Change] Enforcing tensor alignment
- Now the header will automatically align itself to 8 bytes (f64) with
appending extra spaces as necessary.
- This will allow extra fast memory mapping by reinterpreting bytes as
f32/f64 etc.. Unaligned bytes do not allow for this. https://www.reddit.com/r/rust/comments/tanaxm/mutating_a_buffer_of_u8s_as_f32s_in_place/
- This does not change contiguousness of tensors
- This does not change the actual spec (we're just putting extra valid bytes
in the header and using a different serialization ordering)
- Readers should still be able to read old files, they would just need
to be copied before being cast as their final destination when using
mmap
- This has no effect for GPU since copy is already necessary (*I think*,
depends on the cuda API actually if it allows filling f32 addresses
from raw unaligned bytes).
This change will only be interesting if things like https://github.com/Narsil/fast_gpt2
actually pick up. And even with the copy, load times are still vastly
superior to `pytorch`.
We need to be able to read old files.
* Fixup.
* Clippy fix.
* Cargo fmt (clippy --fix broke it ? :( )
yujun [Wed, 8 Feb 2023 10:06:05 +0000 (18:06 +0800)]
add paddle docs (#177)
yujun [Tue, 7 Feb 2023 14:44:54 +0000 (22:44 +0800)]
Add PaddlePaddle backend (#176)
* add paddle backend
* add paddle ace
* update docs
* Some modifications.
* Consistency.
* Showing Paddle format.
* donot modify lib.rs
* remove test_deserialization_safe_open test
* rm unused import
* make style
* Style.
---------
Co-authored-by: Nicolas Patry <patry.nicolas@protonmail.com>
Nicolas Patry [Mon, 6 Feb 2023 11:05:40 +0000 (12:05 +0100)]
Fixing error message for FileNotFound. (#175)
* Fixing error message for FileNotFound.
* Old PR readme fix.
Nicolas Patry [Mon, 30 Jan 2023 13:00:51 +0000 (14:00 +0100)]
Update README.md (#170)
Fixes #169 169
Nicolas Patry [Mon, 30 Jan 2023 12:59:40 +0000 (13:59 +0100)]
Clippy fix. (#171)
* Clippy fix.
* And tests.
Nicolas Patry [Fri, 20 Jan 2023 14:05:24 +0000 (15:05 +0100)]
Better error messages on outdated context manager. (#168)
* Better error messages on outdated context manager.
* Clippy.
* Remove unwrap.
* Fix.
John B Nelson [Fri, 20 Jan 2023 10:07:11 +0000 (02:07 -0800)]
Minor pydoc fixes for torch bindings (#167)
Nicolas Patry [Thu, 19 Jan 2023 13:30:56 +0000 (14:30 +0100)]
Fixing the fact that the context manager wasn't properly cleaning up after itself. (#166)
* Adding failing test for windows.
* This should fail.
* Fixing Windows issue by actually dropping the rust resources.
* Making the rust module private.
Nicolas Patry [Tue, 17 Jan 2023 17:06:34 +0000 (18:06 +0100)]
Adding custom error type for users to properly catch. (#165)
KOLANICH [Tue, 17 Jan 2023 16:39:47 +0000 (16:39 +0000)]
Added JSONSchema of the header. (#151)
Nicolas Patry [Tue, 17 Jan 2023 09:04:04 +0000 (10:04 +0100)]
Enabling 3.8 support for M1. (#162)
Thomas Wang [Tue, 17 Jan 2023 09:02:28 +0000 (10:02 +0100)]
Update README.md (#163)
* Update README.md
Link to huggingface.co documentation
* Make rust doc match
* Why is the documentation at three different places?
Nicolas Patry [Mon, 16 Jan 2023 15:40:29 +0000 (16:40 +0100)]
New unreleased version. (#161)
* New unreleased version.
* Making only 1 release now.
Thomas Wang [Mon, 16 Jan 2023 14:28:18 +0000 (15:28 +0100)]
Improve type hinting (#159)
Nicolas Patry [Mon, 16 Jan 2023 12:42:22 +0000 (13:42 +0100)]
Fix byte order detection for `np.uint8` and other types for which byte order is not defined. (#160)
* Fix byte order detection for `np.uint8` and other types for which byte order is not defined.
* Fixing np.uint8 endianness for `save`.
Co-authored-by: KOLANICH <kolan_n@mail.ru>
Nicolas Patry [Mon, 16 Jan 2023 09:34:28 +0000 (10:34 +0100)]
Preparing next version. (#158)
Nicolas Patry [Fri, 30 Dec 2022 13:28:44 +0000 (14:28 +0100)]
Updating rust ergonomics. (#144)
- `get_` prefix removed in a few functions.
- Make error implement Error.
Nicolas Patry [Thu, 29 Dec 2022 07:17:56 +0000 (08:17 +0100)]
Fixing torch version parsing. (#143)
* Fixing torch version parsing.
* Anticipating a bit more variations of this.
Alvaro Bartolome [Tue, 27 Dec 2022 09:02:52 +0000 (10:02 +0100)]
Update docstrings & type-hints (#139)
Nicolas Patry [Tue, 27 Dec 2022 08:13:28 +0000 (09:13 +0100)]
Making SAFETENSORS_FAST_GPU=1 work on Windows again. (#140)
* Making Windows load cudart differently.
* Remove unsafe.
* Misplaced comment
Nicolas Patry [Mon, 19 Dec 2022 12:50:15 +0000 (13:50 +0100)]
Adding stale bot. (#135)
* Adding stale bot.
* Clippy.
Vilém Zouhar [Thu, 15 Dec 2022 08:38:37 +0000 (09:38 +0100)]
Fix readme typos (#133)
* fix readme typos
* Replicating docs on all 3 files.
Co-authored-by: Nicolas Patry <patry.nicolas@protonmail.com>
Nicolas Patry [Wed, 14 Dec 2022 12:55:28 +0000 (13:55 +0100)]
New version. (#132)
Thomas Wang [Wed, 14 Dec 2022 10:23:50 +0000 (11:23 +0100)]
Update README.md (#131)
* Update README.md
* Update other files.
Co-authored-by: Nicolas Patry <patry.nicolas@protonmail.com>
Nicolas Patry [Tue, 13 Dec 2022 16:17:42 +0000 (17:17 +0100)]
Fixing it for `diffusers`. (#130)
Nicolas Patry [Tue, 13 Dec 2022 15:14:56 +0000 (16:14 +0100)]
Necessary modifications to publish on Rust. (#129)
* Adding Info to publish.
* Bench.
* Update README.
Nicolas Patry [Mon, 12 Dec 2022 13:59:19 +0000 (14:59 +0100)]
Release rust. (#126)
Nicolas Patry [Mon, 12 Dec 2022 10:40:56 +0000 (11:40 +0100)]
Keras new format is not safe. (#127)
Nicolas Patry [Mon, 12 Dec 2022 09:24:49 +0000 (10:24 +0100)]
Adding support for Python 3.11 on Linux + fix the source build wheel. (#125)
Nicolas Patry [Wed, 7 Dec 2022 16:04:03 +0000 (17:04 +0100)]
Python fuzzing. (#123)
lsb [Tue, 6 Dec 2022 09:25:11 +0000 (01:25 -0800)]
Minor typo (#121)
* Minor typo
* READMEs.
* Fix the reamde? ??
Co-authored-by: Nicolas Patry <patry.nicolas@protonmail.com>
Nicolas Patry [Mon, 5 Dec 2022 17:33:12 +0000 (18:33 +0100)]
Adding `cargo fuzz` and found sanitation opportunities. (#119)
* Adding `cargo fuzz` and found sanitation opportunities.
* Better code.
Nicolas Patry [Wed, 30 Nov 2022 16:01:55 +0000 (17:01 +0100)]
Supporting stable-diffusion by default. (#118)
* New updates.
* Force load checkpoint on cpu.
Nicolas Patry [Wed, 30 Nov 2022 13:46:38 +0000 (14:46 +0100)]
Supporting stable-diffusion by default. (#117)
Patrick von Platen [Mon, 28 Nov 2022 13:26:04 +0000 (14:26 +0100)]
Add pip installation guide (#116)
* Add pip installation guide
* Update the 3 locations.
* Those are not doctests.
Co-authored-by: Nicolas Patry <patry.nicolas@protonmail.com>
Nicolas Patry [Sat, 26 Nov 2022 21:17:34 +0000 (22:17 +0100)]
New version. (#114)
Nicolas Patry [Wed, 23 Nov 2022 19:57:32 +0000 (20:57 +0100)]
I hate yaml. (#110)
Nicolas Patry [Wed, 23 Nov 2022 19:27:02 +0000 (20:27 +0100)]
Update workflow. (#109)
Nicolas Patry [Wed, 23 Nov 2022 18:28:38 +0000 (19:28 +0100)]
M1 fix (pyenv cannot use `3.11`. (#108)
Nicolas Patry [Wed, 23 Nov 2022 17:11:10 +0000 (18:11 +0100)]
Fixes https://github.com/huggingface/safetensors/actions/runs/
3534003128 /jobs/
5930362952 (#107)
Nicolas Patry [Wed, 23 Nov 2022 14:41:36 +0000 (15:41 +0100)]
Improve error message when saving bogus object. (#106)
Nicolas Patry [Wed, 23 Nov 2022 14:41:15 +0000 (15:41 +0100)]
Fix `convert.py` to handle diffusers, and its transformers part (#105)
Turns out `diffusers` does rely on `transformers`:
`pytorch_model.safetensors` was not a recognized filename by
`transformers` which expects it to be named `model.safetensors`.
The convert_generic works by simply creating the new files and changing
the extension, which broke this.
Current proposed fix is to handle specially files named
`pytorch_model.bin` since they are more likely to be `transformers`
files.
This is however not necessarily true, we might want to protect with
checking against `model_info.library_name` though I feel like this is
better to just check against the name, since it's still likely to be a
transformers/diffusers/sentence-transformers thing.
Nicolas Patry [Wed, 23 Nov 2022 10:47:35 +0000 (11:47 +0100)]
Preparing for release. (#104)
Nicolas Patry [Tue, 22 Nov 2022 16:00:05 +0000 (17:00 +0100)]
convert hotfix. (#102)
Nicolas Patry [Tue, 22 Nov 2022 15:07:47 +0000 (16:07 +0100)]
Small qol. (#101)
Nicolas Patry [Tue, 22 Nov 2022 14:36:11 +0000 (15:36 +0100)]
Adding suppot for 3.11 where possible (conda does not support 3.11 yet). (#97)
* Adding suppot for 3.11 where possible (conda does not support 3.11 yet).
* Update .github/workflows/python-release.yml
* Update .github/workflows/python-release-conda.yml
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
Nicolas Patry [Tue, 22 Nov 2022 14:25:30 +0000 (15:25 +0100)]
Making convertion working with diffusers/stable-diffusion. (#96)
* Making convertion working with diffusers/stable-diffusion.
* Update bindings/python/convert.py
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
Nicolas Patry [Tue, 22 Nov 2022 14:07:31 +0000 (15:07 +0100)]
Fixing Windows overflow issue with `c_long`. (#99)
* Fixing Windows overflow issue with `c_long`.
* Adding comment to remove the code once fixed.
* Fixing just like PyO3.
Nicolas Patry [Tue, 22 Nov 2022 12:12:42 +0000 (13:12 +0100)]
Ignore unsound criterion. (#100)
Mishig [Fri, 18 Nov 2022 14:47:04 +0000 (15:47 +0100)]
[docs] we want markdnwo headings to show (#94)
Nicolas Patry [Fri, 18 Nov 2022 14:24:35 +0000 (15:24 +0100)]
Accepting `pathlib.Path` in `save_file/load_file/safe_open`. (#86)
* Accepting `pathlib.Path` in `save_file/load_file/safe_open`.
* as_path.
* Update docstrings.
- Removed unused `:obj:`
- Put `os.PathLike` everywhere it's needed
- python stub.py
Nicolas Patry [Fri, 18 Nov 2022 13:40:12 +0000 (14:40 +0100)]
Torch fixes (#90)
* Fix `KeyError: torch.float64` when serializing tensors of doubles and `KeyError: BF16` when parsing.
* Fix non-working `_view2torch` because of the forgotten returns.
Added some tests.
* Test in the same style.
* Like previous style.
Co-authored-by: KOLANICH <kolan_n@mail.ru>
Mishig [Fri, 18 Nov 2022 13:39:31 +0000 (14:39 +0100)]
[docs] fix notebook automatic creation (#92)
Mishig [Fri, 18 Nov 2022 13:15:53 +0000 (14:15 +0100)]
[docs] Fixes the colab btn on speed page (#91)
Mishig [Fri, 18 Nov 2022 12:47:01 +0000 (13:47 +0100)]
Add missing doc build token (#89)