Architectures / Generative
๐ DiT-XL/2
Diffusion Transformer โ replaces the UNet denoiser with a ViT backbone conditioned on timestep + class via adaLN-Zero (Peebles 2023)
Layers
204
Parameters
670.68M
Input
4 ร 32 ร 32
Output
256 ร 32
Verifier
Clean
Every number on this page is computed from the graph by the same functions the app runs, not written by hand.
Open DiT-XL/2 on the canvas
Free, no account needed
When to pick it
Pick when you want the modern transformer-based image-generation backbone (used by Sora/SD3-era models) instead of a convolutional UNet denoiser.
Structure
204 layers. Output shapes are propagated from the input shape, batch dimension excluded.
| Layer | Type | Parameters | Output shape | |
|---|---|---|---|---|
| 1 | noisy_latent | Input | shape=[4, 32, 32] | 4 ร 32 ร 32 |
| 2 | timestep_+_class | Input | shape=[1, 2] | 1 ร 2 |
| 3 | patchify_2x2 | Patch Embed | embedDim=1152, patchSize=2 | 256 ร 1152 |
| 4 | cond_embed | Embedding | 1 ร 2 ร 1152 | |
| 5 | pos_embed | Positional Encoding | embedDim=1152, maxLen=256 | 256 ร 1152 |
| 6 | adaLN_1 | Linear | outFeatures=6912, inFeatures=1152 | 1 ร 2 ร 6912 |
| 7 | norm1_1 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 8 | self_attn_1 | Multi-Head Attention | embedDim=1152, numHeads=16 | 256 ร 1152 |
| 9 | residual1_1 | Add | 256 ร 1152 | |
| 10 | norm2_1 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 11 | mlp_1 | Feed Forward | embedDim=1152, ffDim=4608 | 256 ร 1152 |
| 12 | residual2_1 | Add | 256 ร 1152 | |
| 13 | adaLN_2 | Linear | outFeatures=6912, inFeatures=1152 | 1 ร 2 ร 6912 |
| 14 | norm1_2 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 15 | self_attn_2 | Multi-Head Attention | embedDim=1152, numHeads=16 | 256 ร 1152 |
| 16 | residual1_2 | Add | 256 ร 1152 | |
| 17 | norm2_2 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 18 | mlp_2 | Feed Forward | embedDim=1152, ffDim=4608 | 256 ร 1152 |
| 19 | residual2_2 | Add | 256 ร 1152 | |
| 20 | adaLN_3 | Linear | outFeatures=6912, inFeatures=1152 | 1 ร 2 ร 6912 |
| 21 | norm1_3 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 22 | self_attn_3 | Multi-Head Attention | embedDim=1152, numHeads=16 | 256 ร 1152 |
| 23 | residual1_3 | Add | 256 ร 1152 | |
| 24 | norm2_3 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 25 | mlp_3 | Feed Forward | embedDim=1152, ffDim=4608 | 256 ร 1152 |
| 26 | residual2_3 | Add | 256 ร 1152 | |
| 27 | adaLN_4 | Linear | outFeatures=6912, inFeatures=1152 | 1 ร 2 ร 6912 |
| 28 | norm1_4 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 29 | self_attn_4 | Multi-Head Attention | embedDim=1152, numHeads=16 | 256 ร 1152 |
| 30 | residual1_4 | Add | 256 ร 1152 | |
| 31 | norm2_4 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 32 | mlp_4 | Feed Forward | embedDim=1152, ffDim=4608 | 256 ร 1152 |
| 33 | residual2_4 | Add | 256 ร 1152 | |
| 34 | adaLN_5 | Linear | outFeatures=6912, inFeatures=1152 | 1 ร 2 ร 6912 |
| 35 | norm1_5 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 36 | self_attn_5 | Multi-Head Attention | embedDim=1152, numHeads=16 | 256 ร 1152 |
| 37 | residual1_5 | Add | 256 ร 1152 | |
| 38 | norm2_5 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 39 | mlp_5 | Feed Forward | embedDim=1152, ffDim=4608 | 256 ร 1152 |
| 40 | residual2_5 | Add | 256 ร 1152 | |
| 41 | adaLN_6 | Linear | outFeatures=6912, inFeatures=1152 | 1 ร 2 ร 6912 |
| 42 | norm1_6 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 43 | self_attn_6 | Multi-Head Attention | embedDim=1152, numHeads=16 | 256 ร 1152 |
| 44 | residual1_6 | Add | 256 ร 1152 | |
| 45 | norm2_6 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 46 | mlp_6 | Feed Forward | embedDim=1152, ffDim=4608 | 256 ร 1152 |
| 47 | residual2_6 | Add | 256 ร 1152 | |
| 48 | adaLN_7 | Linear | outFeatures=6912, inFeatures=1152 | 1 ร 2 ร 6912 |
| 49 | norm1_7 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 50 | self_attn_7 | Multi-Head Attention | embedDim=1152, numHeads=16 | 256 ร 1152 |
| 51 | residual1_7 | Add | 256 ร 1152 | |
| 52 | norm2_7 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 53 | mlp_7 | Feed Forward | embedDim=1152, ffDim=4608 | 256 ร 1152 |
| 54 | residual2_7 | Add | 256 ร 1152 | |
| 55 | adaLN_8 | Linear | outFeatures=6912, inFeatures=1152 | 1 ร 2 ร 6912 |
| 56 | norm1_8 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 57 | self_attn_8 | Multi-Head Attention | embedDim=1152, numHeads=16 | 256 ร 1152 |
| 58 | residual1_8 | Add | 256 ร 1152 | |
| 59 | norm2_8 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 60 | mlp_8 | Feed Forward | embedDim=1152, ffDim=4608 | 256 ร 1152 |
| 61 | residual2_8 | Add | 256 ร 1152 | |
| 62 | adaLN_9 | Linear | outFeatures=6912, inFeatures=1152 | 1 ร 2 ร 6912 |
| 63 | norm1_9 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 64 | self_attn_9 | Multi-Head Attention | embedDim=1152, numHeads=16 | 256 ร 1152 |
| 65 | residual1_9 | Add | 256 ร 1152 | |
| 66 | norm2_9 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 67 | mlp_9 | Feed Forward | embedDim=1152, ffDim=4608 | 256 ร 1152 |
| 68 | residual2_9 | Add | 256 ร 1152 | |
| 69 | adaLN_10 | Linear | outFeatures=6912, inFeatures=1152 | 1 ร 2 ร 6912 |
| 70 | norm1_10 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 71 | self_attn_10 | Multi-Head Attention | embedDim=1152, numHeads=16 | 256 ร 1152 |
| 72 | residual1_10 | Add | 256 ร 1152 | |
| 73 | norm2_10 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 74 | mlp_10 | Feed Forward | embedDim=1152, ffDim=4608 | 256 ร 1152 |
| 75 | residual2_10 | Add | 256 ร 1152 | |
| 76 | adaLN_11 | Linear | outFeatures=6912, inFeatures=1152 | 1 ร 2 ร 6912 |
| 77 | norm1_11 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 78 | self_attn_11 | Multi-Head Attention | embedDim=1152, numHeads=16 | 256 ร 1152 |
| 79 | residual1_11 | Add | 256 ร 1152 | |
| 80 | norm2_11 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 81 | mlp_11 | Feed Forward | embedDim=1152, ffDim=4608 | 256 ร 1152 |
| 82 | residual2_11 | Add | 256 ร 1152 | |
| 83 | adaLN_12 | Linear | outFeatures=6912, inFeatures=1152 | 1 ร 2 ร 6912 |
| 84 | norm1_12 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 85 | self_attn_12 | Multi-Head Attention | embedDim=1152, numHeads=16 | 256 ร 1152 |
| 86 | residual1_12 | Add | 256 ร 1152 | |
| 87 | norm2_12 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 88 | mlp_12 | Feed Forward | embedDim=1152, ffDim=4608 | 256 ร 1152 |
| 89 | residual2_12 | Add | 256 ร 1152 | |
| 90 | adaLN_13 | Linear | outFeatures=6912, inFeatures=1152 | 1 ร 2 ร 6912 |
| 91 | norm1_13 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 92 | self_attn_13 | Multi-Head Attention | embedDim=1152, numHeads=16 | 256 ร 1152 |
| 93 | residual1_13 | Add | 256 ร 1152 | |
| 94 | norm2_13 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 95 | mlp_13 | Feed Forward | embedDim=1152, ffDim=4608 | 256 ร 1152 |
| 96 | residual2_13 | Add | 256 ร 1152 | |
| 97 | adaLN_14 | Linear | outFeatures=6912, inFeatures=1152 | 1 ร 2 ร 6912 |
| 98 | norm1_14 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 99 | self_attn_14 | Multi-Head Attention | embedDim=1152, numHeads=16 | 256 ร 1152 |
| 100 | residual1_14 | Add | 256 ร 1152 | |
| 101 | norm2_14 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 102 | mlp_14 | Feed Forward | embedDim=1152, ffDim=4608 | 256 ร 1152 |
| 103 | residual2_14 | Add | 256 ร 1152 | |
| 104 | adaLN_15 | Linear | outFeatures=6912, inFeatures=1152 | 1 ร 2 ร 6912 |
| 105 | norm1_15 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 106 | self_attn_15 | Multi-Head Attention | embedDim=1152, numHeads=16 | 256 ร 1152 |
| 107 | residual1_15 | Add | 256 ร 1152 | |
| 108 | norm2_15 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 109 | mlp_15 | Feed Forward | embedDim=1152, ffDim=4608 | 256 ร 1152 |
| 110 | residual2_15 | Add | 256 ร 1152 | |
| 111 | adaLN_16 | Linear | outFeatures=6912, inFeatures=1152 | 1 ร 2 ร 6912 |
| 112 | norm1_16 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 113 | self_attn_16 | Multi-Head Attention | embedDim=1152, numHeads=16 | 256 ร 1152 |
| 114 | residual1_16 | Add | 256 ร 1152 | |
| 115 | norm2_16 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 116 | mlp_16 | Feed Forward | embedDim=1152, ffDim=4608 | 256 ร 1152 |
| 117 | residual2_16 | Add | 256 ร 1152 | |
| 118 | adaLN_17 | Linear | outFeatures=6912, inFeatures=1152 | 1 ร 2 ร 6912 |
| 119 | norm1_17 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 120 | self_attn_17 | Multi-Head Attention | embedDim=1152, numHeads=16 | 256 ร 1152 |
| 121 | residual1_17 | Add | 256 ร 1152 | |
| 122 | norm2_17 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 123 | mlp_17 | Feed Forward | embedDim=1152, ffDim=4608 | 256 ร 1152 |
| 124 | residual2_17 | Add | 256 ร 1152 | |
| 125 | adaLN_18 | Linear | outFeatures=6912, inFeatures=1152 | 1 ร 2 ร 6912 |
| 126 | norm1_18 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 127 | self_attn_18 | Multi-Head Attention | embedDim=1152, numHeads=16 | 256 ร 1152 |
| 128 | residual1_18 | Add | 256 ร 1152 | |
| 129 | norm2_18 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 130 | mlp_18 | Feed Forward | embedDim=1152, ffDim=4608 | 256 ร 1152 |
| 131 | residual2_18 | Add | 256 ร 1152 | |
| 132 | adaLN_19 | Linear | outFeatures=6912, inFeatures=1152 | 1 ร 2 ร 6912 |
| 133 | norm1_19 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 134 | self_attn_19 | Multi-Head Attention | embedDim=1152, numHeads=16 | 256 ร 1152 |
| 135 | residual1_19 | Add | 256 ร 1152 | |
| 136 | norm2_19 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 137 | mlp_19 | Feed Forward | embedDim=1152, ffDim=4608 | 256 ร 1152 |
| 138 | residual2_19 | Add | 256 ร 1152 | |
| 139 | adaLN_20 | Linear | outFeatures=6912, inFeatures=1152 | 1 ร 2 ร 6912 |
| 140 | norm1_20 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 141 | self_attn_20 | Multi-Head Attention | embedDim=1152, numHeads=16 | 256 ร 1152 |
| 142 | residual1_20 | Add | 256 ร 1152 | |
| 143 | norm2_20 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 144 | mlp_20 | Feed Forward | embedDim=1152, ffDim=4608 | 256 ร 1152 |
| 145 | residual2_20 | Add | 256 ร 1152 | |
| 146 | adaLN_21 | Linear | outFeatures=6912, inFeatures=1152 | 1 ร 2 ร 6912 |
| 147 | norm1_21 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 148 | self_attn_21 | Multi-Head Attention | embedDim=1152, numHeads=16 | 256 ร 1152 |
| 149 | residual1_21 | Add | 256 ร 1152 | |
| 150 | norm2_21 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 151 | mlp_21 | Feed Forward | embedDim=1152, ffDim=4608 | 256 ร 1152 |
| 152 | residual2_21 | Add | 256 ร 1152 | |
| 153 | adaLN_22 | Linear | outFeatures=6912, inFeatures=1152 | 1 ร 2 ร 6912 |
| 154 | norm1_22 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 155 | self_attn_22 | Multi-Head Attention | embedDim=1152, numHeads=16 | 256 ร 1152 |
| 156 | residual1_22 | Add | 256 ร 1152 | |
| 157 | norm2_22 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 158 | mlp_22 | Feed Forward | embedDim=1152, ffDim=4608 | 256 ร 1152 |
| 159 | residual2_22 | Add | 256 ร 1152 | |
| 160 | adaLN_23 | Linear | outFeatures=6912, inFeatures=1152 | 1 ร 2 ร 6912 |
| 161 | norm1_23 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 162 | self_attn_23 | Multi-Head Attention | embedDim=1152, numHeads=16 | 256 ร 1152 |
| 163 | residual1_23 | Add | 256 ร 1152 | |
| 164 | norm2_23 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 165 | mlp_23 | Feed Forward | embedDim=1152, ffDim=4608 | 256 ร 1152 |
| 166 | residual2_23 | Add | 256 ร 1152 | |
| 167 | adaLN_24 | Linear | outFeatures=6912, inFeatures=1152 | 1 ร 2 ร 6912 |
| 168 | norm1_24 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 169 | self_attn_24 | Multi-Head Attention | embedDim=1152, numHeads=16 | 256 ร 1152 |
| 170 | residual1_24 | Add | 256 ร 1152 | |
| 171 | norm2_24 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 172 | mlp_24 | Feed Forward | embedDim=1152, ffDim=4608 | 256 ร 1152 |
| 173 | residual2_24 | Add | 256 ร 1152 | |
| 174 | adaLN_25 | Linear | outFeatures=6912, inFeatures=1152 | 1 ร 2 ร 6912 |
| 175 | norm1_25 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 176 | self_attn_25 | Multi-Head Attention | embedDim=1152, numHeads=16 | 256 ร 1152 |
| 177 | residual1_25 | Add | 256 ร 1152 | |
| 178 | norm2_25 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 179 | mlp_25 | Feed Forward | embedDim=1152, ffDim=4608 | 256 ร 1152 |
| 180 | residual2_25 | Add | 256 ร 1152 | |
| 181 | adaLN_26 | Linear | outFeatures=6912, inFeatures=1152 | 1 ร 2 ร 6912 |
| 182 | norm1_26 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 183 | self_attn_26 | Multi-Head Attention | embedDim=1152, numHeads=16 | 256 ร 1152 |
| 184 | residual1_26 | Add | 256 ร 1152 | |
| 185 | norm2_26 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 186 | mlp_26 | Feed Forward | embedDim=1152, ffDim=4608 | 256 ร 1152 |
| 187 | residual2_26 | Add | 256 ร 1152 | |
| 188 | adaLN_27 | Linear | outFeatures=6912, inFeatures=1152 | 1 ร 2 ร 6912 |
| 189 | norm1_27 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 190 | self_attn_27 | Multi-Head Attention | embedDim=1152, numHeads=16 | 256 ร 1152 |
| 191 | residual1_27 | Add | 256 ร 1152 | |
| 192 | norm2_27 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 193 | mlp_27 | Feed Forward | embedDim=1152, ffDim=4608 | 256 ร 1152 |
| 194 | residual2_27 | Add | 256 ร 1152 | |
| 195 | adaLN_28 | Linear | outFeatures=6912, inFeatures=1152 | 1 ร 2 ร 6912 |
| 196 | norm1_28 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 197 | self_attn_28 | Multi-Head Attention | embedDim=1152, numHeads=16 | 256 ร 1152 |
| 198 | residual1_28 | Add | 256 ร 1152 | |
| 199 | norm2_28 | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 200 | mlp_28 | Feed Forward | embedDim=1152, ffDim=4608 | 256 ร 1152 |
| 201 | residual2_28 | Add | 256 ร 1152 | |
| 202 | final_norm | LayerNorm | normalizedShape=1152 | 256 ร 1152 |
| 203 | unpatchify | Linear | outFeatures=32, inFeatures=1152 | 256 ร 32 |
| 204 | predicted_noise | Output | 256 ร 32 |
What the verifier says
The same 41 structural checks that run on every edit in the app, on this graph.
infoAt 28 stacked attention layers, residual-branch outputs add up; unscaled init lets activation variance grow with depth. GPT-2/LLaMA-family models scale the residual projections by depth (N(0, 0.02 / โ(2L))). Fix: Scale residual output projections by depth: nn.init.normal_(w, std=0.02 / math.sqrt(2 * n_layers)) (self_attn_1)
deep-attention-default-init
deep-attention-default-init
The PyTorch it exports
Generated from the graph above. First 46 lines; the app exports the whole file, plus the training loop, the data contract and a deploy bundle.
# Architecture designed with Neurarch: https://neurarch.com
# PyTorch: compatible with Python 3.8+ and torch>=1.12
# Colab: pip install torch torchvision (usually pre-installed)
import torch
import torch.nn as nn
import torch.nn.functional as F
from typing import Tuple
class DiT_XL2(nn.Module):
def __init__(self):
super().__init__()
self.patchEmbed_1 = nn.Conv2d(4, 1152, kernel_size=2, stride=2) # Patch embedding (ViT-style)
self.embedding_1 = nn.Embedding(1000, 1152)
self.linear_1 = nn.Linear(1152, 6912)
self.layerNorm_1 = nn.LayerNorm(1152)
self.multiHeadAttention_1 = nn.MultiheadAttention(embed_dim=1152, num_heads=16, batch_first=True)
self.layerNorm_2 = nn.LayerNorm(1152)
self.feedForward_1 = nn.Sequential(
nn.Linear(1152, 4608),
nn.ReLU(),
nn.Linear(4608, 1152)
)
self.linear_2 = nn.Linear(1152, 6912)
self.layerNorm_3 = nn.LayerNorm(1152)
self.multiHeadAttention_2 = nn.MultiheadAttention(embed_dim=1152, num_heads=16, batch_first=True)
self.layerNorm_4 = nn.LayerNorm(1152)
self.feedForward_2 = nn.Sequential(
nn.Linear(1152, 4608),
nn.ReLU(),
nn.Linear(4608, 1152)
)
self.linear_3 = nn.Linear(1152, 6912)
self.layerNorm_5 = nn.LayerNorm(1152)
self.multiHeadAttention_3 = nn.MultiheadAttention(embed_dim=1152, num_heads=16, batch_first=True)
self.layerNorm_6 = nn.LayerNorm(1152)
self.feedForward_3 = nn.Sequential(
nn.Linear(1152, 4608),
nn.ReLU(),
nn.Linear(4608, 1152)
)
self.linear_4 = nn.Linear(1152, 6912)
self.layerNorm_7 = nn.LayerNorm(1152)
self.multiHeadAttention_4 = nn.MultiheadAttention(embed_dim=1152, num_heads=16, batch_first=True)
self.layerNorm_8 = nn.LayerNorm(1152)
For agents
This architecture is machine-readable end to end. An agent can list the set, fetch this graph, edit it, and have the edit verified before any GPU time is spent.