Skip to content

Commit

Permalink
bnb device map check
Browse files Browse the repository at this point in the history
  • Loading branch information
a-r-r-o-w committed Dec 5, 2024
1 parent 101d10c commit edd98db
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/diffusers/models/modeling_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,12 @@ def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.P
hf_quantizer = None

if hf_quantizer is not None:
is_bnb_quantization_method = hf_quantizer.quantization_config.quant_method.value == "bitsandbytes"
if is_bnb_quantization_method and device_map is not None:
raise NotImplementedError(
"Currently, `device_map` is automatically inferred for quantized bitsandbytes models. Support for providing `device_map` as an input will be added in the future."
)

hf_quantizer.validate_environment(torch_dtype=torch_dtype, from_flax=from_flax, device_map=device_map)
torch_dtype = hf_quantizer.update_torch_dtype(torch_dtype)

Expand Down

0 comments on commit edd98db

Please sign in to comment.