The one-step generator .
Parameters
configDriftingConfigAttributes
class_ embedlucid.nn.Embedding(num_classes, cond_dim).noise_ embedslucid.nn.ModuleListnoise_coords style codebooks, each (noise_classes, cond_dim).cfg_ embedder_CFGEmbedderpatch_ embedlucid.nn.Linear(p, p, C)-ordered patch.pos_ embedlucid.nn.Parameter(1, num_patches, hidden_size) — trainable, initialised to the
2-D sine-cosine table.cls_ embedlucid.nn.Parameter(1, n_cls_tokens, hidden_size) learnable in-context offsets.blockslucid.nn.ModuleListfinal_FinalLayerNotes
Reference: Deng, Li, Li, Du, and He, "Generative Modeling via Drifting", arXiv:2602.04770, 2026, Appendix A.2 and Table 8.
The conditioning vector is the release's c_cfg_noise_to_cond:
and it drives both adaLN and the 16 in-context tokens, which are
Linear(c) + cls_embed prepended before the first block. RoPE runs
over the flattened sequence, in-context tokens included, as in the
release.
Examples
>>> import lucid
>>> from lucid.models.generative.drifting import DriftingConfig, DriftingModel
>>> config = DriftingConfig(sample_size=8, hidden_size=32, cond_dim=32, depth=1,
... num_heads=4, num_classes=10, noise_classes=4,
... noise_coords=2, n_cls_tokens=2)
>>> model = DriftingModel(config).eval()
>>> model(lucid.randn(2, 4, 8, 8), lucid.tensor([0, 1])).sample.shape
(2, 4, 8, 8)Used by 2
Constructors
1Instance methods
3conditioning(labels: Tensor, guidance_scale: Tensor, style_indices: Tensor, dtype: lucid.dtype)Class, styles and guidance scale summed into (B, cond_dim).
Parameters
Returns
TensorThe (B, cond_dim) conditioning vector.
Raises
ValueErrorstyle_indices does not hold one column per style codebook.The discrete half of the noise: (batch, noise_coords) codebook indices.
Drawn uniformly, as the release does (max(1, ·) keeps the shape
valid when styles are disabled; the indices are then unused).
Parameters
batchintdevicestrReturns
Tensorint64 indices of shape (batch, max(1, noise_coords)), each
in [0, max(1, noise_classes)).
forward(x: Tensor, labels: Tensor, guidance_scale: float | Tensor = 1.0, style_indices: Tensor | None = None)Map noise to a sample in one evaluation.
Parameters
(B, in_channels, H, W) Gaussian noise (already scaled by the
sampling temperature, if any).labelsTensor(B,) class indices.(B,). 1 is
no guidance.(B, noise_coords) style indices. Drawn uniformly when
None, as the release always does.Returns
DiffusionModelOutputsample of shape (B, out_channels, H, W).