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

add method to set default kind of new variables in VarStore #893

Merged
merged 3 commits into from
Sep 12, 2024

Conversation

jquesnelle
Copy link
Contributor

This changes the behavior of VarStore::set_kind to change the default kind for all new variables created in the VarStore, similar to torch.set_default_dtype (but localized to the VarStore).

The need for this is that for larger models like Llama-7b first instantiating an empty model and then filling in the tensors from an mmap-ed safetenstors file (for example) won't work on a 24GB GPU since a 7B won't fit in Kind::Float. Rather, newly inited tensors need to start out as Kind::Half or Kind::BFloat16.

The default behavior of VarStore is unchanged -- existing code that doesn't call set_kind will have new tensors created at as Kind::Float.

@LaurentMazare LaurentMazare merged commit 9c498e6 into LaurentMazare:main Sep 12, 2024
9 of 13 checks passed
@LaurentMazare
Copy link
Owner

Thanks!

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.

2 participants