> ## Documentation Index
> Fetch the complete documentation index at: https://doc.blueapi.ir/llms.txt
> Use this file to discover all available pages before exploring further.

# Phase 3: Advanced Merge Strategies with TIES, DARE, and Franken-Merge

> Extend EMEP with advanced model merging strategies. Phase 3 delivers TIES (Yadav et al. 2023), DARE (Yu et al. 2023), DARE+TIES, Franken-Merge, and the merge validation framework.

Phase 3 expands EMEP beyond foundational merging into the state of the art. You implement four advanced strategies that address specific limitations of basic techniques: parameter redundancy (TIES), magnitude sensitivity (DARE), combined benefits (DARE+TIES), and structural heterogeneity (Franken-Merge). This phase also introduces formal merge validation to ensure that advanced combinations produce reliable, measurable outcomes.

## Purpose

The purpose of Phase 3 is to give EMEP users a comprehensive toolkit for model merging. Linear Merge, SLERP, and Task Arithmetic work well for homogeneous models with aligned objectives, but real-world scenarios often involve redundant parameters, conflicting updates, and incompatible architectures. TIES trims redundant parameters before merging. DARE drops and rescales weights to reduce magnitude bias. DARE+TIES combines both benefits. Franken-Merge handles structural combinations where layer counts or widths differ. You also build validation infrastructure so that every advanced merge is tested before it enters the evolutionary pipeline in Phase 5.

## Entry Criteria

* Phase 2 exit criteria satisfied: TensorEngine, MergeEngine, Linear Merge, SLERP, Task Arithmetic, and MergeStrategy plug-in system are operational
* MergeStrategy plug-in system proven to load new strategies without engine restart
* Test suite from Phase 2 passes as regression baseline
* Literature on TIES, DARE, and structural merging reviewed and algorithm specifications documented

## Exit Criteria

* TIES strategy trims low-magnitude parameters and resolves sign conflicts before merging (Yadav et al. 2023)
* DARE strategy randomly drops weights and rescales survivors to preserve expectation (Yu et al. 2023)
* DARE+TIES strategy applies TIES trimming followed by DARE dropping and rescaling
* Franken-Merge strategy combines structurally different models by aligning and splicing compatible substructures
* Merge validation framework runs automated checks on merged outputs: shape consistency, weight distribution, and sanity benchmarks
* All four strategies integrate with MergeEngine through the existing MergeStrategy plug-in system
* Regression tests for Phase 2 strategies continue to pass

## Primary Components

Phase 3 extends the canonical components established in Phase 2:

* [MergeEngine](/merge/merge-engine): the orchestrator, now executing advanced strategies through the same pipeline it used for basic merges
* [MergeStrategy](/merge/merge-strategies): the plug-in abstraction, now hosting four additional implementations
* [TensorEngine](/merge/tensor-operations): the low-level layer, extended with sparse operations and structural alignment primitives needed by TIES, DARE, and Franken-Merge

New and extended supporting components:

* [ModelCompatibilityAnalyzer](/compatibility/model-compatibility): extended to support structural compatibility checks for Franken-Merge scenarios where layer shapes differ
* [ArtifactStore](/tracking/artifact-registry): extended to store merge validation reports alongside merged checkpoints

## Deliverables

| Deliverable      | Path / Reference                         | Description                                                       |
| ---------------- | ---------------------------------------- | ----------------------------------------------------------------- |
| TIES             | [MergeStrategy](/merge/merge-strategies) | Trimming, electing sign, and disjoint merging (Yadav et al. 2023) |
| DARE             | [MergeStrategy](/merge/merge-strategies) | Drop and rescale with expectation preservation (Yu et al. 2023)   |
| DARE+TIES        | [MergeStrategy](/merge/merge-strategies) | Combined trimming and dropping for robust merging                 |
| Franken-Merge    | [MergeStrategy](/merge/merge-strategies) | Structural merge for heterogeneous architectures                  |
| Merge Validation | `/merge/merge-validation`                | Automated post-merge sanity and quality checks                    |

