-
Notifications
You must be signed in to change notification settings - Fork 976
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
Fix: Resolve #3060, preload_module_classes
is lost for nested modules
#3248
base: main
Are you sure you want to change the base?
Conversation
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.
LGTM ! Thanks for fixing ! Could you share which specific issue you where having ? Also if you can implement a test, it would be nice but not needed to merged this PR. You can fix the CI with make style
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
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.
agreed with Marc, some more details to this issue and adding a test is needed.
preload_module_classes
is lost for nested modules
Hi @muellerzr and @SunMarc Thanks for your review. I have briefly described the issue in overview of this PR. |
@@ -762,3 +762,64 @@ def test_save_model_with_stateful_dataloader(self, use_safetensors, tied_weights | |||
assert torch.allclose(original_linear1, new_linear1) | |||
assert torch.allclose(original_batchnorm, new_batchnorm) | |||
assert torch.allclose(original_linear2, new_linear2) | |||
|
|||
@require_cuda |
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.
we need a require_transformers
decorator if you are going to import transformers here. Otherwise, we can try to not use it and just save the model with
checkpoint = os.path.join(tmp_dir, "pt_model.bin")
torch.save(model.state_dict(), checkpoint)
What does this PR do?
We ran into this issue when try to load VPTQ models by multiple devices, the
VQLinear
layer has embending as its sub-module. This function should move all constant buffers/parameters to the corresponding devices from Meta device.So
add_hook_to_module
should passpreload_module_classes
to the next recursive calling for the nested modules.https://github.com/microsoft/VPTQ/blob/ac7258f461e214ca705f5895513f314576750528/vptq/layers/vqlinear.py#L160C18-L160C18
This PR is to fix #3060