From 9d60b3c5279641ba936facd710c722ebe52fcf40 Mon Sep 17 00:00:00 2001 From: Tim Dettmers Date: Wed, 17 Aug 2022 03:45:57 -0700 Subject: Fixed bug in Linear8bitLt, when the bias is None. --- bitsandbytes/nn/modules.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'bitsandbytes') diff --git a/bitsandbytes/nn/modules.py b/bitsandbytes/nn/modules.py index 24ecf39..b222f54 100644 --- a/bitsandbytes/nn/modules.py +++ b/bitsandbytes/nn/modules.py @@ -248,10 +248,10 @@ class Linear8bitLt(nn.Linear): if self.weight.CB is not None: self.init_8bit_state() - if self.bias.dtype != torch.float16: + + # weights are cast automatically as Int8Params, but the bias has to be cast manually + if self.bias is not None and self.bias.dtype != torch.float16: self.bias.data = self.bias.data.half() - # assert not self.state.has_fp16_weights - # if not self.state.has_fp16_weights: assert self.state.CB is not None or self.state.CxB is not None out = bnb.matmul(x, self.weight, bias=self.bias, state=self.state) -- cgit v1.2.3