Repository: arcee-ai/mergekit

Issue:
The epsilon parameter is not working
During della merging, the sparsification function named `della_magprune` **does not correctly receive the epsilon argument**. 

Just before calling the sparsification function, the task vector is extracted using the `get_task_vector` function in _generalized_task_arithmetic.py around line 118._ 

After that, **_epsilon_** or **_gamma_** is supposed to be extracted based on the returned value **_tvs_** _between lines 129 and 135_, but these variables are not stored in **_tvs_**. 

I would like to know how to properly specify epsilon or gamma. 

I have attached the config.yml file for reference.

``` yml
models:
  - model: ./model_a
    parameters:
      weight: 1.0
  - model: ./model_b
    parameters:
      weight: 1.0
merge_method: della
base_model: microsoft/phi-2
parameters:
  density: 0.8
  epsilon: 0.3
  normalize: true
dtype: float16
```

Hints from issue comments:
@cg123: Your config is correct - this is a bug. It should be fixed on `main` now. Thanks for the report!

Solution patch:
diff --git a/mergekit/merge_methods/generalized_task_arithmetic.py b/mergekit/merge_methods/generalized_task_arithmetic.py
index 3b5a827..9220343 100644
--- a/mergekit/merge_methods/generalized_task_arithmetic.py
+++ b/mergekit/merge_methods/generalized_task_arithmetic.py
@@ -69,6 +69,13 @@ class GeneralizedTaskArithmeticMerge(MergeMethod, BaseModel, frozen=True):
                     default_value=0.01,
                 )
             )
+        if self.sparsification_method == SparsificationMethod.della_magprune:
+            res.append(
+                ConfigParameterDef(
+                    name="epsilon",
+                    default_value=0.15,
+                )
+            )
         return res
 
     def make_task(


Test patch:
diff --git a/tests/test_basic_merges.py b/tests/test_basic_merges.py
index 4193ee4..2b15303 100644
--- a/tests/test_basic_merges.py
+++ b/tests/test_basic_merges.py
@@ -249,6 +249,17 @@ class TestBasicMerges:
         )
         run_and_check_merge(config)
 
+    def test_della_invalid_epsilon(self, model_a, model_b, model_c):
+        config = self.two_model_config(
+            model_a,
+            model_b,
+            merge_method="della",
+            base_model=model_c,
+            params={"density": 0.66, "epsilon": 1.35, "lambda": 0.5},
+        )
+        with pytest.raises(ValueError):
+            run_and_check_merge(config)
+
     def test_karcher_merge(self, model_a, model_b, model_c):
         config = self.two_model_config(
             model_a,