## Dependencies

Phase 3 depends directly on Phase 2:

* [Phase 2: Basic Merge Engine](/project/phases/phase-2): provides TensorEngine, MergeEngine, MergeStrategy plug-in system, and the three baseline strategies that advanced methods extend or contrast against

## Key Tasks

Track Phase 3 work in the project task registry:

* [Project Tasks](/project/tasks)

Typical Phase 3 tasks include:

1. Implement TIES parameter trimming with configurable magnitude threshold
2. Implement TIES sign election and disjoint merging logic (Yadav et al. 2023)
3. Implement DARE random weight dropping with configurable drop rate
4. Implement DARE rescaling to preserve weight expectations (Yu et al. 2023)
5. Compose DARE+TIES as a sequential strategy: trim first, then drop and rescale
6. Implement Franken-Merge structural alignment: layer matching, width padding, and submodel splicing
7. Build merge validation framework with shape checks, distribution tests, and quick benchmark inference
8. Register all four strategies with MergeEngine via the MergeStrategy plug-in system
9. Run regression tests to ensure Phase 2 strategies remain unaffected
10. Document parameter tuning guidance for each advanced strategy

## Risks

* **Hyperparameter sensitivity**: TIES and DARE performance depends heavily on threshold and drop-rate settings. Mitigate by providing sensible defaults and sensitivity analysis in documentation.
* **Franken-Merge brittleness**: Structural alignment may fail for radically different architectures. Mitigate by implementing graceful degradation and clear error messages when alignment is impossible.
* **Validation overhead**: Merge validation may become a bottleneck if it runs full benchmarks. Mitigate by tiering validation into fast sanity checks and optional deep evaluation.

See the full risk register for tracked items and mitigations:

* [Risk Register](/risk/risk-register)

## Quality Gate

Phase 3 is complete when the following checklist is fully satisfied:

* [ ] TIES reproduces published performance trends on a known model pair (Yadav et al. 2023)
* [ ] DARE reproduces published performance trends on a known model pair (Yu et al. 2023)
* [ ] DARE+TIES outperforms or matches both TIES and DARE individually on at least one test case
* [ ] Franken-Merge successfully combines two models with different layer counts without runtime errors
* [ ] Merge validation framework flags at least one injected failure case (e.g., shape mismatch)
* [ ] All Phase 2 regression tests pass with no changes to baseline strategy behavior
* [ ] Each advanced strategy is documented with parameters, constraints, and tuning guidance
* [ ] Memory and compute benchmarks establish resource requirements for each strategy

## Roadmap Position

The diagram below shows Phase 3 as the advanced merge phase, building on Phase 2 and supplying validated merge capabilities to evaluation and evolution in later phases.

```mermaid theme={null}
flowchart LR
    P0["Phase 0<br/>Research + Architecture + Documentation"]
    P1["Phase 1<br/>Model Registry + Compatibility"]
    P2["Phase 2<br/>Basic Merge Engine"]
    P3["<b>Phase 3</b><br/>Advanced Merge Strategies"]:::current
    P4["Phase 4<br/>Evaluation + Benchmarking"]
    P5["Phase 5<br/>Evolution Engine"]
    P6["Phase 6<br/>Quantization + Inference"]
    P7["Phase 7<br/>Offline Deployment"]
    P8["Phase 8<br/>Enterprise Pilot"]
    P9["Phase 9<br/>Optional RAG"]

    P0 --> P1 --> P2 --> P3 --> P4 --> P5 --> P6 --> P7 --> P8 --> P9

    classDef past fill:#e8f5e9,stroke:#2e7d32,stroke-width:1px
    classDef current fill:#e1f5fe,stroke:#01579b,stroke-width:2px
    classDef future fill:#f5f5f5,stroke:#9e9e9e,stroke-width:1px
    class P0,P1,P2 past
    class P4,P5,P6,P7,P8,P9 future
```
