Skip to content

Commit

Permalink
add device index
Browse files Browse the repository at this point in the history
  • Loading branch information
faaany committed Jan 24, 2025
1 parent f6025bc commit 64b2d16
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bitsandbytes/nn/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,9 +660,9 @@ def cpu(self):
self.SCB = SCB
return self

def xpu(self):
def xpu(self, device):
# we store the 8-bit rows-major weight
B = self.data.contiguous().to(torch.float16).xpu()
B = self.data.contiguous().to(torch.float16).xpu(device)
CB, CBt, SCB, SCBt, coo_tensorB = bnb.functional.double_quant(B)
if CBt is not None:
del CBt
Expand Down Expand Up @@ -700,11 +700,11 @@ def to(self, *args, **kwargs):
return self.cpu()
elif device.type == "xpu":
if self.data.dtype == torch.int8:
self.data = self.data.contiguous().xpu()
self.data = self.data.contiguous().xpu(device)
self.CB = self.data
return self
else:
return self.xpu()
return self.xpu(device)
else:
new_param = Int8Params(
super().to(device=device, dtype=dtype, non_blocking=non_blocking),
Expand Down

0 comments on commit 64b2d16

Please sign in to comment.