﻿# Merging a LoRA adapter changes deployment arithmetic

A LoRA update can be merged into a compatible linear weight by addition. Understand scaling, tied configurations and numerical differences between merged and unmerged execution.

Author: Retrivium editorial team
Updated: 2026-11-03
Canonical URL: https://retrivium.ai/journal/lora-adapter-merge-linear-layer/
Language: en

An unmerged LoRA layer computes a base path and an adapter path. For a compatible linear transformation, their contributions can be combined into an effective weight matrix. Merging is an algebraic operation with an artifact contract; it is not retraining and does not automatically make an arbitrary adapter compatible with any similar-looking model.

## Distributivity explains the merge

A base matrix acting on an input plus a scaled low-rank product acting on that same input equals the sum of those matrices acting on the input in exact arithmetic. The merged matrix therefore contains the original weight and the defined adapter update. This statement assumes the relevant operations form the compatible linear path. Dropout used during adapter training and other conditional execution details need to be handled according to the documented evaluation behavior. The merge should reproduce the intended inference computation, not an arbitrary stochastic training pass.

## Scaling belongs to the saved adapter definition

The factors alone do not necessarily specify the effective update. Rank-dependent scaling and the adapter configuration determine its magnitude. Imagine reconstructing the correct factor product but omitting the declared scale: the resulting layer has the right dimensions and the wrong transformation. Module identity matters similarly. A factor intended for one projection cannot be placed into another merely because shapes match. Preserve the exact base revision, target-module mapping and adapter settings so the addition occurs in the coordinates in which the update was trained.

## Finite precision can change exact equality

Computing two paths and adding their outputs can round differently from adding matrices first and performing one multiplication. Quantized weights introduce additional representation and conversion questions. Mathematical distributivity does not guarantee bitwise identical results for all execution formats. Compare outputs under a declared tolerance with the intended serving precision and library path. A visible generation divergence can arise from small score differences near a sampling decision, so inspect intermediate logits as well as finished text when evaluating whether the merge is numerically acceptable.

## Keep reversibility and evaluation explicit

Retain the original base and adapter artifacts separately from any merged export, with hashes and configuration. Validate a small fixed input set before using the export in broader evaluation. Merging does not prove that the adaptation improves quality, and combining several adapters creates a separate composition question. A clear artifact lineage lets a reader reproduce the defined update and distinguish a bad merge from a poor trained adaptation. It also prevents accidental repeated addition of the same update when an already merged checkpoint is mistaken for the original base.

## Primary research and implementation references

- [LoRA: Low-Rank Adaptation of Large Language Models](https://arxiv.org/abs/2106.09685).

- [QLoRA: Efficient Finetuning of Quantized LLMs](https://arxiv.org/abs/2305.14314).

- [Hugging Face PEFT: LoRA and Adapter Merging](https://huggingface.co/docs/peft/v0.21.0/package_reference/lora).

## Related engineering context

[Reproducible inference stacks: preserving a GPU pilot’s result](/journal/software-stack-reproducibility/); [A GPU inference benchmark you can trust](/journal/inference-benchmark-method/).
