When does a PEFT config actually need `modules_to_save` set, and what goes in it?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
modules_to_save trains listed modules fully alongside the LoRA adapter, typically embed_tokens and lm_head when the tokenizer gains new tokens whose random rows LoRA cannot reach.
Imagine your model is a giant library with a fixed catalogue of book topics. LoRA is a small set of margin notes you can scribble on existing pages to adjust how they read. Then one day you add brand new book categories to the library, categories the original catalogue never had. Those new categories need fresh full pages in the index, not margin notes. modules_to_save is the list of pages you mark as needing fresh full pages instead of margin notes. The most common case is adding new words to the model's vocabulary; the input lookup table and the output prediction layer both need new full pages for the new words to make sense.
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: name modules_to_save's semantics, place vocab extension as the canonical use case, list embed_tokens and lm_head, contrast with target_modules, and surface the tied weight and memory caveats.
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.
Treating modules_to_save as a list of LoRA target modules. It is the opposite: these modules bypass LoRA entirely and train at full precision in full rank.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.