Commit ·
8964ec1
1
Parent(s): 181d002
moss docs
Browse filesFiles changed (7)
- moss/README.mdAdded+36
- moss/docs/MOSS_IMAGE_COMBINED_OPTIMIZER_TRAINING_GUIDE.mdAdded+234
- moss/docs/moss-image-lora-stacking-findings.mdAdded+88
- moss/docs/moss-image-lora-training.mdAdded+148
- moss/templates/moss_image_template-adamw8bit.yamlAdded+76
- moss/templates/moss_image_template-automagic3.yamlAdded+81
- moss/templates/moss_image_template-prodigy.yamlAdded+85
123456789101112131415161718192021222324252627282930313233343536# MOSS-Image LoRA Training Hub (`moss/`)
Training notes and templates for character LoRAs on **MOSS-Image Base** (OpenMOSS, 5B), trainedwith [maltrainer](https://github.com/malcolmamal/maltrainer) on ComfyUI's single-file checkpoints.
---
## 🧭 Directory Map
| Path | Description || :--- | :--- || 📘 **[Combined Optimizer Training Guide](docs/MOSS_IMAGE_COMBINED_OPTIMIZER_TRAINING_GUIDE.md)** | The method: train the dataset with AdamW 8-bit, Automagic3 and Prodigy at shorter-than-usual lengths, merge the three LoRAs at 0.7 each, and resize the merge to rank 8. Why it works, how to run it, and what's still open. || 📗 **[MOSS-Image Training Guide](docs/moss-image-lora-training.md)** | maltrainer's guide to MOSS-Image LoRA training: model files, how it matches ComfyUI, the timestep distribution, the templates and the first real run. || 🔬 **[Stacking Findings](docs/moss-image-lora-stacking-findings.md)** | The finding that started the combined method: two under-strength LoRAs, stacked at 1.0 each, gave the best results so far. || 🛠️ **[`templates/`](templates/)** | The three member templates: [`adamw8bit`](templates/moss_image_template-adamw8bit.yaml) (60 epochs), [`automagic3`](templates/moss_image_template-automagic3.yaml) (20 epochs), [`prodigy`](templates/moss_image_template-prodigy.yaml) (30 epochs). |
---
## ⚡ The Method in Four Lines
1. **Train three times**, once per optimizer, each run kept short.2. **Merge** the three LoRAs exactly, at strength 0.7 each (`merge_loras.py`).3. **Resize** the rank-48 merge to rank 8 (`resize_lora.py`).4. **Load** the result at strength 1.0.
It grew out of a finding on MOSS-Image: two separately trained, under-strength LoRAs stacked at1.0 each looked better than either one turned up. The subject adds up across runs, while eachrun's own errors partly cancel.
## 📦 Model Files (`Comfy-Org/MOSS-Image`)
| Role | File || :--- | :--- || DiT (train on the **Base** model) | `diffusion_models/moss_image_base_bf16.safetensors` || VAE | `vae/flux2_vae.safetensors` || Text encoder (caching only) | `text_encoders/qwen3.5_9b_int8_convrot.safetensors` |123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234# MOSS-Image LoRAs: Combined Training With Three Optimizers
[← Back to the MOSS hub](../README.md)
This is how I now train character LoRAs for **MOSS-Image Base** (OpenMOSS, 5B). I train the samedataset three times, once each with **AdamW 8-bit**, **Automagic3** and **Prodigy**. Each run iskept shorter than a normal one. I then merge the three LoRAs into one file (a "LoRA soup") andshrink that file to rank 8.
All training runs on [maltrainer](https://github.com/malcolmamal/maltrainer), my own LoRA trainer,against ComfyUI's single-file MOSS-Image checkpoints.
---
## In short
| Step | What happens | Tool || :--- | :--- | :--- || 1. Train | The dataset is trained once per optimizer, one after another: AdamW 8-bit (60 epochs), Automagic3 (20 epochs), Prodigy (30 epochs) | `train_moss_image_lora.py`, driven by `scripts/train_combined.py` || 2. Merge | The three LoRAs are merged exactly, at **0.7 strength each**, into one rank-48 LoRA | `scripts/merge_loras.py` || 3. Resize | The merge is shrunk to **rank 8** with a per-layer SVD | `scripts/resize_lora.py` || 4. Use | Load the resized file in ComfyUI at **strength 1.0** | ComfyUI's stock LoRA loader |
The three member templates are in [`../templates/`](../templates/).
---
## Where it came from
The first MOSS-Image LoRAs (Felicia Day, 23 images, 512 px) were trained the usual way: oneoptimizer and a long run. The results:
- **Automagic3, 100 epochs (2,300 steps).** The LoRA worked but needed strength 1.4–1.5 to look right. Its adaptive learning rate peaked around step 200 and then decayed for the rest of the run. Likeness at step 500 already matched step 2,300, so the remaining steps added little.- **Prodigy.** Also under-strength. It was better at 1.5, but still not right.
Then the Automagic3 step-500 checkpoint and the Prodigy step-750 checkpoint were loaded**together, both at strength 1.0**. That gave the best results so far, better than either LoRAturned up on its own.
The combined run makes that accident into the recipe:- Every optimizer stops around the point where it stopped adding likeness.- A third optimizer (AdamW 8-bit) joins as another independent opinion.- The merge and the resize are done for you, so you end up with one small file instead of a stack of LoRAs.
---
## Why it works
### Stacking adds the subject and cancels the noise
Loading several LoRAs adds their weight changes together. Each run's change has two parts:
- **The subject:** the face and identity all three runs set out to learn. The runs learn it independently, but it points the same way in each of them, so it **adds up**.- **Each run's own errors:** a pose or lighting it latched onto from one photo, drift from its particular noise draws, the habits of its optimizer. These differ from run to run and point in different directions, so they **partly cancel**.
The soup therefore gets roughly three times the subject with less than three times the errors.Turning a single LoRA up to 1.5 is different: it scales the subject and its errors together.
Averaging separately trained models like this is known as a **model soup**. It works best whenthe members are good but different. Three optimizers are a strong form of "different": they movethrough the weights in genuinely different ways.
| Optimizer | How it moves | Its usual failure || :--- | :--- | :--- || **AdamW 8-bit** | A flat learning rate (1e-4) for the whole run | Can overshoot and memorize when run too long || **Automagic3** | Adapts its own rate per module family (attention / MLP / other); the rate decays as the run settles | Can stall and stop short of full strength || **Prodigy** | Estimates its own step size and grows it | Can overcook late in long runs |
Each member's weakness pulls the soup in a different direction, so no single one dominates it.
### Why fewer epochs per member
A member doesn't have to be a finished LoRA. It needs to have learned the subject, and it shouldstop before it learns too much of its own quirks. Two things make a short run enough:
- **Strength comes from the stack.** Three members at 0.7 each give a total weight of 2.1 on the subject. A member that would be slightly under-strength on its own is the right size for a soup.- **Long runs add mostly noise.** On MOSS-Image the likeness was already there by step 500 (about 22 epochs of 23 images). Later steps mostly add memorization, the "errors" that the soup then has to cancel.
The epoch counts differ per optimizer because they learn at different speeds:
| Member | Epochs | Steps at 23 images | Rationale || :--- | :---: | :---: | :--- || Automagic3 | 20 | 460 | Its rate peaks early and decays; its likeness was in place by ~step 500 || Prodigy | 30 | 690 | Its step size has to grow from a tiny start (d0 1e-6) after a 100-step warmup; the stacked checkpoint was step 750 || AdamW 8-bit | 60 | 1,380 | A flat rate with no estimate to grow, so it needs the most steps; still well short of a long single run |
At about 0.6 s per step on an RTX 5090 (512 px, bf16 base), that is roughly 25 minutes oftraining for all three, plus model loading for each member. The earlier single 100-epochAutomagic3 run took 23 minutes.
### Why resize the merge to rank 8
The merge is exact: three rank-16 LoRAs become one **rank-48** LoRA that applies exactly whatstacking them at 0.7 each would. Resizing then shrinks it:
- For every layer, the SVD finds the few directions that carry almost all of that layer's change and drops the rest. It keeps as many singular values as hold 99.9 % of the layer's norm, and at most 8.- The subject is the part all three members agree on, so it lives in the strong directions and survives the resize. Small, scattered components (much of the members' disagreement) are what gets dropped.- The file ends up a sixth of the merge's size: one small LoRA to keep, share and load.
Load the resized file at **strength 1.0**. The member strengths are already baked in.
---
## The templates
[`../templates/`](../templates/) holds the three member templates, exactly as my trainingfront-end (Stabilis) fills them. All three share everything that isn't the optimizer, so themembers differ only where it matters:
| Shared setting | Value || :--- | :--- || Base model | `moss_image_base_bf16.safetensors` (the **Base** model, not the SFT fine-tune) || VAE / text encoder | `flux2_vae.safetensors` / `qwen3.5_9b_int8_convrot.safetensors` (used for caching only, then unloaded) || LoRA | rank 16, alpha 16, `blocks`: attention + feed-forward of the 42 joint blocks (252 modules) || Resolution | 512 px area, aspect-ratio buckets on a 16 px grid, batch 1 || Timesteps | MOSS-Image's last pretraining interval: logit(σ) ~ N(1.09, 0.95), truncated at 0.95, 1 % uniform, no shift || Caption dropout | 0.05: the reference sampler uses real CFG against the empty prompt || Gradient clip | 1.0 |
| | [`adamw8bit`](../templates/moss_image_template-adamw8bit.yaml) | [`automagic3`](../templates/moss_image_template-automagic3.yaml) | [`prodigy`](../templates/moss_image_template-prodigy.yaml) || :--- | :--- | :--- | :--- || Learning rate | 1e-4, constant | 1e-6 launch point, then adaptive per module family, 8-step sign window | 1.0 (multiplier on Prodigy's own estimate), 100-step warmup || Weight decay | 0.01 | 0 | 0.01, decoupled || EMA of the weights | 0.98 | 0.98 | off || Epochs | 60 | 20 | 30 || Output | `moss_image_<person>_v1_adamw` | `moss_image_<person>_v1_automagic3` | `moss_image_<person>_v1_prodigy` |
### Placeholders
The templates contain placeholders that get filled before a run:
| Placeholder | Fill with || :--- | :--- || `[dataset_location]` / `[person_to_train]` | The folder that holds the dataset, and the dataset's folder name (also the default trigger word) || `[comfyui_diffusion_models]` | ComfyUI's `models/diffusion_models` folder (the templates expect the file under `MOSS/`) || `[comfyui_vae]` / `[comfyui_text_encoders]` | ComfyUI's `models/vae` and `models/text_encoders` folders |
Captions come from a `.txt` file next to each image. An image without one is captioned`a photo of <person>`.
---
## Running it with maltrainer
**1. Fill the three templates** for your dataset, for example as`config/moss_feliciaday_adamw8bit.yaml`, `..._automagic3.yaml` and `..._prodigy.yaml`.
**2. Write the combined config** that lists them with their merge strengths:
```yamltrainer: train_moss_image_lora.pymembers: - config: config/moss_feliciaday_adamw8bit.yaml strength: 0.7 - config: config/moss_feliciaday_automagic3.yaml strength: 0.7 - config: config/moss_feliciaday_prodigy.yaml strength: 0.7output: path: ./output/moss_image_feliciaday_combined name: moss_image_feliciaday_v1_soup dtype: float32 # keeps the merge exact```
**3. Train and merge** in one go:
```bashpython scripts/train_combined.py --config config/moss_feliciaday_combined.yaml```
The members train one after another. If one fails, the run stops and nothing is merged; theLoRAs already trained stay where their configs put them. The merge's path is printed last, on aline starting `Merged LoRA:`.
**4. Resize** the merge to rank 8:
```bashpython scripts/resize_lora.py output/moss_image_feliciaday_combined/moss_image_feliciaday_v1_soup.safetensors --rank 8```
That writes `moss_image_feliciaday_v1_soup_resized.safetensors`. Load it in ComfyUI at strength1.0.
---
## Strengths
| Members | Default strength each | Total || :---: | :---: | :---: || 3 | 0.7 | 2.1 || 2 | 0.95 | 1.9 |
These defaults assume each member is close to full strength on its own.- If the soup looks overcooked (waxy skin, stiff faces, ignored prompts), lower all strengths a little.- If it looks weak, raise them.
Merge and resize again after any change; nothing has to be retrained. Two members also make avalid soup, so a failed or poor member can be left out.
---
## What's known and what isn't
**Measured:**- Two under-strength MOSS-Image LoRAs (Automagic3 step 500 and Prodigy step 750), stacked at 1.0 each, beat either one turned up on its own.- Both long single-optimizer runs ended under-strength at 1.0.- Automagic3's likeness stopped improving after about 500 steps.
**Still open:**- **Different optimizers or different seeds?** Would three runs of one optimizer with different seeds do as well as three optimizers?- **Best strengths.** Are equal strengths best, or should one optimizer weigh more?- **The timesteps.** MOSS-Image's pretraining timestep distribution centres on σ ≈ 0.74, and only about 2 % of steps fall below σ 0.3, where fine identity detail is learned. If single LoRAs keep coming out weak, centring the distribution lower (`timestep_logit_mean: 0`) is the next lever to test.
The full background is in maltrainer's [MOSS-Image training guide](moss-image-lora-training.md)and its notes on [stacking MOSS-Image LoRAs](moss-image-lora-stacking-findings.md).12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788# MOSS-Image: two weak LoRAs that stack into a strong one
Findings from the first feliciaday LoRA runs on MOSS-Image Base, October 2026.
**In short:** two separately trained LoRAs were each under-strength on their own. One came fromAutomagic3, one from Prodigy. Loaded together, both at strength 1.0, the results were the best so far. The likelyreasons, and what to do about them, follow.
## The runs
Both runs used the same setup:
- 23 images, 512×512- the bf16 DiT and the int8 Qwen3.5-9B text encoder- LoRA rank 16, alpha 16, `blocks` targets (252 adapters)- the report's timestep distribution: logit-normal, mean sigma ~0.74, no shift- caption dropout 0.05
They differed only in the optimizer.
| | Automagic3 | Prodigy ||---|---|---|| Config | `train_moss_image_feliciaday_automagic3.yaml`, run for 2300 steps | `train_moss_image_feliciaday_prodigy.yaml` || Optimizer | Automagic3, 8-step sign window, launch 1e-6, EMA 0.98 | Prodigy, lr 1.0, 100 warmup steps, weight decay 0.01, no EMA || Checkpoint used | step 500 | step 750 || Alone at strength 1.0 | under-strength. It worked at 1.4-1.5 | under-strength. Better at 1.5, but not right || Stacked together, both at strength 1.0 | **very good: the best results so far** | |
Observations from the Automagic3 log:
- **Rate.** The adaptive rate peaked at 5.7e-5 around step 200 (MLP 8.4e-5, attention 2.9e-5). It then decayed steadily to 1.1e-5 at step 2300 (attention 7e-6).- **Likeness.** Likeness at step 500 already matched step 2300. After about 500 steps the run added little.- **Loss.** Mean loss went 0.578 → 0.546. With these timesteps the loss is dominated by high-noise steps and says little about likeness.
## Why stacking works better than one LoRA turned up
Loading two LoRAs adds their weight changes. Each change has two parts:
- **The subject**, the thing both runs set out to learn. The two runs learned it independently, but it points the same way in both, so it adds up. Two half-strength LoRAs make one full-strength subject.- **Each run's own errors:** a pose or lighting it latched onto from one photo, drift from its particular noise draws, the optimizer's path. These differ between the runs and point in different directions, so they partly cancel instead of adding up.
So the stack gets roughly twice the subject with less than twice the errors. One LoRA turned upto 1.5 scales its subject and its errors together. That fits what was seen: Prodigy at 1.5 was"better but not exactly right", while the stack looked right.
Averaging or summing separately trained runs like this is known as a "model soup" (for LoRAs,a "LoRA soup"). It works best when the runs are good but different. Two optimizers are astrong form of "different".
## What it says about training
Both optimizers came out under-strength at 1.0, so the optimizer is not the main bottleneck.What the runs share is the more likely cause:
- **The timesteps.** The report's pretraining distribution centres on sigma ~0.74, and only ~2 % of steps fall below sigma 0.3. Fine identity detail is mostly learned at mid and low noise, so each run spends most of its steps where likeness is decided least.- **The update size.** Automagic3's rate decayed to a fraction of its peak, and both runs stopped well short of strength 1.0. More, larger steps in the right noise range should help.
## What to do with it
1. **Keep the result now.** Merge the pair into one file with `scripts/merge_loras.py` at 1.0 each, the strengths of the stack (the default, so no `:strength` is needed). The merge is exact: one rank-32 LoRA that gives exactly the stacked result at strength 1.0. See maltrainer's `docs/merge-loras.md`.2. **Test the diagnosis.** Train one run with `timestep_logit_mean: 0` (centred on sigma 0.5) and everything else unchanged. If that single LoRA is right at strength 1.0, the timesteps were the bottleneck.3. **Use the soup on purpose.** Even once single runs reach full strength, merging two runs should still give a cleaner LoRA than either alone. The runs can differ by optimizer or by seed. At ~0.6 s/step, a 1000-step run takes ~10 minutes, so a second run is cheap. When merging two full-strength LoRAs, start at about 0.5-0.7 each, not 1.0 + 1.0.
## Open questions
- Was the stack better because of the two optimizers, or would two Prodigy runs with different seeds do as well?- Does the soup still help once single runs are at full strength, or does it mainly make up for under-training?- Which merge strengths work best? Equal strengths, or more weight on one optimizer's LoRA?123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148# MOSS-Image LoRA training
`train_moss_image_lora.py` trains LoRAs for **MOSS-Image Base** (OpenMOSS, 5B) from ComfyUI'ssingle-file checkpoints. It caches each image's latent and each caption's embedding once,unloads the encoders, then trains on the frozen DiT.
There are three ways to run it:
```bashpython train_moss_image_lora.py --config config/train_moss_image_feliciaday_automagic3.yaml```
```bashrun_moss_image_training.bat feliciaday # fills config/moss_image_automagic_template.yaml (Automagic3)run_moss_image_training.bat feliciaday prodigy # fills config/moss_image_prodigy_template.yamlrun_moss_image_training.bat feliciaday adamw8bit # fills config/moss_image_adamw_template.yaml```
The third is the web UI: pick **MOSS-Image (Base)**, a dataset and an optimizer.
`run_moss_image_training.bat` wraps `scripts/train_from_template.py`. That script fills thetemplate's placeholders and writes the filled config into the output folder before it starts.Pass `--max-steps`, `--epochs`, `--trigger` or `--dry-run` after the optimizer.
## Model files
All files come from `Comfy-Org/MOSS-Image`. ComfyUI loads MOSS-Image natively from the2026-10 update onwards (`comfy/ldm/moss_image`).
| Key | File | Notes ||---|---|---|| `model.transformer_path` | `diffusion_models/moss_image_base_bf16.safetensors` | 10 GB. `moss_image_base_int8_convrot` also works. The `_sft_` files are OpenMOSS's fine-tune of the base; the trainer warns || `model.vae_path` | `vae/flux2_vae.safetensors` | The Flux2 VAE, the same file FLUX.3 uses (`flux2-vae.safetensors` in the repo) || `model.text_encoder_path` | `text_encoders/qwen3.5_9b_int8_convrot.safetensors` | Qwen3.5-9B. A plain bf16 file also works. The `w4a8_gptq` file is not supported |
The text encoder runs only while prompts are cached. Its Linears stay int8 on the GPU (~10 GB),and it is unloaded before the DiT loads.
## How it matches ComfyUI
Checked numerically against ComfyUI on CPU, with small random-weight models in ComfyUI's filelayouts:
| Part | Reference | Relative difference ||---|---|---|| DiT, fp32 (plain and fused-qkv files) | `comfy.sd.load_diffusion_model` → `apply_model` | ~7e-7 || DiT, bf16 | ComfyUI's own bf16 drift from fp32 is 6.6e-3; maltrainer's is the same | — || Saved LoRA, applied by `comfy.lora` (plain and fused-qkv files) | the training forward | ~1e-6 || Text encoder, fp32 / bf16 / int8 | ComfyUI's `MOSSImageTEModel` | 2e-7 / 2e-7 / 5e-7 || Text encoder, fp32 | transformers' `Qwen3_5TextModel` | 3.5e-7 || Token ids (template, empty prompt, newlines, CJK, emoji, special-token text) | ComfyUI's `MOSSImageTokenizer` | identical |
Conventions it follows:
- **DiT input.** The Flux2 VAE's 128-channel latent, one token per 16 px, joined with the text as `[image | text]`. All 42 blocks take one shared modulation of the timestep, text tokens included.- **Timestep.** The DiT gets sigma in [0, 1]. Its sinusoidal embedding is of 1000 × sigma, with phases in float64, as in the training code.- **Target.** The flow velocity `v = noise − x0`, under a plain per-token MSE (report equation 3).- **Text.** The prompt is stripped and wrapped in Qwen's chat template with thinking enabled: `<|im_start|>user\n{prompt}<|im_end|>\n<|im_start|>assistant\n<think>\n`. The encoder output is every token's final hidden state after the last norm, at the prompt's true length (no padding, capped at 4096 tokens). The DiT's RoPE follows that length, so training runs at batch size 1. Use `gradient_accumulation_steps` for larger batches.- **Encoder precision.** As in ComfyUI, the encoder's activations run in fp32 while its weights stay int8/bf16. An all-bf16 run drifts ~3× further from fp32.- **Caption dropout** encodes the empty prompt. That is the negative prompt the reference sampler's CFG uses (scale 3, 50 steps, shift 5).
## Timesteps
The defaults reproduce the technical report's last pretraining interval (appendix A.2, Table 6):
- logit(sigma) ~ N(1.09, 0.95)- truncated at sigma ≤ 0.95 and rescaled onto [0, 1]- rounded up onto the 1000-step grid- mixed with 1 % uniform- no shift
The sampler's mean sigma is 0.745 against 0.744 for the report's equation 4. P(sigma > 0.9) is0.217 against 0.215.
This distribution favours high noise: only ~2 % of steps fall below sigma 0.3. If a likenessLoRA learns composition but not fine detail, try `timestep_logit_mean: 0` (centred on sigma 0.5)and compare checkpoints.
| Key | Default | Meaning ||---|---|---|| `train.timestep_distribution` | `logit_normal` | or `uniform` || `train.timestep_logit_mean` / `_std` | 1.09 / 0.95 | logit-normal on sigma; positive = noisier || `train.timestep_cutoff` | 0.95 | truncate at sigma ≤ cutoff, then divide by it; 1 = off || `train.timestep_uniform_mix` | 0.01 | share of uniform draws || `train.timestep_shift` | 1.0 | `s·σ / (1 + (s − 1)·σ)`; 1 = none || `train.timestep_grid` | 1000 | round sigma up onto {1/N … 1}; 0 = continuous |
## Templates
All three templates use the same model files, LoRA (rank 16, alpha 16, `blocks`), timestepsand 512 px buckets, so their runs compare directly.
- `config/moss_image_automagic_template.yaml`: **Automagic3**. Launch point 1e-6. Attention, MLP and other layers each adapt their own rate, over an **8-step** sign window. On FLUX.3 a 16-step window left the rate stuck near 3e-5 and the LoRA under-trained. EMA 0.98, 20 epochs.- `config/moss_image_prodigy_template.yaml`: **Prodigy**, with FLUX.3's Prodigy settings. lr 1.0 (a multiplier on Prodigy's own estimate d), 100 warmup steps, decoupled weight decay 0.01, beta2 0.99, bias correction and safeguarded warmup, no EMA, 20 epochs.- `config/moss_image_adamw_template.yaml`: **AdamW 8-bit** at a flat 1e-4 (Fizgig 8.1's rate for FLUX.3 and Krea 2), weight decay 0.01, EMA 0.98, as in the Automagic3 template.
The feliciaday runs built from them are `config/train_moss_image_feliciaday_automagic3.yaml`,`_prodigy.yaml` and `_adamw.yaml`.
LoRA target presets (`lora.targets`):
| Preset | Adapters | What ||---|---|---|| `blocks` | 252 | attention (`proj.q/k/v/o`) + feed-forward (`proj.ffn_up_gate/ffn_down`) of the 42 joint blocks || `attn` | 168 | attention only || `all` | 269 | `blocks` + the 2 text-embedder blocks + input, timestep, modulation and output Linears |
Saved keys are ComfyUI's module paths (`diffusion_model.layers.N.proj.q.lora_A.weight`).ComfyUI loads them with its stock LoRA loader, including on the repacked files with a fused`proj.qkv`.
## First real run (feliciaday, Automagic3, 2026-10-17)
The run used 23 images at 512×512, 100 epochs (2300 steps), the Automagic3 template, the bf16 DiTand the int8 text encoder.
- **Loading.** The real `moss_image_base_bf16` file stores **fused** `proj.qkv`. The LoRA still saves separate q/k/v adapters, which ComfyUI slices in. The text encoder logged 32 layers (8 full attention) and hidden 4096. Captions were 43-82 tokens.- **Speed.** ~0.6 s/step, 23 minutes for the run.- **Rate.** Automagic3's average rate peaked at 5.7e-5 by step 200 (MLP 8.4e-5, attention 2.9e-5). It then decayed steadily to 1.1e-5 by the end (attention 7e-6).- **Loss.** Mean loss went 0.578 → 0.546. It is dominated by the high-noise timesteps, so it says little about likeness.- **Result.** The LoRA works but needs strength 1.4-1.5, so it is under-trained. Likeness at step 500 already matched step 2300, which fits the decaying rate.
Two levers are untested yet: a higher constant rate (the AdamW template) and lower-noisetimesteps (`timestep_logit_mean: 0`). Change one per run to see which one matters.
The Prodigy run was under-strength too. Stacked at 1.0 each, the Automagic3 step-500 andProdigy step-750 LoRAs gave the best results so far: see[moss-image-lora-stacking-findings.md](moss-image-lora-stacking-findings.md). To keep such astack as one file, merge it with maltrainer's `scripts/merge_loras.py`.12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576# MOSS-Image LoRA -- MalTrainer (train_moss_image_lora.py), AdamW 8-bit.## The recipe of MalTrainer's own config/moss_image_adamw_template.yaml# (docs/moss-image-lora-training.md there), 60 epochs. Trains the bf16 BASE model ComfyUI# already has, so nothing is downloaded.## Placeholders filled by trainer-runner-config.service.ts:# [dataset_location] [person_to_train] the dataset folder# [comfyui_diffusion_models] [comfyui_vae] [comfyui_text_encoders]# COMFYUI_MODELS_PATH / COMFYUI_VAE_PATH / COMFYUI_TEXT_ENCODERS_PATH# `trigger` and `default_caption` are rewritten from the job's token and class.## The output file is moss_image_<person>_v1_adamw.safetensors. After training it is copied into# ComfyUI's loras/Moss/celebs (resized first when "Resize LoRA" is on), with the version raised# when that name is taken. moss_image_template-combined.yaml trains this template as one member# of a soup.
model: transformer_path: '[comfyui_diffusion_models]/MOSS/moss_image_base_bf16.safetensors' vae_path: '[comfyui_vae]/flux2_vae.safetensors' # Qwen3.5-9B. Only used while caching prompt embeddings, then unloaded. text_encoder_path: '[comfyui_text_encoders]/qwen3.5_9b_int8_convrot.safetensors'
dataset: path: '[dataset_location]/[person_to_train]' resolution: 512 # area target; buckets keep each image's aspect on a 16 px grid aspect_mode: 'bucket' trigger: '[person_to_train]' default_caption: 'a photo of [person_to_train]' repeats: 1
lora: rank: 16 alpha: 16 prefix: 'diffusion_model.' targets: 'blocks' # attention + feed-forward of the 42 joint blocks (252 modules) dtype: 'float32'
train: batch_size: 1 gradient_accumulation_steps: 1 max_steps: 0 # 0 = train num_epochs full epochs num_epochs: 60 save_every: 0 # 0 = only the final file # The report's last pretraining interval: logit(sigma) ~ N(1.09, 0.95), truncated at 0.95, # 1 % uniform, no shift. timestep_distribution: 'logit_normal' timestep_logit_mean: 1.09 timestep_logit_std: 0.95 timestep_cutoff: 0.95 timestep_uniform_mix: 0.01 timestep_shift: 1.0 timestep_grid: 1000 max_grad_norm: 1.0 gradient_checkpointing: true int8_grad_precision: 'bf16' optimizer: 'adamw8bit' learning_rate: 1.0e-4 # constant, no warmup weight_decay: 0.01 ema_decay: 0.98 # checkpoints save the average # The reference sampler uses real CFG against the empty prompt; dropping a caption now and then # keeps the LoRA's unconditional branch in step. caption_dropout: 0.05
dtype: 'bfloat16'mixed_precision: 'bf16'seed: 42
output: path: './output/moss_image_[person_to_train]_adamw' name: 'moss_image_[person_to_train]_v1_adamw' dtype: 'bfloat16' embed_config: true
logging: level: 'INFO'123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081# MOSS-Image LoRA -- MalTrainer (train_moss_image_lora.py), Automagic3.## The recipe of MalTrainer's own config/moss_image_automagic_template.yaml# (docs/moss-image-lora-training.md there), 20 epochs. Trains the bf16 BASE model ComfyUI# already has, so nothing is downloaded.## Placeholders filled by trainer-runner-config.service.ts:# [dataset_location] [person_to_train] the dataset folder# [comfyui_diffusion_models] [comfyui_vae] [comfyui_text_encoders]# COMFYUI_MODELS_PATH / COMFYUI_VAE_PATH / COMFYUI_TEXT_ENCODERS_PATH# `trigger` and `default_caption` are rewritten from the job's token and class.## The output file is moss_image_<person>_v1_automagic3.safetensors. After training it is copied into# ComfyUI's loras/Moss/celebs (resized first when "Resize LoRA" is on), with the version raised# when that name is taken. moss_image_template-combined.yaml trains this template as one member# of a soup.
model: transformer_path: '[comfyui_diffusion_models]/MOSS/moss_image_base_bf16.safetensors' vae_path: '[comfyui_vae]/flux2_vae.safetensors' # Qwen3.5-9B. Only used while caching prompt embeddings, then unloaded. text_encoder_path: '[comfyui_text_encoders]/qwen3.5_9b_int8_convrot.safetensors'
dataset: path: '[dataset_location]/[person_to_train]' resolution: 512 # area target; buckets keep each image's aspect on a 16 px grid aspect_mode: 'bucket' trigger: '[person_to_train]' default_caption: 'a photo of [person_to_train]' repeats: 1
lora: rank: 16 alpha: 16 prefix: 'diffusion_model.' targets: 'blocks' # attention + feed-forward of the 42 joint blocks (252 modules) dtype: 'float32'
train: batch_size: 1 gradient_accumulation_steps: 1 max_steps: 0 # 0 = train num_epochs full epochs num_epochs: 20 save_every: 0 # 0 = only the final file # The report's last pretraining interval: logit(sigma) ~ N(1.09, 0.95), truncated at 0.95, # 1 % uniform, no shift. timestep_distribution: 'logit_normal' timestep_logit_mean: 1.09 timestep_logit_std: 0.95 timestep_cutoff: 0.95 timestep_uniform_mix: 0.01 timestep_shift: 1.0 timestep_grid: 1000 max_grad_norm: 1.0 gradient_checkpointing: true int8_grad_precision: 'bf16' optimizer: 'automagic3' learning_rate: 1.0e-6 # Automagic3 launch point; it adapts from here weight_decay: 0.0 automagic_param_groups: true # attention / MLP / other each adapt their own rate automagic_polarity_history: 8 automagic_clip_threshold: 1.0 automagic_beta2: 0.999 automagic_eps: 1.0e-30 ema_decay: 0.98 # checkpoints save the average # The reference sampler uses real CFG against the empty prompt; dropping a caption now and then # keeps the LoRA's unconditional branch in step. caption_dropout: 0.05
dtype: 'bfloat16'mixed_precision: 'bf16'seed: 42
output: path: './output/moss_image_[person_to_train]_automagic3' name: 'moss_image_[person_to_train]_v1_automagic3' dtype: 'bfloat16' embed_config: true
logging: level: 'INFO'12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485# MOSS-Image LoRA -- MalTrainer (train_moss_image_lora.py), Prodigy.## The recipe of MalTrainer's own config/moss_image_prodigy_template.yaml# (docs/moss-image-lora-training.md there), 30 epochs. Trains the bf16 BASE model ComfyUI# already has, so nothing is downloaded.## Placeholders filled by trainer-runner-config.service.ts:# [dataset_location] [person_to_train] the dataset folder# [comfyui_diffusion_models] [comfyui_vae] [comfyui_text_encoders]# COMFYUI_MODELS_PATH / COMFYUI_VAE_PATH / COMFYUI_TEXT_ENCODERS_PATH# `trigger` and `default_caption` are rewritten from the job's token and class.## The output file is moss_image_<person>_v1_prodigy.safetensors. After training it is copied into# ComfyUI's loras/Moss/celebs (resized first when "Resize LoRA" is on), with the version raised# when that name is taken. moss_image_template-combined.yaml trains this template as one member# of a soup.
model: transformer_path: '[comfyui_diffusion_models]/MOSS/moss_image_base_bf16.safetensors' vae_path: '[comfyui_vae]/flux2_vae.safetensors' # Qwen3.5-9B. Only used while caching prompt embeddings, then unloaded. text_encoder_path: '[comfyui_text_encoders]/qwen3.5_9b_int8_convrot.safetensors'
dataset: path: '[dataset_location]/[person_to_train]' resolution: 512 # area target; buckets keep each image's aspect on a 16 px grid aspect_mode: 'bucket' trigger: '[person_to_train]' default_caption: 'a photo of [person_to_train]' repeats: 1
lora: rank: 16 alpha: 16 prefix: 'diffusion_model.' targets: 'blocks' # attention + feed-forward of the 42 joint blocks (252 modules) dtype: 'float32'
train: batch_size: 1 gradient_accumulation_steps: 1 max_steps: 0 # 0 = train num_epochs full epochs num_epochs: 30 save_every: 0 # 0 = only the final file # The report's last pretraining interval: logit(sigma) ~ N(1.09, 0.95), truncated at 0.95, # 1 % uniform, no shift. timestep_distribution: 'logit_normal' timestep_logit_mean: 1.09 timestep_logit_std: 0.95 timestep_cutoff: 0.95 timestep_uniform_mix: 0.01 timestep_shift: 1.0 timestep_grid: 1000 max_grad_norm: 1.0 gradient_checkpointing: true int8_grad_precision: 'bf16' optimizer: 'prodigy' learning_rate: 1.0 # Prodigy's multiplier on its own estimated step size learning_rate_warmup_steps: 100 weight_decay: 0.01 adam_beta1: 0.9 prodigy_beta2: 0.99 prodigy_eps: 1.0e-8 prodigy_d0: 1.0e-6 # initial step-size guess; Prodigy grows it prodigy_d_coef: 1.0 prodigy_decouple: true prodigy_use_bias_correction: true prodigy_safeguard_warmup: true ema_decay: 0.0 # Prodigy's step size does the smoothing # The reference sampler uses real CFG against the empty prompt; dropping a caption now and then # keeps the LoRA's unconditional branch in step. caption_dropout: 0.05
dtype: 'bfloat16'mixed_precision: 'bf16'seed: 42
output: path: './output/moss_image_[person_to_train]_prodigy' name: 'moss_image_[person_to_train]_v1_prodigy' dtype: 'bfloat16' embed_config: true
logging: level: 'INFO'moss/README.mdAdded+36
moss/docs/MOSS_IMAGE_COMBINED_OPTIMIZER_TRAINING_GUIDE.mdAdded+234
moss/docs/moss-image-lora-stacking-findings.mdAdded+88
moss/docs/moss-image-lora-training.mdAdded+148
moss/templates/moss_image_template-adamw8bit.yamlAdded+76
moss/templates/moss_image_template-automagic3.yamlAdded+81
moss/templates/moss_image_template-prodigy.yamlAdded+85