After calling `merge_and_unload()` on a PEFT model, what does the returned object look like?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
merge_and_unload folds the LoRA delta into each base weight and strips the adapter wrapper, returning a plain transformer model with a single matmul per linear and no PEFT runtime.
Picture a violin with a small electronic effects pedal attached by a cable. While the cable is plugged in, the sound is the violin plus the pedal effect every time you play. The pedal is the adapter. merge_and_unload is like baking the pedal effect into the violin's wood itself, then unplugging and discarding the pedal. The instrument now plays the combined sound on its own, no pedal, no cable. The downside is that you can no longer swap pedals to get a different effect; the violin is permanently the merged version. The upside is that anyone can pick it up and play without needing to know about pedals or cables. That is exactly what merge_and_unload does to a PEFT model: it fuses the adapter into the weights and removes the wrapper.
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.
4 min: walk what merge does at each linear, what unload strips, how the returned object differs, name the deployment benefit, and call out the trade off in adapter flexibility plus the quantised base caveat.
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.
Thinking merge_and_unload keeps the adapter for fast hot-swap later. It does the opposite: it fuses the delta into the base and removes the adapter, trading flexibility for a plain serving stack.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.