Highlights

Contents

Part VI
06

Choosing and carrying an adapter

An adapter depends on more than its saved matrices. Targets, scaling, and base identity determine its effect. Inspect those dependencies and validate any merge before treating the result as a standalone checkpoint.

THE AGENT AND ITS TRAINING PATHDefine tools01Run the loop02Measure tasks03Choose training04Build LoRA05Count adapters06Serialize traces07Train and validate08Generate tasks09Check traces10Compare models11Prepare inference12

#Section 34LoRA target modules

A library accepts target_modules, but naming a projection does not guarantee the intended tensors changed. Inspect the model’s actual modules and report the trainable names and shapes before training.

Q, K, V, and output projection

A target module is a projection chosen for adaptation. Q changes the questions, K changes matching, V changes content, and O changes how heads combine.

Gate, up, and down projections

The gate projection controls the up projection through SiLU and multiplication. The down projection returns to model width. Adapting these changes feature transformation rather than attention matching.

ALL SEVEN ADAPTED PROJECTIONS, WITH THEIR ACTUAL PATHSinput: 512 featuresQ512 x 512K128 x 512V128 x 512Q compares K; weighted V returns head outputsO: 512 x 512gate: 1536 x 512up: 1536 x 512SiLUxdown: 512 x 1536normalization and residual additions omitted; outputs have 512 features
Figure 5.32Computed Finch-24 projection shapes inside one block. Normalization and residual adds are omitted for readability; all seven projections are adapted in the counting example.

Attention-only and all-projection adapters affect different mechanisms. Compare held-out behavior, and inspect module layouts rather than copying another model’s target names.

#Section 35Choosing rank

An adapter fits the demonstrations perfectly at rank 32. That makes it better than rank 8 only if the extra capacity improves unseen behavior enough to pay for itself.

Capacity, memory, and small vs large rank

Capacity is the range of behavior trainable parameters can express. Higher rank permits more independent correction directions and increases trainable state.

RANK CHANGES CAPACITY AND PARAMETER COUNT TOGETHERr = 4303,104r = 8606,208r = 161,212,416r = 322,424,832Finch-24: all Q, K, V, O, gate, up, and down projections
Figure 5.33Computed all-projection Finch-24 adapter counts grow linearly with rank. The highlighted rank is the teaching configuration, not an experimentally chosen optimum.

Overfitting

Overfitting means gains on training examples fail to transfer to the intended unseen distribution. Higher rank makes memorization easier but does not decide it alone; dataset size, diversity, epochs, learning rate, and the starting model matter too.

Keep rank comparisons controlled. Under original scaling, fixing alpha changes alpha/r, and fixing the ratio changes alpha, so say which you did. Run a small grid on one split and model version, then pick the cheapest configuration that meets task and regression requirements.

The factors are not unique: scaling BB by a nonzero number and AA by its inverse leaves BABA unchanged. Factor norms therefore underdescribe the update, so compare the product or its effect on inputs.

#Section 36Trainable parameter count

The report says "1.5% trainable." Without a denominator, you cannot tell whether that compares with the base or with base plus adapter.

Base parameters, adapter parameters, and percentage trainable

The trainable parameter count includes every tensor the optimizer can update. Inspect the enabled parameters, including any trained biases or embeddings.

ONE FINCH-24 BLOCK: 75,776 ADAPTER PARAMETERS AT RANK 8Q8,192K5,120V5,120O8,192gate16,384up16,384down16,3848 blocks x 75,776 = 606,208 parametersrectangular projections need rectangular counts
Figure 5.34Computed factor counts show why the feed-forward projections dominate this adapter's total. Segment widths are proportional to parameter counts.

#Section 37Adapter checkpoints

You send a small adapter file to someone who loads it onto a different revision of the same model family. The tensors fit and the results change: the adapter's base is part of its identity.

Saving adapters and loading adapters

An adapter checkpoint stores the trained factors and the configuration to attach them: target modules, rank, alpha, scaling convention, base revision, tokenizer revision, template, and any extra trained modules. Resuming training also needs optimizer state, schedule, RNG state, and data position; inference does not.

The PEFT checkpoint-format documentation separates adapter weights from configuration. Loading rebuilds the base, attaches adapters, restores factors, and checks metadata; a clean deserialization proves nothing.

THE SMALL CHECKPOINT DEPENDS ON THE EXACT BASEbase weights40,509,952A, Bconfig + identity606,208loadeffective modela matching shape is insufficient; preserve revision and scaling
Figure 5.35Computed parameter counts contrast the base and adapter artifacts. The effective model depends on both, including the exact base identity and scaling.

Base-model dependency and multiple adapters

Base-model dependency means the adapter was learned against particular frozen weights, which a model name may not pin down. Multiple adapters can specialize one base for different tasks, but switching them changes cache validity and behavior.

Combining independently trained adapters needs an explicit policy. Adding corrections does not guarantee useful composition.

#Section 38Merging LoRA

The runtime computes two branches per projection. If only one adapter will ever be used, storing their sum as one matrix may be simpler.

Folding adapter weights into base weights

Merging stores W + sBA as one effective matrix. In exact arithmetic it gives the same linear map as the separate branches.

MERGING CHANGES STORAGE, NOT THE INTENDED LINEAR MAPW1001+scale BA612816=W merged712817W merged x = [7 x 2 + 12, 8 x 2 + 17] = [26, 33]the branch becomes part of the weight tensor
Figure 5.36Every entry in the illustrative merged matrix is computed. Applied to [2,1] it returns [26,33], the same output as the separate branch.

Merged checkpoints and runtime implications

A merged checkpoint stores full effective weights, so inference drops the adapter branch and the separate load. It also loses easy adapter switching unless the base and factors are kept elsewhere.

PEFT's merge_and_unload merges supported configurations; assign its returned model and verify it, since quantized or specialized paths differ in support. PEFT LoRA merge reference.

Rounding and multiplication order make merged and unmerged logits differ slightly, and adapter dropout must be off for the comparison. Saving and reloading is a further boundary, tested separately in Section 69.