Model Merging Guide: MergeKit, TIES, DARE & SLERP

The Problem: The Catastrophic Forgetting and Compute Wall of Multi-Task Training
In modern enterprise AI systems, intelligent desktop extractors, and autonomous multi-agent pipelines like AiFetchly, deploying language models that excel across disparate cognitive tasks—such as mathematical reasoning, high-precision code synthesis, instruction adherence, and structured JSON formatting—is a core operational requirement.
Historically, organizations attempted to achieve multi-capability performance through two primary engineering avenues: sequential fine-tuning or joint multi-task training. However, both paradigms collide with severe algorithmic and economic barriers.
1. The Catastrophic Forgetting Tax in Sequential Fine-Tuning
When a pre-trained foundation model undergoes sequential parameter updates across multiple domains (for example, fine-tuning on Python coding, then fine-tuning on legal contract analysis, followed by conversational instruction-following), gradient descent prioritizes the loss landscape of the most recent dataset:
- Weight Drift and Subspace Overwriting: New gradient steps overwrite orthogonal parameter directions learned during earlier stages. The model rapidly suffers from catastrophic forgetting, losing its ability to solve math or generate valid code while optimizing for conversational style.
- Fragile Learning Rates: Lowering learning rates to preserve previous capabilities leads to underfitting on the new task, forcing engineers into endless hyperparameter searches.
2. Joint Multi-Task Training: The Compute and Data Squeeze
To avert sequential catastrophic forgetting, teams attempt to combine all domain datasets into a single massive mixture and fine-tune simultaneously:
- Massive Compute Expenditure: Re-training a 70B parameter model on a comprehensive multi-task dataset demands hundreds of thousands of dollars in GPU cluster compute (NVIDIA H100/H200 clusters), making continuous updates economically unfeasible.
- Dataset Imbalance and Task Interference: Negative gradient interference frequently occurs when diverse objectives conflict. Gradients from creative writing or dialogue generation actively degrade formal mathematical proofs, forcing artificial sample-weight balancing tricks that yield compromised “jack-of-all-trades, master-of-none” checkpoints.
3. The Multi-Model Hosting Tax in Production Runtimes
When multi-task training fails, organizations often fall back on deploying multiple distinct, task-specific checkpoints in parallel:
- VRAM Multiplier: Serving one specialized 8B model for code extraction, another 8B model for SQL translation, and a third for conversational dialogue requires 3x the GPU High-Bandwidth Memory (HBM).
- Latency Spikes from Model Swapping: In local desktop environments or single-GPU servers, swapping multi-gigabyte weight tensors across PCIe buses introduces severe Time-to-First-Token (TTFT) latency penalties (500ms to 2000ms), degrading real-time responsiveness.
The Mathematical Foundations: From Linear Averaging to Task Arithmetic
To overcome the compute and memory walls of training, researchers turned to a counter-intuitive discovery in deep learning loss landscapes: Mode Connectivity and Weight-Space Geometry.
When multiple models are fine-tuned from the exact same pre-trained base model on different tasks, their final weight vectors reside within a shared low-loss basin. Instead of re-training through data backpropagation, can we combine their capabilities directly in weight space?
1. Simple Linear Interpolation and Its Failures
The simplest approach to model merging is parameter-wise linear averaging (often derived from Federated Averaging or “Model Soups”):
$$\theta_{\text{merged}} = \alpha \theta_A + (1 - \alpha) \theta_B$$
Where $\theta_A$ and $\theta_B$ represent the parameter tensors of two fine-tuned checkpoints, and $\alpha \in [0, 1]$ is a scalar mixing coefficient.
While linear averaging works well for models fine-tuned on the same distribution with different random seeds (Model Soups), it breaks down catastrophically when merging across distinct task distributions:
- Magnitude Shrinkage: High-dimensional weight vectors are not scalar numbers; their norms reflect activation scales. Direct linear interpolation cuts through the interior of the hypersphere rather than traversing the manifold surface, causing the norm of the merged weights to collapse: $||\theta_{\text{merged}}|| < \min(||\theta_A||, ||\theta_B||)$.
- Feature Blur: Diluting divergent weights without accounting for geometric orientation blurs distinct activation patterns, causing immediate degradation in syntax generation and factual recall.
2. Task Arithmetic: The Vector Algebra of Fine-Tuning Updates
A major conceptual leap occurred with Task Arithmetic (Ilharco et al., 2023). Rather than averaging raw absolute weights $\theta$, task arithmetic operates on the task vectors (weight deltas) produced by fine-tuning:
$$\tau_m = \theta_m - \theta_{\text{base}}$$
Where $\theta_{\text{base}}$ is the pre-trained foundation checkpoint, and $\theta_m$ is the fine-tuned model for task $m$. The task vector $\tau_m$ represents the precise directional shift in parameter space required to execute task $m$.
Under task arithmetic, models can be manipulated using linear vector algebra:
- Task Addition: $\theta_{\text{merged}} = \theta_{\text{base}} + \lambda_1 \tau_1 + \lambda_2 \tau_2$ (combines skills 1 and 2).
- Task Negation (Unlearning): $\theta_{\text{merged}} = \theta_{\text{base}} - \lambda \tau_{\text{toxic}}$ (surgically removes toxic or hallucinated behaviors without retraining).
- Task Analogy: $\theta_{\text{merged}} = \theta_{\text{base}} + (\tau_{\text{code}} - \tau_{\text{text}})$.
Despite its elegance, naive task addition fails when scaling beyond two small models due to parameter interference: individual parameter deltas in different task vectors frequently have opposite signs, canceling each other out and destroying domain performance.
The Modern Merging Algorithms: Resolving Interference
To scale model merging to frontier 8B, 70B, and MoE architectures, modern algorithms explicitly identify and eliminate parameter interference. Three foundational methods dominate production pipelines: SLERP, TIES-Merging, and DARE.

