High severity intermediate · Fix: 5-10 min

DeprecationWarning

transformers.utils.versions.DeprecationWarning

What this error means
The bits_and_bytes configuration for model quantization is deprecated and no longer supported in recent transformers and bitsandbytes versions.

Stack trace

traceback
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)
QUICK FIX
Remove 'bits_and_bytes' config from your model loading code and update to the latest quantization API per transformers and bitsandbytes docs.

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

1

Using the deprecated 'bits_and_bytes' parameter in model loading or quantization config

✓ Fix

Remove the 'bits_and_bytes' parameter and switch to the new quantization API or configuration method as per the latest transformers and bitsandbytes documentation.

2

Outdated code or tutorials referencing old quantization config syntax

✓ Fix

Update your codebase and dependencies to the latest versions and follow the current official quantization setup guides.

3

Mixing incompatible versions of transformers and bitsandbytes libraries

✓ Fix

Ensure compatible versions of transformers and bitsandbytes are installed, matching the new quantization API requirements.

Code: broken vs fixed

Broken - triggers the error
python
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained(
    'model-name',
    bits_and_bytes_config={'load_in_4bit': True}  # This line triggers the deprecation warning
)
Fixed - works correctly
python
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')
Removed the deprecated 'bits_and_bytes_config' parameter and replaced it with the updated quantization parameter 'load_in_4bit' directly, following the latest API.

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.

Python 3.9+ · transformers >=4.30.0 · tested on 4.31.x
Verified 2026-04
Verify ↗

Community Notes

No notes yetBe the first to share a version-specific fix or tip.