Skip to content

Commit 31b667b

Browse files
committed
Quant Method missing
1 parent 874b262 commit 31b667b

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

unsloth/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,10 @@
8989
# except:
9090
# raise ImportError("Unsloth: Please update unsloth_zoo via `pip install --upgrade --no-cache-dir --no-deps unsloth_zoo`")
9191
import unsloth_zoo
92-
except:
93-
raise ImportError("Unsloth: Please install unsloth_zoo via `pip install unsloth_zoo`")
92+
except NotImplementedError as e:
93+
raise NotImplementedError(str(e))
94+
except Exception as e:
95+
raise ImportError(f"Unsloth: Please install unsloth_zoo via `pip install unsloth_zoo` Also error = {str(e)}")
9496
pass
9597

9698
from unsloth_zoo.device_type import (

unsloth/models/vision.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,14 @@ def from_pretrained(
538538
if hasattr(auto_config, "quantization_config"):
539539
from transformers.quantizers.auto import AUTO_QUANTIZATION_CONFIG_MAPPING
540540
quantization_config = auto_config.quantization_config
541-
quantizer = AUTO_QUANTIZATION_CONFIG_MAPPING[quantization_config["quant_method"]]
541+
quant_method = quantization_config["quant_method"]
542+
# Sometimes bitsandbytes_4bit + bitsandbytes_8bit is provided
543+
if quant_method == "bitsandbytes" and "bitsandbytes" not in AUTO_QUANTIZATION_CONFIG_MAPPING:
544+
if "bitsandbytes_4bit" not in AUTO_QUANTIZATION_CONFIG_MAPPING:
545+
raise KeyError("Unsloth: AUTO_QUANTIZATION_CONFIG_MAPPING does not have `bitsandbytes_4bit`")
546+
quantizer = AUTO_QUANTIZATION_CONFIG_MAPPING["bitsandbytes_4bit"]
547+
else:
548+
quantizer = AUTO_QUANTIZATION_CONFIG_MAPPING[quant_method]
542549
quantizer_kwargs = {}
543550
# We cannot dequantize since gpt-oss-20b MXFP4 will now be gpt-oss-20b-BF16
544551
if load_in_16bit and "dequantize" in inspect.signature(quantizer).parameters:

0 commit comments

Comments
 (0)