Quantized Modules and Functional Primitives
Use this sub-skill when the task needs direct bitsandbytes.nn, bitsandbytes.functional, bitsandbytes.matmul, bitsandbytes.matmul_4bit, or torch.ops.bitsandbytes APIs rather than Hugging Face model-loading wrappers.
Choose this sub-skill for
- Replacing
torch.nn.Linearortorch.nn.EmbeddingwithLinear8bitLt,Linear4bit,LinearNF4,LinearFP4,Embedding8bit,Embedding4bit,EmbeddingNF4, orEmbeddingFP4in custom PyTorch code. - Working directly with
Int8Params,Params4bit,QuantState,matmul,matmul_4bit, int8 vectorwise quantization, 4-bit quantization, or blockwise quantization primitives. - Debugging direct module state dicts, quantized checkpoints,
SCB/CBfields,.to(device)quantization timing,quant_statehandling, blocksize rules, or quantized tensor storage dtype. - Creating CPU-safe construction/signature checks for agents or CI without requiring quantized GPU kernels.
Route elsewhere
- Hugging Face
BitsAndBytesConfig,load_in_8bit,load_in_4bit, QLoRA model loading, PEFT, Accelerate, Diffusers, and FSDP-QLoRA workflows route totransformers-integrations. - Package installation, backend compatibility, missing native library, CUDA/ROCm/XPU/HPU/MPS setup, and
python -m bitsandbytesfailures route toinstallation-diagnostics. Adam8bit,AdamW8bit, paged optimizers,GlobalOptimManager,StableEmbedding, and training-loop optimizer behavior route tooptimizers-training.
Start here
- Read
references/api-reference.mdfor verified constructor/function signatures and parameter notes. - Use
references/workflows.mdfor direct layer replacement, quantize-on-.to(device), save/load caveats, and primitive recipes. - Use
references/troubleshooting.mdto map common symptoms to recovery steps. - Run
scripts/quantized-module-smoke.pyfor a deterministic CPU-safe import/construction/signature check; pass--device cudaor another backend only when that backend is available and native quantized kernels are expected to work.
