What Sana is
Sana (Xie et al.) is a text-to-image diffusion transformer built to be cheap at high resolution. Attention over tokens costs , and a 4096 px image in Stable Diffusion's latent space would be tens of thousands of tokens. Sana cuts both factors: an autoencoder that compresses 32 times per side instead of 8 gives far fewer tokens, and linear attention makes each token's cost independent of how many there are. It also replaces T5 with a small decoder-only language model and samples with a flow-matching solver. The paper reports that Sana-0.6B is 20 times smaller than FLUX-12B and over 100 times faster in measured throughput.
This tab records Sana 600M at 512 px drawing the PixArt tab's prompt, A small cactus with a happy face in the Sahara desert., with 20 steps, guidance 4.5 and seed 0. The transformer has 592 M parameters in 28 blocks of width 1152; block 1 is drawn in full at , 785 and 345.
A 32× autoencoder
The Autoencoder card is DC-AE f32c32 (Chen et al.), 312 M parameters: 32 latent channels at 1/32 of the image's side. A 512 px image becomes a 32 × 16 × 16 latent, 8,192 numbers, where Stable Diffusion's VAE gives 4 × 64 × 64 = 16,384. More important for the transformer, the grid is only 16 × 16, so Sana needs no patching: each latent pixel is one token, 256 tokens in all, against the 1,024 patches PixArt-α makes from the same image.
High spatial compression usually hurts reconstruction. DC-AE makes it work with residual autoencoding, in which each downsampling stage also passes its input through a space-to-channel rearrangement as a shortcut, so the network only learns a residual, and with a separate high-resolution adaptation phase in training.
Linear attention
Softmax attention makes every score positive with and normalises each row; the matrix of scores must be formed. Linear attention (Katharopoulos et al.) makes the scores positive with a feature map instead, here a ReLU as in EfficientViT, and normalises by the row sum:
Because the dot product is linear, the sum over keys can be done once: is a state per head, and the cost is proportional to instead of . Sana's blocks have 36 heads of 32, so each head's state is 32 × 32. The Linear Attention panel draws the matrix that this computation equals, for six tokens, beside the state the model actually computes; the rows still sum to 1 over all 256 tokens. Without the exponential nothing sharpens large scores against small ones, so linear attention spreads its weight more evenly than softmax attention tends to.
Cross-attention, Mix-FFN and no position embedding
Each block is PixArt-α's, with linear self-attention and a different feed-forward:
Cross-Attention to the prompt keeps the softmax, with 16 heads of 72; the prompt is short, so its cost is small. The Mix-FFN puts the tokens back on the 16 × 16 grid, expands them to channels, runs a separate 3 × 3 depthwise convolution on each channel and gates half of them with the other half:
Sana adds no position embedding to its tokens. Attention of either kind ignores token order, so the convolution, which mixes each token with its eight neighbours, is the only place a token learns where it is, the role Xie et al. first gave Mix-FFN in SegFormer.
Gemma-2 as the text encoder
The Text encoder card shows Gemma-2 2B, an instruction-tuned decoder-only language model of 26 layers, 2304 wide and 2.61 B parameters, in place of T5-XXL. Sana puts a fixed 208-token instruction before the prompt, which the paper calls a complex human instruction: it asks for the prompt to be rewritten with concrete visual detail and gives two examples. Gemma never generates the rewrite; its hidden states for the prompt tokens, which have read the instruction, are the conditioning. The mask then keeps only 14 slots, the beginning-of-sequence token and the 13 prompt tokens; the instruction is cut away, but every kept token has already read it. A caption projection maps them from 2304 to 1152.
The timestep reaches the blocks through adaLN-single, as in PixArt-α: one MLP and one shared Linear for all 28 blocks, plus each block's learned table.
Flow matching and the solver
Sana is trained by flow matching rather than noise prediction. A latent is placed on the straight line between the image and noise, and the model predicts the line's velocity:
The shift (shift 3) moves more of the 20 steps towards high noise; the timestep the blocks see is , from 999 down to 136 over the 20 steps. The Sampling loop card runs DPM-Solver++ on these flow sigmas, the paper's Flow-DPM-Solver: , then the same second-order multistep update as on the PixArt tab. Guidance mixes the velocities, .
Where Sana came from
Sana (2024) comes from authors of PixArt-α and DC-AE and combines older pieces: linear attention from Katharopoulos et al. (2020), ReLU linear attention for high-resolution vision from EfficientViT, convolutional feed-forward layers in place of position embeddings from SegFormer, and flow matching, which SD 3.5 and FLUX also use. The PixArt tab shows the softmax design it replaces; the SD 3.5 tab shows a larger flow-matching transformer with joint attention instead of cross-attention.
Papers
- SANA: Efficient High-Resolution Image Synthesis with Linear Diffusion Transformers The model this tab records: DC-AE latents, linear attention, Mix-FFN without position embedding, Gemma-2 with an instruction, and Flow-DPM-Solver.
- Deep Compression Autoencoder for Efficient High-Resolution Diffusion Models DC-AE: residual autoencoding and high-resolution adaptation for 32× and higher spatial compression.
- Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention Linear attention: a feature map in place of the softmax, and the state that makes the cost linear in sequence length.
- EfficientViT: Multi-Scale Linear Attention for High-Resolution Dense Prediction ReLU linear attention for high-resolution vision, the form Sana's blocks use.
- SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers Mix-FFN: a 3 × 3 convolution in the feed-forward layer that gives tokens their position.
- Gemma 2: Improving Open Language Models at a Practical Size The decoder-only language model whose 2B version encodes the prompt.
- Flow Matching for Generative Modeling Training a velocity field along fixed paths from noise to data, the objective Sana is trained with.
- PixArt-α: Fast Training of Diffusion Transformer for Photorealistic Text-to-Image Synthesis The cross-attention DiT with adaLN-single that Sana's blocks start from.