]> khamidou — GitHub mirrors - safetensors.git/commit
feat: Add filter for shared storage non overlapping tensors (#309)
authorNicolas Patry <patry.nicolas@protonmail.com>
Mon, 7 Aug 2023 07:08:02 +0000 (09:08 +0200)
committerGitHub <noreply@github.com>
Mon, 7 Aug 2023 07:08:02 +0000 (09:08 +0200)
commita01ff65dfbb66e5334e143b44242a93a2ece10eb
treec11965fc2b21e7e0c1768c5ff5ee6fc64aa4cf4b
parent6724ea0344918774fc25faa2257ed64dccb7054f
feat: Add filter for shared storage non overlapping tensors (#309)

* feat: Add filter for shared storage non overlapping tensors

Deepspeed does some tensor sharing but not actually overlapping
tensors. (It's not exactly clear why).

This PR fixes it by adding a global check for all shared tensors if the
actual offsets are overlapping or not.
It looks at all (start, stop) pointers of the tensors, sorts them by start pointer, and decides 2 tensors are disjoint if stop(previous) <= start(next)

* Style.

* Update for zero-sized tensors.

* Update test that now passes.
bindings/python/py_src/safetensors/torch.py
bindings/python/tests/test_pt_comparison.py
bindings/python/tests/test_pt_model.py
bindings/python/tests/test_simple.py