Skip to content
data

DriftingConfig

extendsGenerativeModelConfig
DriftingConfig(sample_size: int | tuple[int, int] = 32, in_channels: int = 4, out_channels: int = 4, act_fn: GenerativeActivation = 'silu', patch_size: int = 2, hidden_size: int = 768, depth: int = 12, num_heads: int = 12, mlp_ratio: float = 4.0, cond_dim: int = 768, num_classes: int = 1000, noise_classes: int = 64, noise_coords: int = 32, n_cls_tokens: int = 16, use_qknorm: bool = True, use_swiglu: bool = True, use_rope: bool = True, use_rmsnorm: bool = True, attn_fp32: bool = True, use_remat: bool = False, frequency_embedding_size: int = 256, temperatures: tuple[float, ...] = (0.2, 0.05, 0.02), gen_per_label: int = 64, cfg_min: float = 1.0, cfg_max: float = 4.0, neg_cfg_pw: float = 5.0, no_cfg_frac: float = 0.0, patch_mean_size: tuple[int, ...] = (2, 4), patch_std_size: tuple[int, ...] = (2, 4), use_mean: bool = True, use_std: bool = True, every_k_block: int | None = 2, pos_per_sample: int = 64, neg_per_sample: int = 32, positive_bank_size: int = 128, negative_bank_size: int = 1000, use_mae: bool = True, use_convnext: bool = False, mae_base_channels: int = 640, mae_layers: tuple[int, int, int, int] = (3, 4, 6, 3), mae_input_patch_size: int = 1)

Configuration for the Drifting Model family.

Parameters

sample_sizeint= 32
Side of the generated field — the official input_size. 32 for the SD-VAE latent models, 256 for the pixel models.
in_channelsint= 4, 4
Channels of the noise and of the output. The generator maps a noise field to a sample of the same shape, so they must match.
out_channelsint= 4, 4
Channels of the noise and of the output. The generator maps a noise field to a sample of the same shape, so they must match.
patch_sizeint= 2
Tokenisation patch — 2 for B/2 / L/2, 16 for B/16 / L/16. Both give 256 tokens.
hidden_sizeint= 768
Transformer width.
depthint= 12
Number of blocks.
num_headsint= 12
Attention heads.
mlp_ratiofloat= 4.0
Feed-forward expansion before the SwiGLU two-thirds rule.
cond_dimint= 768
Width of the conditioning vector that drives adaLN and the in-context tokens. Every released model sets it equal to hidden_size.
num_classesint= 1000
Class vocabulary. There is no null class: guidance is trained in by conditioning on α\alpha, not by label dropout.
noise_classesint= 64
Codebook size of the random style embeddings — the discrete half of the noise. 0 disables them.
noise_coordsint= 32
How many style indices are drawn per sample; their embeddings are summed into the conditioning vector.
n_cls_tokensint= 16
In-context conditioning tokens prepended to the sequence.
use_qknormbool= True
The LightningDiT modernisations the paper adopts (A.2).
use_swiglubool= True
The LightningDiT modernisations the paper adopts (A.2).
use_ropebool= True
The LightningDiT modernisations the paper adopts (A.2).
use_rmsnormbool= True
The LightningDiT modernisations the paper adopts (A.2).
attn_fp32bool= True
Run attention in float32 when the model is in a narrower dtype. False for the released latent B/2 and L/2.
use_rematbool= False
Recompute each block on the backward pass instead of storing its activations. True for the released pixel models.
frequency_embedding_sizeint= 256
Width of the sinusoid the guidance scale is embedded through.
temperaturestuple of float= (0.2, 0.05, 0.02)
Kernel temperatures τ\tau (the release's R_list). One normalised drift per temperature, summed.
gen_per_labelint= 64
Generated samples per class label, NnegN_\mathrm{neg}.
cfg_minfloat= 1.0, 4.0
Range of the training-time guidance scale α\alpha.
cfg_maxfloat= 1.0, 4.0
Range of the training-time guidance scale α\alpha.
neg_cfg_pwfloat= 5.0
Exponent of the power law p(α)∝α−kp(\alpha) \propto \alpha^{-k} the scale is drawn from.
no_cfg_fracfloat= 0.0
Probability of replacing the drawn scale by 1 (no guidance). 0.5 for the released L/2.
patch_mean_sizetuple of int= (2, 4)
Patch sides over which local feature means / stds are pooled (A.5).
patch_std_sizetuple of int= (2, 4)
Patch sides over which local feature means / stds are pooled (A.5).
use_meanbool= True
Whether each feature map also contributes its global mean / std.
use_stdbool= True
Whether each feature map also contributes its global mean / std.
every_k_blockint or None= 2
Also take features from every k-th residual block of each stage. None keeps only the stage outputs.
pos_per_sampleint= 64
Positive (same-class) samples drawn per label, NposN_\mathrm{pos}.
neg_per_sampleint= 32
Unconditional real samples drawn per label, NuncN_\mathrm{unc}. 0 trains without guidance negatives.
positive_bank_sizeint= 128
Per-class sample-queue length.
negative_bank_sizeint= 1000
Global unconditional queue length.
use_maebool= True
Compute the loss in the latent- / pixel-MAE feature space. No trained encoder is published, so see DriftingForImageGeneration.load_feature_encoder.
use_convnextbool= False
Also use ConvNeXt-V2-Base (ImageNet-22k) features. Pixel models only.
mae_base_channelsint= 640
MAE ResNet base width CC; stages are C,2C,4C,8CC, 2C, 4C, 8C.
mae_layerstuple of int= (3, 4, 6, 3)
Basic blocks per MAE stage — ResNet-34's.
mae_input_patch_sizeint= 1
Space-to-depth patch applied before the MAE ResNet: 1 for the 32x32x4 latent, 8 for 256x256x3 pixels (giving 32x32x192).

Notes

Reference: Deng, Li, Li, Du, and He, "Generative Modeling via Drifting", arXiv:2602.04770, 2026. Architecture: Appendix A.2 and Table 8. Loss: Alg. 2 and Appendices A.5–A.7.

Where Table 8 and the released configs/gen/*.yaml disagree, the release wins, because the authors' checkpoints were trained by it: the latent B/2 uses 64 positives per label (Table 8 says 128).

Examples

>>> from lucid.models.generative.drifting import DriftingConfig
>>> config = DriftingConfig()
>>> config.hidden_size, config.depth, config.patch_size
(768, 12, 2)
>>> config.num_patches, config.swiglu_hidden_size
(256, 2048)

Used by 4

Properties

4
prop

grid_size

→int
grid_size: int

Tokens per side of the patch grid.

prop

head_dim

→int
head_dim: int

Per-head width.

prop

num_patches

→int
num_patches: int

Image tokens — (sample_size / patch_size)^2, 256 for every release.

prop

swiglu_hidden_size

→int
swiglu_hidden_size: int

SwiGLU inner width: two thirds of hidden * mlp_ratio, rounded up to 32.

The release computes int(2/3 * int(hidden * mlp_ratio)) and then rounds up to a multiple of 32 — 2048 for B, 2752 for L.