Blogs博客›JiT
October 2, 20262026 年 10 月 2 日

Starting from JiT's Patches从 JiT 的 patch 开始

JiT runs diffusion directly on pixels. With no VAE to shrink the image first, it keeps the token count down with large patches, so each patch holds from hundreds to over ten thousand values. It then has the network predict the clean image rather than the noise. This note starts from the arithmetic of patches and works up to that choice.

JiT 直接在像素上做 diffusion。没有 VAE 先把图压小,它用大 patch 控制 token 数,每个 patch 因此有几百到上万个数值。它让网络预测干净图像,而不是预测噪声。这篇从切 patch 的算术讲起,一直讲到这个选择。

Patch count and patch dimensionpatch 的个数和维度

The patch size sets two things: how many patches there are, and how many raw values each patch holds. Cut a $256\times256\times3$ image with patch size 16 and each side has $256/16=16$ patches, $16\times16=256$ in all, each with $16\times16\times3=768$ values. With patch size 32, each side has 8, giving 64 patches of $32\times32\times3=3072$ values.

patch size 决定两件事:patch 的个数,和每个 patch 的原始维度。一张 $256\times256\times3$ 的图按 patch size 16 切,每边 $256/16=16$ 个,一共 $16\times16=256$ 个 patch,每个有 $16\times16\times3=768$ 个数值。按 patch size 32 切,每边 8 个,一共 64 个 patch,每个有 $32\times32\times3=3072$ 个数值。

$$256\times256\times3 \;\to\; 256\times768 \ \ (p=16), \qquad 256\times256\times3 \;\to\; 64\times3072 \ \ (p=32)$$

patch size 16每边 16 个16 per side展平flatten256 × 76816×16×3 = 768256 个 patch256 patchespatch size 32每边 8 个8 per side展平flatten64 × 307232×32×3 = 307264 个 patch64 patches两种切法都是 196608 个数值:两个矩形面积相同Both cuts hold 196,608 values: the two rectangles have the same area

A larger patch size means fewer patches, each with more values. The cut itself loses nothing: $256\times768$ and $64\times3072$ are both 196,608, the same RGB values split into a different number of groups. No patch embedding has been applied yet.

patch size 变大,patch 变少,每个 patch 的维度变高。切分本身不丢信息:$256\times768$ 和 $64\times3072$ 都是 196608,只是把同样多的 RGB 数值分成不同数量的组。这里还没有经过 patch embedding。

Patch dimension and hidden dimpatch 维度和 hidden dim

The number of values in a raw patch is not the width of a token inside the Transformer. Each patch first goes through a trainable patch embedding that turns it into a Transformer input. With $N$ patches, the shape changes as

每个 patch 原本有多少维,和进入 Transformer 后每个 token 有多少维,是两回事。patch 先经过一个可训练的 patch embedding,变成 Transformer 的输入。设一共有 $N$ 个 patch,形状的变化是:

$$N\times D_{\text{raw}} \;\to\; N\times d_{\text{model}}, \qquad D_{\text{raw}} = p\times p\times 3$$

Here $d_{\text{model}}$ is the model's hidden dim, and $N$ counts image patches only, not extra condition tokens. A 3072-value patch going into a model with hidden dim 768 is mapped from 3072 to 768 dimensions. So a larger patch size does not force a wider Transformer: the inside can stay at 768 while only the mappings at the input and output change. In JiT the output layer is a linear layer that projects each token back to a $p\times p\times3$ patch.

$d_{\text{model}}$ 是模型自己的 hidden dim,$N$ 只算图像 patch,不算额外的 condition token。原始 patch 是 3072 维、hidden dim 是 768 时,patch embedding 把 3072 维映射到 768 维。所以 patch size 变大,不一定要跟着改 hidden dim:Transformer 内部可以一直是 768,只改输入和输出两头的映射。JiT 的输出层就是一个线性层,把每个 token 投回 $p\times p\times3$ 维的 patch。

