Spaces:
Running on Zero
Running on Zero
Fix bnb Params4bit.shape tuple (.numel via math.prod); unpin bitsandbytes for cu130
Browse files
diffusers_src/src/diffusers/quantizers/bitsandbytes/bnb_quantizer.py
CHANGED
|
@@ -16,6 +16,7 @@ Adapted from
|
|
| 16 |
https://github.com/huggingface/transformers/blob/c409cd81777fb27aadc043ed3d8339dbc020fb3b/src/transformers/quantizers/quantizer_bnb_4bit.py
|
| 17 |
"""
|
| 18 |
|
|
|
|
| 19 |
from typing import TYPE_CHECKING, Any
|
| 20 |
|
| 21 |
from ...utils import get_module_from_name
|
|
@@ -209,7 +210,8 @@ class BnB4BitDiffusersQuantizer(DiffusersQuantizer):
|
|
| 209 |
current_param_shape = current_param.shape
|
| 210 |
loaded_param_shape = loaded_param.shape
|
| 211 |
|
| 212 |
-
|
|
|
|
| 213 |
inferred_shape = (n,) if "bias" in param_name else ((n + 1) // 2, 1)
|
| 214 |
if loaded_param_shape != inferred_shape:
|
| 215 |
raise ValueError(
|
|
|
|
| 16 |
https://github.com/huggingface/transformers/blob/c409cd81777fb27aadc043ed3d8339dbc020fb3b/src/transformers/quantizers/quantizer_bnb_4bit.py
|
| 17 |
"""
|
| 18 |
|
| 19 |
+
import math
|
| 20 |
from typing import TYPE_CHECKING, Any
|
| 21 |
|
| 22 |
from ...utils import get_module_from_name
|
|
|
|
| 210 |
current_param_shape = current_param.shape
|
| 211 |
loaded_param_shape = loaded_param.shape
|
| 212 |
|
| 213 |
+
# newer bitsandbytes returns Params4bit.shape as a plain tuple (no .numel()); math.prod handles both.
|
| 214 |
+
n = math.prod(current_param_shape)
|
| 215 |
inferred_shape = (n,) if "bias" in param_name else ((n + 1) // 2, 1)
|
| 216 |
if loaded_param_shape != inferred_shape:
|
| 217 |
raise ValueError(
|
requirements.txt
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
transformers==5.8.0
|
| 2 |
peft==0.19.1
|
| 3 |
accelerate==1.10.1
|
| 4 |
-
bitsandbytes
|
| 5 |
sentencepiece
|
| 6 |
outlines==1.3.0
|
| 7 |
pydantic>=2
|
|
|
|
| 1 |
transformers==5.8.0
|
| 2 |
peft==0.19.1
|
| 3 |
accelerate==1.10.1
|
| 4 |
+
bitsandbytes
|
| 5 |
sentencepiece
|
| 6 |
outlines==1.3.0
|
| 7 |
pydantic>=2
|