Skip to content

Commit 0609d8f

Browse files
authored
Merge pull request #2595 from bghira/main
merge
2 parents 426dc96 + 210061f commit 0609d8f

43 files changed

Lines changed: 504 additions & 99 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

documentation/LYCORIS.es.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,46 @@ Campos obligatorios:
5959

6060
Para más información sobre LyCORIS, consulta la [documentación en la librería](https://github.com/KohakuBlueleaf/LyCORIS/tree/main/docs).
6161

62+
### Módulos objetivo de Flux 2 (Klein)
63+
64+
Los modelos Flux 2 usan clases de módulo personalizadas en lugar de los nombres genéricos `Attention` y `FeedForward`. Una configuración LoKR de Flux 2 debe apuntar a:
65+
66+
- `Flux2Attention` — bloques de atención de doble flujo
67+
- `Flux2FeedForward` — bloques feedforward de doble flujo
68+
- `Flux2ParallelSelfAttention` — bloques paralelos de atención+feedforward de flujo único (proyecciones QKV y MLP fusionadas)
69+
70+
Incluir `Flux2ParallelSelfAttention` entrena los bloques de flujo único, lo que puede mejorar la convergencia a costa de un mayor riesgo de sobreajuste. Si tienes dificultades para que LyCORIS LoKR converja en Flux 2, se recomienda agregar este objetivo.
71+
72+
Ejemplo de configuración LoKR para Flux 2:
73+
74+
```json
75+
{
76+
"bypass_mode": true,
77+
"algo": "lokr",
78+
"multiplier": 1.0,
79+
"full_matrix": true,
80+
"linear_dim": 10000,
81+
"linear_alpha": 1,
82+
"factor": 4,
83+
"apply_preset": {
84+
"target_module": [
85+
"Flux2Attention", "Flux2FeedForward", "Flux2ParallelSelfAttention"
86+
],
87+
"module_algo_map": {
88+
"Flux2FeedForward": {
89+
"factor": 4
90+
},
91+
"Flux2Attention": {
92+
"factor": 2
93+
},
94+
"Flux2ParallelSelfAttention": {
95+
"factor": 2
96+
}
97+
}
98+
}
99+
}
100+
```
101+
62102
## Problemas potenciales
63103

64104
Al usar Lycoris en SDXL, se ha observado que entrenar los módulos FeedForward puede romper el modelo y llevar la pérdida a valores `NaN` (Not-a-Number).

documentation/LYCORIS.hi.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,46 @@ LyCORIS कॉन्फ़िगरेशन फ़ाइल का फ़ॉर
5959

6060
LyCORIS के बारे में अधिक जानकारी के लिए, [लाइब्रेरी के दस्तावेज़](https://github.com/KohakuBlueleaf/LyCORIS/tree/main/docs) देखें।
6161

62+
### Flux 2 (Klein) मॉड्यूल टारगेट
63+
64+
Flux 2 मॉडल generic `Attention` और `FeedForward` नामों के बजाय कस्टम मॉड्यूल क्लासेस का उपयोग करते हैं। Flux 2 LoKR config में निम्नलिखित को टारगेट करें:
65+
66+
- `Flux2Attention` — डबल-स्ट्रीम अटेंशन ब्लॉक
67+
- `Flux2FeedForward` — डबल-स्ट्रीम फीडफॉरवर्ड ब्लॉक
68+
- `Flux2ParallelSelfAttention` — सिंगल-स्ट्रीम पैरेलल अटेंशन+फीडफॉरवर्ड ब्लॉक (फ्यूज्ड QKV और MLP प्रोजेक्शन)
69+
70+
`Flux2ParallelSelfAttention` को शामिल करने से सिंगल-स्ट्रीम ब्लॉक भी ट्रेन होते हैं, जो convergence में सुधार कर सकता है लेकिन overfitting का जोखिम बढ़ सकता है। यदि Flux 2 पर LyCORIS LoKR को converge करने में कठिनाई हो रही है, तो इस टारगेट को जोड़ने की सिफारिश की जाती है।
71+
72+
Flux 2 LoKR config का उदाहरण:
73+
74+
```json
75+
{
76+
"bypass_mode": true,
77+
"algo": "lokr",
78+
"multiplier": 1.0,
79+
"full_matrix": true,
80+
"linear_dim": 10000,
81+
"linear_alpha": 1,
82+
"factor": 4,
83+
"apply_preset": {
84+
"target_module": [
85+
"Flux2Attention", "Flux2FeedForward", "Flux2ParallelSelfAttention"
86+
],
87+
"module_algo_map": {
88+
"Flux2FeedForward": {
89+
"factor": 4
90+
},
91+
"Flux2Attention": {
92+
"factor": 2
93+
},
94+
"Flux2ParallelSelfAttention": {
95+
"factor": 2
96+
}
97+
}
98+
}
99+
}
100+
```
101+
62102
## संभावित समस्याएँ
63103

64104
SDXL पर Lycoris उपयोग करते समय यह नोट किया गया है कि FeedForward मॉड्यूल्स को ट्रेन करने से मॉडल टूट सकता है और loss `NaN` (Not‑a‑Number) हो सकता है।

documentation/LYCORIS.ja.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,46 @@ LyCORIS 設定ファイルの形式は次のとおりです:
5959

6060
LyCORIS の詳細は、[ライブラリのドキュメント](https://github.com/KohakuBlueleaf/LyCORIS/tree/main/docs) を参照してください。
6161

62+
### Flux 2 (Klein) モジュールターゲット
63+
64+
Flux 2 モデルは、汎用の `Attention``FeedForward` ではなく、カスタムモジュールクラスを使用します。Flux 2 の LoKR 設定では以下をターゲットに設定してください:
65+
66+
- `Flux2Attention` — ダブルストリームアテンションブロック
67+
- `Flux2FeedForward` — ダブルストリームフィードフォワードブロック
68+
- `Flux2ParallelSelfAttention` — シングルストリーム並列アテンション+フィードフォワードブロック(QKV と MLP 投影が融合)
69+
70+
`Flux2ParallelSelfAttention` を含めるとシングルストリームブロックも学習対象となり、収束が改善する可能性がありますが、過学習のリスクが増加します。Flux 2 で LyCORIS LoKR の収束が困難な場合、このターゲットの追加を推奨します。
71+
72+
Flux 2 LoKR 設定例:
73+
74+
```json
75+
{
76+
"bypass_mode": true,
77+
"algo": "lokr",
78+
"multiplier": 1.0,
79+
"full_matrix": true,
80+
"linear_dim": 10000,
81+
"linear_alpha": 1,
82+
"factor": 4,
83+
"apply_preset": {
84+
"target_module": [
85+
"Flux2Attention", "Flux2FeedForward", "Flux2ParallelSelfAttention"
86+
],
87+
"module_algo_map": {
88+
"Flux2FeedForward": {
89+
"factor": 4
90+
},
91+
"Flux2Attention": {
92+
"factor": 2
93+
},
94+
"Flux2ParallelSelfAttention": {
95+
"factor": 2
96+
}
97+
}
98+
}
99+
}
100+
```
101+
62102
## 予想される問題
63103

64104
SDXL に Lycoris を使用すると、FeedForward モジュールの学習でモデルが壊れ、損失が `NaN`(Not-a-Number)に飛ぶことがあります。

documentation/LYCORIS.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,46 @@ Mandatory fields:
5959

6060
For more information on LyCORIS, please refer to the [documentation in the library](https://github.com/KohakuBlueleaf/LyCORIS/tree/main/docs).
6161

62+
### Flux 2 (Klein) module targets
63+
64+
Flux 2 models use custom module classes instead of the generic `Attention` and `FeedForward` names. A Flux 2 LoKR config should target:
65+
66+
- `Flux2Attention` — double-stream attention blocks
67+
- `Flux2FeedForward` — double-stream feedforward blocks
68+
- `Flux2ParallelSelfAttention` — single-stream parallel attention+feedforward blocks (fused QKV and MLP projections)
69+
70+
Including `Flux2ParallelSelfAttention` trains the single-stream blocks, which may improve convergence at the cost of increased risk of overfitting. If you are having difficulty getting LyCORIS LoKR to converge on Flux 2, adding this target is recommended.
71+
72+
Example Flux 2 LoKR config:
73+
74+
```json
75+
{
76+
"bypass_mode": true,
77+
"algo": "lokr",
78+
"multiplier": 1.0,
79+
"full_matrix": true,
80+
"linear_dim": 10000,
81+
"linear_alpha": 1,
82+
"factor": 4,
83+
"apply_preset": {
84+
"target_module": [
85+
"Flux2Attention", "Flux2FeedForward", "Flux2ParallelSelfAttention"
86+
],
87+
"module_algo_map": {
88+
"Flux2FeedForward": {
89+
"factor": 4
90+
},
91+
"Flux2Attention": {
92+
"factor": 2
93+
},
94+
"Flux2ParallelSelfAttention": {
95+
"factor": 2
96+
}
97+
}
98+
}
99+
}
100+
```
101+
62102
## Potential problems
63103

64104
When using Lycoris on SDXL, it's noted that training the FeedForward modules may break the model and send loss into `NaN` (Not-a-Number) territory.

documentation/LYCORIS.pt-BR.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,46 @@ Campos obrigatorios:
5959

6060
Para mais informacoes sobre LyCORIS, consulte a [documentacao na biblioteca](https://github.com/KohakuBlueleaf/LyCORIS/tree/main/docs).
6161

62+
### Modulos alvo do Flux 2 (Klein)
63+
64+
Os modelos Flux 2 usam classes de modulo personalizadas em vez dos nomes genericos `Attention` e `FeedForward`. Uma configuracao LoKR para Flux 2 deve ter como alvo:
65+
66+
- `Flux2Attention` — blocos de atencao de fluxo duplo
67+
- `Flux2FeedForward` — blocos feedforward de fluxo duplo
68+
- `Flux2ParallelSelfAttention` — blocos paralelos de atencao+feedforward de fluxo unico (projecoes QKV e MLP fundidas)
69+
70+
Incluir `Flux2ParallelSelfAttention` treina os blocos de fluxo unico, o que pode melhorar a convergencia ao custo de maior risco de overfitting. Se voce esta tendo dificuldade para convergir LyCORIS LoKR no Flux 2, e recomendado adicionar este alvo.
71+
72+
Exemplo de configuracao LoKR para Flux 2:
73+
74+
```json
75+
{
76+
"bypass_mode": true,
77+
"algo": "lokr",
78+
"multiplier": 1.0,
79+
"full_matrix": true,
80+
"linear_dim": 10000,
81+
"linear_alpha": 1,
82+
"factor": 4,
83+
"apply_preset": {
84+
"target_module": [
85+
"Flux2Attention", "Flux2FeedForward", "Flux2ParallelSelfAttention"
86+
],
87+
"module_algo_map": {
88+
"Flux2FeedForward": {
89+
"factor": 4
90+
},
91+
"Flux2Attention": {
92+
"factor": 2
93+
},
94+
"Flux2ParallelSelfAttention": {
95+
"factor": 2
96+
}
97+
}
98+
}
99+
}
100+
```
101+
62102
## Problemas potenciais
63103

64104
Ao usar Lycoris no SDXL, foi observado que treinar os modulos FeedForward pode quebrar o modelo e levar a loss para valores `NaN` (Not-a-Number).

documentation/LYCORIS.zh.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,46 @@ LyCORIS 配置文件格式如下:
5959

6060
更多信息请参考 [库文档](https://github.com/KohakuBlueleaf/LyCORIS/tree/main/docs)
6161

62+
### Flux 2 (Klein) 模块目标
63+
64+
Flux 2 模型使用自定义模块类,而非通用的 `Attention``FeedForward` 名称。Flux 2 的 LoKR 配置应以下列模块为目标:
65+
66+
- `Flux2Attention` — 双流注意力块
67+
- `Flux2FeedForward` — 双流前馈块
68+
- `Flux2ParallelSelfAttention` — 单流并行注意力+前馈块(融合的 QKV 和 MLP 投影)
69+
70+
包含 `Flux2ParallelSelfAttention` 会训练单流块,可能改善收敛性,但会增加过拟合的风险。如果在 Flux 2 上使用 LyCORIS LoKR 难以收敛,建议添加此目标。
71+
72+
Flux 2 LoKR 配置示例:
73+
74+
```json
75+
{
76+
"bypass_mode": true,
77+
"algo": "lokr",
78+
"multiplier": 1.0,
79+
"full_matrix": true,
80+
"linear_dim": 10000,
81+
"linear_alpha": 1,
82+
"factor": 4,
83+
"apply_preset": {
84+
"target_module": [
85+
"Flux2Attention", "Flux2FeedForward", "Flux2ParallelSelfAttention"
86+
],
87+
"module_algo_map": {
88+
"Flux2FeedForward": {
89+
"factor": 4
90+
},
91+
"Flux2Attention": {
92+
"factor": 2
93+
},
94+
"Flux2ParallelSelfAttention": {
95+
"factor": 2
96+
}
97+
}
98+
}
99+
}
100+
```
101+
62102
## 潜在问题
63103

64104
在 SDXL 上使用 Lycoris 时,训练 FeedForward 模块可能会破坏模型并使损失变为 `NaN`

documentation/OPTIONS.es.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,10 @@ Donde `foo` es tu entorno de configuración; o simplemente usa `config/config.js
138138

139139
- **Qué**: Patrones glob separados por comas que limitan qué módulos Linear se convierten a RamTorch.
140140
- **Predeterminado**: Todas las capas Linear se convierten cuando no se proporciona un patrón.
141-
- **Notas**: Coincide con nombres de módulos completamente calificados o nombres de clase (se permiten comodines).
141+
- **Notas**:
142+
- Coincide con nombres de módulos completamente calificados o nombres de clase usando la sintaxis glob de `fnmatch`.
143+
- Los patrones deben incluir un comodín `.*` al final para coincidir con las capas dentro de un bloque. Por ejemplo, `transformer_blocks.0.*` coincide con todas las capas dentro del bloque 0, mientras que `transformer_blocks.*` coincide con todos los bloques transformer. Un nombre simple como `transformer_blocks.0` sin `.*` también funciona (se expande automáticamente), pero se recomienda la forma explícita con comodín para mayor claridad.
144+
- Ejemplo: `"transformer_blocks.*,single_transformer_blocks.0.*,single_transformer_blocks.1.*"`
142145

143146
### `--ramtorch_text_encoder`
144147

documentation/OPTIONS.hi.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,10 @@ simpletuner configure config/foo/config.json
138138

139139
- **What**: Comma‑separated glob patterns जो यह सीमित करते हैं कि कौन‑से Linear modules को RamTorch में बदला जाए।
140140
- **Default**: यदि कोई pattern नहीं दिया गया, तो सभी Linear layers convert होती हैं।
141-
- **Notes**: fully qualified module names या class names को match करता है (wildcards allowed)।
141+
- **Notes**:
142+
- `fnmatch` glob syntax का उपयोग करके fully qualified module names या class names को match करता है।
143+
- किसी block के अंदर की layers को match करने के लिए patterns में trailing `.*` wildcard शामिल होना चाहिए। उदाहरण के लिए, `transformer_blocks.0.*` block 0 के अंदर सभी layers को match करता है, जबकि `transformer_blocks.*` सभी transformer blocks को match करता है। `transformer_blocks.0` जैसा bare name बिना `.*` के भी काम करेगा (यह automatically expand होता है), लेकिन clarity के लिए explicit wildcard form recommended है।
144+
- उदाहरण: `"transformer_blocks.*,single_transformer_blocks.0.*,single_transformer_blocks.1.*"`
142145

143146
### `--ramtorch_text_encoder`
144147

documentation/OPTIONS.ja.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,10 @@ simpletuner configure config/foo/config.json
139139

140140
- **内容**: RamTorch に変換する Linear モジュールを制限するカンマ区切りの glob パターン。
141141
- **既定**: パターン未指定の場合、すべての Linear レイヤーを変換。
142-
- **注記**: 完全修飾モジュール名またはクラス名にマッチ(ワイルドカード可)。
142+
- **注記**:
143+
- `fnmatch` glob 構文を使用して完全修飾モジュール名またはクラス名にマッチ。
144+
- ブロック内のレイヤーにマッチさせるには、末尾に `.*` ワイルドカードを含める必要があります。例えば、`transformer_blocks.0.*` はブロック 0 内のすべてのレイヤーにマッチし、`transformer_blocks.*` はすべての transformer ブロックにマッチします。`transformer_blocks.0` のような `.*` なしの名前も動作します(自動的に展開されます)が、明確さのために明示的なワイルドカード形式を推奨します。
145+
- 例: `"transformer_blocks.*,single_transformer_blocks.0.*,single_transformer_blocks.1.*"`
143146

144147
### `--ramtorch_text_encoder`
145148

documentation/OPTIONS.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,10 @@ Where `foo` is your config environment - or just use `config/config.json` if you
138138

139139
- **What**: Comma-separated glob patterns limiting which Linear modules are converted to RamTorch.
140140
- **Default**: All Linear layers are converted when no pattern is provided.
141-
- **Notes**: Matches fully qualified module names or class names (wildcards allowed).
141+
- **Notes**:
142+
- Matches fully qualified module names or class names using `fnmatch` glob syntax.
143+
- Patterns must include a trailing `.*` wildcard to match layers inside a block. For example, `transformer_blocks.0.*` matches all layers inside block 0, while `transformer_blocks.*` matches all transformer blocks. A bare name like `transformer_blocks.0` without `.*` will also work (it is expanded automatically), but the explicit wildcard form is recommended for clarity.
144+
- Example: `"transformer_blocks.*,single_transformer_blocks.0.*,single_transformer_blocks.1.*"`
142145

143146
### `--ramtorch_text_encoder`
144147

0 commit comments

Comments
 (0)