Spaces:
Runtime error
Runtime error
Move bnb Params4bit.shape fix to a runtime shim in app.py; restore pristine bundled diffusers
Browse filesFiles changed (2)
18 unmodified lines19202122232418 unmodified linesfrom diffusers import Ideogram4PipelineMODEL_ID = "diffusers-internal-dev/ideogram-4-nf4-v2"LM_HEAD_REPO = "multimodalart/qwen3-vl-8b-instruct-lm-head"AOTI_REPO = "multimodalart/i4-block-aoti"18 unmodified lines19202122232425262728293031323334353637383940414218 unmodified linesfrom diffusers import Ideogram4Pipeline# Runtime shim (keeps the bundled diffusers pristine): cu130-era bitsandbytes returns Params4bit.shape as a# plain tuple, but diffusers' check_quantized_param_shape calls .numel() on it. math.prod handles both, so# this is a no-op once diffusers/bnb fix it upstream.import math # noqa: E402from diffusers.quantizers.bitsandbytes.bnb_quantizer import BnB4BitDiffusersQuantizer # noqa: E402def _check_quantized_param_shape(self, param_name, current_param, loaded_param):n = math.prod(tuple(current_param.shape))inferred_shape = (n,) if "bias" in param_name else ((n + 1) // 2, 1)if tuple(loaded_param.shape) != tuple(inferred_shape):raise ValueError(f"Expected flattened shape of {param_name} to be {inferred_shape}, got {tuple(loaded_param.shape)}.")return TrueBnB4BitDiffusersQuantizer.check_quantized_param_shape = _check_quantized_param_shapeMODEL_ID = "diffusers-internal-dev/ideogram-4-nf4-v2"LM_HEAD_REPO = "multimodalart/qwen3-vl-8b-instruct-lm-head"AOTI_REPO = "multimodalart/i4-block-aoti"
15 unmodified lines16171819202122187 unmodified lines21021121221321421521621715 unmodified lineshttps://github.com/huggingface/transformers/blob/c409cd81777fb27aadc043ed3d8339dbc020fb3b/src/transformers/quantizers/quantizer_bnb_4bit.py"""import mathfrom typing import TYPE_CHECKING, Anyfrom ...utils import get_module_from_name187 unmodified linescurrent_param_shape = current_param.shapeloaded_param_shape = loaded_param.shape# newer bitsandbytes returns Params4bit.shape as a plain tuple (no .numel()); math.prod handles both.n = math.prod(current_param_shape)inferred_shape = (n,) if "bias" in param_name else ((n + 1) // 2, 1)if loaded_param_shape != inferred_shape:raise ValueError(15 unmodified lines161718192021187 unmodified lines20921021121221321421515 unmodified lineshttps://github.com/huggingface/transformers/blob/c409cd81777fb27aadc043ed3d8339dbc020fb3b/src/transformers/quantizers/quantizer_bnb_4bit.py"""from typing import TYPE_CHECKING, Anyfrom ...utils import get_module_from_name187 unmodified linescurrent_param_shape = current_param.shapeloaded_param_shape = loaded_param.shapen = current_param_shape.numel()inferred_shape = (n,) if "bias" in param_name else ((n + 1) // 2, 1)if loaded_param_shape != inferred_shape:raise ValueError(
app.py+18
diffusers_src/src/diffusers/quantizers/bitsandbytes/bnb_quantizer.py+1-3