File size: 11,031 Bytes
a2213cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c802bec
 
a2213cd
 
 
 
 
 
 
 
 
 
 
 
 
 
c802bec
 
 
a2213cd
 
 
 
 
 
 
 
 
 
c802bec
a2213cd
 
 
 
 
 
 
 
 
 
 
 
 
c802bec
 
a2213cd
 
 
 
 
 
 
 
 
 
 
c802bec
 
a2213cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c802bec
a2213cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c802bec
a2213cd
 
 
 
 
 
 
 
 
 
 
c802bec
a2213cd
 
 
 
 
 
 
 
 
c802bec
 
a2213cd
 
 
 
 
 
 
 
 
 
 
c802bec
a2213cd
 
 
 
 
 
 
c802bec
 
 
 
 
 
a2213cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c802bec
 
a2213cd
 
 
 
 
 
 
 
 
 
 
c802bec
a2213cd
 
 
 
 
 
c802bec
 
 
a2213cd
 
 
c802bec
 
a2213cd
c802bec
 
a2213cd
 
 
c802bec
 
 
a2213cd
c802bec
 
 
a2213cd
c802bec
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
---
license: apache-2.0
base_model: Comfy-Org/Qwen3-VL
pipeline_tag: text-to-image
tags:
  - comfyui
  - ideogram4
  - qwen3-vl
  - text-encoder
  - lora
  - fp8
  - flow-matching
  - experimental
---

# Ideogram 4 Natural-Language Text Encoder — S020 v1

This repository contains an experimental, stock-shaped replacement for the Qwen3-VL 8B text encoder
used by Ideogram 4, plus the matching training LoRA. It is intended to make Ideogram 4 respond to
ordinary natural-language prompts more like the stock model responds to structured Magic-Prompt JSON.
It operates as a direct checkpoint replacement through the stock ComfyUI loader.

This release is the first strength-0.2 milestone. The nominal 500-step milestone resolved to the first
complete checkpoint in that checkpoint band, **optimizer step 510**.

## Files

| File | Purpose | Size | SHA-256 |
|---|---|---:|---|
| `text_encoders/qwen3vl_8b_ideogram4_nl_s020_v1_step_00000510_fp8_scaled.safetensors` | Standalone drop-in scaled-FP8 text encoder | 10,588,637,800 bytes | `f0d1009af7407b60bda169967bb5e4c3e8ea264042b70f3d7b667bb0c2404ece` |
| `loras/qwen3vl_8b_ideogram4_nl_s020_v1_step_00000510_r64_a64.safetensors` | Matching unmerged research LoRA | 698,404,608 bytes | `85359811e619276f85742072c2b3327915bbb56bcefb874f2f3101a5d1216eef` |
| `manifests/checkpoint_step_00000510.json` | Training checkpoint and controller metadata | — | See `SHA256SUMS` |
| `manifests/merge_step_00000510.json` | Merge inputs, output hash, and per-projection quantization metrics | — | See `SHA256SUMS` |
| `COMPATIBILITY.md` | Component boundary, provenance, and third-party compatibility notice | — | See `SHA256SUMS` |

The LoRA uses this project's native tensor names (`layers.N.<projection>.lora_a` and `lora_b`). The
merged text encoder is the recommended artifact for inference; the LoRA is provided for research,
inspection, and reproducibility.

## Installation

Download the merged file into the normal ComfyUI text-encoder directory:

```text
ComfyUI/models/text_encoders/
```

Select it in the same Ideogram 4 text-encoder loader used for the stock
`qwen3vl_8b_fp8_scaled.safetensors`.

## What was trained

### Task definition

Observed stock behavior motivated the following target:

```text
short natural language       -> weak/broken stock conditioning
detailed natural language    -> weak/broken stock conditioning
structured Magic-Prompt JSON -> functional stock conditioning
```

Each natural-language prompt therefore has a structured teacher target. Because the natural-language
and JSON sequences differ in length, training matches their effect at Ideogram's image-side response:

