DeprecationWarning
transformers.utils.versions.DeprecationWarning
Stack trace
DeprecationWarning: The 'bits_and_bytes' config parameter is deprecated and will be removed in future versions. Please update your quantization setup accordingly.
warnings.warn("The 'bits_and_bytes' config parameter is deprecated and will be removed in future versions.", DeprecationWarning) Why it happens
Recent updates to the transformers and bitsandbytes libraries have deprecated the 'bits_and_bytes' configuration parameter for model quantization. This parameter is no longer recognized, causing warnings or errors when used. The libraries now require updated APIs or different configuration methods for quantization.
Detection
Monitor your application logs for DeprecationWarning messages mentioning 'bits_and_bytes' config usage during model loading or quantization initialization.
Causes & fixes
Using the deprecated 'bits_and_bytes' parameter in model loading or quantization config
Remove the 'bits_and_bytes' parameter and switch to the new quantization API or configuration method as per the latest transformers and bitsandbytes documentation.
Outdated code or tutorials referencing old quantization config syntax
Update your codebase and dependencies to the latest versions and follow the current official quantization setup guides.
Mixing incompatible versions of transformers and bitsandbytes libraries
Ensure compatible versions of transformers and bitsandbytes are installed, matching the new quantization API requirements.
Code: broken vs fixed
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained(
'model-name',
bits_and_bytes_config={'load_in_4bit': True} # This line triggers the deprecation warning
) import os
from transformers import AutoModelForCausalLM
# Removed deprecated bits_and_bytes_config and use new quantization API
model = AutoModelForCausalLM.from_pretrained(
os.environ['MODEL_NAME'],
load_in_4bit=True # Use updated parameter directly if supported
)
print('Model loaded with updated quantization config') Workaround
If immediate upgrade is not possible, suppress DeprecationWarnings temporarily using Python warnings filter, but plan to update code soon to avoid future breakage.
Prevention
Regularly update transformers and bitsandbytes libraries and refactor quantization code to use the latest supported APIs to avoid deprecated config usage.