-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Move buffers to device #10523
Move buffers to device #10523
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -246,6 +246,17 @@ def load_model_dict_into_meta( | |
else: | ||
set_module_tensor_to_device(model, param_name, device, value=param) | ||
|
||
for param_name, param in model.named_buffers(): | ||
if is_quantized and ( | ||
hf_quantizer.check_if_quantized_param(model, param, param_name, state_dict, param_device=device) | ||
): | ||
hf_quantizer.create_quantized_param(model, param, param_name, device, state_dict, unexpected_keys) | ||
else: | ||
if accepts_dtype: | ||
set_module_tensor_to_device(model, param_name, device, value=param, **set_module_kwargs) | ||
else: | ||
set_module_tensor_to_device(model, param_name, device, value=param) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting. Let's also have a test for this? Cc: @SunMarc too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. persistant buffer should be in the state dict no ? It is for non persistant buffers ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, for non-persistent buffers. |
||
return unexpected_keys | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we move the changes outside of the function? it takes a
state_dict
as input so it is strange that it also do something with model.named_buffer()would it work if we run
load_model_dict_into_meta
on the buffers in a seperate call? if not, we could add an additional argument