Skip to main content

do_merge

Function do_merge 

Source
pub fn do_merge(existing: &Tensor, new: &Tensor, weight: f64) -> Result<Tensor>
Expand description

Direction-Only Merge (DO-Merge) from Yang et al. 2025.

Decomposes each tensor into magnitude (Frobenius norm) and direction (unit-norm tensor), merges them independently, then reconstructs.

This preserves the geometric structure of weight matrices better than simple additive merging.

Formula: magnitude_merged = (1-w) * ||existing|| + w * ||new|| direction_merged = normalize((1-w) * dir(existing) + w * dir(new)) result = magnitude_merged * direction_merged