Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Efficiently read safetensors from disk #4

Merged
merged 3 commits into from
Sep 26, 2023
Merged

Conversation

josevalim
Copy link
Contributor

@jonatanklosko if you agree with the direction, it may be a good idea to use safetensor as the default way of loading models for Bumblebee. It puts lets pressure on memory.

lib/safetensors.ex Outdated Show resolved Hide resolved
@jonatanklosko
Copy link
Member

@josevalim sounds good!

This makes a difference assuming that the binaries are garbage collected as we go. Do you know if the Erlang compiler would optimise it if we are not keeping a reference, or is it still going to be allocated globally?

lib/safetensors.ex Outdated Show resolved Hide resolved
Co-authored-by: Jonatan Kłosko <jonatanklosko@gmail.com>
@josevalim
Copy link
Contributor Author

@jonatanklosko we don't know when the GC will run but this will at least allow the GC to run. We can also force it in the future by calling :erlang.garbage_collect for certain input sizes, but baby steps. :)

@josevalim josevalim merged commit e259162 into main Sep 26, 2023
2 checks passed
@josevalim
Copy link
Contributor Author

💚 💙 💜 💛 ❤️

@josevalim josevalim deleted the jv-safetensor-read branch September 26, 2023 08:31
@grzuy
Copy link
Contributor

grzuy commented Sep 26, 2023

💯 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants