File size: 5,062 Bytes
569ee3b
 
 
 
 
 
 
a47f2ff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
569ee3b
 
 
 
 
 
 
 
 
 
 
 
 
 
9640807
569ee3b
 
9640807
569ee3b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9640807
569ee3b
 
 
9640807
 
569ee3b
 
 
 
 
9640807
569ee3b
9640807
a2f7136
 
 
 
 
 
9640807
a2f7136
9640807
a2f7136
9640807
a2f7136
9640807
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
---
license: gpl-3.0
tags:
  - lora
  - merge
  - comfyui
  - stable-diffusion
configs:
  - config_name: config
    data_files: "config/*.json"
    features:
      - name: algo_version
        dtype: string
      - name: arch_preset
        dtype: string
      - name: lora_content_hashes
        sequence: string
      - name: score
        dtype: float64
      - name: config
        dtype:
          struct:
            - name: merge_mode
              dtype: string
            - name: sparsification
              dtype: string
            - name: sparsification_density
              dtype: float64
            - name: dare_dampening
              dtype: float64
            - name: merge_refinement
              dtype: string
            - name: auto_strength
              dtype: string
            - name: optimization_mode
              dtype: string
            - name: strategy_set
              dtype: string
      - name: candidates
        sequence:
          struct:
            - name: rank
              dtype: int64
            - name: config
              dtype:
                struct:
                  - name: merge_mode
                    dtype: string
                  - name: sparsification
                    dtype: string
                  - name: sparsification_density
                    dtype: float64
                  - name: dare_dampening
                    dtype: float64
                  - name: merge_refinement
                    dtype: string
                  - name: auto_strength
                    dtype: string
                  - name: optimization_mode
                    dtype: string
                  - name: strategy_set
                    dtype: string
            - name: score_heuristic
              dtype: float64
            - name: score_measured
              dtype: float64
            - name: score_final
              dtype: float64
---

# LoRA Optimizer — Community Cache

Shared analysis results for the [LoRA Optimizer](https://github.com/ethanfel/ComfyUI-LoRA-Optimizer) ComfyUI node.

LoRA merge analysis is hardware-agnostic — the same LoRA files always produce the same conflict metrics and optimal merge config regardless of GPU tier. This dataset lets users share and reuse those results so nobody has to run the AutoTuner from scratch.

---

## How It Works

The AutoTuner computes pairwise conflict metrics (cosine similarity, sign conflicts, subspace overlap) and tests merge parameter combinations to find the best config for a set of LoRAs. These results are keyed by **content hash** (SHA256[:16] of file contents) — not by filename — so they're portable across systems and private by design.

When `community_cache=upload_and_download` is set in the AutoTuner node:

- **Download:** Before running analysis, the node checks this dataset for existing results. A config hit skips the entire sweep (~30–120s saved). Lora/pair cache hits speed up the analysis phase even without a full config hit.
- **Upload:** After a successful sweep (or when replaying from local memory), results are uploaded if the local score beats the current community score for that LoRA set.

---

## Privacy

**LoRA filenames are never stored here.** Only SHA256[:16] content hashes are used as keys. The uploaded data contains:
- Per-prefix conflict metrics (cosine similarity, sign conflict ratios, subspace overlap)
- Winning merge configuration (sparsification method, merge strategy, refinement level, etc.)
- A composite quality score

No file paths, no usernames, no LoRA names.

---

## File Structure

```
lora/
  {content_hash}.lora.json       # Per-LoRA per-prefix conflict stats
pair/
  {hash_a}_{hash_b}.pair.json   # Pairwise conflict metrics (hashes sorted)
config/
  {hash_a}_{hash_b}_..._{arch}.config.json  # Best merge config + score for a LoRA set
```

All files include an `algo_version` field. Results from incompatible algorithm versions are ignored automatically.

---

## Usage

In the **LoRA AutoTuner** node, set `community_cache` to `upload_and_download`. That's the only option — there's no passive download-only mode. If you benefit from the cache, you contribute back.

| Value | Behavior |
|-------|----------|
| `disabled` (default) | No network interaction |
| `upload_and_download` | Download precomputed results and contribute yours back |

Network errors are silently ignored — the node always falls back to local computation.

---

## Setup

**One time:**

```bash
pip install huggingface_hub
huggingface-cli login
```

The node picks up your stored token automatically. No environment variables needed for most users.

**Headless/server alternative:** set `HF_TOKEN` as an environment variable.

**Then:** set `community_cache=upload_and_download` in the AutoTuner node and run as normal. Everything else is automatic.

---

## Score-Based Replacement

Configs are only uploaded when your local score beats the community score. Users with more thorough sweeps (`top_n=10`) or better hardware naturally contribute higher-quality results over time.