Adapting frontier autoregressive Transformer language models with tens or hundreds of billions of parameters to specialized downstream domains—or pre-training them from scratch on commodity accelerator clusters—confronts a severe hardware memory wall governed by optimizer state multiplication, gradient activation storage, and multi-tenant checkpoint sprawl. In standard 16-bit (BF16 / FP16) full fine-tuning with mixed-precision Adam (Kingma & Ba, 2015), every trainable parameter requires not only $2\text{ bytes}$ for the model weight itself and $2\text{ bytes}$ for its backpropagated gradient, but up to $12\text{--}16\text{ bytes}$ of FP32 master weights, first-moment momentum ($m_t$), and second-moment variance ($v_t$) states. Consequently, full fine-tuning of GPT-3 175B ($175,255.8\text{M}$ parameters) consumes $1.2\text{TB}$ of active VRAM (arXiv:2106.09685), while full fine-tuning of LLaMA-65B requires $>780\text{GB}$ of GPU memory (arXiv:2305.14314)—exceeding the capacity of an entire 8-GPU A100-80GB server node and producing an isolated $350\text{GB}$ checkpoint per customized downstream task.
Between 2021 and 2026, seven foundational mathematical and systems innovations reshaped how neural networks are adapted, quantized during backpropagation, projected into low-rank gradient subspaces, and fused across homologous fine-tuned checkpoints without GPU retraining:
- Low-Rank Adaptation (
LoRA, Hu et al., Microsoft, ICLR 2022,arXiv:2106.09685): Inspired by the discovery that over-parameterized pre-trained models reside on a low intrinsic dimensionality during task adaptation, LoRA freezes the pre-trained weight matrix $W_0 \in \mathbb{R}^{d \times k}$ and parameterizes its task-specific update via a low-rank bilinear decomposition $\Delta W = B A$, where $B \in \mathbb{R}^{d \times r}$, $A \in \mathbb{R}^{r \times k}$, and $r \ll \min(d, k)$. OnGPT-3 175B, LoRA ($r = 4$ on $W_q, W_v$) reduces trainable parameters by $10,000\times$ (from $175.26\text{B}$ to $4.7\text{M}$, shrinking checkpoints from $350\text{GB}$ to $35\text{MB}$), cuts training VRAM by $3\times$ (from $1.2\text{TB}$ to $350\text{GB}$), eliminates the $+20.7\%\text{ to }+30.3\%$ batch-1 inference latency penalty of sequential bottleneck adapters by algebraically merging $W = W_0 + \frac{\alpha}{r}BA$ at deployment, and outperforms full fine-tuning acrossWikiSQL($73.4\%$ at $4.7\text{M}$ and $74.0\%$ at $37.7\text{M}$ vs. $73.8\%$ FT),MultiNLI-matched($91.7\%$ vs. $89.5\%$ FT), andSAMSum($53.8 / 29.8 / 45.9$ vs. $52.0 / 28.0 / 44.5$ FT). - Rank-Stabilized Scaling (
rsLoRA, Kalajdzievski,arXiv:2312.03732): Why do conventional LoRA adapters fail to improve—or suffer unstable learning—when rank $r$ is scaled up from $r = 8$ to $r = 64, 128,$ or $512$? In Theorem 3.2 ofarXiv:2312.03732, Damjan Kalajdzievski proves that standard LoRA scaling $\gamma_r = \frac{\alpha}{r}$ causes a $1/\sqrt{r}$ collapse in both forward adapter norms and backpropagated gradient magnitudes as $r \to \infty$. By replacing the divisor with the square root of the rank—$\gamma_r = \frac{\alpha}{\sqrt{r}}$ (rsLoRA)—the adapter output and learning dynamics remain strictly $\Theta_r(1)$ across all ranks, unlocking a direct compute-vs-accuracy trade-off at high ranks with zero inference overhead. - 4-Bit NormalFloat (
NF4), Double Quantization (DQ), and Paged Optimizers (QLoRA, Dettmers et al., NeurIPS 2023,arXiv:2305.14314): QLoRA backpropagatesBF16gradients through a frozen, 4-bit quantized pretrained backbone intoBF16LoRA adapters. By introducing 4-bit NormalFloat (NF4) (an information-theoretically optimal quantile data type for zero-mean normal distributions $\mathcal{N}(0, \sigma^2)$), Double Quantization (DQ) (which quantizes first-level 32-bit blocksize-64 scales $c_2^{\text{FP32}}$ into 8-bit floats $c_2^{\text{FP8}}$ with blocksize 256, cutting scale overhead from $32/64 = 0.5\text{ bits/param}$ to $8/64 + 32/(64 \cdot 256) = 0.127\text{ bits/param}$—a net savings of $0.373\text{ bits/param}$ or $\approx 3\text{GB}$ on a $65\text{B}$ model), and NVIDIA Unified Memory Paged Optimizers, QLoRA slashesLLaMA-65Bfine-tuning memory from $>780\text{GB}$ to $<48\text{GB}$. Its resultingGuanaco 65Bmodel trains in 24 hours on a single 48GB GPU and achieves $99.3\%$ of ChatGPT's performance (Elo 1022vs. ChatGPT966) on the Vicuna benchmark. - Magnitude-Direction Weight Decomposition (
DoRA, Liu et al., NVIDIA & HKUST, ICML 2024 Oral,arXiv:2402.09353): Analyzing weight updates via polar magnitude-direction decomposition reveals that full fine-tuning (FT) exhibits a negative slope coupling between magnitude changes $\Delta M$ and directional changes $\Delta D$, whereas standard LoRA couples them positively. DoRA (Weight-Decomposed Low-Rank Adaptation) reparameterizes each pre-trained weight matrix into a decoupled trainable scalar magnitude vector $m \in \mathbb{R}^{1 \times k}$ ($+0.01\%$ parameters) and a directional matrix $V$ adapted via LoRA: $W' = \underline{m} \frac{W_0 + \underline{B}\underline{A}}{\|W_0 + \underline{B}\underline{A}\|_c}$. Using a detached denominator norm $C = \|V'\|_c$ during backpropagation reduces DoRA's gradient-graph memory overhead by $24.4\%$ onLLaMA-7Bwhile boosting 8-task commonsense reasoning accuracy over LoRA by $+3.7\%$ onLLaMA-7B($78.4\%$ vs. $74.7\%$, beating ChatGPT's $77.0\%$), $+1.0\%$ onLLaMA-13B($81.5\%$ vs. $80.5\%$), $+2.9\%$ onLLaMA2-7B($\text{DoRA}^\dagger$ $80.5\%$ vs. $77.6\%$), and $+4.4\%$ onLLaMA3-8B($85.2\%$ vs. $80.8\%$). - Gradient Low-Rank Projection (
GaLore, Zhao et al., Caltech, Meta, UT Austin & CMU, ICML 2024 Oral,arXiv:2403.03507): Because LoRA restricts weight updates $\Delta W = BA$ to a single static low-rank parameter subspace, it fails when pre-training LLMs from scratch (e.g.,LLaMA-1BC4 validation perplexity degrading to $19.21$ vs. full-rank $15.56$). GaLore proves that while weights must remain full-rank, the gradient matrix $G_t \in \mathbb{R}^{m \times n}$ rapidly becomes low-rank during training: projecting gradients via $R_t = P_t^\top G_t \in \mathbb{R}^{r \times n}$ and updating the projection matrix $P_t$ via truncated SVD every $T = 200$ steps allows the weight trajectory to traverse multiple subspaces while reducing memory to $(mn + mr + 2nr)$ (vs. LoRA's $mn + 3mr + 3nr$). 8-bit GaLore cuts optimizer memory by up to $82.5\%$ ($65.5\%$ over 8-bit Adam) and total training memory by $63.3\%$ ($37.92\text{GB}$ saved), enabling full-parameter pre-training ofLLaMA-7Bon a single $24\text{GB}$ NVIDIA RTX 4090 GPU and matching 8-bit Adam perplexity on $19.7\text{B}$ C4 tokens ($14.65$ at $18\text{GB}$ vs. $14.61$ at $26\text{GB}$). - Sign-Conflict Resolution (
TIES-Merging, Yadav et al., NeurIPS 2023,arXiv:2306.01708) & Bernoulli Delta Sparsification (DARE, Yu et al., Alibaba, ICML 2024,arXiv:2311.03099): When combining multiple fine-tuned homologous checkpoints $\theta_t = \theta_{\text{init}} + \tau_t$ without retraining, naive linear interpolation and Task Arithmetic suffer catastrophic capability loss due to redundant parameter noise and parameter sign interference. TIES-Merging (TrIm, Elect Sign & Merge) trims the bottom $80\%$ of task-vector magnitudes (retaining only the top-$20\%$), elects an aggregate majority sign $\gamma_m = \operatorname{sgn}(\sum_{t=1}^n \hat{\tau}t)$, and performs a disjoint mean strictly across aligned signs—outperforming Task Arithmetic by $+2.3\%$ in NLP and $+1.7\%$ in Vision in-domain (Table 1) and $+4.4\%$ onT5-largeout-of-domain (Table 6). DARE (Drop And REscale) discovers that SFT delta parameters $\bm{\delta}^t = \bm{\theta}{\text{SFT}}^t - \bm{\theta}_{\text{PRE}}$ have tiny magnitude ranges ($\le 0.002$) with extreme redundancy: randomly zeroing fraction $p \in [0.90, 0.99]$ of delta parameters via $\bm{m}^t \sim \operatorname{Bernoulli}(p)$ and rescaling survivors by $1 / (1 - p)$ eliminates $90\%\text{ to }99\%$ of delta weights while preserving expected activation embeddings, boosting a mergedWizardLM-13B + WizardMath-13B + Code-Alpaca-13Bmodel onAlpacaEvalfrom $65.91\%$ to $72.50\%$ (surpassing the single-taskWizardLM-13Bbaseline of $67.20\%$).
Geometric Visualization of Singular Value Decomposition and Low-Rank Matrix Factorization Governing LoRA and GaLore Projections
This engineering reference derives the complete mathematical formulations, asymptotic proofs, memory footprint equations, primary benchmark tables, and production PyTorch implementations across LoRA, rsLoRA, QLoRA, DoRA, GaLore, TIES-Merging, and DARE.
Executive Summary: Verified Mathematical & Empirical Benchmarks Across LoRA, rsLoRA, QLoRA, DoRA, GaLore, TIES-Merging & DARE
- LoRA (
arXiv:2106.09685) & rsLoRA (arXiv:2312.03732): Freezing $W_0 \in \mathbb{R}^{d \times k}$ and training $\Delta W = \gamma_r B A$ ($r \ll \min(d,k)$) onGPT-3 175Bcuts trainable parameters by 10,000× (4.7Mvs.175,255.8M), shrinks checkpoints from 350GB to 35MB, reduces training VRAM from 1.2TB to 350GB, and achieves 74.0% WikiSQL / 91.7% MNLI-m / 53.8 R1 SAMSum (vs.73.8% / 89.5% / 52.0for full fine-tuning) with 0.0% inference latency overhead (vs.+20.7% to +30.3%for sequential adapters at batch size 1). rsLoRA (Theorem 3.2) proves that scaling by $\gamma_r = \alpha / \sqrt{r}$ instead of $\alpha / r$ is both necessary and sufficient to prevent $1/\sqrt{r}$ gradient collapse as $r \to \infty$. - QLoRA (
arXiv:2305.14314): Combines 4-bit NormalFloat (NF4) quantile quantization, Double Quantization (DQ) ($c_2^{\text{FP32}} \to c_2^{\text{FP8}}$ with blocksize $B_1 = 64, B_2 = 256$, reducing quantization constant overhead from $0.5\text{ bits/param}$ to $0.127\text{ bits/param}$ for a 0.373 bits/param reduction), and Paged Optimizers. Fine-tunesLLaMA-65Bin <48GB VRAM (down from >780GB), yieldingGuanaco 65B(Vicuna Elo 1022 ± 1, 99.3% of ChatGPT's score in 24 hours on 1 GPU). - DoRA (
arXiv:2402.09353): Reparameterizes weights into magnitude $m \in \mathbb{R}^{1 \times k}$ and directional LoRA updates $W' = \underline{m} \frac{W_0 + \underline{B}\underline{A}}{\|W_0 + \underline{B}\underline{A}\|_c}$, detaching $\|V'\|_c$ during backprop to save 24.4% training memory onLLaMA-7B. Surpasses LoRA on 8 commonsense reasoning benchmarks across every backbone:LLaMA-7B(78.4% vs. 74.7%, +3.7%),LLaMA-13B(81.5% vs. 80.5%, +1.0%),LLaMA2-7B($\text{DoRA}^\dagger$ 80.5% vs. 77.6%, +2.9%), andLLaMA3-8B(85.2% vs. 80.8%, +4.4%). - GaLore (
arXiv:2403.03507): Projects full-parameter gradients $G_t \in \mathbb{R}^{m \times n}$ into low-rank $R_t = P_t^\top G_t \in \mathbb{R}^{r \times n}$ with SVD subspace switching every $T = 200$ steps, cutting memory to $mn + mr + 2nr$. 8-bit GaLore reduces optimizer states by up to 82.5% and total memory by 63.3% (37.92GB saved), pre-trainingLLaMA-7Bon a single 24GB RTX 4090 and reaching 14.65 C4 perplexity at 150K steps / 19.7B tokens ($18\text{GB}$ memory vs. 8-bit Adam's $14.61$ at $26\text{GB}$). - TIES-Merging (
arXiv:2306.01708) & DARE (arXiv:2311.03099): TIES-Merging trims the bottom 80% of task-vector weights, elects majority parameter signs $\gamma_m = \operatorname{sgn}(\sum \hat{\tau}_t)$, and averages only sign-aligned weights (+2.3% NLP / +1.7% Vision in-domain; +4.4% T5-large out-of-domain). DARE drops 90%–99% of SFT delta parameters ($\le 0.002$ range) via $\operatorname{Bernoulli}(p)$ and rescales by $1/(1-p)$, lifting 3-model mergedWizardLM/Math/Code-13BAlpacaEval win rate from 65.91% to 72.50% solely on CPU.
1. Low-Rank Adaptation (LoRA, arXiv:2106.09685) and Rank-Stabilized Scaling (rsLoRA, arXiv:2312.03732)
Prior to Low-Rank Adaptation, parameter-efficient transfer learning relied primarily on two families of architectures, each carrying a structural deployment penalty (arXiv:2106.09685, Section 2):
- Sequential Bottleneck Adapters (
Houlsby et al., 2019;Lin et al., 2020;Pfeiffer et al., 2021): Insert two sequential projection layers with a nonlinearity between them after self-attention and MLP sub-blocks. Because adapter layers must be executed sequentially along the critical path of the forward pass, they introduce a hard wall-clock latency penalty—especially in low-batch online serving. As measured by Hu et al. (arXiv:2106.09685, Table 1) onGPT-2 Mediumon anNVIDIA Quadro RTX 8000, sequential adapters ($\text{Adapter}^{\text{L}}$ and $\text{Adapter}^{\text{H}}$ with $|\Theta| = 11\text{M}$ parameters) increase single-pass inference latency at batch size $1$ (seq_len = 128) from $19.8 \pm 2.7\text{ ms}$ to $23.9 \pm 2.1\text{ ms}$ ($+20.7\%$) and $25.8 \pm 2.2\text{ ms}$ ($+30.3\%$), respectively. - Prefix-Tuning & Prompt-Tuning (
Li & Liang, 2021;Lester et al., 2021): Prepend $l_p$ learnable continuous key-value prefix tokens directly to the input context or attention layers. Prefix-tuning consumes valuable sequence length out of the model's finite context window and fails to scale monotonically with parameter count: onGPT-3 175B(arXiv:2106.09685, Section 5.5 & Figure 2), validation accuracy drops sharply when exceeding $256$ prefix-embedding tokens or $32$ prefix-layer tokens.
1. Intrinsic Rank Deficiency and Bilinear Reparameterization
Building on the empirical finding of Aghajanyan et al. (2020) that pre-trained language models exhibit a low "intrinsic dimension" when adapted to downstream tasks, Edward J. Hu et al. ("LoRA: Low-Rank Adaptation of Large Language Models", arXiv:2106.09685, Section 4.1) hypothesize that the weight update matrix $\Delta W$ accumulated during task adaptation also has a low intrinsic rank.
For any dense pre-trained linear projection matrix $W_0 \in \mathbb{R}^{d \times k}$, LoRA freezes $W_0$ (disabling gradient computation and clearing its Adam optimizer states) and constrains the update $\Delta W$ via a rank-$r$ factorized product (arXiv:2106.09685, Equation 3):
$$h = W_0 x + \Delta W x = W_0 x + \frac{\alpha}{r} B A x$$
where $B \in \mathbb{R}^{d \times r}$, $A \in \mathbb{R}^{r \times k}$, and the rank satisfies $r \ll \min(d, k)$. To ensure that the adapted network begins fine-tuning from the exact functional behavior of the pre-trained checkpoint at step $t = 0$:
- $A$ is initialized with random Gaussian noise $A_{ij} \sim \mathcal{N}(0, \sigma^2)$ (or Kaiming uniform initialization in modern implementations).
- $B$ is initialized strictly to zero ($B = 0_{d \times r}$), guaranteeing that $\Delta W = B A = 0$ at the start of training.
- Zero-Latency Deployment Merge: Because $W_0 x + \frac{\alpha}{r} B A x = \left(W_0 + \frac{\alpha}{r} B A\right) x$ is purely linear, at deployment time the adapter matrix $\frac{\alpha}{r} B A \in \mathbb{R}^{d \times k}$ is added directly into $W_0$ in-place (
W_merged = W_0 + (alpha / r) * (B @ A)), yielding zero additional FLOPs and $0.0\%$ inference latency overhead compared to the base model. Furthermore, switching to a different downstream task requires simply subtracting $\frac{\alpha}{r} B_1 A_1$ and adding $\frac{\alpha}{r} B_2 A_2$ in microseconds.
GPT-3 175B Adaptation Method (arXiv:2106.09685, Table 4) |
Trainable Params ($|\Theta|$) | WikiSQL Acc. ($\pm 0.5\%$) | MultiNLI-m Acc. ($\pm 0.1\%$) | SAMSum (Rouge-1 / 2 / L) | Batch-1 Latency Overhead (Table 1) |
|---|---|---|---|---|---|
Full Fine-Tuning (GPT-3 FT) |
175,255.8M (100%) |
73.8% |
89.5% |
52.0 / 28.0 / 44.5 |
0.0% (19.8 ms baseline) |
| BitFit (Bias-Only Tuning) | 14.2M (0.008%) |
71.3% |
91.0% |
51.3 / 27.4 / 43.5 |
0.0% |
Prefix-Embedding (PreEmbed) |
3.2M (0.002%) |
63.1% |
88.6% |
48.3 / 24.2 / 40.5 |
Context window reduction |
Prefix-Layer (PreLayer) |
20.2M (0.012%) |
70.1% |
89.5% |
50.8 / 27.3 / 43.5 |
Context window reduction |
| Sequential Adapter ($\text{Adapter}^{\text{H}}$, 7.1M) | 7.1M (0.004%) |
71.9% |
89.8% |
53.0 / 28.9 / 44.8 |
+20.7% to +30.3% (23.9–25.8 ms) |
| Sequential Adapter ($\text{Adapter}^{\text{H}}$, 40.1M) | 40.1M (0.023%) |
73.2% |
91.5% |
53.2 / 29.0 / 45.1 |
+30.3% (25.8 ms at batch 1) |
| LoRA ($r=4$, $W_q, W_v$) | 4.7M (10,000× smaller) |
73.4% |
91.7% |
53.8 / 29.8 / 45.9 |
0.0% (19.8 ms merged) |
| LoRA ($r=16$, $W_q, W_v$) | 37.7M (0.022%) |
74.0% |
91.6% |
53.4 / 29.2 / 45.1 |
0.0% (19.8 ms merged) |
2. Which Weight Matrices Should Be Adapted and At What Rank $r$?
In Section 7.1–7.2 of arXiv:2106.09685 (Tables 5 and 6), Hu et al. conduct a controlled ablation on GPT-3 175B under a fixed parameter budget of $18\text{M}$ trainable parameters (approx. $35\text{MB}$ in FP16):
- Target Module Allocation (
Table 5): Adapting only a single attention projection matrix with rank $r = 8$ yields70.4%(WikiSQL) and91.0%(MultiNLI) for $W_q$ alone,70.0% / 90.8%for $W_k$ alone,73.0% / 91.0%for $W_v$ alone, and73.2% / 91.3%for $W_o$ alone. Splitting the same $18\text{M}$ parameter budget across both $W_q$ and $W_v$ at rank $r = 4$ jumps accuracy to $73.7\%$ (WikiSQL) and $91.3\%$ (MultiNLI), while adapting all four attention projections $\{W_q, W_k, W_v, W_o\}$ at rank $r = 2$ achieves $73.7\%$ (WikiSQL) and $91.7\%$ (MultiNLI)—proving that adapting more weight matrices at a smaller rank dominates adapting a single weight matrix at a higher rank. - Subspace Similarity Across Ranks (
Table 6& Grassmann Distance Analysis): Evaluating $W_q, W_v$ across $r \in \{1, 2, 4, 8, 64\}$ shows that even rank $r = 1$ achieves $73.4\%$ onWikiSQLand $91.3\%$ onMultiNLI(compared to $73.8\% / 91.6\%$ at $r = 8$ and $73.5\% / 91.4\%$ at $r = 64$). By computing the normalized subspace similarity $\phi(A_{r=8}, A_{r=64}, i, j) = \frac{\|U_{A_{r=8}}^{i \top} U_{A_{r=64}}^j\|F^2}{\min(i, j)} \in [0, 1]$ between the top singular vectors of $A{r=8}$ and $A_{r=64}$, Hu et al. show that the top singular direction ($i = j = 1$) shares a Grassmann similarity $> 0.5$, explaining why $r = 1\text{--}8$ captures the core adaptation subspace.
3. Why Standard LoRA Collapses at Large Ranks and How rsLoRA (arXiv:2312.03732) Fixes It
Although $r \in \{4, 8, 16\}$ suffices for narrow domain tasks, complex multi-domain reasoning and continual instruction tuning benefit from much higher capacity ($r \in \{64, 128, 256, 512\}$). Yet practitioners repeatedly observed that increasing $r$ in standard LoRA slows convergence and yields no accuracy improvement over $r = 8$.
In "A Rank Stabilization Scaling Factor for Fine-Tuning with LoRA" (arXiv:2312.03732, Section 3), Damjan Kalajdzievski proves mathematically why this occurs. Consider the $j$-th entry of the adapter output vector $y = \gamma_r B A x$, which is a sum of $r$ inner-product terms over the latent rank dimension. During gradient descent, once $B$ moves away from zero, each rank component contributes variance of order $\Theta_r(1/r)$ when scaled by $\gamma_r = \frac{\alpha}{r}$, causing the moments and gradient norms to decay asymptotically as $1/\sqrt{r}$.
In Theorem 3.2 (arXiv:2312.03732, Equations 4–5), Kalajdzievski proves that for any LoRA adapter $\gamma_r B A$ where $B$ is initialized to $0_{d_1 \times r}$ and entries of $A$ are i.i.d. with mean $0$ and $r$-independent variance $\sigma_A^2$, the adapter forward activations and backpropagated gradients are rank-stabilized ($\Theta_r(1)$ in expectation at every point along the learning trajectory as $r \to \infty$) if and only if:
$$\gamma_r \in \Theta_r\left(\frac{1}{\sqrt{r}}\right) \implies \gamma_r^{\text{rsLoRA}} = \frac{\alpha}{\sqrt{r}}$$
This single one-line modification—dividing by $\sqrt{r}$ instead of $r$ (supported natively in Hugging Face peft via use_rslora=True)—prevents gradient collapse at $r = 64\text{--}512$ and unlocks monotonic fine-tuning performance scaling with rank $r$.
2. QLoRA (arXiv:2305.14314): 4-Bit NormalFloat (NF4), Double Quantization, and Paged Optimizers
While LoRA eliminates optimizer states for the frozen weights $W_0$, loading a frozen $65\text{B}$-parameter backbone in 16-bit precision (BF16 / FP16) still consumes $65 \times 10^9 \times 2\text{ bytes} = 130\text{GB}$ of static VRAM before allocating a single activation tensor. In "QLoRA: Efficient Finetuning of Quantized LLMs" (arXiv:2305.14314, NeurIPS 2023), Tim Dettmers, Artidoro Pagnoni, Ari Holtzman, and Luke Zettlemoyer reduce the average memory requirement of fine-tuning a $65\text{B}$ model from $>780\text{GB}$ to $<48\text{GB}$ without any degradation compared to 16-bit full fine-tuning.
Matrix Factorization Schematic Illustrating Low-Rank Adapter Decomposition Over Quantized Frozen Weights
1. Information-Theoretically Optimal 4-Bit NormalFloat (NF4) Quantization
Pre-trained neural network weights naturally follow a zero-centered normal (Gaussian) distribution $\mathcal{N}(0, \sigma^2)$. Standard uniform 4-bit integer (INT4) or 4-bit floating-point (FP4) quantization wastes quantization bins in the sparse tails of the bell curve while under-resolving the dense region near zero.
Quantile Quantization ensures that every quantization bin among the $2^k = 16$ available 4-bit levels contains an equal expected number of weights. Because empirical cumulative distribution estimation is slow, Dettmers et al. (arXiv:2305.14314, Section 3) observe that scaling any weight block by its absolute maximum absmax maps all weights into $[-1, 1]$ with standard deviation $\sigma$, allowing exact analytical pre-computation of the $2^k = 16$ quantization levels from the inverse cumulative distribution function (quantile function) $Q_X(\cdot)$ of a standard normal distribution $\mathcal{N}(0, 1)$:
$$q_i = \frac{1}{2}\left( Q_X\left(\frac{i}{2^k + 1}\right) + Q_X\left(\frac{i + 1}{2^k + 1}\right) \right), \quad i \in \{0, 1, \dots, 2^k - 1\}$$
To guarantee an exact zero representation ($0.0$) for zero padding and sparse masks, NF4 partitions the $16$ levels asymmetrically around zero: it estimates $2^{k-1} = 8$ quantiles for the negative half $[-1, 0]$, $2^{k-1} + 1 = 9$ quantiles for the positive half $[0, 1]$, merges their shared zero quantile $0.0$, and normalizes the resulting $16$ values into $[-1, 1]$. For every contiguous weight block of size $B_1 = 64$, the block is normalized by its absmax scale $c_2^{\text{FP32}}$ and mapped to the nearest NF4 index.
2. Double Quantization (DQ): Saving $0.373\text{ Bits per Parameter}$
Because NF4 uses a fine-grained blocksize of $B_1 = 64$ weights to prevent outlier distortion, storing one 32-bit floating-point quantization scale $c_2^{\text{FP32}}$ per 64 weights adds a substantial memory overhead:
$$\text{Single-Level Scale Overhead} = \frac{32\text{ bits}}{64\text{ parameters}} = 0.500\text{ bits/parameter}$$
Double Quantization (DQ) (arXiv:2305.14314, Section 3) treats the first-level quantization scales $c_2^{\text{FP32}}$ as inputs to a second stage of quantization. First, the mean is subtracted from $c_2^{\text{FP32}}$ to center the strictly positive scales around zero, and the centered scales are quantized into symmetric 8-bit floating-point numbers $c_2^{\text{FP8}}$ using a second-level blocksize of $B_2 = 256$ and second-level 32-bit scales $c_1^{\text{FP32}}$. This reduces the quantization constant footprint to:
$$\text{Double-Quantized Scale Overhead} = \frac{8}{64} + \frac{32}{64 \times 256} = 0.125 + 0.001953125 \approx 0.127\text{ bits/parameter}$$
This yields a net reduction of $0.500 - 0.127 = 0.373\text{ bits per parameter}$—saving approximately $3\text{GB}$ of VRAM on a $65\text{B}$-parameter model ($65 \times 10^9 \times 0.373 / 8 \approx 3.03\text{GB}$) with zero measurable drop in 4-bit MMLU or Vicuna accuracy.
3. Dual-Precision Forward/Backward Pass and Paged Optimizers
QLoRA maintains two distinct data types (arXiv:2305.14314, Equations 5–6): a 4-bit storage data type (NF4) and a 16-bit computation data type (BF16). For a linear layer with frozen quantized weights $\mathbf{W}^{\text{NF4}}$ and trainable BF16 LoRA matrices $\mathbf{L}_1^{\text{BF16}} \in \mathbb{R}^{d \times r}, \mathbf{L}_2^{\text{BF16}} \in \mathbb{R}^{r \times k}$, the forward pass dequantizes $\mathbf{W}^{\text{NF4}}$ on the fly inside the CUDA kernel:
$$\mathbf{Y}^{\text{BF16}} = \mathbf{X}^{\text{BF16}} \operatorname{doubleDequant}\left(c_1^{\text{FP32}}, c_2^{\text{FP8}}, \mathbf{W}^{\text{NF4}}\right) + \mathbf{X}^{\text{BF16}} \mathbf{L}_1^{\text{BF16}} \mathbf{L}_2^{\text{BF16}}$$
where double dequantization reconstructs the weight matrix via:
$$\operatorname{doubleDequant}\left(c_1^{\text{FP32}}, c_2^{\text{FP8}}, \mathbf{W}^{\text{NF4}}\right) = \operatorname{dequant}\left(\operatorname{dequant}\left(c_1^{\text{FP32}}, c_2^{\text{FP8}}\right), \mathbf{W}^{\text{NF4}}\right) = \mathbf{W}^{\text{BF16}}$$
During backpropagation, parameter gradients $\frac{\partial E}{\partial \mathbf{W}_i}$ are never stored for the frozen 4-bit weights; only activation gradients $\frac{\partial E}{\partial \mathbf{X}_i}$ are computed via dequantized $\mathbf{W}^{\text{BF16}}$ to update $\frac{\partial E}{\partial \mathbf{L}_i}$. Finally, to prevent transient out-of-memory (OOM) crashes caused by activation spikes during gradient checkpointing over long sequences, Paged Optimizers allocate AdamW optimizer states in NVIDIA Unified Memory, automatically paging optimizer state blocks to CPU RAM when GPU HBM nears capacity and paging them back during the optimizer update step.
Model (arXiv:2305.14314, Table 1) |
Deployment Memory Footprint | Fine-Tuning Method & Hardware | Vicuna Benchmark Elo Rating (10,000 Random Orderings) | Relative Performance vs. ChatGPT |
|---|---|---|---|---|
GPT-4 (Proprietary Reference) |
Cloud API | Proprietary RLHF | 1348 ± 1 |
— (Judge Reference) |
Guanaco 65B (QLoRA on OASST1) |
41 GB (4-bit) |
QLoRA NF4 + DQ (<48GB, 24h on 1 GPU) | 1022 ± 1 |
99.3% of ChatGPT level |
Guanaco 33B (QLoRA on OASST1) |
21 GB (4-bit) |
QLoRA NF4 + DQ (<24GB, <12h on 1 GPU) | 992 ± 1 |
97.8% of ChatGPT level |
Vicuna 13B (Full 16-Bit Fine-Tuning) |
26 GB (16-bit) |
Full FT on ShareGPT (Multi-GPU) | 974 ± 1 |
Outperformed by Guanaco 33B/65B |
ChatGPT (OpenAI Baseline) |
Cloud API | Proprietary RLHF | 966 ± 1 |
100.0% baseline |
Guanaco 13B (QLoRA on OASST1) |
10 GB (4-bit) |
QLoRA NF4 + DQ (Consumer GPU) | 916 ± 1 |
Beats Google Bard (902 ± 1) |
Bard (Google Baseline) |
Cloud API | Proprietary Fine-Tuning | 902 ± 1 |
Below Guanaco 13B/33B/65B |
Guanaco 7B (QLoRA on OASST1) |
6 GB (5 GB weights) |
QLoRA NF4 + DQ (Consumer GPU) | 879 ± 1 |
Beats 26 GB Alpaca by >20% pts |
3. Weight-Decomposed Low-Rank Adaptation (DoRA, arXiv:2402.09353): Decoupling Magnitude and Direction
Despite LoRA's zero-latency deployment advantage, a persistent accuracy gap often remains between LoRA and full fine-tuning (FT) on complex reasoning and multi-modal instruction benchmarks. In "DoRA: Weight-Decomposed Low-Rank Adaptation" (arXiv:2402.09353, ICML 2024 Oral), Shih-Yang Liu et al. (NVIDIA & HKUST) uncover the geometric root cause of this gap by decomposing any weight matrix $W \in \mathbb{R}^{d \times k}$ into its column-wise magnitude vector $m \in \mathbb{R}^{1 \times k}$ and directional matrix $V \in \mathbb{R}^{d \times k}$ (arXiv:2402.09353, Equation 2):
$$W = m \frac{V}{\|V\|_c} = \|W\|_c \frac{W}{\|W\|_c}$$
where $\|\cdot\|_c$ denotes the vector-wise $L_2$ norm computed independently across each column of $W$.
1. Weight Decomposition Analysis: Why LoRA Struggles to Decouple $\Delta M$ and $\Delta D$
By measuring the average magnitude change $\Delta M_W^t$ and directional cosine shift $\Delta D_W^t = 1 - \cos(W_0, W_t)$ across training checkpoints (arXiv:2402.09353, Section 3.2, Equations 3–4 & Figure 2), Liu et al. reveal a striking contrast between Full Fine-Tuning and LoRA:
- Full Fine-Tuning (
FT): Exhibits a negative regression slope between $\Delta M$ and $\Delta D$—meaning FT frequently makes large directional adjustments with minimal magnitude change (or subtly scales magnitude while keeping direction fixed). - Standard
LoRA: Exhibits a positive regression slope where magnitude updates and directional updates are coupled proportionally, because a single rank-$r$ additive update $\Delta W = B A$ cannot easily alter column norms independently of column directions without wasting rank capacity.
2. DoRA Formulation, Gradient Conditioning, and the Detached-Norm Memory Optimization
To give low-rank adaptation the decoupled learning dynamics of full fine-tuning while adding only $+0.01\%$ trainable parameters, DoRA initializes $m = \|W_0\|_c \in \mathbb{R}^{1 \times k}$ and $V = W_0$, freezes $V$, and updates $m$ as a trainable 1D vector while updating the directional matrix exclusively via LoRA (arXiv:2402.09353, Equation 5):
$$W' = \underline{m} \frac{V + \Delta V}{\|V + \Delta V\|_c} = \underline{m} \frac{W_0 + \underline{B}\underline{A}}{\|W_0 + \underline{B}\underline{A}\|_c}$$
where underlined parameters ($\underline{m}, \underline{B}, \underline{A}$) denote the trainable tensors. Differentiating the loss $\mathcal{L}$ with respect to the directional matrix $V' = V + \Delta V$ and magnitude $m$ yields (arXiv:2402.09353, Section 4.2, Equations 6–7):
$$\nabla_{V'} \mathcal{L} = \frac{m}{\|V'\|c} \left( I - \frac{V' V'^\top}{\|V'\|_c^2} \right) \nabla{W'} \mathcal{L}, \qquad \nabla_m \mathcal{L} = \frac{\nabla_{W'} \mathcal{L} \cdot V'}{\|V'\|_c}$$
Notice two crucial properties of $\nabla_{V'} \mathcal{L}$: first, the scaling factor $\frac{m}{\|V'\|_c}$ acts like Weight Normalization (Salimans & Kingma, 2016) to improve gradient conditioning; second, the projection operator $\left(I - \frac{V' V'^\top}{\|V'\|_c^2}\right)$ projects the gradient orthogonally to the current weight vector $V'$, ensuring that $\Delta V = B A$ focuses $100\%$ of its low-rank capacity on pure directional rotation while $m$ handles radial magnitude scaling.
However, backpropagating through the denominator $\|V + \Delta V\|_c$ requires retaining intermediate computation graphs across every linear layer. In Section 4.3 (arXiv:2402.09353, Equation 11), Liu et al. detach the column norm $\|V'\|_c$ from the backpropagation graph—treating $C = \|V + \Delta V\|_c$ as a forward-evaluated constant during the backward pass:
$$W' = \underline{m} \frac{V + \Delta V}{C}, \quad \text{where } C = \|V + \Delta V\|_c.\text{detach()}$$
This modification leaves the magnitude gradient $\nabla_m \mathcal{L}$ completely unchanged, simplifies the directional gradient to $\nabla_{V'} \mathcal{L} = \frac{m}{C} \nabla_{W'} \mathcal{L}$, and reduces DoRA training memory consumption by $24.4\%$ on LLaMA-7B and $12.4\%$ on VL-BART (arXiv:2402.09353, Section 4.3) with only a $0.2\%$ accuracy difference on LLaMA and $0.0\%$ on VL-BART. Like LoRA, once training completes, $W'$ is evaluated once and merged permanently into a single dense matrix, adding zero inference latency.
Backbone & PEFT Method (arXiv:2402.09353, Table 1) |
% Params | BoolQ | PIQA | SIQA | HellaSwag | WinoGrande | ARC-e | ARC-c | OBQA | 8-Task Avg. |
|---|---|---|---|---|---|---|---|---|---|---|
ChatGPT (gpt-3.5-turbo 0-shot CoT) |
— | 73.1 |
85.4 |
68.5 |
78.5 |
66.1 |
89.8 |
79.9 |
74.8 |
77.0% |
LLaMA-7B — Prefix-Tuning |
0.11% |
64.3 |
76.8 |
73.9 |
42.1 |
72.1 |
72.9 |
54.0 |
60.6 |
64.6% |
LLaMA-7B — Series / Parallel Adapter |
0.99% / 3.54% |
63.0 / 67.9 |
79.2 / 76.4 |
76.3 / 78.8 |
67.9 / 69.8 |
75.7 / 78.9 |
74.5 / 73.7 |
57.1 / 57.3 |
72.4 / 75.2 |
70.8% / 72.2% |
LLaMA-7B — LoRA ($r=32$) |
0.83% |
68.9 |
80.7 |
77.4 |
78.1 |
78.8 |
77.8 |
61.3 |
74.8 |
74.7% |
LLaMA-7B — $\text{DoRA}^\dagger$ (Half-Rank $r=16$) |
0.43% |
70.0 |
82.6 |
79.7 |
83.2 |
80.6 |
80.6 |
65.4 |
77.6 |
77.5% (+2.8%) |
LLaMA-7B — DoRA ($r=32$) |
0.84% |
69.7 |
83.4 |
78.6 |
87.2 |
81.0 |
81.9 |
66.2 |
79.2 |
78.4% (+3.7%) |
LLaMA-13B — LoRA ($r=32$) |
0.67% |
72.1 |
83.5 |
80.5 |
90.5 |
83.7 |
82.8 |
68.3 |
82.4 |
80.5% |
LLaMA-13B — DoRA ($r=32$) |
0.68% |
72.4 |
84.9 |
81.5 |
92.4 |
84.2 |
84.2 |
69.6 |
82.8 |
81.5% (+1.0%) |
LLaMA2-7B — LoRA ($r=32$) |
0.83% |
69.8 |
79.9 |
79.5 |
83.6 |
82.6 |
79.8 |
64.7 |
81.0 |
77.6% |
LLaMA2-7B — $\text{DoRA}^\dagger$ ($r=16$) / DoRA ($r=32$) |
0.43% / 0.84% |
72.0 / 71.8 |
83.1 / 83.7 |
79.9 / 76.0 |
89.1 / 89.1 |
83.0 / 82.6 |
84.5 / 83.7 |
71.0 / 68.2 |
81.2 / 82.4 |
80.5% / 79.7% |
LLaMA3-8B — LoRA ($r=32$) |
0.70% |
70.8 |
85.2 |
79.9 |
91.7 |
84.3 |
84.2 |
71.2 |
79.0 |
80.8% |
LLaMA3-8B — $\text{DoRA}^\dagger$ ($r=16$) / DoRA ($r=32$) |
0.35% / 0.71% |
74.5 / 74.6 |
88.8 / 89.3 |
80.3 / 79.9 |
95.5 / 95.5 |
84.7 / 85.6 |
90.1 / 90.5 |
79.1 / 80.4 |
87.2 / 85.8 |
85.0% / 85.2% (+4.4%) |
Furthermore, when combined with 4-bit NF4 quantization (QDoRA, Section 6.1 of arXiv:2402.09353), QDoRA consistently outperforms QLoRA and even matches full fine-tuning on Orca-Math across both LLaMA2-7B and LLaMA3-8B.
4. Gradient Low-Rank Projection (GaLore, arXiv:2403.03507): Full-Parameter Pre-Training on a Single 24GB GPU
While LoRA and DoRA excel at fine-tuning a pre-trained checkpoint, they fail when pre-training an LLM from scratch because constraining $\Delta W = B A$ locks the cumulative weight update $\sum_t \Delta W_t$ inside a single fixed rank-$r$ subspace throughout training (arXiv:2403.03507, Section 1 & Table 2). Even ReLoRA (Lialin et al., 2023), which periodically merges $BA$ into $W_0$ and resets $B, A$, requires a full-rank warm start and degrades significantly without it.
In "GaLore: Memory-Efficient LLM Training by Gradient Low-Rank Projection" (arXiv:2403.03507, ICML 2024 Oral), Jiawei Zhao et al. establish a fundamental theoretical insight: while the weight matrix $W_t \in \mathbb{R}^{m \times n}$ must be able to explore the full-rank parameter space, the instantaneous gradient matrix $G_t = -\nabla_W \mathcal{L}(W_t) \in \mathbb{R}^{m \times n}$ rapidly becomes low-rank during reversible neural network training (Theorem 3.2 & Lemma 3.5).
1. Subspace Switching and Low-Rank Optimizer State Projection
Assuming without loss of generality that $m \le n$, GaLore keeps the full-rank weight matrix $W_t \in \mathbb{R}^{m \times n}$ intact and projects only the gradient $G_t$ into a compact $r \times n$ subspace using an orthogonal left projection matrix $P_t \in \mathbb{R}^{m \times r}$ (arXiv:2403.03507, Equations 4–6 & 12–13):
$$R_t = P_t^\top G_t \in \mathbb{R}^{r \times n}$$
The stateful optimizer $\rho_t$ (such as Adam, which tracks first and second moments $M_t, V_t \in \mathbb{R}^{r \times n}$) operates exclusively inside this compressed $r \times n$ subspace:
$$M_t = \beta_1 M_{t-1} + (1 - \beta_1) R_t, \qquad V_t = \beta_2 V_{t-1} + (1 - \beta_2) R_t^2$$
$$\tilde{G}t = \alpha P_t \rho_t(R_t) = \alpha P_t \frac{\hat{M}_t}{\sqrt{\hat{V}_t} + \epsilon} \in \mathbb{R}^{m \times n}, \qquad W_t = W{t-1} + \eta \tilde{G}_t$$
To allow the cumulative weight trajectory $W_T = W_0 + \eta \sum_{i} P_{T_i} \sum_{\tau} \rho_\tau(R_\tau)$ to span the entire full-rank parameter space, GaLore refreshes the projection matrix $P_t$ every $T = 200$ iterations ($\alpha = 0.25$) by computing the truncated Singular Value Decomposition (SVD) of the current gradient $G_t$:
$$G_t = U S V^\top \approx \sum_{i=1}^r s_i u_i v_i^\top \implies P_t = [u_1, u_2, \dots, u_r] \in \mathbb{R}^{m \times r}$$
Because $W_t$ is updated directly in place, GaLore never stores separate $B$ and $A$ adapter weights or their separate optimizer states:
- GaLore Memory Footprint (
Table 1, $m \le n$): $mn$ (weights) $+ mr$ (projector $P_t$) $+ 2nr$ (low-rank Adam moments $M_t, V_t$) $= \mathbf{mn + mr + 2nr}$. - LoRA Memory Footprint (
Table 1): $(mn + mr + nr)$ (frozen $W_0$ + trainable $B, A$) $+ (2mr + 2nr)$ (Adam moments for $B, A$) $= \mathbf{mn + 3mr + 3nr}$.
Thus, GaLore is strictly more memory-efficient than LoRA (up to $30\%$ lower memory during pre-training) while performing true full-parameter learning across switching subspaces.
Pre-Training Method on C4 (arXiv:2403.03507, Table 2) |
LLaMA 60M ($r/d=128/256$, 1.1B tok) | LLaMA 130M ($r/d=256/768$, 2.2B tok) | LLaMA 350M ($r/d=256/1024$, 6.4B tok) | LLaMA 1B ($r/d=512/2048$, 13.1B tok) | LLaMA 7B (150K steps, 19.7B tok, Table 3) |
|---|---|---|---|---|---|
| Full-Rank BF16 Adam (8-bit Adam for 7B) | 34.06 PPL (0.36 GB) |
25.08 PPL (0.76 GB) |
18.80 PPL (2.06 GB) |
15.56 PPL (7.80 GB) |
14.61 PPL (26 GB, 8-bit Adam) |
| GaLore ($T=200, \alpha=0.25$; 8-bit for 7B) | 34.88 PPL (0.24 GB) |
25.36 PPL (0.52 GB) |
18.95 PPL (1.22 GB) |
15.64 PPL (4.38 GB) |
14.65 PPL (18 GB, $r=1024$) |
| Direct Low-Rank Factorization ($W = BA$) | 78.18 PPL (0.26 GB) |
45.51 PPL (0.54 GB) |
37.41 PPL (1.08 GB) |
142.53 PPL (3.57 GB) |
Diverges / High PPL |
| LoRA ($W = W_0 + BA$, no warm start) | 34.99 PPL (0.36 GB) |
33.92 PPL (0.80 GB) |
25.58 PPL (1.76 GB) |
19.21 PPL (6.17 GB) |
Subspace-limited |
| ReLoRA (Periodic Merge, no warm start) | 37.04 PPL (0.36 GB) |
29.37 PPL (0.80 GB) |
29.08 PPL (1.76 GB) |
18.33 PPL (6.17 GB) |
Requires full-rank warmup |
2. Pre-Training LLaMA-7B on a Single 24GB NVIDIA RTX 4090
By combining 8-bit GaLore (bitsandbytes 8-bit Adam states over projected gradients $R_t$, saving $9.6\text{GB}$ / $65.5\%$ of optimizer memory vs. 8-bit Adam and $82.5\%$ vs. BF16 Adam) with per-layer weight updates during backward execution (post_accumulate_grad_hook, which updates each layer's weight tensor immediately as its gradient is computed and frees the gradient immediately, saving $13.5\text{GB}$ of weight-gradient memory), Zhao et al. (arXiv:2403.03507, Section 5.5 & Figure 2) reduce total LLaMA-7B training memory by $37.92\text{GB}$ ($63.3\%$ vs. BF16 Adam) and $24.5\text{GB}$ ($52.3\%$ vs. 8-bit Adam)—fitting the entire $7\text{B}$ model ($14\text{GB}$ weights + compressed optimizer states + single-layer gradient + $2\text{GB}$ activations at token batch size 256) comfortably inside a single $24\text{GB}$ NVIDIA RTX 4090 GPU without model parallelism, activation checkpointing, or CPU offloading.
5. Model Merging Without Retraining: TIES-Merging (arXiv:2306.01708) and DARE (arXiv:2311.03099)
Once multiple task-specific fine-tuned models $\{\theta_t\}{t=1}^n$ (or merged LoRA adapters) have been trained from a shared pre-trained foundation checkpoint $\theta{\text{init}}$, Model Merging seeks to fuse them into a single unified multi-task checkpoint $\theta_m$ entirely in weight space—requiring zero additional gradient descent and zero GPUs.
In Task Arithmetic (Ilharco et al., 2023), each fine-tuned model defines a task vector $\tau_t = \theta_t - \theta_{\text{init}} \in \mathbb{R}^d$, and the merged model is formed via scaled addition $\theta_m = \theta_{\text{init}} + \lambda \sum_{t=1}^n \tau_t$. However, as the number of merged models $n$ grows, Task Arithmetic suffers steep accuracy degradation.
1. TIES-Merging (arXiv:2306.01708): Resolving Redundancy and Sign Interference
In "TIES-Merging: Resolving Interference When Merging Models" (arXiv:2306.01708, NeurIPS 2023), Prateek Yadav, Derek Tam, Leshem Choshen, Colin Raffel, and Mohit Bansal identify two distinct destructive interference mechanisms when summing task vectors (arXiv:2306.01708, Section 3 & Figures 2–4):
- Interference from Redundant Parameters: Across 11 fine-tuned NLP tasks, keeping only the top-$20\%$ highest-magnitude parameters in each task vector $\tau_t$ and zeroing the remaining $80\%$ produces zero drop in single-task accuracy (
Figure 3). When left untrimmed, the $80\%$ noisy low-magnitude drift parameters of $n - 1$ tasks dilute the critical high-magnitude weight update of the task that actually depends on that coordinate. - Interference from Sign Disagreement: Even after trimming the bottom $80\%$ of parameters, different task vectors frequently assign opposite signs ($+1$ vs. $-1$) to the same parameter coordinate $p$ (
Figure 4). Summing positive and negative updates cancels out the parameter's movement toward zero, destroying task-specific representations in both models.
To eliminate both failure modes, TIES-Merging (TrIm, Elect Sign & Merge, arXiv:2306.01708, Algorithm 1) executes three deterministic vector operations across task vectors $\{\tau_t\}_{t=1}^n$:
- Step 1 — Trim ($\hat{\tau}_t = \operatorname{trim}_k(\tau_t)$): For each task $t \in [n]$, retain the top-$k\%$ (typically $k = 20\%$) parameters with the largest absolute magnitude $|\tau_t^p|$ and reset the bottom $(100 - k)\%$ coordinates to $0$. Decompose each trimmed vector into its sign vector $\hat{\gamma}_t = \operatorname{sgn}(\hat{\tau}_t)$ and magnitude $\hat{\mu}_t = |\hat{\tau}_t|$.
- Step 2 — Elect Final Signs ($\gamma_m$): For every parameter coordinate $p \in \{1, \dots, d\}$, elect the dominant sign that has the highest total cumulative magnitude across all $n$ trimmed task vectors: $$\gamma_m^p = \operatorname{sgn}\left( \sum_{t=1}^n \hat{\tau}_t^p \right) \in \{+1, -1\}$$
- Step 3 — Disjoint Merge ($\tau_m^p$): For each coordinate $p$, form the active agreement set $\mathcal{A}^p = \{t \in [n] \mid \hat{\gamma}t^p = \gamma_m^p\}$ containing only the models whose trimmed sign matches the elected sign $\gamma_m^p$ (discarding conflicting signs and zeros), compute their disjoint mean, and add the scaled merged task vector back to $\theta{\text{init}}$: $$\tau_m^p = \frac{1}{|\mathcal{A}^p|} \sum_{t \in \mathcal{A}^p} \hat{\tau}t^p, \qquad \theta_m = \theta{\text{init}} + \lambda \tau_m$$
Across in-domain multi-task merging benchmarks (arXiv:2306.01708, Table 1), TIES-Merging outperforms the strongest prior baseline (Task Arithmetic) by an average of $+2.3\%$ absolute in NLP and $+1.7\%$ in Vision:
- PEFT (
(IA)³onT0-3B, 11 datasets): Task Arithmetic63.9%$\to$ TIES-Merging66.4%(+2.5%) (and64.9%without a validation set,+6.6%over weight averaging). - Full Fine-Tuning (
T5-base/T5-large, 7 NLP tasks): Task Arithmetic73.2%/73.3%$\to$ TIES-Merging73.9%(+0.7%) /76.9%(+3.6%). - Computer Vision (
ViT-B/32/ViT-L/14, 8 Vision tasks): Task Arithmetic70.1%/84.5%$\to$ TIES-Merging73.6%(+3.5%over Task Arithmetic,+1.8%over RegMean71.8%) /86.0%(+1.5%). - Out-of-Domain Generalization (
Table 6, 5 held-out T5 tasks): Outperforms the strongest baseline by $+1.0\%$ onT5-baseand $+4.4\%$ onT5-large.
2. DARE (arXiv:2311.03099): Drop And REscale Delta Parameters
While TIES-Merging prunes by magnitude ranking, Le Yu et al. ("Language Models are Super Mario: Absorbing Abilities from Homologous Models as a Free Lunch", arXiv:2311.03099, ICML 2024) discover an even more surprising statistical property of Supervised Fine-Tuning (SFT) delta parameters $\bm{\delta}^t = \bm{\theta}{\text{SFT}}^t - \bm{\theta}{\text{PRE}}$:
- In SFT models, delta parameter values are concentrated within an extremely narrow range (typically $|\delta| \le 0.002$, compared to $\sim 0.03$ after continual pre-training) and exhibit massive coordinate redundancy.
- Rather than sorting magnitudes, DARE (Drop And REscale,
arXiv:2311.03099, Section 3.1, Equation 1) applies a random Bernoulli dropout mask with rescaling directly to the delta parameters $\bm{\delta}^t$ before inference or model merging:
$$\bm{m}^t \sim \operatorname{Bernoulli}(p), \qquad \bm{\widetilde{\delta}}^t = (\bm{1} - \bm{m}^t) \odot \bm{\delta}^t, \qquad \bm{\hat{\delta}}^t = \frac{\bm{\widetilde{\delta}}^t}{1 - p}$$
$$\bm{\theta}{\text{DARE}}^t = \bm{\theta}{\text{PRE}} + \bm{\hat{\delta}}^t$$
Why is the $1 / (1 - p)$ rescaling factor mathematically essential? Consider a linear layer transforming input embeddings $\bm{x} \in \mathbb{R}^d$ by delta weights $\Delta \bm{h} = \bm{\delta}^t \bm{x}$. In expectation over the Bernoulli mask $\bm{m}^t \sim \operatorname{Bernoulli}(p)$ (where each coordinate is kept with probability $1 - p$ and dropped with probability $p$), the expected delta activation is (arXiv:2311.03099, Section 3.1.1):
$$\mathbb{E}\left[\hat{h}j - h_j^{\text{PRE}}\right] = \sum{i=1}^d \mathbb{E}\left[\hat{\delta}{i,j}^t\right] x_i = \sum{i=1}^d \left( (1 - p) \frac{\delta_{i,j}^t}{1 - p} + p \cdot 0 \right) x_i = \sum_{i=1}^d \delta_{i,j}^t x_i$$
Because $\mathbb{E}[\bm{\hat{\delta}}^t] = \bm{\delta}^t$ preserves the exact expected layer embeddings while reducing the density of non-zero delta coordinates to $(1 - p)$, DARE can eliminate $90\%$ ($p = 0.90$) to $99\%$ ($p = 0.99$, e.g., on WizardMath-70B) of SFT delta parameters with negligible performance loss. When merging $K$ homologous SFT models with drop rate $p$, the probability that two models collide at the same non-zero coordinate drops from $1$ to $(1 - p)^2$ (e.g., for $p = 0.90$, only $(0.10)^2 = 1\%$ of coordinates overlap!).
Merging Method & 13B Homologous Checkpoints (arXiv:2311.03099, Table 1) |
Use DARE? | AlpacaEval (Win %) | GSM8K (0-Shot %) | MATH (0-Shot %) | HumanEval (Pass@1) | MBPP (Pass@1) |
|---|---|---|---|---|---|---|
Single Unmerged: WizardLM-13B (LM) |
No | 67.20% |
2.20% |
0.04% |
36.59% |
34.00% |
Single Unmerged: WizardMath-13B (Math) |
No | — | 64.22% |
14.02% |
— | — |
Single Unmerged: llama-2-13b-code-alpaca (Code) |
No | — | — | — | 23.78% |
27.60% |
Task Arithmetic: LM & Code |
No / Yes | 68.07% / 67.83% |
— | — | 31.70% / 35.98% |
32.40% / 33.00% |
Task Arithmetic: Math & Code |
No / Yes | — | 64.67% / 65.05% |
13.98% / 13.96% |
8.54% / 10.37% |
8.60% / 9.80% |
Task Arithmetic: LM & Math & Code |
No / Yes | 69.03% / 69.28% |
58.45% / 56.48% |
9.88% / 10.16% |
18.29% / 23.17% |
29.80% / 31.60% |
TIES-Merging: LM & Math |
No / Yes | 68.63% / 68.70% |
15.77% / 36.16% |
2.04% / 4.56% |
37.80% / 36.59% |
35.60% / 37.00% |
TIES-Merging: LM & Code |
No / Yes | 63.63% / 67.15% |
— | — | 0.00% / 18.29% |
0.00% / 26.40% |
TIES-Merging: LM & Math & Code (DARE-TIES) |
No / Yes | 65.91% / 72.50% |
62.55% / 58.00% |
9.54% / 9.20% |
21.95% / 29.27% |
30.40% / 31.40% |
6. Architectural Comparison Matrix & Engineering Decision Framework
Choosing the right adaptation, gradient projection, or checkpoint fusion strategy depends on whether your workload is pre-training from scratch, single-GPU memory-constrained fine-tuning, high-rank multi-domain adaptation, or zero-GPU multi-task synthesis.
| Method & Primary Citation | Mathematical Update / Projection Rule | Memory Complexity ($W \in \mathbb{R}^{m \times n}, m \le n$) | Pre-Training Capable? | Inference Latency Overhead | Optimal Production Use Case |
|---|---|---|---|---|---|
LoRA (arXiv:2106.09685) |
$W = W_0 + \frac{\alpha}{r} B A$ | $mn + 3mr + 3nr$ (16-bit $W_0$) | No (single subspace) | 0.0% (merged in-place) |
Low-rank ($r \le 16$) multi-tenant task adaptation & hot-swapping |
rsLoRA (arXiv:2312.03732) |
$W = W_0 + \frac{\alpha}{\sqrt{r}} B A$ | $mn + 3mr + 3nr$ | No | 0.0% (merged in-place) |
High-rank ($r \in [32, 512]$) fine-tuning without gradient collapse |
QLoRA (arXiv:2305.14314) |
$\mathbf{Y} = \mathbf{X}\operatorname{dDequant}(\mathbf{W}^{\text{NF4}}) + \mathbf{X}\mathbf{L}_1\mathbf{L}_2$ | $4.127\text{ bits}\cdot mn + \text{BF16}(3mr+3nr)$ | No | 0.0% after dequant-merge |
Fine-tuning 33B–70B+ LLMs on a single 24GB–48GB GPU |
DoRA / QDoRA (arXiv:2402.09353) |
$W' = \underline{m} \frac{W_0 + \underline{B}\underline{A}}{\|W_0 + \underline{B}\underline{A}\|_c.\text{detach()}}$ | LoRA $+ 3n$ ($+0.01\%$ params) | No | 0.0% (merged in-place) |
Closing the FT accuracy gap on reasoning & VLM instruction tuning |
GaLore / 8-Bit GaLore (arXiv:2403.03507) |
$R_t = P_t^\top G_t, \; \tilde{G}_t = \alpha P_t \rho_t(R_t)$ | $mn + mr + 2nr$ (8-bit moments) | Yes ($T=200$ SVD switch) | 0.0% (native $W \in \mathbb{R}^{m \times n}$) |
Full-parameter pre-training & continual pre-training on consumer GPUs |
DARE-TIES (arXiv:2306.01708, 2311.03099) |
$\hat{\delta}^t = \frac{(1-m^t)\odot \delta^t}{1-p} \to \operatorname{TIES}(\{\hat{\delta}^t\})$ | CPU RAM only (zero GPU VRAM) | Post-SFT fusion | 0.0% (single checkpoint) |
Combining chat, math, and coding SFT checkpoints without GPU training |
7. Production PyTorch Implementation: LoRA / rsLoRA, DoRA (Detached-Norm), NF4 Double Quantization, GaLore Projector, and DARE-TIES Model Merger
The following self-contained PyTorch implementation provides mathematically exact, executable modules for LoRA / rsLoRA (arXiv:2106.09685, arXiv:2312.03732), DoRA with detached column-norm backpropagation (arXiv:2402.09353, Equation 11), QLoRA 4-bit NormalFloat (NF4) quantile generation and Double Quantization (arXiv:2305.14314, Section 3), GaLore SVD gradient projection (arXiv:2403.03507, Algorithm 1), and DARE-TIES multi-task checkpoint merging (arXiv:2306.01708, arXiv:2311.03099).
import math
from typing import Dict, List, Optional, Tuple
import torch
import torch.nn as nn
import torch.nn.functional as F
class LoRAAndRsLoRALinear(nn.Module):
"""Low-Rank Adaptation (arXiv:2106.09685) with Rank-Stabilized Scaling rsLoRA (arXiv:2312.03732, Theorem 3.2)."""
def __init__(
self,
base_layer: nn.Linear,
r: int = 16,
alpha: float = 32.0,
use_rslora: bool = True,
dropout: float = 0.0,
) -> None:
super().__init__()
self.in_features = base_layer.in_features
self.out_features = base_layer.out_features
self.r = r
self.alpha = alpha
# Theorem 3.2 (arXiv:2312.03732): scale by alpha / sqrt(r) for rank stability, or alpha / r for standard LoRA
self.scaling = (alpha / math.sqrt(r)) if use_rslora else (alpha / float(r))
self.weight = base_layer.weight
self.bias = base_layer.bias
self.weight.requires_grad_(False)
if self.bias is not None:
self.bias.requires_grad_(False)
# A in R^{r x k} initialized Gaussian/Kaiming; B in R^{d x r} initialized strictly to zero
self.lora_A = nn.Parameter(torch.empty(r, self.in_features, dtype=self.weight.dtype, device=self.weight.device))
self.lora_B = nn.Parameter(torch.zeros(self.out_features, r, dtype=self.weight.dtype, device=self.weight.device))
nn.init.kaiming_uniform_(self.lora_A, a=math.sqrt(5))
self.dropout = nn.Dropout(p=dropout) if dropout > 0.0 else nn.Identity()
def forward(self, x: torch.Tensor) -> torch.Tensor:
base_out = F.linear(x, self.weight, self.bias)
lora_out = F.linear(F.linear(self.dropout(x), self.lora_A), self.lora_B) * self.scaling
return base_out + lora_out
@torch.no_grad()
def merge_weights(self) -> nn.Linear:
"""Merge W = W_0 + gamma_r * B @ A in-place for zero-latency inference deployment."""
merged = nn.Linear(self.in_features, self.out_features, bias=self.bias is not None)
merged.weight.copy_(self.weight + self.scaling * (self.lora_B @ self.lora_A))
if self.bias is not None:
merged.bias.copy_(self.bias)
return merged
class DoRALinear(nn.Module):
"""Weight-Decomposed Low-Rank Adaptation (arXiv:2402.09353, Eq. 5 & Eq. 11) with detached column norm."""
def __init__(
self,
base_layer: nn.Linear,
r: int = 16,
alpha: float = 32.0,
use_rslora: bool = True,
) -> None:
super().__init__()
self.in_features = base_layer.in_features
self.out_features = base_layer.out_features
self.scaling = (alpha / math.sqrt(r)) if use_rslora else (alpha / float(r))
# Freeze pre-trained directional base matrix V = W_0 (shape: out_features x in_features)
self.weight = base_layer.weight
self.bias = base_layer.bias
self.weight.requires_grad_(False)
if self.bias is not None:
self.bias.requires_grad_(False)
# Trainable magnitude vector m = ||W_0||_c across each output row (1 x out_features in PyTorch F.linear convention)
with torch.no_grad():
init_mag = torch.linalg.norm(self.weight, dim=1, keepdim=True)
self.m = nn.Parameter(init_mag)
self.lora_A = nn.Parameter(torch.empty(r, self.in_features, dtype=self.weight.dtype, device=self.weight.device))
self.lora_B = nn.Parameter(torch.zeros(self.out_features, r, dtype=self.weight.dtype, device=self.weight.device))
nn.init.kaiming_uniform_(self.lora_A, a=math.sqrt(5))
def forward(self, x: torch.Tensor) -> torch.Tensor:
delta_v = (self.lora_B @ self.lora_A) * self.scaling
v_prime = self.weight + delta_v
# Eq. 11 (arXiv:2402.09353): detach norm C = ||V + \Delta V||_c from backprop graph (-24.4% memory on LLaMA-7B)
c_norm = torch.linalg.norm(v_prime, dim=1, keepdim=True).detach().clamp(min=1e-8)
w_dora = (self.m / c_norm) * v_prime
return F.linear(x, w_dora, self.bias)
def build_nf4_codebook(device: torch.device = torch.device("cpu")) -> torch.Tensor:
"""Compute exact 16-level 4-bit NormalFloat (NF4) quantiles with exact zero (arXiv:2305.14314, Section 3 & Appendix E)."""
def std_normal_quantile(p: torch.Tensor) -> torch.Tensor:
return math.sqrt(2.0) * torch.erfinv(2.0 * p - 1.0)
# Asymmetric split around 0 so 0.0 is represented exactly: 8 negative quantiles, 9 positive quantiles sharing 0.0
neg_idx = torch.arange(1, 9, dtype=torch.float64)
pos_idx = torch.arange(8, 17, dtype=torch.float64)
p_neg = 0.5 * (neg_idx / 17.0 + (neg_idx - 1.0) / 17.0)
p_pos = 0.5 * (pos_idx / 19.0 + (pos_idx + 1.0) / 19.0)
q_neg = std_normal_quantile(p_neg)
q_pos = std_normal_quantile(p_pos)
q_neg = q_neg / torch.abs(q_neg[0])
q_pos = q_pos / torch.abs(q_pos[-1])
codebook = torch.cat([q_neg[:-1], torch.zeros(1, dtype=torch.float64), q_pos[1:]], dim=0)
return codebook.to(dtype=torch.float32, device=device)
def qlora_nf4_double_quantize(
weight: torch.Tensor,
blocksize_1: int = 64,
blocksize_2: int = 256,
) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor]:
"""Perform QLoRA NF4 blockwise quantization + Double Quantization (0.127 bits/param scale overhead, arXiv:2305.14314)."""
codebook = build_nf4_codebook(weight.device)
flat = weight.detach().to(torch.float32).reshape(-1)
assert flat.numel() % (blocksize_1 * blocksize_2) == 0, "Weight count must be divisible by B1 * B2"
# First-stage quantization (blocksize B1 = 64)
blocks = flat.reshape(-1, blocksize_1)
c2_fp32 = blocks.abs().max(dim=-1, keepdim=True).values.clamp(min=1e-12)
norm_weights = blocks / c2_fp32
# Nearest-neighbor lookup in 16-entry NF4 codebook
q_indices = torch.argmin(torch.abs(norm_weights.unsqueeze(-1) - codebook), dim=-1).to(torch.uint8)
# Second-stage Double Quantization on c2_fp32 (blocksize B2 = 256) after subtracting mean
c2_groups = c2_fp32.reshape(-1, blocksize_2)
c2_mean = c2_groups.mean(dim=-1, keepdim=True)
c2_centered = c2_groups - c2_mean
c1_fp32 = c2_centered.abs().max(dim=-1, keepdim=True).values.clamp(min=1e-12)
c2_int8 = torch.round((c2_centered / c1_fp32) * 127.0).clamp(-127, 127).to(torch.int8)
return q_indices, c2_int8, c1_fp32.squeeze(-1), c2_mean.squeeze(-1)
class GaLoreProjector:
"""Gradient Low-Rank Projection with periodic SVD subspace switching (arXiv:2403.03507, Algorithm 1, Eq. 12-13)."""
def __init__(self, rank: int = 128, update_proj_gap: int = 200, scale: float = 0.25) -> None:
self.rank = rank
self.update_proj_gap = update_proj_gap
self.scale = scale
self.ortho_matrix: Optional[torch.Tensor] = None
@torch.no_grad()
def project(self, full_rank_grad: torch.Tensor, step: int) -> torch.Tensor:
"""Project full-rank gradient G_t in R^{m x n} into low-rank R_t in R^{r x n} (or R^{m x r} if m > n)."""
m, n = full_rank_grad.shape
if self.ortho_matrix is None or step % self.update_proj_gap == 0:
u, _, vh = torch.linalg.svd(full_rank_grad.to(torch.float32), full_matrices=False)
if m <= n:
self.ortho_matrix = u[:, : self.rank].to(full_rank_grad.dtype)
else:
self.ortho_matrix = vh[: self.rank, :].to(full_rank_grad.dtype)
if m <= n:
return self.ortho_matrix.T @ full_rank_grad # shape (r, n)
return full_rank_grad @ self.ortho_matrix.T # shape (m, r)
@torch.no_grad()
def project_back(self, low_rank_grad: torch.Tensor) -> torch.Tensor:
"""Project low-rank optimizer update rho_t(R_t) back to full parameter space R^{m x n}."""
assert self.ortho_matrix is not None
if low_rank_grad.shape[0] == self.rank:
return self.scale * (self.ortho_matrix @ low_rank_grad)
return self.scale * (low_rank_grad @ self.ortho_matrix)
@torch.no_grad()
def dare_ties_merge_checkpoints(
base_state: Dict[str, torch.Tensor],
finetuned_states: List[Dict[str, torch.Tensor]],
dare_drop_rate_p: float = 0.90,
ties_keep_top_k_ratio: float = 0.20,
scaling_lambda: float = 1.0,
) -> Dict[str, torch.Tensor]:
"""Fuse multiple homologous SFT checkpoints via DARE (arXiv:2311.03099) + TIES-Merging (arXiv:2306.01708, Alg. 1)."""
merged_state: Dict[str, torch.Tensor] = {}
keep_prob = 1.0 - dare_drop_rate_p
for key, w_init in base_state.items():
# 1. Compute task vectors tau_t = theta_t - theta_init and apply DARE Bernoulli drop & 1/(1-p) rescaling
trimmed_vectors: List[torch.Tensor] = []
for state in finetuned_states:
delta = (state[key].to(torch.float32) - w_init.to(torch.float32))
if dare_drop_rate_p > 0.0:
keep_mask = torch.bernoulli(torch.full_like(delta, keep_prob))
delta = (delta * keep_mask) / keep_prob
# 2. TIES Step 1 (Trim): Keep only top-k% highest-magnitude parameters per task vector
flat_abs = delta.abs().reshape(-1)
k_count = max(1, int(math.ceil(flat_abs.numel() * ties_keep_top_k_ratio)))
threshold = torch.topk(flat_abs, k_count, largest=True).values[-1]
trimmed = torch.where(delta.abs() >= threshold, delta, torch.zeros_like(delta))
trimmed_vectors.append(trimmed)
stacked = torch.stack(trimmed_vectors, dim=0) # shape (N_models, ...)
# 3. TIES Step 2 (Elect Final Signs): gamma_m = sgn(sum_t \hat{\tau}_t)
elected_sign = torch.sgn(stacked.sum(dim=0))
# 4. TIES Step 3 (Disjoint Merge): average strictly over models whose non-zero sign matches elected_sign
sign_match = (torch.sgn(stacked) == elected_sign) & (elected_sign != 0)
aligned_sum = torch.where(sign_match, stacked, torch.zeros_like(stacked)).sum(dim=0)
aligned_count = sign_match.sum(dim=0).clamp(min=1).to(torch.float32)
tau_merged = aligned_sum / aligned_count
merged_state[key] = (w_init.to(torch.float32) + scaling_lambda * tau_merged).to(w_init.dtype)
return merged_state8. Frequently Asked Questions (FAQ)
1. Why does LoRA achieve zero additional inference latency compared to the 20.7%–30.3% latency penalty of sequential bottleneck adapters? In arXiv:2106.09685 (Section 4.1 & Table 1), sequential bottleneck adapters (Houlsby et al., 2019) insert non-linear projection layers in series after attention and MLP blocks, adding depth to the sequential computation graph and increasing single-pass GPT-2 Medium latency at batch size $1$ (seq_len = 128) by $+20.7\%$ ($\text{Adapter}^{\text{L}}, 23.9\text{ ms}$) to $+30.3\%$ ($\text{Adapter}^{\text{H}}, 25.8\text{ ms}$) over the $19.8\text{ ms}$ baseline. By contrast, LoRA parameterizes the parallel linear update $\Delta W = \frac{\alpha}{r} B A$. Because matrix multiplication distributes over matrix addition, $W_0 x + \frac{\alpha}{r} B A x = (W_0 + \frac{\alpha}{r} B A)x$, allowing $\frac{\alpha}{r} B A$ to be permanently added into $W_0$ prior to serving with zero extra parameters or FLOPs at runtime.
2. Why does standard LoRA fail to improve when rank $r$ is increased to 64 or 256, and how does rsLoRA fix it? In arXiv:2312.03732 (Theorem 3.2, Equations 4–5), Damjan Kalajdzievski proves that because each entry of the matrix product $B A x$ sums $r$ inner-product terms, dividing the adapter by the conventional scaling factor $\gamma_r = \frac{\alpha}{r}$ causes both the forward activation magnitude and backpropagated gradients to decay asymptotically as $\Theta_r(1/\sqrt{r})$ as $r \to \infty$. Replacing the scaling factor with $\gamma_r = \frac{\alpha}{\sqrt{r}}$ (rsLoRA) is mathematically necessary and sufficient to guarantee $\Theta_r(1)$ rank-stabilized forward outputs and gradients at any rank $r$.
3. How much memory does QLoRA's Double Quantization save, and why is 4-bit NormalFloat (NF4) optimal for neural network weights? In arXiv:2305.14314 (Section 3), pre-trained Transformer weights follow a zero-centered normal distribution. 4-bit NormalFloat (NF4) estimates $2^4 = 16$ equal-probability quantiles of $\mathcal{N}(0, 1)$ normalized to $[-1, 1]$ with an exact $0.0$ value, making it information-theoretically optimal for Gaussian data. Because NF4 uses a small blocksize of $B_1 = 64$, storing a 32-bit scale $c_2^{\text{FP32}}$ per block normally adds $32 / 64 = 0.5\text{ bits/parameter}$. Double Quantization (DQ) quantizes those scales into 8-bit floats $c_2^{\text{FP8}}$ with second-level blocksize $B_2 = 256$, reducing overhead to $8/64 + 32/(64 \times 256) = 0.127\text{ bits/parameter}$—saving $0.373\text{ bits/parameter}$ ($\approx 3\text{GB}$ on LLaMA-65B) and enabling $65\text{B}$ fine-tuning in $<48\text{GB}$ VRAM (down from $>780\text{GB}$).
4. How does DoRA outperform LoRA by up to +4.4% on LLaMA-3-8B while adding only 0.01% trainable parameters? In arXiv:2402.09353 (Sections 3.2, 4.1–4.3 & Table 1), polar weight decomposition shows that full fine-tuning decouples magnitude updates from directional updates, whereas standard LoRA locks them in a positive correlation. DoRA decomposes weights into a trainable scalar magnitude vector $m \in \mathbb{R}^{1 \times k}$ ($+0.01\%$ parameters) and a directional matrix $V$ updated via LoRA: $W' = \underline{m} \frac{W_0 + \underline{B}\underline{A}}{\|W_0 + \underline{B}\underline{A}\|c}$. This orthogonalizes the directional gradient $\nabla{V'}\mathcal{L}$ against $V'$ while improving gradient conditioning, lifting 8-task commonsense reasoning accuracy by $+3.7\%$ on LLaMA-7B ($78.4\%$ vs. $74.7\%$), $+1.0\%$ on LLaMA-13B, $+2.9\%$ on LLaMA2-7B ($\text{DoRA}^\dagger$), and $+4.4\%$ on LLaMA3-8B ($85.2\%$ vs. $80.8\%$)—and detaching $\|V'\|_c$ during backprop reduces DoRA's training memory by $24.4\%$.
5. Why can GaLore pre-train an LLM from scratch on a 24GB GPU while LoRA cannot? In arXiv:2403.03507 (Sections 3–5, Tables 1–3), LoRA constrains the weight trajectory $\Delta W = B A$ to a single fixed rank-$r$ parameter subspace, causing LLaMA-1B C4 pre-training perplexity to degrade to $19.21$ (vs. full-rank $15.56$). GaLore keeps full-rank weights $W \in \mathbb{R}^{m \times n}$ and projects only the gradient $R_t = P_t^\top G_t \in \mathbb{R}^{r \times n}$, refreshing $P_t$ via SVD every $T = 200$ steps so weights traverse multiple subspaces while requiring only $mn + mr + 2nr$ memory (less than LoRA's $mn + 3mr + 3nr$). Combined with 8-bit Adam states and per-layer weight updates, 8-bit GaLore cuts optimizer memory by $82.5\%$ and total memory by $63.3\%$ ($37.92\text{GB}$ saved), pre-training LLaMA-7B on a single $24\text{GB}$ RTX 4090 and reaching $14.65$ perplexity on $19.7\text{B}$ C4 tokens.
6. How do TIES-Merging and DARE combine multiple fine-tuned LLMs on CPU without catastrophic interference? In arXiv:2306.01708 (Algorithm 1) and arXiv:2311.03099 (Equation 1 & Table 1), SFT task vectors $\bm{\delta}^t = \bm{\theta}{\text{SFT}}^t - \bm{\theta}{\text{PRE}}$ have tiny magnitudes ($\le 0.002$) with $80\%\text{--}99\%$ redundant parameters. DARE randomly drops fraction $p \in [0.90, 0.99]$ of delta parameters via $\operatorname{Bernoulli}(p)$ and rescales survivors by $1/(1-p)$ to preserve expected layer embeddings $\mathbb{E}[\bm{\hat{\delta}}^t] = \bm{\delta}^t$. TIES-Merging trims low-magnitude noise, elects the dominant sign $\gamma_m = \operatorname{sgn}(\sum \hat{\tau}_t)$, and averages strictly across sign-aligned parameters—lifting a 3-way merged WizardLM-13B + WizardMath-13B + Code-Alpaca-13B model on AlpacaEval from $65.91\%$ to $72.50\%$ without a single GPU step.
9. Primary Sources & Official Technical References
- LoRA — Low-Rank Adaptation of Large Language Models (Hu, Shen, Wallis, Allen-Zhu, Li, Wang, Wang, and Chen, Microsoft Corporation, ICLR 2022 — "LoRA: Low-Rank Adaptation of Large Language Models"): https://arxiv.org/abs/2106.09685 and full HTML text https://ar5iv.labs.arxiv.org/html/2106.09685
- rsLoRA — Rank-Stabilized LoRA Scaling Factor (Kalajdzievski, Tenyx 2023 — "A Rank Stabilization Scaling Factor for Fine-Tuning with LoRA"): https://arxiv.org/abs/2312.03732 and full HTML text https://ar5iv.labs.arxiv.org/html/2312.03732
- QLoRA — 4-Bit NormalFloat, Double Quantization & Paged Optimizers (Dettmers, Pagnoni, Holtzman, and Zettlemoyer, University of Washington, NeurIPS 2023 — "QLoRA: Efficient Finetuning of Quantized LLMs"): https://arxiv.org/abs/2305.14314 and full HTML text https://ar5iv.labs.arxiv.org/html/2305.14314
- DoRA — Weight-Decomposed Low-Rank Adaptation (Liu, Wang, Yin, Molchanov, Wang, Cheng, and Chen, NVIDIA & HKUST, ICML 2024 Oral — "DoRA: Weight-Decomposed Low-Rank Adaptation"): https://arxiv.org/abs/2402.09353 and full HTML text https://arxiv.org/html/2402.09353v6
- GaLore — Gradient Low-Rank Projection for Full-Parameter LLM Pre-Training (Zhao, Zhang, Chen, Wang, Anandkumar, and Tian, Caltech, Meta AI, UT Austin & CMU, ICML 2024 Oral — "GaLore: Memory-Efficient LLM Training by Gradient Low-Rank Projection"): https://arxiv.org/abs/2403.03507 and full HTML text https://arxiv.org/html/2403.03507v2
- TIES-Merging — Resolving Redundancy and Sign Interference in Model Merging (Yadav, Tam, Choshen, Raffel, and Bansal, UNC Chapel Hill, IBM Research & MIT, NeurIPS 2023 — "TIES-Merging: Resolving Interference When Merging Models"): https://arxiv.org/abs/2306.01708 and full HTML text https://ar5iv.labs.arxiv.org/html/2306.01708
- DARE — Drop And REscale Delta Parameters for Homologous LLM Merging (Yu, Yu, Yu, Huang, and Li, Alibaba Group, ICML 2024 — "Language Models are Super Mario: Absorbing Abilities from Homologous Models as a Free Lunch"): https://arxiv.org/abs/2311.03099 and full HTML text https://arxiv.org/html/2311.03099v3