Merging a LoRA back into an NF4-quantized base hits one subtle problem: name it and explain why
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
QLoRA stores the base weights in NF4 (4-bit) and trains LoRA adapters in bf16 on top. After training, you want to merge the LoRA delta back into the base so inference can use a plain weight tensor with no adapter overhead. Name the subtle problem you hit, explain the underlying type-arithmetic issue, and give the practical merge pattern teams actually use.
You can't add a bf16 delta directly to an NF4 codebook; either dequant-add and keep bf16 (loses memory win) or dequant-add and requant (distorts the delta), so teams merge into a bf16 base and ship a separate NF4 build.
Picture a chef who organises a pantry with about a dozen labelled jars that approximate every spice they ever use. A guest hands them a new spice blend in a measuring cup. They cannot just pour the blend into one of the jars; the jars hold the codes, not the spices themselves. The chef has to pull a few jars off the shelf, mix them up to make the real spice, add the guest's blend, and then either keep the mixture in the measuring cup or pour it back into the closest jar, which will round the new blend to whatever pre-set ratio is nearest. Keeping the cup is accurate but takes more shelf space. Rounding into a jar saves space but loses the guest's exact recipe. Teams take the cup home for accuracy and brew a fresh small-jar version separately for serving.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
7 min: explain why NF4 codes cannot accept a bf16 add directly, walk through dequant, add, resolve with both lossy choices, prescribe the bf16-merge plus separate NF4-deploy pattern, and call out merge_and_unload behaviour plus double quantization pitfalls.
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Calling merge_and_unload on a model loaded in 4-bit and expecting a clean NF4 output. The merge dequantizes silently or fails; either way the deployment artifact is not what you think it is.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.