```text
c_T = stock_text_encoder(teacher_json)
c_S = adapted_text_encoder(natural_language)

v_T = ideogram_conditional(z_t, t, c_T)
v_S = ideogram_conditional(z_t, t, c_S)

loss = mean((v_S - v_T) ** 2)
```

Ideogram parameters remain frozen while gradients pass through the student conditional forward to the
text-encoder adapters. The objective is entirely focused on matching the structured teacher response.

### Stock text-encoder path

The stock Ideogram path uses Qwen3-VL 8B as a contextual feature extractor. Hidden states from 13 taps
(`0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 35`) are concatenated to 53,248 features per text token,
then projected to the 4,608-wide Ideogram DiT. The student preserves this architecture and tensor layout.

### Dataset and teacher

- 4,000 source prompts from public Civitai generation metadata.
- Exactly 1,000 prompts from each source rating group: SFW, R, X, and XXX.
- Exact MaxMin diversity selection in Ideogram's own conditioning space, after literal cleanup,
  provenance filtering, and exclusion of edit/image-input records.
- 3,900 training prompts and 100 deterministic owner-reviewed holdouts (25 per rating group).
- Eight cached behavior states per training prompt: 31,200 training examples.
- Teacher JSON generated by `accounts/fireworks/models/nemotron-3-ultra-nvfp4` through Fireworks,
  temperature 0, high reasoning effort, using the project's Magic-Prompt system instructions.
- Teacher conditioning encoded through the exact stock Comfy tokenizer, Qwen taps, and Ideogram ingress
  projection, stored as float16.

This release contains the trained weights, configuration, checkpoint metadata, and merge provenance.

### Eight-state trajectory supervision

Teacher trajectories use the stock `V4_DEFAULT_20` 20-step schedule at 512×512. Eight deterministic
pre-step states are captured at loop indices:

```text
[19, 16, 14, 11, 8, 5, 3, 0]
```

Each cache entry stores the pre-step latent and exact positive conditional teacher velocity. All eight
states are independent velocity-matching examples during training. The unconditional branch is a
separate text-free model and is identical for teacher and student, so conditional velocity matching is
sufficient for the text-encoder objective.

### Strength-0.2 first-step steering target

The teacher trajectory includes one first-conditional-pass spatial correction derived from the
authoritative Ideogram 4 debanner direction:

- correction tensor SHA-256: `5ce873adae5701e9d5f05ebfa8f8b923a1622745c6e9a2bcb3e22fd090ed30c3`;
- Ideogram blocks: 25, 26, 27, and 28;
- distillation strength: `0.2`;
- first denoising step and first positive conditional pass only;
- image tokens only;
- subtract the nearest-neighbor-resized 8×8 spatial direction, then restore each image token's
  original L2 norm;
- the correction is confined to the positive conditional pass.

Only the first cached target velocity is directly corrected. The later seven target velocities are
uncorrected but evaluated on the trajectory produced by the corrected first update. The student always
uses an unpatched stock Ideogram conditional model; the behavior is distilled into the text encoder.

The cache contract fingerprints the correction tensor, metadata, strength, block set, schedule,
resolution, conditional checkpoint, conditioning, and all eight target velocities. Incompatible caches
are rejected before model loading.

## Adapter geometry

This checkpoint uses the following adapter geometry:

- rank: 64;
- alpha: 64;
- blocks: all 36 Qwen text blocks (`0–35`);
- projections per block: `q_proj`, `k_proj`, `v_proj`, `o_proj`, `gate_proj`, `up_proj`, `down_proj`;
- adapted projections: 252;
- trainable parameters: 174,587,904;
- LoRA tensors: 504.

Per block, the adapter contains 4,849,664 parameters. Adapting all 36 blocks gives every tapped depth a
trainable path for reshaping the conditioning features consumed by Ideogram.

## Optimization and numerics

