npx skills add ...
npx skills add firecrawl/ai-research-skills --skill quantizing-models-bitsandbytes
Quantizes LLMs to 8-bit or 4-bit for 50-75% memory reduction with minimal accuracy loss. Use when GPU memory is limited, need to fit larger models, or want faster inference. Supports INT8, NF4, FP4 formats, QLoRA training, and 8-bit optimizers. Works with HuggingFace Transformers.
npx skills add firecrawl/ai-research-skills --skill quantizing-models-bitsandbytes
bitsandbytes reduces LLM memory by 50% (8-bit) or 75% (4-bit) with <1% accuracy loss.
Installation:
8-bit quantization (50% memory reduction):
4-bit quantization (75% memory reduction):
Copy this checklist:
Step 1: Calculate memory requirements
Estimate model memory:
Step 2: Choose quantization level
| GPU VRAM | Model Size | Recommended |
|---|---|---|
| 8 GB | 3B | 4-bit |
| 12 GB | 7B | 4-bit |
| 16 GB | 7B | 8-bit or 4-bit |
| 24 GB | 13B | 8-bit or 70B 4-bit |
| 40+ GB | 70B | 8-bit |
Step 3: Configure quantization
For 8-bit (better accuracy):
For 4-bit (maximum memory savings):
Step 4: Load and verify model
QLoRA enables fine-tuning large models on consumer GPUs.
Copy this checklist:
Step 1: Install dependencies
Step 2: Configure 4-bit base model
Step 3: Add LoRA adapters
Step 4: Train with standard Trainer
Use 8-bit Adam/AdamW to reduce optimizer memory by 75%.
Step 1: Replace standard optimizer
Manual optimizer usage:
Step 2: Configure training
Compare memory:
Step 3: Monitor memory savings
Use bitsandbytes when:
Use alternatives instead:
Issue: CUDA error during loading
Install matching CUDA version:
Issue: Model loading slow
Use CPU offload for large models:
Issue: Lower accuracy than expected
Try 8-bit instead of 4-bit:
Or use NF4 with double quantization:
Issue: OOM even with 4-bit
Enable CPU offload:
QLoRA training guide: See references/qlora-training.md for complete fine-tuning workflows, hyperparameter tuning, and multi-GPU training.
Quantization formats: See references/quantization-formats.md for INT8, NF4, FP4 comparison, double quantization, and custom quantization configs.
Memory optimization: See references/memory-optimization.md for CPU offloading strategies, gradient checkpointing, and memory profiling.
Supported platforms: NVIDIA GPUs (primary), AMD ROCm, Intel GPUs (experimental)