From 6f8fe138a5e211abeaa2c6aa9e1c688defb19a43 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Mon, 24 Nov 2025 05:50:22 -0800 Subject: [PATCH] Update vision.py --- unsloth/models/vision.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/unsloth/models/vision.py b/unsloth/models/vision.py index c0084f7d55..30d381c791 100644 --- a/unsloth/models/vision.py +++ b/unsloth/models/vision.py @@ -618,16 +618,24 @@ class FastBaseModel: else: quantizer = AUTO_QUANTIZATION_CONFIG_MAPPING[quant_method] quantizer_kwargs = {} - # We cannot dequantize since gpt-oss-20b MXFP4 will now be gpt-oss-20b-BF16 - if ( - load_in_16bit - and "dequantize" in inspect.signature(quantizer).parameters - ): - quantizer_kwargs["dequantize"] = True - quantization_config = quantizer.from_dict( - quantization_config, **quantizer_kwargs - ) - kwargs["quantization_config"] = quantization_config + if quant_method == "compressed-tensors": + # Ignore these + pass + else: + # We cannot dequantize since gpt-oss-20b MXFP4 will now be gpt-oss-20b-BF16 + if ( + load_in_16bit + and "dequantize" in inspect.signature(quantizer).parameters + ): + quantizer_kwargs["dequantize"] = True + try: + # Sometimes this fails so we wrap it in a try except + quantization_config = quantizer.from_dict( + quantization_config, **quantizer_kwargs + ) + except: + pass + kwargs["quantization_config"] = quantization_config # Check if using forced float32 - we load it in bfloat16, then cast to float16! torch_dtype = dtype