asdf98 commited on
Commit
70ea268
Β·
verified Β·
1 Parent(s): 3bbd6a9

Update README with Colab training instructions and VRAM budget

Browse files
Files changed (1) hide show
  1. README.md +114 -16
README.md CHANGED
@@ -1,30 +1,128 @@
1
  # IRIS: Iterative Refinement Image Synthesizer
2
 
3
- A mobile-first image generation architecture designed from recent research (2025-2026).
4
 
5
- **17/17 tests pass** β€” all modules verified for shape correctness, gradient flow, weight sharing, numerical stability, and actual training convergence.
6
 
7
- See `iris/README.md` for full documentation.
8
 
9
- ## Quick Start
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  ```python
12
  from iris import IRIS, get_model_config, flow_matching_loss, euler_sample
13
  import torch
14
 
15
- model = IRIS(**get_model_config("iris-small")) # 40M params
16
- z_0 = torch.randn(4, 32, 16, 16) * 2.5
17
- text_emb = torch.randn(4, 16, 512)
18
- losses = flow_matching_loss(model, z_0, text_emb, num_iterations=4)
 
 
 
19
  losses["loss"].backward()
 
 
 
 
 
 
 
20
  ```
21
 
22
- ## Model Variants
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
- | Config | Params | Tokens | FP16 Memory |
25
- |--------|--------|--------|-------------|
26
- | iris-tiny | 10.3M | 16 | 21 MB |
27
- | iris-small | 40.0M | 16 | 80 MB |
28
- | iris-base | 53.4M | 64 | 107 MB |
29
- | iris-medium | 181.2M | 64 | 362 MB |
30
- | iris-large | 430.9M | 64 | 862 MB |
 
1
  # IRIS: Iterative Refinement Image Synthesizer
2
 
3
+ A mobile-first image generation architecture designed from recent research (2025-2026). **17/17 tests pass.**
4
 
5
+ ## Colab Quick Start (Free Tier T4 β€” Just Run It)
6
 
7
+ **One script, real dataset, real training, ~20 minutes total.**
8
 