On the input side JiT goes narrower still. It replaces the linear patch embedding with two linear layers in a row: the first reduces the patch to a bottleneck dimension $d'$, the second expands it to the hidden dim. The final models use $d'=128$ for the B and L sizes and 256 for H and G. In the paper's sweep on JiT-B/16, a bottleneck as small as 16 does not break training, and anything from 32 to 512 lowers FID by up to about 1.3.

JiT 在输入这一头还更窄。它把线性的 patch embedding 换成两个串联的线性层:第一层降到一个瓶颈维度 $d'$,第二层再升到 hidden dim。最终模型里 B、L 两档的 $d'$ 是 128,H、G 两档是 256。论文在 JiT-B/16 上扫了 $d'$:降到 16 训练也不会崩,取 32 到 512 时 FID 最多能降约 1.3。

FID against the bottleneck dimension of the patch embeddingpatch embedding 瓶颈维度与 FID
Bottleneck embedding瓶颈 embeddingNo bottleneck无瓶颈FID-50K5678910163264128256512Bottleneck dimension d'瓶颈维度 d'
Each dot is one bottleneck dimension d'; the dashed line is a single linear embedding on the raw 768-value patch.每个点是一个瓶颈维度 d';虚线是直接对 768 维原始 patch 做一层线性 embedding。Source: Paper Figure 4 (values printed on the figure): JiT-B/16, ImageNet 256×256, FID-50K, 200 epochs, with CFG出处:论文图 4(图中标注的数值):JiT-B/16,ImageNet 256×256,FID-50K,200 epoch,带 CFG

Why fewer tokens为什么希望 token 少

In global self-attention every token is compared with every other token, so that part of the compute grows with $N^2$. Going from 256 tokens to 64 cuts $N$ to a quarter and $N^2$ to a sixteenth. That holds only for the pairwise part of attention. The linear projections, the FFN and the input and output layers do not grow with $N^2$, so the whole model does not become 16 times faster. A large patch buys fewer tokens at the price of a higher raw dimension per patch.

全局 self-attention 里每个 token 都要和所有 token 算一次关系,这部分的计算量随 $N^2$ 增长。token 从 256 个减到 64 个,$N$ 变成 1/4,$N^2$ 变成 1/16。这只算 attention 两两交互的那部分;线性投影、FFN 和输入输出层的计算量不随 $N^2$ 变化,整个模型不会快 16 倍。大 patch 换来的是 token 少,代价是每个 patch 的原始维度高。

Backbone and generation spacebackbone 和生成空间

Most image generators also turn the image into tokens for a Transformer, so two questions need to be kept apart: which backbone is used, and in which space the generation happens. DiT uses a Transformer as the diffusion backbone[2]. The original DiT works on VAE latents, but a Transformer backbone does not require a VAE.

一般的生成模型也是把图变成 token 送进 Transformer。这里要把两件事分开:backbone 用什么,在什么空间里生成。DiT 用 Transformer 做 diffusion 的 backbone[2]。原始 DiT 在 VAE 的 latent 上做,但 Transformer backbone 本身不要求有 VAE。

On the VAE route, a VAE encoder first turns the image into a latent, diffusion runs in that latent space, and a VAE decoder turns the result back into an image. Patches are cut from the grid of the latent, not from RGB pixels.

VAE 路线里,VAE encoder 先把图像变成 latent,diffusion 在 latent space 里进行,最后由 VAE decoder 还原成图像。切 patch 切的是 latent 的格子,不是原始 RGB 像素。

RAE[3] replaces the VAE with a pretrained representation encoder such as DINO, SigLIP or MAE, and trains a decoder that turns the representation back into an image. There is no conventional VAE, but generation still happens in a latent space.

RAE[3] 把 VAE 换成预训练的 representation encoder,比如 DINO、SigLIP、MAE,再训练一个 decoder 把 representation 还原成图像。这里没有传统的 VAE,但仍然在 latent space 里生成。

JiT[1] works in pixel space, with no encoder or decoder around the Transformer. One forward pass takes the noisy image, cuts it into patches, runs them through the patch embedding, the Transformer and the output layer, and outputs the clean image.

JiT[1] 直接在像素空间里做,Transformer 前后没有 encoder 和 decoder。网络的一次 forward 拿到加噪的图像,切成 patch,经过 patch embedding、Transformer 和输出层,输出干净图像。

Transformer 的输入what the Transformer seesVAE图像image图像imageVAE encoderVAE latentTransformerVAE decoderRAE图像image图像image表征 encoderrepresentation encoderRAE latentTransformerdecoder(训练)trained decoderDINO / SigLIP / MAEJiT图像image图像image没有 encoderno encoder像素 patchpixel patchesTransformer没有 decoderno decoder深色:预训练好、训练时冻结的部分Dark: pretrained and kept frozen

After the network predicts the clean image, the sampler uses it to update the current state and moves to the next step; sampling one image takes many forward passes. All three routes can use a Transformer. What differs is what the Transformer processes: VAE latents, RAE latents or raw pixels.

网络预测出干净图像后,sampler 用它更新当前状态,再走下一步;采样一张图要做多次 forward。三条路线都可以用 Transformer,区别在于 Transformer 处理的是什么:VAE latent、RAE latent,还是原始像素。

Predicting the clean image预测干净图像

Because JiT takes RGB directly, no VAE has made the image smaller, and the only way to keep the token count down is a large patch. A patch then holds from hundreds to over ten thousand values while the hidden dim stays fixed. The question is what the network should predict.

JiT 直接处理 RGB,图像没有经过 VAE 压小,要控制 token 数只能把 patch 切大。这样一个 patch 里有几百到上万个数值,hidden dim 却是固定的。问题变成:网络该预测什么。

JiT has the network predict the clean image, called x-prediction, instead of the noise (ε-prediction) or the velocity (v-prediction). The paper's reason is the manifold assumption: natural images are high-dimensional, but their values do not combine freely and lie roughly on a low-dimensional manifold, while a noised quantity spreads over the whole high-dimensional space. For a network of limited capacity, predicting a clean image on the manifold and predicting high-dimensional noise are tasks of different difficulty.

JiT 让网络直接预测干净图像,即 x-prediction,而不是预测噪声(ε-prediction)或 velocity(v-prediction)。论文的理由是 manifold assumption:自然图像维度虽高,数值并不是随意组合的,大致落在一个低维流形上;加了噪声的量则散布在整个高维空间里。对容量有限的网络,预测流形上的干净图像和预测高维的噪声,难度不一样。

Table 2 of the paper crosses the three prediction targets with three losses for JiT-B/16 on ImageNet 256×256, where each raw patch has 768 values, the same as JiT-B's hidden dim of 768. With x-prediction, FID is between 8.62 and 10.45 under all three losses. ε-prediction gives FID between 372 and 395 and v-prediction between 97 and 127: both fail.

论文表 2 在 ImageNet 256×256、JiT-B/16 上把三种预测目标和三种 loss 交叉比较。这里每个原始 patch 是 768 维,正好等于 JiT-B 的 hidden dim 768。x-prediction 在三种 loss 下 FID 都在 8.62 到 10.45 之间;ε-prediction 的 FID 在 372 到 395 之间,v-prediction 在 97 到 127 之间,两者都训练失败。

The other half of Table 2 uses ImageNet 64×64 with patch size 4, so each patch has 48 values. There all nine combinations land between 3.46 and 6.20, and the gaps are small. This is a different resolution from the 256 setting; it should not be read as changing only the patch size from 4 to 16 at the same resolution.

表 2 的另一组是 ImageNet 64×64、patch size 4,每个 patch 48 维。这组九种组合的 FID 都在 3.46 到 6.20 之间,差距很小。它和 256 那组分辨率不同,不能读成在同一分辨率下只把 patch size 从 4 改成 16。

