Add core_ta Core Space merge method #645
Open
+150
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a new merge method,
core_ta, which implements Task Arithmetic in Core Space as described in:The method performs model merging in a shared "core space" constructed from low-rank factorizations of parameter deltas, then reconstructs the merged weights back in the original parameter space.
What this PR changes
Adds
mergekit/merge_methods/core_space.pyimplementing:core_space_task_arithmetic(tensors, base_tensor, rank=16)decorated viaeasy_define.merge_methodwith:name="core_ta"pretty_name="Task Arithmetic in Core Space"_core_space_ta_single, which for each 2D weight matrix:base_tensor.ΔW ≈ B @ A, LoRA-style).A_stack,B_stack) via SVD.M_t.M_merged = Σ_t M_t).Δ_merged = U_B_ref @ M_merged @ Vh_A_ref) and adds it back tobase_tensor.A fallback path for non-matrix tensors (
base_tensor.ndim < 2) that uses standard task arithmetic on the deltas, to avoid unnecessary SVD.Registers the method in
mergekit/merge_methods/__init__.pyso it is available asmerge_method: core_tain YAML configs.Usage example
A minimal YAML example: