File size: 29,982 Bytes
6daffc2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
263b26f
6daffc2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
263b26f
 
6daffc2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
# dflow_2b Technical Report

[Model card](README.md) · [Manual](MANUAL.md) · [Example gallery](GALLERY.md) ·
[Release notes](RELEASES.md)

## Overview

dflow_2b is an indie text-to-image model, trained from scratch on a single GPU,
mostly on photographs and classical art. Its denoiser has 2.1 billion
parameters. It reads natural-language prompts and structured JSON layout
prompts.

A generation has three stages:

```text
prompt
  -> T5Gemma 2 encoder (12 layers, three hidden-state taps)
  -> projection to width 2304, learned suffix tokens
  -> denoiser: 2 text-refiner blocks, then 30 joint text-image blocks
  -> 96-channel latent at 1/16 resolution
  -> dinac3_96 decoder
  -> RGB image
```

Text and image tokens share one stream of joint attention. The middle of the
network is trained mostly on all tokens, a variant of SPRINT described under
[Dense SPRINT](#dense-sprint).

## Flow matching

Let \\(x_0\\) be a clean image latent and \\(\varepsilon \sim \mathcal{N}(0, I)\\)
Gaussian noise. The model is trained on the linear path

$$
x_t = (1-t)\,x_0 + t\,\varepsilon, \qquad t \in [0,1],
$$

so \\(t=0\\) is data and \\(t=1\\) is pure noise. The velocity along this path is
constant,

$$
\frac{\mathrm{d}x_t}{\mathrm{d}t} = \varepsilon - x_0,
$$

and the network \\(v_\theta\\) predicts it directly. Given a prediction
\\(v\\) at \\((x_t, t)\\), the clean estimate is \\(\hat{x}_0 = x_t - t\,v\\), and an
Euler step towards data is \\(x_{t-h} = x_t - h\,v\\).

Noise levels are compared through the log signal-to-noise ratio
\\(\lambda(t) = 2\ln\frac{1-t}{t}\\). Adding a shift \\(s\\) to \\(\lambda\\) moves a
time \\(t\\) to

$$
t' = \sigma\!\left(\operatorname{logit}(t) - \tfrac{s}{2}\right),
$$

where \\(\sigma\\) is the logistic function. A negative shift moves times towards
the noisy end. Larger images need more noise to hide the same structure, so both
training and sampling use a shift that depends on the image size:

$$
s(A) = \min\!\left(0,\; -0.25 - \ln\frac{A}{256^2}\right),
$$

where \\(A\\) is the number of pixels in the image. For an 832×1216 image
this gives \\(s = -2.99\\).

| Symbol | Meaning |
| --- | --- |
| \\(x_0\\) | Clean dinac3_96 latent of an image |
| \\(\varepsilon\\) | Standard Gaussian noise with the shape of \\(x_0\\) |
| \\(t\\) | Flow time; 0 is data, 1 is noise |
| \\(x_t\\) | Noised latent on the linear path |
| \\(v_\theta\\) | The denoiser; it outputs a velocity |
| \\(\hat{x}_0\\) | Clean estimate \\(x_t - t\,v\\) |
| \\(\lambda(t)\\) | Log signal-to-noise ratio at time \\(t\\) |
| \\(s\\) | Additive shift on \\(\lambda\\) |
| \\(A\\) | Number of pixels in the image, width times height |

## Latent space

The denoiser works in the latent space of
[dinac3_96](https://huggingface.co/data-archetype/dinac3_96), our own
deterministic autoencoder. Its latent has 96 channels at a spatial stride of 16
pixels: 64 unconstrained channels that carry detail and 32 channels aligned
with DINOv3 features. Its own report describes the autoencoder and its
measurements.

The denoiser uses a patch size of 1: each latent cell is one image token. An
832×1216 image is a 52×76 grid, or 3,952 image tokens. Image width and height
must be multiples of 16.

## Text conditioning

### Encoder and taps

Google's T5Gemma 2 270M-270M is an encoder-decoder language model; dflow_2b
uses its encoder, frozen, and leaves out the decoder. The encoder's hidden width
is 640. Only layers 1 to 12 run. Hidden states are read
after layers 2, 6 and 12, so that the denoiser sees features from early layers,
which stay close to the tokens and their spelling, together with later, more
contextual ones.

Gemma hidden states contain a few channels with very large activations. Each
tap is therefore standardised per channel with fixed means and standard
deviations, computed once on 20,000 training captions. The three standardised
taps pass through three bias-free linear maps from 640 to 2304 channels and the
results are summed:

$$
e_i = \sum_{k \in \{2,6,12\}} P_k \,\frac{h^{(k)}_i - \operatorname{mean}_k}{\operatorname{std}_k},
$$

where \\(h^{(k)}_i\\) is the hidden state of token \\(i\\) after layer \\(k\\),
\\(\operatorname{mean}_k\\) and \\(\operatorname{std}_k\\) are the per-channel
statistics of that tap, the division is per channel, and \\(P_k\\) is the tap's
linear map.

### Learned tokens

Three learned tokens are appended to every prompt, so every caption ends with
the same three text positions whatever its length.

The null text used for classifier-free guidance is also learned: one
unconditional token followed by the same three suffix tokens, four tokens in
all. An empty prompt maps to this sequence.

### Tokenisation of visible text

Text that should appear in the image is tokenised one character at a time, so
each character of the string is its own token and the spelling is explicit in
the token sequence. LongCat-Image uses the same technique. In a plain prompt
this applies to every double-quoted span, quote marks included. In a JSON layout
prompt it applies to the value of every `"text"` field and to escaped-quote
spans inside other strings. Everything else uses the standard tokeniser.

Prompts can be up to 6,144 tokens long, the longest caption length used in
training. Longer prompts raise an error.

## Denoiser

### One stream for text and image

Each sample is a single sequence made of its image tokens and its text tokens.
Every layer applies self-attention over the whole sequence, so image tokens read
the text and each other in the same operation, and text tokens are updated along
with the image.

The projected text first passes through two text-only refiner blocks. These
blocks see only the text, so their output is computed once per prompt and
reused at every sampling step and by every guidance pass. The image latent is
embedded by a 1×1 convolution from 96 to 2304 channels.

All blocks have width 2304 and 18 attention heads of 128 channels.

### Position encoding

Position enters through 3D rotary position embeddings (3D RoPE) in attention.
Each token has a position on three axes, one for sequence order and two spatial
ones, and each head splits its 128 channels over the axes as 32, 48 and 48,
with frequency base 10,000.

For a prompt of \\(L\\) tokens and an image grid of \\(n_y\\) rows and \\(n_x\\)
columns of tokens:

- text token \\(i\\), counted from 1, sits at \\((i, 0, 0)\\);
- the image token in row \\(i_y\\) and column \\(i_x\\), both counted from 0, sits
  at \\(\left(L+1,\; i_y - \tfrac{n_y-1}{2},\; i_x - \tfrac{n_x-1}{2}\right)\\).

The first axis orders the text and places the whole image one step after it.
This 3D layout follows modern single-stream image transformers such as
Z-Image. Following MOSS-Image, the spatial axes are also centred on the image
centre, so text tokens, at spatial position 0, sit at the centre of the image at
every size and aspect ratio, and the largest spatial offset between a text token
and an image token is half the grid. Attention between image tokens is unchanged
by the centring because RoPE depends only on position differences.

### Timestep conditioning

The timestep is embedded as 256 sinusoidal features of \\(1000\,t\\), followed by
a two-layer MLP with a hidden width of 1024 and an output \\(\tau(t)\\) of
width 256.

Every image block has its own linear projector from
\\(\operatorname{SiLU}(\tau(t))\\) to four vectors of width 2304: a scale and a gate
for attention, and a scale and a gate for the MLP. The time embedding is narrow
because a timestep is a single scalar: measured in model ablations, the per-layer modulation
signals occupied at most 14 dimensions at 99.99% of their energy.
With a 256-wide input, an unshared dense projector per layer costs 2.4M
parameters, 71M over the 30 layers.

### Block

Each block is a standard pre-norm transformer block with shift-free AdaLN
modulation and sandwich normalisation: an RMSNorm before and after both the
attention and the MLP branch. The modulation is a scale on the pre-norm output
and a tanh gate on the branch output:

$$
z \leftarrow z + \tanh(\rho_{\mathrm{att}})\odot N_2\!\left(\operatorname{Attn}\!\left((1+\alpha_{\mathrm{att}})\odot N_1(z)\right)\right),
$$

$$
z \leftarrow z + \tanh(\rho_{\mathrm{mlp}})\odot N_4\!\left(\operatorname{MLP}\!\left((1+\alpha_{\mathrm{mlp}})\odot N_3(z)\right)\right),
$$

where \\(z\\) is the token stream, \\(N_1\\) to \\(N_4\\) are RMSNorms with learned
weights, and \\(\alpha\\) and \\(\rho\\) are the layer's scales and gates from its
AdaLN projector. The modulation applies to every token in the stream, text
included. The two text-refiner blocks are the same block without modulation.

- **Attention:** fused bias-free QKV projection, RMSNorm on each head's queries
  and keys, 3D RoPE, scaled dot-product attention, bias-free output projection.
- **MLP:** GELU, expansion ratio 4, with biases.
- **Output:** after the last block the image tokens pass through an RMSNorm, a
  timestep scale and shift, and a linear head from 2304 to 96 channels that
  predicts the velocity. The text tokens are dropped.

## SPRINT and path-drop guidance

The 30 image blocks are organised as in SPRINT (Park et al.).
[Dense SPRINT](#dense-sprint) describes what dflow_2b changes.

### Sparse middle

SPRINT splits a diffusion transformer into three parts. A short **prefix** runs
on every token. A long **middle** runs on a random subset: in the published
method 75% of the image tokens are dropped before the middle. A
short **suffix** again runs on every token. Between the middle and the suffix, a
**tail join** fuses the prefix output with the middle output, with a learned mask
token standing in at positions the middle did not process.

Most of the network's depth runs on a quarter of the tokens, which cuts
training cost. At inference the middle runs on all tokens. To close this gap
between training and inference, SPRINT finishes with a short fine-tuning stage
on all tokens.

### Path drop

For a fraction of the training samples the whole middle is skipped. The tail
join then receives the mask token at every position, and the output comes from
the prefix and suffix alone. This is called path drop. It trains a second,
shallower predictor inside the same weights.

### Path-drop guidance

Path-drop guidance (PDG) uses that shallow predictor as a guidance reference at
sampling time. Write \\(v_{\mathrm{full}}\\) for the prediction with every layer
and \\(v_{\mathrm{weak}}\\) for the prediction of the same network, same input and
same prompt, with the middle skipped. The guided velocity is

$$
v_{\mathrm{PDG}}
= v_{\mathrm{weak}} + w\left(v_{\mathrm{full}} - v_{\mathrm{weak}}\right),
$$

with scale \\(w \ge 1\\). Like autoguidance (Karras et al.), this extrapolates away
from a weaker version of the model itself, so it pushes along whatever the
skipped layers contribute. Both passes see the same prompt (the default weak
pass reads it with a [bias](#suffix-caption-bias)), so PDG works from the
prompt alone. The weak pass is cheap: in dflow_2b it runs 12 of the 30 image
blocks.

## Dense SPRINT

### What changed

dflow_2b keeps SPRINT's structure and its three routes through the middle, and
changes how often each is trained and how deep the outer parts are.

The layout is 6 prefix, 18 middle and 6 suffix blocks. Each training sample
takes one of three routes:

| Share of samples | Route | Middle runs on |
| ---: | --- | --- |
| 80% | Dense | every image and text token |
| 10% | Path drop | nothing; the middle is skipped |
| 10% | Three-quarter drop | one image token of each 2×2 group, chosen at random, and every text token |

A sparse mix trains most samples on the three-quarter route, for example 10%
dense, 10% path drop and 80% three-quarter drop. Here the middle is trained
mostly on full token grids from the first step. We call this arrangement dense
SPRINT.

Counting a block on all image tokens as 1 and a block on a quarter of them as
0.25, an average training sample costs about
\\(12 + 18\,(0.8 + 0.1\cdot 0.25) = 26.9\\) block evaluations. The sparse mix
above costs 17.4 on the same layout, and a network that runs every block on
every token costs 30. Dense SPRINT saves about 10% of the training compute and
that sparse mix about 40%.

### The tail join

Let \\(p\\) be the prefix output and \\(m\\) the middle output, both of width
\\(D = 2304\\). At rows the middle skipped, \\(m\\) is replaced by a learned mask
token \\(\mu\\); call the result \\(\tilde{m}\\). The join scales the two streams by
time-dependent gains, concatenates them and projects back to width \\(D\\). Rows
the middle skipped also receive a separate projection of the prefix stream:

$$
z = W\left[\,(1+\gamma_p(t))\odot p \;;\; (1+\gamma_m(t))\odot \tilde{m}\,\right]
  + b + \chi\,R\left((1+\gamma_p(t))\odot p\right),
$$

where \\([\,\cdot\;;\;\cdot\,]\\) is concatenation along the channel axis.

| Symbol | Meaning |
| --- | --- |
| \\(p\\) | Prefix output for one token |
| \\(z\\) | Token entering the suffix |
| \\(\tilde{m}\\) | Middle output for that token, or the mask token \\(\mu\\) if the middle skipped it |
| \\(\gamma_p(t), \gamma_m(t)\\) | Gains of width \\(D\\) each, a linear function of \\(\operatorname{SiLU}(\tau(t))\\) |
| \\(W, b\\) | Projection from \\(2D\\) to \\(D\\) and its bias |
| \\(R\\) | Bias-free \\(D \times D\\) projection for skipped rows |
| \\(\chi\\) | 1 if the middle skipped the token, 0 otherwise |

Under path drop every row has \\(\chi = 1\\). Under the three-quarter route the
dropped image tokens have \\(\chi = 1\\) and the kept tokens and the text have
\\(\chi = 0\\). The extra projection \\(R\\) gives skipped rows weights of their own
for the prefix stream, and the time-dependent gains let the balance between the
two streams vary along the trajectory. In ablations against the plain
concatenation join of the original SPRINT, both gave a consistent improvement.

### Why train the middle dense

Sparse SPRINT gives good coherence and textures but struggles to place fine
detail and text precisely. Good detail never converges at low resolution and
still lags at high resolution. Training the middle mostly on all tokens
corrects this.

The two sparse routes stay in the mix for different reasons. The 10% path-drop
route trains the weak predictor of path-drop guidance, which works like
guidance by a weaker model and gives much better results than CFG. The 10%
three-quarter route acts as a regulariser and improves coherence and
convergence.

The weak predictor needs enough depth to be a useful guidance reference. The 2
to 4 outer blocks of the original SPRINT proved too few, and in ablations a weak
path of about a third of the main path's depth was the best compromise. dflow_2b
therefore has 6 prefix and 6 suffix blocks, 12 of its 30.

One drawback is that on the high-noise part of the trajectory, with \\(t\\) close
to 1, the full and path-drop predictions largely agree. This gives more
oversaturation than sparse SPRINT, which the
[self-attention gain](#self-attention-gain), a small increase of the attention
temperature, mitigates. Sparse SPRINT has much of the same issue and also
benefits from this softening.

### Alternatives that were tried

Two layouts that mix sparse and dense blocks inside the middle were tested in
small-scale experiments: one alternating two sparse blocks with one dense
block, and one with eight sparse blocks, a second join and four dense blocks.
Neither improved on the uniform middle that dflow_2b uses.

## Architecture summary

| Component | Setting |
| --- | --- |
| Latent | dinac3_96, 96 channels, stride 16, patch size 1 |
| Text encoder | T5Gemma 2 270M-270M encoder, layers 1–12, frozen |
| Text taps | After layers 2, 6 and 12, standardised per channel, three linear maps 640 → 2304, summed |
| Learned text tokens | 3 suffix tokens; 1 unconditional token for the null text |
| Maximum prompt length | 6,144 tokens |
| Width, heads | 2304; 18 heads of 128 |
| Text refiner | 2 blocks, text only, no timestep modulation |
| Image blocks | 30: 6 prefix, 18 middle, 6 suffix, joint self-attention over text and image |
| Attention | RMSNorm on queries and keys, bias-free projections |
| MLP | GELU, expansion ratio 4 |
| Position encoding | Centred 3D RoPE, 32/48/48 channels per head, base 10,000 |
| Timestep conditioning | 256-wide embedding; one projector per block to attention and MLP scales and gates |
| Tail join | Concatenation with time-dependent gains, mask token, separate prefix projection for skipped rows |
| Prediction | Velocity on the linear flow-matching path |
| Parameters | 2,133,866,592 |

## Sampling and guidance

### Default preset

| Setting | Default |
| --- | --- |
| Size | 832×1216 |
| Solver | ER-SDE, noise scale 1 |
| Schedule | 50 steps at the quantiles of Beta(1.25, 1.25) |
| Timestep shift | \\(s(A)\\), the training shift; −2.99 at 832×1216 |
| Guidance | PDG, constant scale 2.5, reference conditioned on the prompt with a −4 caption bias in its six suffix blocks |
| Classifier-free guidance | Off |
| Self-attention gain | −0.03 on the full pass, 0 on the reference pass |

The schedule places its 51 time points at equal-probability quantiles of a
Beta(1.25, 1.25) distribution, which is slightly denser in the middle of the
trajectory than a uniform grid, and then applies the shift \\(s(A)\\) from
[Flow matching](#flow-matching). Using the training shift at sampling time
means the sampler spends its steps where training placed its timesteps for that
image size.

ER-SDE (Cui et al.) is a stochastic solver for the reverse-time SDE; the release
uses its three-stage form. A noise scale of 1 is the solver's own noise level
and 0 makes it deterministic. The package also includes Euler, Euler–Maruyama,
DPM++ 2M, DPM++ 2M SDE and a two-stage Adams–Bashforth–Moulton solver.

Each step runs the full pass and the weak pass, so 50 steps are 100 denoiser
calls, of which the 50 weak calls run 12 of 30 blocks.

### Guidance formulas

With the prompt \\(c\\), scale \\(w\\), gain \\(g\\) and caption bias \\(b\\) defined below, the
default guided velocity is

$$
v = v_{\mathrm{weak}}(x_t, t, c;\, b)
  + w\left(v_{\mathrm{full}}(x_t, t, c;\, g) - v_{\mathrm{weak}}(x_t, t, c;\, b)\right),
\qquad w = 2.5,\; b = -4 .
$$

| Symbol | Meaning |
| --- | --- |
| \\(c\\) | Text conditioning of the prompt |
| \\(v_{\mathrm{full}}\\) | Prediction with all 30 image blocks |
| \\(v_{\mathrm{weak}}\\) | Prediction with the 18 middle blocks skipped |
| \\(w\\) | PDG scale; 1 is no guidance |
| \\(g\\) | Self-attention gain of the full pass |
| \\(b\\) | Caption bias of the weak pass, described under [Suffix caption bias](#suffix-caption-bias) |

### Self-attention gain

The gain \\(g\\) multiplies the queries of the 30 image blocks by \\(e^{g}\\) after
the query-key normalisation and RoPE. This divides every attention logit by a
temperature \\(e^{-g}\\), so a negative gain makes attention slightly more
diffuse.

The gain is applied to the full pass only. With \\(\delta\\) the change it makes to
the full prediction, PDG becomes

$$
v = v_{\mathrm{weak}} + w\left(v_{\mathrm{full}} - v_{\mathrm{weak}}\right) + w\,\delta ,
$$

so a small softening of the full pass reaches the output multiplied by the
guidance scale. The weak pass runs without the gain: the same change in both
passes would largely cancel in their difference. The gain counters the over-contrast and oversaturation that PDG adds, described
under [Why train the middle dense](#why-train-the-middle-dense), and reduces
structural errors with it.

The default of −0.03 suits images up to about one megapixel. Larger images need
a gain closer to 0, roughly linear in the logarithm of the area:

| Image area | Example sizes | Gain |
| --- | --- | --- |
| up to about 1.05 MP | 832×1216, 1216×832, 1024×1024 | −0.03 (default) |
| about 1.3 MP | 1536×832, 1216×1088 | −0.02 |
| about 1.6 MP | 1024×1536 | −0.015 |
| about 2.5 MP and above | 1280×1920 | 0 to −0.01 |

At about one megapixel, a gain closer to 0 gives oversaturation and more
structural defects. At larger sizes, too negative a gain gives washed-out
images.

### Suffix caption bias

By default the weak pass reads the prompt less in its six suffix blocks. In
those blocks every query, image or text, has a constant \\(b = -4\\) added to its
attention logits on the prompt's tokens:

$$
\ell_{ij} = \frac{q_i \cdot k_j}{\sqrt{d}} + b\,\chi_j .
$$

| Symbol | Meaning |
| --- | --- |
| \\(\ell_{ij}\\) | Attention logit of query \\(i\\) on key \\(j\\) |
| \\(q_i, k_j\\) | Normalised, rotated query and key of one head |
| \\(d\\) | Head width, 128 |
| \\(\chi_j\\) | 1 for a prompt token; 0 for image tokens and the three learned suffix tokens |

The bias applies on every step, to whichever text the weak pass reads: the
prompt in the default mode, the negative prompt or the null text in the
contrastive modes. The full pass and the CFG passes are unchanged. Because the
reference sees less of the prompt, more of the prompt's effect stays in
\\(v_{\mathrm{full}} - v_{\mathrm{weak}}\\) and is amplified by the guidance
scale. Prompt following improves, and colour and layout stay close to plain
PDG.

We also tried biasing the learned suffix tokens, biasing every block or only
part of the run, other bias strengths, contrastive and alternating references,
frequency-split guidance, CFG with skipped layers and projected guidance. In
blind side-by-side comparisons on 18 prompts with the released weights, the
biased reference was preferred on 16, with fewer anatomy errors and missed
prompt elements.

### Other guidance options

Contrastive PDG conditions the weak pass on a negative prompt, or on the
learned null text. It gives stronger guidance and less diversity, and we
generally prefer plain PDG. The [manual](MANUAL.md#guidance) describes it with
classifier-free guidance, scale ramps and curves, projected guidance and the
other options.

## Prompt emphasis

A phrase can be weighted with the markup `(phrase:weight)`. The weight
\\(\omega\\) is applied inside attention, with a global strength \\(\kappa\\) that
defaults to 1. For \\(\omega > 0\\), a bias is added to the attention logits of
every query towards the keys of the weighted tokens. The bias is
\\(\kappa \ln \omega\\) in the logarithmic mapping, which at \\(\kappa = 1\\)
multiplies those tokens' unnormalised attention weight by \\(\omega\\), or
\\(2\kappa(\omega - 1)\\) in the linear mapping. For \\(\omega \le 0\\), the tokens'
attention values are multiplied by \\(1 + \kappa(\omega - 1)\\), so 0 mutes them
and −1 subtracts them. The bias and scale apply in the text refiner and in all
30 image blocks, and optionally inside the text encoder's own attention.
Emphasis works on plain-text prompts only. A JSON layout is encoded exactly as
written, so parentheses and colons in its captions and text stay literal and
carry no weight.

## JSON layout prompts

The model was also trained on structured captions that describe an image as a
set of boxes. About 10% of the samples in the most recent training used one as
their caption.

A layout is a JSON object with three parts:

- `summary`: a list of `meta` tags, the `canvas` type and a `caption` of the
  whole image;
- `frame`: a `caption`, `tags` and a colour `palette` for the canvas as a whole;
- `items`: a list of boxes. Each has a `label` (`character`, `object` or
  `text`), an optional `caption`, `tags` and `palette`, and a box
  `box_2d = [y0, x0, y1, x1]` on a 0–1000 scale. Text items also carry the exact
  `text` to render.

The optional fields were dropped at random during training, so they can be
omitted.

Before encoding, a layout is compiled for the image size: the frame becomes a
first item covering the whole canvas, and every box is converted to pixels
measured from the image centre, the same origin as the denoiser's position
encoding. The compiled format follows the layout prompts of MOSS-Image. The
[manual](MANUAL.md#json-layouts) gives the format field by field and the
compilation rules.

## Training

### Objective

Each training sample draws a noise \\(\varepsilon\\), a time \\(t\\), a route \\(r\\)
through the middle and a possibly dropped caption \\(\tilde{c}\\), and contributes
a squared velocity error:

$$
\mathcal{L}
= \mathbb{E}_{x_0,\,\varepsilon,\,t,\,r,\,\tilde{c}}
  \left\lVert v_\theta(x_t, t, \tilde{c};\, r) - (\varepsilon - x_0) \right\rVert_2^2 .
$$

| Symbol | Sampling |
| --- | --- |
| \\(t\\) | Beta(2, 2), then log-SNR shifted by \\(s(A) = \min\left(0,\, -0.25 - \ln\frac{A}{256^2}\right)\\) for the sample's pixel area \\(A\\): −0.25 at 256×256, −1.64 at 512×512, −2.99 at 832×1216 ([flow matching](#flow-matching)). 1% of samples are set to \\(t = 1\\) |
| \\(r\\) | Dense with probability 0.8, path drop 0.1, three-quarter drop 0.1 |
| \\(\tilde{c}\\) | The caption, replaced by the learned null text with probability 0.1 |

Every sample is one forward pass on one route, and the loss above is the whole
objective.

### Optimisation

| Setting | Value |
| --- | --- |
| Optimiser | Dion ([dionw](https://github.com/JTriggerFish/dionw) implementation) on the large weight matrices, AdamW on the remaining parameters |
| Learning rate | \\(5 \times 10^{-5}\\), linear warmup over 4,000 steps, then constant |
| AdamW betas | (0.9, 0.95) |
| Weight decay | 0.01 |
| Gradient clipping | Norm 1.0 |
| Batch size | 128, with gradient accumulation |
| Precision | bfloat16 autocast |
| EMA | Updated every 10 steps; half-life 4,000 steps, 2,000 from step 400,000 |
| Hardware | One GH200 |

At 512 px a batch is accumulated over 4 micro-batches. At 1024 px it is
accumulated over 16, or over 24 when the batch contains very long captions.

For an EMA half-life of \\(T\\) steps and an update every 10 steps, each update
uses the decay \\(2^{-10/T}\\).

### Resolution stages

Training uses aspect-ratio buckets: each nominal resolution is a family of
landscape, square and portrait shapes of similar area, and every batch holds
images of one shape.

| Stage | Steps | Training images |
| --- | --- | ---: |
| 256 and 384 px buckets | 0 – 400,000 | about 21 million |
| 512 px buckets, with 10% of batches at 1024 px | 400,000 – 540,412 | about 20 million |
| 1024 px buckets | from 540,412 | about 10 million |

Structured layout captions were introduced in the 1024 px stage and make up
about 10% of its recent samples.

The released weights are the average, with equal weights, of the EMAs at steps
593,000 and 594,000.

## Limitations

- This is a preview of a model that is still training. Quality varies between
  prompts and seeds, and later checkpoints will behave differently.
- Anatomy errors are common, in limbs and hands especially.
- Small text and long passages of text are unreliable.
- The model was trained on aspect-ratio buckets of about one megapixel. It is
  less reliable at sizes far from those shapes and well above one megapixel. The
  default guidance settings were tuned at 832×1216; larger images need a
  self-attention gain closer to 0.
- The training data is mostly photographs and classical art, and other styles
  are covered less well.
- A compiled layout prompt is valid for one image size only.

## References

### Flow matching

Lipman et al., “Flow Matching for Generative Modeling,” ICLR 2023.
[arXiv:2210.02747](https://arxiv.org/abs/2210.02747).

Liu et al., “Flow Straight and Fast: Learning to Generate and Transfer Data with
Rectified Flow,” ICLR 2023.
[arXiv:2209.03003](https://arxiv.org/abs/2209.03003).

### SPRINT and path-drop guidance

Park et al., “Sprint: Sparse-Dense Residual Fusion for Efficient Diffusion
Transformers,” 2025. [arXiv:2510.21986](https://arxiv.org/abs/2510.21986).
Path-drop guidance is introduced in the same paper.

### Autoguidance

Karras et al., “Guiding a Diffusion Model with a Bad Version of Itself,”
NeurIPS 2024. [arXiv:2406.02507](https://arxiv.org/abs/2406.02507).

### Classifier-free guidance

Ho and Salimans, “Classifier-Free Diffusion Guidance,” 2022.
[arXiv:2207.12598](https://arxiv.org/abs/2207.12598).

### Adaptive projected guidance

Sadat et al., “Eliminating Oversaturation and Artifacts of High Guidance Scales
in Diffusion Models,” ICLR 2025.
[arXiv:2410.02416](https://arxiv.org/abs/2410.02416).

### ER-SDE

Cui et al., “Elucidating the Solution Space of Extended Reverse-Time SDE for
Diffusion Models,” 2023. [arXiv:2309.06169](https://arxiv.org/abs/2309.06169).

### Rotary position embedding

Su et al., “RoFormer: Enhanced Transformer with Rotary Position Embedding,”
2021. [arXiv:2104.09864](https://arxiv.org/abs/2104.09864).

### Z-Image

Z-Image Team, “Z-Image: An Efficient Image Generation Foundation Model with
Single-Stream Diffusion Transformer,” 2025.
[arXiv:2511.22699](https://arxiv.org/abs/2511.22699).

### T5Gemma 2

Zhang et al., “T5Gemma 2: Seeing, Reading, and Understanding Longer,” 2025.
[arXiv:2512.14856](https://arxiv.org/abs/2512.14856).
[Model card](https://huggingface.co/google/t5gemma-2-270m-270m).

### LongCat-Image

Meituan LongCat Team, “LongCat-Image Technical Report,” 2025.
[arXiv:2512.07584](https://arxiv.org/abs/2512.07584).

### DINOv3 and dinac3_96

Siméoni et al., “DINOv3,” 2025.
[arXiv:2508.10104](https://arxiv.org/abs/2508.10104).

data-archetype, “dinac3_96,” 2026.
[Model and technical report](https://huggingface.co/data-archetype/dinac3_96).

### Dion

Ahn et al., “Dion: Distributed Orthonormalized Updates,” 2025.
[arXiv:2504.05295](https://arxiv.org/abs/2504.05295).

Our implementation, used for training:
[github.com/JTriggerFish/dionw](https://github.com/JTriggerFish/dionw).

### AdamW

Loshchilov and Hutter, “Decoupled Weight Decay Regularization,” ICLR 2019.
[arXiv:1711.05101](https://arxiv.org/abs/1711.05101).

### MOSS-Image

MOSI.AI, “MOSS-Image Technical Report,” 2026.
[arXiv:2610.23374](https://arxiv.org/abs/2610.23374).