diff --git a/bitsandbytes/nn/modules.py b/bitsandbytes/nn/modules.py index d3332acfe..9c0a647cb 100644 --- a/bitsandbytes/nn/modules.py +++ b/bitsandbytes/nn/modules.py @@ -515,7 +515,9 @@ def _save_to_state_dict(self, destination, prefix, keep_vars): save weight and bias, then fill state_dict with components of quant_state """ - if getattr(self.weight.quant_state, "packing_format_for_cpu", False): + if getattr(self.weight, "quant_state", None) is not None and getattr( + self.weight.quant_state, "packing_format_for_cpu", False + ): self.weight.data, self.weight.quant_state = _convert_weight_packed_for_cpu_inverse( self.weight.data, self.weight.quant_state )