Instructions to use leffff/diffusion-distillation-workshop-adapters with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use leffff/diffusion-distillation-workshop-adapters with PEFT:
Task type is invalid.
- Sana
How to use leffff/diffusion-distillation-workshop-adapters with Sana:
# Load the model and infer image from text import torch from app.sana_pipeline import SanaPipeline from torchvision.utils import save_image sana = SanaPipeline("configs/sana_config/1024ms/Sana_1600M_img1024.yaml") sana.from_pretrained("hf://leffff/diffusion-distillation-workshop-adapters") image = sana( prompt='a cyberpunk cat with a neon sign that says "Sana"', height=1024, width=1024, guidance_scale=5.0, pag_guidance_scale=2.0, num_inference_steps=18, ) - Notebooks
- Google Colab
- Kaggle
4-NFE Sana-600M students: CM, LADD, DMD, PDD adapters + samples
Browse files- .gitattributes +6 -0
- README.md +44 -0
- adapter_cm.pt +3 -0
- adapter_dmd.pt +3 -0
- adapter_ladd.pt +3 -0
- adapter_pdd.pt +3 -0
- samples/cm_samples.png +3 -0
- samples/comparison.png +3 -0
- samples/diversity.png +3 -0
- samples/dmd_samples.png +3 -0
- samples/ladd_samples.png +3 -0
- samples/pdd_samples.png +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,9 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
samples/cm_samples.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
samples/comparison.png filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
samples/diversity.png filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
samples/dmd_samples.png filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
samples/ladd_samples.png filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
samples/pdd_samples.png filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: Efficient-Large-Model/Sana_600M_512px_diffusers
|
| 4 |
+
library_name: peft
|
| 5 |
+
tags:
|
| 6 |
+
- diffusion
|
| 7 |
+
- distillation
|
| 8 |
+
- sana
|
| 9 |
+
- lora
|
| 10 |
+
- text-to-image
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# Diffusion Distillation Workshop: 4-step Sana-600M students
|
| 14 |
+
|
| 15 |
+
LoRA adapters that distill [Sana-600M-512px](https://huggingface.co/Efficient-Large-Model/Sana_600M_512px_diffusers) from 40 NFE (20 steps with CFG 4.5) into **4-NFE students** using four methods. They were trained with the workshop notebook on one H100. Data: [`leffff/diffusion-distillation-workshop`](https://huggingface.co/datasets/leffff/diffusion-distillation-workshop).
|
| 16 |
+
|
| 17 |
+
| file | method | sampler (4 NFE) | training | CLIP ↑ | diversity | latent MSE to teacher |
|
| 18 |
+
|---|---|---|---|---|---|---|
|
| 19 |
+
| teacher | — | 20 Euler steps + CFG (40 NFE) | — | 32.29 | 0.075 | 0 |
|
| 20 |
+
| teacher | — | 4 Euler steps + CFG (8 NFE) | — | 30.73 | 0.117 | 0.54 |
|
| 21 |
+
| `adapter_cm.pt` | multistep (phased) consistency distillation | Euler | 5 min, 933 it × 16 | 32.67 | 0.088 | 0.41 |
|
| 22 |
+
| `adapter_ladd.pt` | LADD (adversarial, teacher-feature discriminator) | x0 + renoise | 5 min, 853 it × 16 | 31.95 | 0.101 | 1.42 |
|
| 23 |
+
| `adapter_dmd.pt` | DMD2 (reverse KL, fake score, backward simulation) | x0 + renoise | 30 min, 3101 it × 16, LR 1e-5 | 31.25 | 0.091 | 1.01 |
|
| 24 |
+
| `adapter_pdd.pt` | Parallel Decoding Distillation (N=32, L=8, midpoint) | 4 block-Euler steps | 5 min, 866 it × 16 | 32.88 | 0.093 | 0.42 |
|
| 25 |
+
|
| 26 |
+
Metrics: 6 eval prompts × 4 seeds, CLIP ViT-B/32. Trajectory methods (CM, PDD) keep the teacher's noise→image map (low MSE); distribution methods (LADD, DMD) do not.
|
| 27 |
+
|
| 28 |
+
Note on DMD: the same config with LR 5e-5 (3100 it × 16) reached CLIP 32.37. That adapter is not included here.
|
| 29 |
+
|
| 30 |
+

|
| 31 |
+
|
| 32 |
+
## Format
|
| 33 |
+
|
| 34 |
+
Each `.pt` file is a dict produced by the notebook's `save_adapter`: a peft LoRA state dict (`get_peft_model_state_dict`; r=32 for CM/LADD/PDD, r=128 for DMD; targets `to_q, to_k, to_v, to_out.0, conv_inverted, conv_point, proj_out.base`). `adapter_pdd.pt` also contains `grid.w` / `grid.b`: PDD's 32 output heads.
|
| 35 |
+
|
| 36 |
+
## Usage (in the workshop notebook)
|
| 37 |
+
|
| 38 |
+
```python
|
| 39 |
+
from huggingface_hub import hf_hub_download
|
| 40 |
+
import shutil
|
| 41 |
+
for m in ["cm", "ladd", "dmd", "pdd"]:
|
| 42 |
+
shutil.copy(hf_hub_download("leffff/diffusion-distillation-workshop-adapters", f"adapter_{m}.pt"), f"{CACHE_DIR}/adapter_{m}.pt")
|
| 43 |
+
load_adapter(m)
|
| 44 |
+
```
|
adapter_cm.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d3efbcfcb534193464da30aeef54ece0d1f0c7019ba449f489677282f5923d69
|
| 3 |
+
size 105621507
|
adapter_dmd.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a6c13d7e8bbc137bfe4ee12297dc5f15aa12d1dfc077593c265d296d2b529878
|
| 3 |
+
size 421928507
|
adapter_ladd.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3d8f7e535e9bd7bb600c78e18914403ab82a0081654c6570a584f7fac41dbd87
|
| 3 |
+
size 105622643
|
adapter_pdd.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2aad2c37358cdbaaa69b772b11111702cfcfb69f4f67e3469940769b2422e993
|
| 3 |
+
size 110345343
|
samples/cm_samples.png
ADDED
|
Git LFS Details
|
samples/comparison.png
ADDED
|
Git LFS Details
|
samples/diversity.png
ADDED
|
Git LFS Details
|
samples/dmd_samples.png
ADDED
|
Git LFS Details
|
samples/ladd_samples.png
ADDED
|
Git LFS Details
|
samples/pdd_samples.png
ADDED
|
Git LFS Details
|