System Info
transformers version: 5.1.0
- Platform: Windows-11-10.0.26200-SP0
- Python version: 3.12.11
- Huggingface_hub version: 1.27.0
- Safetensors version: 0.8.0
- Accelerate version: 1.14.0
- Accelerate config: not found
- DeepSpeed version: not installed
- PyTorch version (GPU?): 2.5.1+cu124 (True)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- bitsandbytes version: 0.50.0
Who can help?
@SunMarc @MekkCyber
Information
Tasks
Reproduction
from transformers import AutoModelForCausalLM, BitsAndBytesConfig
from peft import PeftModel
quant_config = BitsAndBytesConfig(load_in_8bit=True)
base_model = AutoModelForCausalLM.from_pretrained(
"meta-llama/Meta-Llama-3-8B-Instruct",
quantization_config=quant_config,
device_map="auto",
)
# Next call triggers _load_pretrained_model again via load_adapter
model = PeftModel.from_pretrained(base_model, "some-peft-adapter")
Traceback:
File "transformers/modeling_utils.py", line 4677, in caching_allocator_warmup
total_byte_count = get_total_byte_count(model, accelerator_device_map, hf_quantizer)
File "transformers/modeling_utils.py", line 4634, in get_total_byte_count
param = model.get_parameter_or_buffer(param_name)
File "transformers/modeling_utils.py", line 4550, in get_parameter_or_buffer
raise AttributeError(f"`{target}` is neither a parameter, buffer, nor extra state.")
AttributeError: `layers.0.self_attn.q_proj.base_layer.SCB` is neither a parameter, buffer, nor extra state.
Expected behavior
A clear and concise description of what you would expect to happen:
Loading a PEFT adapter on top of a bitsandbytes-quantized model should succeed.
Now, caching_allocator_warmup (introduced in 5.x) crashes because expanded_device_map includes entries like layers.0.self_attn.q_proj.base_layer.SCB, which are bitsandbytes internal tensors stored as plain Python attributes on Int8Params (not registered via register_parameter()/register_buffer()), so get_parameter_or_buffer() cannot find them.
caching_allocator_warmup already exempts HQQ and Quark by skipping the warmup entirely for those quantization methods, but BITS_AND_BYTES is missing from that exemption list, I add that to the list fix the problem #47919
System Info
transformersversion: 5.1.0Who can help?
@SunMarc @MekkCyber
Information
Tasks
examplesfolder (such as GLUE/SQuAD, ...)Reproduction
Traceback:
Expected behavior
A clear and concise description of what you would expect to happen:
Loading a PEFT adapter on top of a bitsandbytes-quantized model should succeed.
Now,
caching_allocator_warmup(introduced in 5.x) crashes becauseexpanded_device_mapincludes entries likelayers.0.self_attn.q_proj.base_layer.SCB, which are bitsandbytes internal tensors stored as plain Python attributes onInt8Params(not registered viaregister_parameter()/register_buffer()), soget_parameter_or_buffer()cannot find them.caching_allocator_warmupalready exempts HQQ and Quark by skipping the warmup entirely for those quantization methods, butBITS_AND_BYTESis missing from that exemption list, I add that to the list fix the problem #47919