- Optimizer: AdamW, FP32 adapter parameters and optimizer state.
- Weight decay: `0.01`.
- Physical batch size: 2.
- Gradient accumulation: 8.
- Effective optimizer batch: 16 behavior examples.
- Adaptive packing: batch 2 through 1,017 student tokens; longer examples use singleton microbatches.
- Gradient clipping: global norm `1.0`.
- Optimizer state is held on CPU between updates.
- The training graph contains the Qwen text transformer with all 36 text blocks.
- Initial learning rate: `3.2e-4`.

Training is quantization-aware for the final deployment format. For each adapted projection, the forward
path forms the dequantized stock weight plus the LoRA delta, then requantizes using the stock per-tensor
scale to `float8_e4m3fn`. A straight-through estimator supplies LoRA gradients without constructing a
dense base-weight gradient.

Learning rate is managed by a transactional loss-curve controller. It evaluates fixed 50-step windows
every 10 steps, estimates log-loss descent relative to robust residual noise, confirms a failed window
for 20 additional steps, locates the elbow, restores the complete optimizer/sampler/RNG state at the
rollback boundary, and continues at half the LR. A rollback requires both deterministic held-out loss
and interval-averaged training loss to fail their descent tests. Reaching the positive LR floor allows
training to continue.

## Step-510 checkpoint metrics

| Metric | Value |
|---|---:|
| Optimizer step | 510 |
| Training velocity MSE | 0.0179036569 |
| Held-out velocity MSE | 0.0171197626 |
| Learning rate | `8e-5` |
| LR reductions completed | 2 |
| Gradient norm | 0.0149142 |
| Step time on RTX 5090 | 12.94 s |
| Peak reserved VRAM | 24.463 GiB |
| Behavior microbatches | 8 batch-2, 0 singleton |

Evaluation combines velocity MSE with fixed-seed stock/teacher/checkpoint image comparisons and owner
visual review. Standardized perceptual, OCR, and broad safety benchmarking remain future work.

## Merge and deployment format

The standalone file was merged on CPU into the exact stock Comfy scaled-FP8 checkpoint layout:

- stock base SHA-256: `4ba424cf62e51392e4d1a39933e803706f4e823c1065f36aaf149c6453f66bcd`;
- adapter SHA-256: `85359811e619276f85742072c2b3327915bbb56bcefb874f2f3101a5d1216eef`;
- output SHA-256: `f0d1009af7407b60bda169967bb5e4c3e8ea264042b70f3d7b667bb0c2404ece`;
- output tensors: 1,254;
- merged projections: 252;
- stock per-tensor FP8 scales preserved;
- tensor inventory remains compatible with the stock text-encoder checkpoint layout.

The base file is byte-identical to the text encoder published in `Comfy-Org/Qwen3-VL` and
`Comfy-Org/Ideogram-4` under the base SHA above.

## Limitations

- Step 510 is the first public research milestone from a longer training lineage.
- The learned conditioning targets Ideogram 4's frozen conditional model and Comfy text-encoder ingress
  path; its intended use is image-conditioning inference through that interface.
- Training and validation use cached 512×512 trajectories from one fixed sampler contract. Behavior at
  other resolutions, schedules, samplers, and seeds requires independent evaluation.
- Teacher targets can be imperfect or semantically inconsistent despite validation.
- The corpus deliberately spans adult source-rating groups. Deployment requires an application-level
  safety policy appropriate to the intended use.
- Static text conditioning may only approximate a first-step, latent-dependent spatial intervention.
- FP8 requantization rounds low-magnitude LoRA deltas to the available scaled-FP8 grid; per-projection
  retention metrics are included in the merge manifest.

## Component and licensing boundary

The release artifacts consist exclusively of modified Qwen3-VL text-encoder parameters. They start
from the independently published `Comfy-Org/Qwen3-VL` scaled-FP8 checkpoint and are released under its
Apache-2.0 license.

During training, a separately obtained, frozen Ideogram 4 model served as a differentiable downstream
evaluator of the conditioning interface. Optimization updated the Qwen adapter parameters, and the
release files contain the resulting Qwen text-encoder weights.

Ideogram 4 is acquired separately under its own license and usage policy. Users combining the two
components are responsible for the terms applicable to each. This repository is independently produced
and has no affiliation with Ideogram, Inc.