BitsAndBytes enables -bit and -bit quantization. It's what makes QLoRA possible.
model = AutoModelForCausalLM.from_pretrained(
model_id,
load_in_4bit=True,
bnb_4bit_compute_dtype=torch.bfloat16
)
BitsAndBytes handles the quantization math. You just set the config option. Works with most Hugging Face models.