Skip to content

Commit 01d060d

Browse files
fix
1 parent 1c96a34 commit 01d060d

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

  • bitsandbytes/backends/default

bitsandbytes/backends/default/ops.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@ def _(
248248

249249
# Quantize with the lookup table
250250
code = CODE[quant_type].to(scaled.device).to(scaled.dtype)
251+
# Pad to even length so packing pairs all elements
252+
if scaled.numel() % 2 != 0:
253+
scaled = torch.nn.functional.pad(scaled, (0, 1), value=0.0)
251254
quantized = torch.argmin(torch.abs(scaled.view(-1, 1) - code), dim=-1, keepdim=True).to(torch.uint8)
252255

253256
# Pack two quantized values per byte

0 commit comments

Comments
 (0)