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

4-bit quantization meta device bias loading bug: fixes #2742 #2743

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/accelerate/utils/modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,11 @@ def set_module_tensor_to_device(
elif module.__class__.__name__ == "Linear4bit" and getattr(module.weight, "quant_state", None) is None:
# quantize only if necessary
device_index = torch.device(device).index if torch.device(device).type == "cuda" else None
if not getattr(module.weight, "quant_state", None) and device_index is not None:
if (
not getattr(module.weight, "quant_state", None)
and device_index is not None
and str(module.weight.device) != "meta"
Copy link
Member

@SunMarc SunMarc May 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's put this additional condition in the above condtion where we check for Linear4bit class , to mimic what we did for Linear8bitLt

):
module.weight = module.weight.cuda(device_index)
# clean pre and post foward hook
if device != "cpu":
Expand Down
Loading