From e2afe84c6978b40ac349b885c321a6f106cf6a32 Mon Sep 17 00:00:00 2001 From: 2sumtech <2sumtech@gmail.com> Date: Thu, 20 Aug 2026 16:39:44 -0700 Subject: [PATCH] Fix CPU dequantize_4bit output shape for 1-D inputs --- bitsandbytes/backends/cpu/ops.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bitsandbytes/backends/cpu/ops.py b/bitsandbytes/backends/cpu/ops.py index 44fb5dceb..7774477e3 100755 --- a/bitsandbytes/backends/cpu/ops.py +++ b/bitsandbytes/backends/cpu/ops.py @@ -169,9 +169,10 @@ def _( if absmax.dtype != torch.float32: absmax = absmax.float() - if len(shape) == 1: - shape = (1, shape[0]) - + # The kernel views the input as a 2-D (m, n) matrix, with m == 1 for 1-D + # inputs. The output buffer keeps the caller-provided shape: the + # CUDA/default/MPS backends and the registered fake kernel all return + # exactly `shape`. m = prod(shape[:-1]) n = shape[-1]