Per-Group Adaptive Merge — Deep Dive
The key insight: two LoRAs may overlap in some model blocks but not others. A face LoRA and a style LoRA might only conflict in attention layers 4-7, while the rest of the model is touched by only one of them.
Instead of picking one global strategy (which either wastes TIES trimming on non-overlapping blocks or misses real conflicts), the optimizer decides **per resolved target group**:
| Condition | Strategy |
|-----------|----------|
| Only 1 LoRA touches this group | `weighted_sum` — full strength, no dilution |
| 2+ LoRAs, low excess conflict + low subspace overlap | `weighted_average` — mostly independent updates |
| 2+ LoRAs, high similarity + low excess conflict | `consensus` — aligned, low-interference merge |
| 2+ LoRAs, excess conflict > 25% with overlapping subspaces | `ties` — resolve real conflicts with trim/elect/merge |
| Magnitude ratio > 2x in the group | `total` sign method (stronger LoRA dominates) |
| Magnitude ratio <= 2x in the group | `frequency` sign method (equal votes) |
This means non-overlapping regions keep 100% of their LoRA's effect, while genuinely conflicting regions get proper TIES resolution. When `decision_smoothing > 0`, those per-group metrics are softly pulled toward the block average so adjacent layers do not flip strategies due to noisy samples.

#### Two-Pass Streaming Architecture
The optimizer uses a **two-pass streaming architecture** for low memory usage:
- **Pass 1 (Analysis):** Resolves trainer aliases to target weights, aggregates alias collisions per LoRA, samples conflict and magnitude statistics per target group, then discards the diffs. Only lightweight scalars are kept.
- **Pass 2 (Merge):** Recomputes diffs per target group, looks up that group's conflict data, picks a strategy for it, and merges. Each group is freed after merging. Standard linear merges stay in exact low-rank form; nonlinear merges and optional compression still use dense/SVD paths.
Peak memory is still roughly "one target group at a time," but the exact peak depends on the largest layer, how many LoRAs hit it, and whether extra quality/compression steps are enabled. GPU-accelerated on both passes.
What It Analyzes
- Per-LoRA metrics (rank, key count, effective L2 norms)
- Pairwise raw + magnitude-weighted conflict ratios per target group (sampled for efficiency)
- Excess conflict over the cosine baseline, plus low-rank subspace overlap
- Pairwise cosine similarity (directional alignment between LoRAs)
- Magnitude / activation-importance distribution per target group
- Key overlap between LoRAs
---
## Optimizer Features