diff --git a/bitsandbytes/autograd/_functions.py b/bitsandbytes/autograd/_functions.py index b34f4a943..0258768e2 100644 --- a/bitsandbytes/autograd/_functions.py +++ b/bitsandbytes/autograd/_functions.py @@ -378,7 +378,8 @@ def matmul_4bit( out: Optional[torch.Tensor] = None, bias: Optional[torch.Tensor] = None, ): - assert quant_state is not None + if quant_state is None: + raise ValueError("quant_state cannot be None") # Change dtype to input dtype on CPU if A.device.type == "cpu": quant_state.dtype = A.dtype diff --git a/bitsandbytes/functional.py b/bitsandbytes/functional.py index 6ce846277..22109c3d2 100644 --- a/bitsandbytes/functional.py +++ b/bitsandbytes/functional.py @@ -707,7 +707,8 @@ def dequantize_blockwise( The dequantized tensor. The datatype is indicated by `quant_state.dtype` and defaults to `torch.float32`. """ - assert quant_state is not None or absmax is not None + if quant_state is None and absmax is None: + raise ValueError("Either quant_state or absmax must be provided") if code is None and quant_state is None: if "dynamic" not in name2qmap: name2qmap["dynamic"] = create_dynamic_map().to(A.device)