Instructions to use AEUPH/moss4gb with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use AEUPH/moss4gb with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("AEUPH/moss4gb", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
Add the measured single-image trainable lane as a documented reference
Browse files- TRAINABLE-REFERENCE.md +108 -0
TRAINABLE-REFERENCE.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Trainable lane — one image in, one LoRA out (proven, referenced)
|
| 2 |
+
|
| 3 |
+
This is the part of the project that already **worked**, recorded so it can be
|
| 4 |
+
reused instead of rediscovered. Two artefacts make up the lane:
|
| 5 |
+
|
| 6 |
+
| Artefact | Role | Status |
|
| 7 |
+
|---|---|---|
|
| 8 |
+
| `micro_lora_batch.py` (kohya_ss) | resumable driver: **one source image -> one `.safetensors` LoRA**, one training run per image, journaled | built, documented, dry-run/VRAM-planned |
|
| 9 |
+
| The QAT LoRA run (backup `2026-10-22`) | the first run in the project where a **trained adapter visibly bound a subject to its prompt** | measured, two seeds on record |
|
| 10 |
+
|
| 11 |
+
Everything below is a quotation of measured numbers from those two sources.
|
| 12 |
+
Nothing here is aspirational.
|
| 13 |
+
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
## 1. The single-image recipe (why each number is what it is)
|
| 17 |
+
|
| 18 |
+
Training on one image is a **memorisation** task, so the settings are chosen for
|
| 19 |
+
recall, not generalisation:
|
| 20 |
+
|
| 21 |
+
| Setting | Value | Reason |
|
| 22 |
+
|---|---|---|
|
| 23 |
+
| rank / alpha | **16 / 8** | one image needs little capacity; `alpha = dim/2` keeps the blend moderate at weight 1.0 |
|
| 24 |
+
| network | **U-Net only** | text encoders add nothing for a single caption; both encoder outputs are cached to disk and never enter the loop |
|
| 25 |
+
| steps / lr | **250**, cosine, AdamW8bit, lr **2e-4** | converges a single image, keeps the run short, 8-bit Adam keeps optimizer state off the VRAM budget |
|
| 26 |
+
| min-SNR gamma | **5.0** | down-weights high-loss low-timestep steps; the single biggest stabiliser on tiny datasets |
|
| 27 |
+
| noise offset | **0.0357** | the value SDXL was trained with; without it single-image LoRAs fail on dark/bright images |
|
| 28 |
+
| scale weight norms | **1.0** | stops an over-trained single-image LoRA blowing out contrast when merged |
|
| 29 |
+
| VAE | **no half VAE, fp16** | SDXL's VAE NaNs in fp16; fp16 is the only half precision sm_61 supports |
|
| 30 |
+
| buckets | no-upscale, step 64, min 512 / max 1024 | sources run 512 px to 4096 px; nothing is inflated past what the model can use |
|
| 31 |
+
| caption | trigger token (`mlpic`) by default | no caption competing for capacity: all parameters go into recalling the image |
|
| 32 |
+
|
| 33 |
+
Measured on the 4 GB card: **r16, FP8 U-Net, 512 px, batch 1, gradient
|
| 34 |
+
checkpointing -> peak 3.38 GB VRAM, 9.8 GB commit, 14.5-16.9 s/step, ~70 min per
|
| 35 |
+
LoRA.** Two separate walls are handled separately (commit charge at load vs VRAM
|
| 36 |
+
during training); `--dry-run` prints the plan and refuses when nothing fits.
|
| 37 |
+
|
| 38 |
+
## 2. The run that proved the lane (backup `2026-10-22`)
|
| 39 |
+
|
| 40 |
+
* Adapter: rank-8 QAT LoRA, 3.2 MB, **1,594,368 trainable params (0.185 % of the
|
| 41 |
+
U-Net)**, 300 steps at ~3.25 s/step.
|
| 42 |
+
* Data: 2 images at 1024 px, **VAE-encoded per image** (a 2-image batch at 1024
|
| 43 |
+
exceed 4 GB and silently fell back to system RAM; batch 1 fixed it).
|
| 44 |
+
* Optimisation: AdamW lr 1e-4, canonical SD1.5 DDPM schedule, **cfg_dropout 0.1**
|
| 45 |
+
so guidance does not decorrelate, base weights fixed.
|
| 46 |
+
* Loss: first-10 **0.372** -> last-10 **0.090**.
|
| 47 |
+
* Result: seed 1234 and seed 777 are the first renders in the project where the
|
| 48 |
+
prompt binds to a subject; both files and their md5s are in the backup.
|
| 49 |
+
|
| 50 |
+
### The one bug that made every earlier attempt look like a failure
|
| 51 |
+
|
| 52 |
+
The deploy loader multiplied the LoRA delta by the **rank** instead of
|
| 53 |
+
`alpha / r`:
|
| 54 |
+
|
| 55 |
+
```
|
| 56 |
+
delta = (lora_alpha / r) * B @ A # correct (peft contract)
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
With `alpha == r == 8` the correct multiplier is **1.0**; the loader applied
|
| 60 |
+
**8.0**, i.e. ~50 % of the weight scale instead of ~7 %, which satured attention
|
| 61 |
+
and produced flat RGB confetti. Same seed, same base, same sampler: **only the
|
| 62 |
+
multiplier changed**, and the output went from noise to figures. Any adapter
|
| 63 |
+
that "does nothing" or "explodes" should be checked against this rule first.
|
| 64 |
+
|
| 65 |
+
### Hydration rule
|
| 66 |
+
|
| 67 |
+
Train against **the exact container that deploys**: every >=2-D weight was
|
| 68 |
+
loaded from the deployed checkpoint (282/282 tensors mapped, 0 mismatches)
|
| 69 |
+
rather than a uniform approximation. An adapter trained on a nearby-but-different
|
| 70 |
+
base is a silent quality ceiling.
|
| 71 |
+
|
| 72 |
+
## 3. The MOSS-Image bridge (designed, not yet trained)
|
| 73 |
+
|
| 74 |
+
MOSS-Image takes no image input, but the text slot is just `[S, 4096]` floats,
|
| 75 |
+
and `NOTES.md` records the minimal bridge:
|
| 76 |
+
|
| 77 |
+
1. `Linear(128 -> 4096)` on VAE latents, plus
|
| 78 |
+
2. a LoRA on the two `_TextProjection` blocks.
|
| 79 |
+
|
| 80 |
+
RoPE constraint that decides the design: **the image tokens' frame coordinate
|
| 81 |
+
equals the text length**, so 64 image tokens must be trained and inferred at the
|
| 82 |
+
same token count (200-token caption -> frame 200, 64 image tokens -> frame 64).
|
| 83 |
+
|
| 84 |
+
## 4. Why this is a selling point, not a footnote
|
| 85 |
+
|
| 86 |
+
* **$0 iteration.** The trainer is local on the 1050 Ti; a LoRA is ~70 min of a
|
| 87 |
+
card you already own, and re-running is free.
|
| 88 |
+
* **One image is the whole dataset.** No scrape, no consent problem, no
|
| 89 |
+
captioning pass: a product photo, a character sheet cell or a style sample is
|
| 90 |
+
enough to ship a LoRA.
|
| 91 |
+
* **Inference is free here too.** This Space runs the same family of model on a
|
| 92 |
+
free ZeroGPU slot with a prompt-embedding bank; the LoRA lab is the only place
|
| 93 |
+
the project spends wall-clock time, and it spends it on your own hardware.
|
| 94 |
+
* **Packaging is the same artefact.** A rank-8/16 LoRA is 3 MB; it travels with
|
| 95 |
+
the model card, the bank and the workflow as one reproducible bundle.
|
| 96 |
+
|
| 97 |
+
## 5. Reuse checklist
|
| 98 |
+
|
| 99 |
+
```
|
| 100 |
+
python tools/micro_lora_batch.py --dry-run --limit 10 # plan + VRAM, no GPU
|
| 101 |
+
python tools/micro_lora_batch.py --limit 3 --keep-work # smoke 3 images
|
| 102 |
+
python tools/micro_lora_batch.py # whole pending queue
|
| 103 |
+
```
|
| 104 |
+
|
| 105 |
+
* keep `alpha = dim/2` and verify the deploy loader uses `alpha / r`;
|
| 106 |
+
* per-image VAE encode, batch 1;
|
| 107 |
+
* never merge above weight 1.0 without re-checking contrast;
|
| 108 |
+
* measure against a fixed seed A/B before claiming an adapter helps.
|