FID for each prediction target and loss每种预测目标和 loss 组合的 FID
x-lossε-lossv-loss256×256, JiT-B/16256×256,JiT-B/16FID-50K0100200300400x-predictionx-predictionε-predictionε-predictionv-predictionv-prediction64×64, JiT-B/464×64,JiT-B/4FID-50K02468x-predictionx-predictionε-predictionε-predictionv-predictionv-prediction
Left: 256×256 with JiT-B/16, 768 values per patch. Right: 64×64 with JiT-B/4, 48 values per patch. Bars are grouped by prediction target and coloured by loss.左:256×256、JiT-B/16,每个 patch 768 维;右:64×64、JiT-B/4,每个 patch 48 维。柱子按预测目标分组,颜色表示 loss。Source: Paper Table 2: ImageNet, FID-50K, 200 epochs, with CFG出处:论文表 2:ImageNet,FID-50K,200 epoch,带 CFG

The final JiT uses x-prediction with a v-loss. The noisy input is $z_t = t\,x + (1-t)\,\epsilon$, where $x$ is the clean image, $\epsilon$ the noise, and $t=1$ the clean end. The network outputs the clean image, which is converted to a velocity for the loss:

最终的 JiT 用 x-prediction 加 v-loss。加噪后的输入是 $z_t = t\,x + (1-t)\,\epsilon$,$x$ 是干净图像,$\epsilon$ 是噪声,$t=1$ 时就是干净图像。网络输出干净图像,再换算成 velocity 算 loss:

$$v_\theta = \frac{\text{net}_\theta(z_t, t) - z_t}{1-t}$$

The three predictions can be converted into one another by formula, yet they train very differently. Understanding why means separating what the network outputs from the space in which the loss is computed; that is the next question to work out.

x、ε、v 三种预测在公式上可以互相换算,训练起来却差得很远。要弄清原因,得把网络直接输出什么和 loss 算在哪个空间分开看,这是接下来要弄清的问题。

Higher resolutions分辨率继续变大

So far the image size was fixed and the patch size changed. Table 5 of the paper scales the image and the patch together.

前面固定图像大小、改 patch size。论文表 5 让图像和 patch 按同样比例一起变大。

Image图像Model模型Patchespatch 数Values per patch每个 patch 维度hidden dim
256×256×3JiT-B/16256768768
512×512×3JiT-B/322563072768
1024×1024×3JiT-B/6425612288768

Every row has $16\times16=256$ patches, so the Transformer sees the same number of tokens at a higher resolution. What grows is the input and output dimension of each patch, and only the patch embedding and the output layer grow with it. From 256 to 1024, parameters go from 131M to 141M and the compute of one forward pass from 25 to 30 Gflops.

每一行都是 $16\times16=256$ 个 patch,分辨率变高,Transformer 处理的 token 数不变。变的是每个 patch 的输入输出维度,跟着变大的只有 patch embedding 和输出层。从 256 到 1024,参数量从 131M 增加到 141M,一次 forward 的计算量从 25 Gflops 增加到 30 Gflops。

Parameters and compute of JiT-B at three resolutionsJiT-B 在三种分辨率下的参数量和计算量
Params (M)参数量(M)04080120160256×256,256×256, B/B/1616512×512,512×512, B/B/32321024×1024,1024×1024, B/64131133141Gflops010203040256×256,256×256, B/B/1616512×512,512×512, B/B/32321024×1024,1024×1024, B/64252630
Each bar is one resolution with its patch size; every model has 256 patches and hidden dim 768.每根柱是一种分辨率和对应的 patch size;三个模型都是 256 个 patch、hidden dim 768。Source: Paper Table 5: ImageNet, settings of Table 4 with CFG interval出处:论文表 5:ImageNet,设置同表 4,带 CFG interval

References参考文献

  1. Tianhong Li and Kaiming He. Back to Basics: Let Denoising Generative Models Denoise. arXiv preprint, 2025. Table numbers in this post follow arXiv:2511.13720v1.
  2. William Peebles and Saining Xie. Scalable Diffusion Models with Transformers. ICCV, 2023. arXiv:2212.09748
  3. Boyang Zheng, Nanye Ma, Shengbang Tong, and Saining Xie. Diffusion Transformers with Representation Autoencoders. arXiv preprint, 2025. arXiv:2510.11690