9
+ 1. Open [Google Colab](https://colab.research.google.com)
10
+ 2. Set runtime to **T4 GPU** (Runtime β†’ Change runtime type β†’ T4 GPU)
11
+ 3. Create a new cell and paste:
12
+
13
+ ```python
14
+ !wget -q https://huggingface.co/asdf98/iris-image-gen/resolve/main/colab_train_iris.py
15
+ %run colab_train_iris.py
16
+ ```
17
+
18
+ **What happens:**
19
+ - Installs deps (~30s)
20
+ - Downloads IRIS code + DC-AE encoder + text encoder (~2min)
21
+ - Encodes 833 Pokemon images to latents (~2min on T4)
22
+ - Trains IRIS-Small (40M params) for 3000 steps (~15min on T4)
23
+ - Generates sample images and plots loss curve
24
+ - Saves checkpoint to `./iris_checkpoints/`
25
+
26
+ **Colab free tier (2025):** T4 GPU (16GB VRAM), ~12.7GB RAM, PyTorch 2.5+
27
+
28
+ ### VRAM Budget (Colab T4, 16 GB)
29
+
30
+ | Phase | Component | VRAM |
31
+ |-------|-----------|------|
32
+ | Encoding | DC-AE (fp16) | ~2.4 GB |
33
+ | Encoding | text encoder | ~0.35 GB |
34
+ | Training | IRIS-Small (40M, fp32) | ~0.16 GB |
35
+ | Training | Optimizer states | ~0.48 GB |
36
+ | Training | Batch + activations (BS=16, R=3, checkpointed) | ~2-4 GB |
37
+ | **Peak** | **Encoding phase** | **~3 GB** |
38
+ | **Peak** | **Training phase** | **~5 GB** |
39
+
40
+ Encoders are freed before training starts β†’ plenty of headroom.
41
+
42
+ ### Configs for Different Hardware
43
+
44
+ | Hardware | Config | Command |
45
+ |----------|--------|---------|
46
+ | Colab Free (T4 16GB) | `iris-small` | Default β€” just run the script |
47
+ | Colab Pro (A100 40GB) | `iris-medium` | Change `get_model_config("iris-medium")` and `text_dim=384` |
48
+ | Kaggle (P100 16GB) | `iris-small` | Same as Colab free tier |
49
+ | Local RTX 3090 (24GB) | `iris-base` | Use `iris-base` config, BS=32 |
50
+
51
+ ### Dependencies (All pip-installable, no special builds)
52
+
53
+ ```
54
+ torch>=2.0 # preinstalled in Colab
55
+ diffusers>=0.32.0 # for AutoencoderDC
56
+ sentence-transformers # for text encoding (all-MiniLM-L6-v2, 87MB)
57
+ datasets # for HF dataset loading
58
+ accelerate # diffusers dependency
59
+ huggingface_hub # for downloading IRIS code
60
+ ```
61
+
62
+ No `flash-attn`, no `triton`, no `apex`, no custom CUDA kernels. Pure PyTorch.
63
+
64
+ ---
65
+
66
+ ## Model Variants
67
+
68
+ | Config | Params | Tokens | Patch Size | Target Device | FP16 Memory |
69
+ |--------|--------|--------|------------|---------------|-------------|
70
+ | `iris-tiny` | 10.3M | 16 | 4 | Any phone | 21 MB |
71
+ | `iris-small` | 40.0M | 16 | 4 | Modern phone / Colab | 80 MB |
72
+ | `iris-base` | 53.4M | 64 | 2 | Phone/tablet | 107 MB |
73
+ | `iris-medium` | 181.2M | 64 | 2 | Desktop/cloud | 362 MB |
74
+ | `iris-large` | 430.9M | 64 | 2 | Cloud | 862 MB |
75
+
76
+ ## Architecture
77
+
78
+ IRIS combines five innovations:
79
+
80
+ 1. **PDE-SSM spatial mixing** β€” O(N log N) Fourier-domain PDE, native 2D. [PDE-SSM-DiT](https://arxiv.org/abs/2603.13663)
81
+ 2. **Weight-shared refinement** β€” 6 blocks Γ— R iterations, same weights. [GRN](https://arxiv.org/abs/2604.13030)
82
+ 3. **Structured latent canvas** β€” DC-AE with channel masking. [DC-AE 1.5](https://arxiv.org/abs/2508.00413)
83
+ 4. **Tiny decoder** β€” 0.1M params PixelShuffle. [SnapGen](https://arxiv.org/abs/2412.09619)
84
+ 5. **MQA + 2D RoPE + QK-RMSNorm** β€” Mobile-optimized. [SnapGen++](https://arxiv.org/abs/2601.08303)
85
+
86
+ ## Python API
87
 
88
  ```python
89
  from iris import IRIS, get_model_config, flow_matching_loss, euler_sample
90
  import torch
91
 
92
+ # Create model (with text projection for 384-dim MiniLM embeddings)
93
+ model = IRIS(**get_model_config("iris-small"), text_dim=384)
94
+
95
+ # Training step
96
+ z_0 = torch.randn(4, 32, 16, 16) * 2.5 # DC-AE latents
97
+ text_emb = torch.randn(4, 1, 384) # MiniLM text embeddings
98
+ losses = flow_matching_loss(model, z_0, text_emb, num_iterations=3)
99
  losses["loss"].backward()
100
+
101
+ # Sampling
102
+ model.eval()
103
+ noise = torch.randn(1, 32, 16, 16)
104
+ with torch.no_grad():
105
+ z_pred = euler_sample(model, noise, text_emb[:1], num_steps=20, num_iterations=3)
106
+ image = model.decode_latent(z_pred) # (1, 3, 512, 512)
107
  ```
108
 
109
+ ## Files
110
+
111
+ ```
112
+ colab_train_iris.py # <-- ONE-CLICK COLAB NOTEBOOK
113
+ iris/
114
+ __init__.py # Public API
115
+ model.py # IRIS model (Patchify, Unpatchify, TinyDecoder, IRIS)
116
+ core.py # RefinementCore (weight-shared block loop)
117
+ pde_ssm.py # SpectralConv2d, TokenDifferential, PDESSMBlock
118
+ blocks.py # MQA, RoPE2D, UIB-FFN, TimestepEmbed, IterationEmbed
119
+ flow_matching.py # Rectified flow loss, Euler sampler
120
+ configs.py # 5 model configurations (tiny β†’ large)
121
+ train.py # Training utilities (dataset, scheduler)
122
+ train_production.py # CLI training script
123
+ test_all.py # 17-test suite
124
+ ```
125
+
126
+ ## License
127
 
128
+ MIT