AI Coding Tools List
February 7, 2025
Recap on ML
February 7, 2025
February 7, 2025
June 8, 2024
May 27, 2024
May 5, 2024
ValueError: SegformerForImageClassification does not support device_map='auto'. To implement support, the modelclass needs to implement the _no_split_modules attribute.
and
ValueError: SegformerForImageClassification does not support device_map='sequential'. To implement support, the modelclass needs to implement the _no_split_modules attribute.
from_pretrained()
supports device_map='auto'
, but not SegformerForImageClassificationdevice_map=0
(cuda:0) as default param into SegformerForImageClassification.from_pretrained()
RuntimeError: Input type (float) and bias type (c10::Half) should be the same
copy()
input dict and half()
the pixel_values
RuntimeError: "slow_conv2d_cpu" not implemented for 'Half'
UserWarning: Input type into Linear4bit is torch.float16, but bnb_4bit_compute_type=torch.float32 (default). This will lead to slow inference or training speed.
BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_compute_dtype=<dtpype>)
RuntimeError: Input type (float) and bias type (c10::Half) should be the same
collate_fn
with tensor.half()
ValueError: The model you want to train is loaded in 8-bit precision. if you want to fine-tune an 8-bit model, please make sure that you have installed bitsandbytes>=0.37.2.
Trainer()
despite having bitsandbytes>=0.37.0
installed and imported, e.g. %pip list | grep bitsandbytes
yields bitsandbytes 0.41.1
UserWarning: You are calling save_pretrained to a 8-bit converted model you may likely encounter unexepected behaviors. If you want to save 8-bit models, make sure to have bitsandbytes>0.37.2 installed.
NotImplementedError: You are calling save_pretrained on a 4-bit converted model. This is currently not supported
RuntimeError: Loading a quantized checkpoint into non-quantized Linear8bitLt is not supported. Please call module.cuda() before module.load_state_dict()
Designing a device map
"auto", "balanced", "balanced_low_0", "sequential"
accelerate.infer_auto_device_map
device_map=0
or device_map={'':torch.cuda.current_device()}
May 5, 2024
8-bit quantization with bitsandbytes
From LLM.int8() Paper, Source GH. 8-bit HF inference example
bnb.optim.Adam8bit(....)
bnb.nn.Embedding(..)
linear = bnb.nn.Linear8bitLt(...)
LLM.int8()
methodBitsAndBytesConfig
also offers configuration support.
from transformers import BitsAndBytesConfig
# quantization_config = BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_compute_dtype=bf16)
nf4_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
)
torch.distributed.run