1. SLERP: Spherical Linear Interpolation for Two Models
When merging exactly two models, linear interpolation fails because it cuts through the hypersphere chord, collapsing weight magnitudes. SLERP (Spherical Linear Interpolation) solves this by interpolating along the spherical arc at a constant angular velocity, preserving the geometric curvature and norm of high-dimensional parameter tensors.
Given two normalized weight vectors $\hat{v}_0$ and $\hat{v}_1$, the angle $\Omega$ between them is defined by their dot product:
$$\cos(\Omega) = \hat{v}_0 \cdot \hat{v}_1 = \frac{v_0 \cdot v_1}{||v_0|| \cdot ||v_1||}$$
The interpolated vector at blend factor $t \in [0, 1]$ is computed as:
$$\text{SLERP}(v_0, v_1; t) = \frac{\sin((1 - t)\Omega)}{\sin(\Omega)} v_0 + \frac{\sin(t\Omega)}{\sin(\Omega)} v_1$$
Key Operational Properties:
- Magnitude & Variance Conservation: SLERP ensures that the output vector retains the expected scale of activations across intermediate layers, preventing numerical drift and layer-norm saturation.
- Layer-Wise Gradients: In practice, blend factors $t$ are smoothly varied across transformer layers (e.g., keeping early attention layers closer to a base reasoning model while steering late MLP layers toward a creative or coding specialist).
2. TIES-Merging: Trimming, Electing Sign, and Disjoint Merging
While SLERP is ideal for exactly two models, multi-model merging (e.g., fusing math, code, vision, and instruction models) requires resolving multi-directional parameter conflict. Introduced by Yadav et al. (NeurIPS 2023), TIES-Merging (TRIM, ELECT SIGN & MERGE) addresses two root causes of degradation: parameter redundancy and sign interference.
The TIES pipeline executes in three sequential stages:
Step 1: Trim (Reset Redundant Parameters): Fine-tuning only alters a tiny fraction of parameters significantly; the vast majority of delta values are small noise. For each task vector $\tau_m$, TIES retains only the top-$k$% parameters (typically $k = 20%$) with the largest absolute magnitude, setting the remaining $(100 - k)%$ to zero:
$$\hat{\tau}_m^p = \begin{cases} \tau_m^p & \text{if } |\tau_m^p| \ge \text{TopK}(|\tau_m|, k) \ 0 & \text{otherwise} \end{cases}$$
Step 2: Elect Sign (Resolve Directional Conflict): When multiple models adjust the same parameter, they often disagree on whether the weight should increase or decrease. Naive averaging causes destructive cancellation ($+0.5$ and $-0.5$ average to $0.0$). TIES creates a unified parameter-level consensus vector $\gamma^p \in {-1, +1}$ by computing the total signed mass:
$$\gamma^p = \text{sign}\left(\sum_{m=1}^M \hat{\tau}_m^p\right)$$
Step 3: Disjoint Merge (Consensus Averaging): For each parameter $p$, TIES filters out any model whose delta sign opposes the majority direction $\gamma^p$. Only agreeing parameters are averaged into the final task update:
$$\tau_{\text{merged}}^p = \frac{1}{|A^p|} \sum_{m \in A^p} \hat{\tau}_m^p, \quad \text{where } A^p = {m : \text{sign}(\hat{\tau}_m^p) = \gamma^p}$$
$$\theta_{\text{merged}} = \theta_{\text{base}} + \lambda \tau_{\text{merged}}$$
3. DARE: Drop And REscale via Bernoulli Sparsification
While TIES trims parameters deterministically based on magnitude thresholds, DARE (Drop And REscale) (Yu et al., 2024) uncovered a staggering empirical reality of modern LLMs: extreme delta parameter redundancy.
Yu et al. demonstrated that up to 90% to 99% of fine-tuned delta weights can be dropped completely at random without degrading task performance, provided the remaining weights are rescaled to preserve the expected activation value!
DARE operates on each task vector $\tau_m = \theta_m - \theta_{\text{base}}$ via two mathematical steps:
1. Random Bernoulli Masking: Each delta parameter is independently zeroed out with drop probability $p \in [0.90, 0.99]$:
$$m^p \sim \text{Bernoulli}(1 - p)$$
$$\tilde{\tau}_m^p = m^p \odot \tau_m^p$$
2. Expectation-Preserving Rescaling: To ensure that the expectation of the sparsified delta matches the original fine-tuned delta ($\mathbb{E}[\tilde{\tau}_m] = \tau_m$), the surviving $(1 - p)$ fraction of weights is scaled by the inverse probability:
$$\tau_{\text{DARE}, m}^p = \frac{\tilde{\tau}_m^p}{1 - p}$$
The DARE-TIES Synergy: When DARE sparsification is applied as a pre-processing step before TIES-Merging (DARE-TIES), multi-task interference is virtually eliminated. Because each model’s task vector is 90% sparse, the probability of multiple models colliding on the same parameter drops exponentially. DARE-TIES stands as the premier algorithm for creating state-of-the-art open models on the Hugging Face Leaderboard.
4. Comparison of Model Merging Techniques
| Technique | Optimal Model Count | Primary Mechanism | Handles Sign Conflict? | GPU Required? | Best Used For |
|---|---|---|---|---|---|
| Linear / Soup | 2 to $N$ (same task) | Direct parameter weighted average | No (destructive cancellation) | No (CPU only) | Combining multiple checkpoints of the same run |
| Task Arithmetic | 2 to 4 models | Direct delta vector addition ($\theta_{\text{base}} + \sum \lambda_i \tau_i$) | No (blind superposition) | No (CPU only) | Targeted skill editing and task unlearning |
| SLERP | Exactly 2 models | Spherical interpolation preserving angular norm | Partially (smooth rotation) | No (CPU only) | Fusing base model with a strong single specialist |
| TIES-Merging | 3 to 10+ models | Top-k magnitude trim, majority sign election | Yes (discard opposing signs) | No (CPU only) | Multi-task fusion across distinct domains |
| DARE-TIES | 3 to 10+ models | 90% random drop + $1/(1-p)$ rescale + TIES | Yes (extreme sparsity + sign consensus) | No (CPU only) | High-performance multi-capability foundation models |
| Passthrough | 1 to 2 models | Interleaving / stacking transformer layers | N/A (structural architectural expansion) | No (CPU only) | Creating expanded parameter scale (e.g. 7B to 11B) |
Practical Implementation: Building and Merging Models with MergeKit
To understand the internal mechanics before running production CLI tools, let us examine the core mathematical operators for SLERP, TIES, and DARE in PyTorch, followed by a production MergeKit configuration.
1. PyTorch Implementation of Merging Operators
import torch
import torch.nn.functional as F
from typing import List
def slerp(v0: torch.Tensor, v1: torch.Tensor, t: float, eps: float = 1e-8) -> torch.Tensor:
"""
Spherical Linear Interpolation between two parameter tensors.
Preserves tensor magnitude and angular geometry.
"""
v0_flat = v0.flatten()
v1_flat = v1.flatten()
# Calculate unit vectors
v0_norm = torch.norm(v0_flat)
v1_norm = torch.norm(v1_flat)
u0 = v0_flat / (v0_norm + eps)
u1 = v1_flat / (v1_norm + eps)
# Calculate cosine of angle between vectors
dot = torch.sum(u0 * u1)
dot = torch.clamp(dot, -1.0 + eps, 1.0 - eps)
omega = torch.acos(dot)
sin_omega = torch.sin(omega)
if sin_omega < eps:
# Vectors are colinear; fall back to linear interpolation
res = (1.0 - t) * v0_flat + t * v1_flat
else:
scale0 = torch.sin((1.0 - t) * omega) / sin_omega
scale1 = torch.sin(t * omega) / sin_omega
res = scale0 * v0_flat + scale1 * v1_flat
# Scale result to interpolated magnitude
res_norm = (1.0 - t) * v0_norm + t * v1_norm
res = (res / (torch.norm(res) + eps)) * res_norm
return res.view_as(v0)
def dare_sparsify(task_vector: torch.Tensor, drop_rate: float = 0.9) -> torch.Tensor:
"""
Drop And REscale (DARE): Randomly mask drop_rate percentage of weights
and rescale surviving weights by 1 / (1 - drop_rate).
"""
if drop_rate <= 0.0:
return task_vector
keep_prob = 1.0 - drop_rate
mask = torch.bernoulli(torch.full_like(task_vector, keep_prob))
return (task_vector * mask) / keep_prob
def ties_merge(base_param: torch.Tensor,
task_vectors: List[torch.Tensor],
density: float = 0.2,
merge_weight: float = 1.0) -> torch.Tensor:
"""
TIES-Merging: Trimming, Sign Election, and Disjoint Consensus Averaging.
"""
num_models = len(task_vectors)
stacked_deltas = torch.stack(task_vectors, dim=0) # [M, ...]
# Step 1: Trim bottom (1 - density)% by absolute magnitude
k = max(1, int(stacked_deltas.numel() / num_models * density))
flat_deltas = stacked_deltas.view(num_models, -1)
trimmed_deltas = torch.zeros_like(flat_deltas)
for m in range(num_models):
threshold = torch.topk(flat_deltas[m].abs(), k, sorted=True).values[-1]
mask = flat_deltas[m].abs() >= threshold
trimmed_deltas[m] = flat_deltas[m] * mask
# Step 2: Elect parameter sign by majority mass
sum_signs = torch.sum(trimmed_deltas, dim=0)
elected_signs = torch.sign(sum_signs) # +1, -1, or 0
# Step 3: Disjoint Consensus Average
# Filter only parameters matching the elected sign
aligned_mask = (torch.sign(trimmed_deltas) == elected_signs.unsqueeze(0)) & (elected_signs.unsqueeze(0) != 0)
filtered_deltas = trimmed_deltas * aligned_mask
agree_counts = torch.sum(aligned_mask, dim=0).clamp(min=1)
consensus_delta = torch.sum(filtered_deltas, dim=0) / agree_counts
merged_flat = base_param.flatten() + merge_weight * consensus_delta
return merged_flat.view_as(base_param) 2. Production MergeKit Configuration (config.yaml)
MergeKit is the industry-standard framework developed by Charles Goddard and Arcee AI. It processes models out-of-core with low RAM overhead, enabling engineers to merge 70B parameter models on a standard desktop workstation without GPU acceleration.
Here is a battle-tested DARE-TIES configuration combining three specialized LLaMA-3-8B fine-tunes into a unified intelligence engine:
models:
- model: meta-llama/Meta-Llama-3-8B
# Base model provides anchor parameters
- model: cognitivecomputations/dolphin-2.9-llama3-8b
parameters:
density: 0.5
weight: [0.2, 0.4, 0.6, 0.8, 0.6, 0.4, 0.2] # Gradient layer weighting
- model: WizardLM/WizardMath-7B-V1.1
parameters:
density: 0.5
weight: 0.4
- model: deepseek-ai/deepseek-coder-6.7b-instruct
parameters:
density: 0.5
weight: 0.4
merge_method: dare_ties
base_model: meta-llama/Meta-Llama-3-8B
parameters:
int8_mask: true
dtype: bfloat16
tokenizer_source: base 3. Executing the Merge via MergeKit CLI
To execute the merge without consuming GPU VRAM, use the --lazy-unpickle flag, which memory-maps weights directly from disk:
# Install MergeKit from source
pip install mergekit
# Run CPU-based out-of-core merge (zero GPU VRAM required)
mergekit-yaml config.yaml ./merged-llama3-omni --cuda-device cpu --lazy-unpickle --low-cpu-memory --copy-tokenizer Production Benchmarks & Empirical Trade-Offs
How well do merged models perform when evaluated on standardized reasoning, coding, and instruction benchmarks?
Empirical results from the Hugging Face Open LLM Leaderboard and evaluations on 8B parameter models reveal the performance retention across individual domains:
| Architecture / Evaluation Method | MMLU (General Knowledge) | GSM8K (Math Reasoning) | HumanEval (Python Code) | IFEval (Instruction Adherence) | Memory Overhead to Train |
|---|---|---|---|---|---|
| Base Model (Llama-3-8B) | 66.7% | 45.8% | 34.2% | 68.4% | N/A (Baseline) |
| Fine-Tune A (Math Specialist) | 64.1% | 78.2% | 31.0% | 55.2% | 1x Full Fine-Tune Cost |
| Fine-Tune B (Code Specialist) | 65.0% | 48.5% | 68.9% | 59.8% | 1x Full Fine-Tune Cost |
| Fine-Tune C (Chat/Instruct) | 67.2% | 51.0% | 36.5% | 79.5% | 1x Full Fine-Tune Cost |
| Linear Average (Soup) | 61.2% | 52.4% | 41.2% | 63.0% | $0 (Degraded by cancellation) |
| SLERP (Math + Code) | 66.8% | 72.1% | 61.5% | 65.4% | $0 (Preserves norms for 2 models) |
| TIES-Merging (A + B + C) | 67.8% | 74.5% | 63.8% | 75.2% | $0 (Removes sign cancellation) |
| DARE-TIES (A + B + C) | 68.9% | 76.8% | 66.4% | 78.6% | $0 (Near-lossless multi-task fusion) |
Key Empirical Insights:
- Linear Averaging Suffers from Interference: Naive linear blending causes a 5.5% drop on MMLU and severe coding regressions due to sign cancellations in attention projection heads.
- DARE-TIES Retains Over 96% of Specialist Peak Performance: The DARE-TIES merged model captures 76.8% on GSM8K (within 1.4% of the standalone math model) and 66.4% on HumanEval (within 2.5% of the dedicated code model), while simultaneously outperforming the base model on general instruction adherence.
- Synergistic Emergence: On complex reasoning tasks (such as mathematical word problems requiring code verification), the DARE-TIES merged model occasionally outperforms both parent models due to the cross-pollination of code logic and mathematical decomposition.
Strategic Recommendations: Merging Models in 2026
For engineering teams architecting high-throughput data extraction platforms and autonomous desktop applications like AiFetchly, model merging provides a transformative cost-performance advantage.
1. Synthesize Domain Subagents into Single-Checkpoint 8B Models
Rather than running an expensive orchestration layer that routes prompts between separate code, translation, and structured data extraction models:
- Train or download targeted LoRA adapters or full fine-tunes for each subagent specialty.
- Fuse the task vectors into a single unified 8B model via DARE-TIES.
- Deploy a single model in local GPU memory (8GB VRAM with 4-bit quantization), eliminating PCIe context switching latency and tripling concurrent throughput.
2. Choose the Right Algorithm for the Problem Topology
- Use SLERP when blending exactly two models: If you have an exceptionally strong reasoning base (e.g., Llama-3-8B-Instruct) and want to inject a single domain capability (e.g., medical extraction or roleplay), SLERP provides the cleanest mathematical interpolation without hyperparameter tuning.
- Use DARE-TIES when merging three or more models: Whenever three or more models are involved, parameter collisions are guaranteed. Set
density: 0.5anddrop_rate: 0.9with majority sign election. - Use Passthrough / Frankenmerging for Architecture Upscaling: When you need more representational capacity without training from scratch, interleave duplicate layers from a 7B model to create a 10.7B model (as pioneered by Solar-10.7B).
3. Post-Merge Calibration and Alignment Guidelines
While model merging requires zero training data, executing a lightweight post-merge pass ensures peak stability:
- Normalize LayerNorm Biases: In rare instances, merging distinct MLP blocks causes slight variance shifts in LayerNorm parameters. Inspecting activation kurtosis and running a brief 50-step calibration on unlabelled domain text restores razor-sharp token distribution.
- Merge Only Compatible Lineages: Crucially, model merging requires that all parent models share a common pre-trained base checkpoint. Attempting to merge a Mistral-7B model with a Llama-3-8B model in parameter space is mathematically invalid and yields gibberish outputs.