Download TECHNICAL_REPORT.md from data-archetype/dflow_2b: direct link, hf CLI and curl.
- Browser
- Download file 30 kB
-
https://huggingface.co/data-archetype/dflow_2b/resolve/main/TECHNICAL_REPORT.md
- Command line
-
hf download hf://data-archetype/dflow_2b/TECHNICAL_REPORT.md
-
curl -L -o TECHNICAL_REPORT.md https://huggingface.co/data-archetype/dflow_2b/resolve/main/TECHNICAL_REPORT.md
dflow_2b Technical Report
Model card · Manual · Example gallery · Release notes
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:
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.
Flow matching
Let be a clean image latent and Gaussian noise. The model is trained on the linear path
so is data and is pure noise. The velocity along this path is constant,
and the network predicts it directly. Given a prediction at , the clean estimate is , and an Euler step towards data is .
Noise levels are compared through the log signal-to-noise ratio . Adding a shift to moves a time to
where 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:
where is the number of pixels in the image. For an 832×1216 image this gives .
| Symbol | Meaning |
|---|---|
| Clean dinac3_96 latent of an image | |
| Standard Gaussian noise with the shape of | |
| Flow time; 0 is data, 1 is noise | |
| Noised latent on the linear path | |
| The denoiser; it outputs a velocity | |
| Clean estimate | |
| Log signal-to-noise ratio at time | |
| Additive shift on | |
| Number of pixels in the image, width times height |
Latent space
The denoiser works in the latent space of 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:
where is the hidden state of token after layer , and are the per-channel statistics of that tap, the division is per channel, and 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 tokens and an image grid of rows and columns of tokens:
- text token , counted from 1, sits at ;
- the image token in row and column , both counted from 0, sits at .
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 , followed by a two-layer MLP with a hidden width of 1024 and an output of width 256.
Every image block has its own linear projector from 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:
where is the token stream, to are RMSNorms with learned weights, and and 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 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 for the prediction with every layer and for the prediction of the same network, same input and same prompt, with the middle skipped. The guided velocity is
with scale . 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), 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 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 be the prefix output and the middle output, both of width . At rows the middle skipped, is replaced by a learned mask token ; call the result . The join scales the two streams by time-dependent gains, concatenates them and projects back to width . Rows the middle skipped also receive a separate projection of the prefix stream:
where is concatenation along the channel axis.
| Symbol | Meaning |
|---|---|
| Prefix output for one token | |
| Token entering the suffix | |
| Middle output for that token, or the mask token if the middle skipped it | |
| Gains of width each, a linear function of | |
| Projection from to and its bias | |
| Bias-free projection for skipped rows | |
| 1 if the middle skipped the token, 0 otherwise |
Under path drop every row has . Under the three-quarter route the dropped image tokens have and the kept tokens and the text have . The extra projection 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 close to 1, the full and path-drop predictions largely agree. This gives more oversaturation than sparse SPRINT, which the 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 | , 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 from 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 , scale , gain and caption bias defined below, the default guided velocity is
| Symbol | Meaning |
|---|---|
| Text conditioning of the prompt | |
| Prediction with all 30 image blocks | |
| Prediction with the 18 middle blocks skipped | |
| PDG scale; 1 is no guidance | |
| Self-attention gain of the full pass | |
| Caption bias of the weak pass, described under Suffix caption bias |
Self-attention gain
The gain multiplies the queries of the 30 image blocks by after the query-key normalisation and RoPE. This divides every attention logit by a temperature , so a negative gain makes attention slightly more diffuse.
The gain is applied to the full pass only. With the change it makes to the full prediction, PDG becomes
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, 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 added to its attention logits on the prompt's tokens:
| Symbol | Meaning |
|---|---|
| Attention logit of query on key | |
| Normalised, rotated query and key of one head | |
| Head width, 128 | |
| 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 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 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 is applied inside attention, with a global strength that
defaults to 1. For , a bias is added to the attention logits of
every query towards the keys of the weighted tokens. The bias is in the logarithmic mapping, which at
multiplies those tokens' unnormalised attention weight by , or in the linear mapping. For , the tokens'
attention values are multiplied by , 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 ofmetatags, thecanvastype and acaptionof the whole image;frame: acaption,tagsand a colourpalettefor the canvas as a whole;items: a list of boxes. Each has alabel(character,objectortext), an optionalcaption,tagsandpalette, and a boxbox_2d = [y0, x0, y1, x1]on a 0–1000 scale. Text items also carry the exacttextto 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 gives the format field by field and the compilation rules.
Training
Objective
Each training sample draws a noise , a time , a route through the middle and a possibly dropped caption , and contributes a squared velocity error:
| Symbol | Sampling |
|---|---|
| Beta(2, 2), then log-SNR shifted by for the sample's pixel area : −0.25 at 256×256, −1.64 at 512×512, −2.99 at 832×1216 (flow matching). 1% of samples are set to | |
| Dense with probability 0.8, path drop 0.1, three-quarter drop 0.1 | |
| 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 implementation) on the large weight matrices, AdamW on the remaining parameters |
| Learning rate | , 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 steps and an update every 10 steps, each update uses the decay .
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.
Liu et al., “Flow Straight and Fast: Learning to Generate and Transfer Data with Rectified Flow,” ICLR 2023. arXiv:2209.03003.
SPRINT and path-drop guidance
Park et al., “Sprint: Sparse-Dense Residual Fusion for Efficient Diffusion Transformers,” 2025. arXiv: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.
Classifier-free guidance
Ho and Salimans, “Classifier-Free Diffusion Guidance,” 2022. arXiv:2207.12598.
Adaptive projected guidance
Sadat et al., “Eliminating Oversaturation and Artifacts of High Guidance Scales in Diffusion Models,” ICLR 2025. arXiv:2410.02416.
ER-SDE
Cui et al., “Elucidating the Solution Space of Extended Reverse-Time SDE for Diffusion Models,” 2023. arXiv:2309.06169.
Rotary position embedding
Su et al., “RoFormer: Enhanced Transformer with Rotary Position Embedding,” 2021. arXiv:2104.09864.
Z-Image
Z-Image Team, “Z-Image: An Efficient Image Generation Foundation Model with Single-Stream Diffusion Transformer,” 2025. arXiv:2511.22699.
T5Gemma 2
Zhang et al., “T5Gemma 2: Seeing, Reading, and Understanding Longer,” 2025. arXiv:2512.14856. Model card.
LongCat-Image
Meituan LongCat Team, “LongCat-Image Technical Report,” 2025. arXiv:2512.07584.
DINOv3 and dinac3_96
Siméoni et al., “DINOv3,” 2025. arXiv:2508.10104.
data-archetype, “dinac3_96,” 2026. Model and technical report.
Dion
Ahn et al., “Dion: Distributed Orthonormalized Updates,” 2025. arXiv:2504.05295.
Our implementation, used for training: github.com/JTriggerFish/dionw.
AdamW
Loshchilov and Hutter, “Decoupled Weight Decay Regularization,” ICLR 2019. arXiv:1711.05101.
MOSS-Image
MOSI.AI, “MOSS-Image Technical Report,” 2026. arXiv:2610.23374.