Generative foundation models have historically operated under two distinct mathematical paradigms: autoregressive sequence modeling over discrete vocabularies (used in text and code generation) and iterative denoising diffusion over continuous vector spaces (used in image and video synthesis). Early attempts to unify both modalities in a single end-to-end transformer forced continuous perceptual data into discrete codebooks using vector quantization (such as VQ-VAE or VQGAN). While discretization allows standard cross-entropy language modeling across all tokens, it introduces an irreversible loss of high-frequency visual information, inflates sequence lengths, and creates optimization instabilities.
Transfusion, introduced by Meta FAIR in late 2024 (Zhou et al., arXiv:2408.11039), establishes a unified transformer architecture that trains on discrete text and continuous image data simultaneously without quantization. By pairing cross-entropy next-token prediction with continuous mean squared error diffusion loss over a shared transformer trunk, Transfusion bridges the architectural divide between language models and continuous generative models.

Unified Sequence Representation and Latent Patchification
Transfusion processes mixed-modality documents as single continuous sequences containing discrete tokens and continuous patch vectors. The model avoids discrete image codebooks by extracting continuous latent representations from a pre-trained Variational Autoencoder (VAE).
- Text Tokenization: Text strings are mapped to integer indices from a fixed vocabulary (such as the 32,000-token Llama vocabulary) and projected into hidden dimension using a learned embedding matrix .
- VAE Latent Encoding: Input images of resolution are compressed via an 86M-parameter convolutional VAE encoder into continuous latent tensors . Each 8-dimensional latent vector corresponds conceptually to an pixel patch in the original image.
- Patchification: Local spatial windows of size latent vectors are flattened and linearly projected into the transformer hidden dimension . For , an image is represented by continuous patch vectors in . For combined with U-Net downsampling blocks, an image can be compressed into as few as 16 patch tokens.
- Modality Delimiters: Continuous image patches are wrapped with discrete beginning-of-image (BOI) and end-of-image (EOI) control tokens within the unified sequence:
[Text Prefix, BOI, Patch_1, ..., Patch_N, EOI, Text Suffix].
During pre-training, diffusion timestep noise is sampled per image, and an embedding of timestep is added to each patch vector before projection into the transformer trunk.
Hybrid Attention: Causal Sequence Routing with Bidirectional Image Blocks
Autoregressive language models enforce strict causal attention masking so that token only attends to prior tokens . Images, however, are non-causal 2D spatial signals where patch relies on surrounding spatial context across all spatial coordinates.
Transfusion resolves this contradiction by introducing a hybrid attention mask :
- Cross-Modality and Inter-Token Causality: For any token or patch at position and antecedent position , attention is permitted (). All forward positions are masked () by default.
- Intra-Image Bidirectional Attention: For any two patch positions and belonging to the same image instance delimited by , bidirectional visibility is unmasked () regardless of whether .
- Boundary Isolation: Tokens preceding the image cannot attend to future image patches, and tokens appearing after attend to all image patches causally as a completed prefix.
In ablation studies on MS-COCO image synthesis, switching from strict causal attention to intra-image bidirectional attention lowered zero-shot Fréchet Inception Distance (FID) from 61.3 to 20.3 on linear-projection models, confirming that unrestricted spatial self-attention within image blocks is critical for generative quality.

Dual Objective Formulation and Optimization Dynamics
Transfusion optimizes a single set of shared transformer parameters across both discrete and continuous losses in every mini-batch:
Discrete Language Modeling Loss
For discrete text tokens , the standard cross-entropy loss computes negative log-likelihood over predicted vocabulary distributions:
The cross-entropy loss is evaluated on all text tokens and modality delimiters (BOI and EOI), but is omitted over internal image patch positions.
Continuous Latent Diffusion Loss
For continuous image latents , Gaussian noise is added at diffusion step according to a cosine variance schedule:
The transformer output representations at the image patch positions are projected back to latent space via an output linear head (or U-Net decoder block) to predict the added noise vector , conditioned on sequence context :
Balancing Coefficient and Stability
The balancing coefficient scales the mean squared error loss relative to the cross-entropy objective. Meta FAIR empirical sweeps established as optimal. Because continuous diffusion does not partition the output layer into categorical logits, Transfusion avoids the softmax normalization instabilities and severe gradient competition observed when discrete visual codebooks share an output projection matrix with text vocabularies.
Inference and Modality-Switching Decoding
During generation, Transfusion operates as a dual-mode state machine that transitions dynamically based on sampled control tokens:
- Text Mode: The model computes output logits over vocabulary given the current KV cache. Tokens are sampled autoregressively using standard temperature or top- nucleus sampling.
- Transition to Diffusion Mode: When the model emits the discrete
BOItoken, the decoder shifts into iterative continuous denoising. - Iterative Image Denoising:
- The sequence is extended with pure Gaussian noise patch vectors .
- Over reverse diffusion steps (typically 50 to 250 steps), the model predicts noise , applies Classifier-Free Guidance (CFG), and computes the less-noisy latent .
- The latent state overwrites in place, ensuring that the transformer KV cache always conditions exclusively on the latest denoised latent state rather than historical diffusion trajectories.
- Transition to Text Mode: Once is fully reconstructed, the latent tensor is decoded into RGB pixels by the VAE decoder, the discrete
EOItoken is appended to the sequence, and standard autoregressive token generation resumes.
Empirical Scaling Laws and Compute Efficiency
Controlled scaling benchmarks comparing Transfusion against Chameleon (the standard discrete-token multimodal baseline) demonstrate consistent efficiency advantages across parameter scales from 0.16B to 7B parameters:
- Compute Parity in Image Generation: In text-to-image synthesis on MS-COCO 30k, Transfusion achieves FID parity with Chameleon while consuming 34 times fewer training FLOPs (Parity FLOP Ratio of 0.029). When trained under identical compute budgets, Transfusion reduces FID from 29.6 to 16.8.
- Image-to-Text Captioning: On MS-COCO captioning (CIDEr), Transfusion reaches performance parity with Chameleon at 21.8% of the training compute (Parity FLOP Ratio of 0.218), achieving a CIDEr score of 27.2 compared to Chameleon's 18.0 at 7B scale.
- Text-to-Text Language Modeling: Transfusion achieves lower perplexity on Wikipedia (4.28 vs 4.69) and C4 (7.72 vs 8.41) compared to Chameleon. The discrete visual tokens in Chameleon degrade text modeling capacity by fragmenting output vocabulary allocations, whereas continuous diffusion loss leaves text representation spaces largely uncompromised.
- High-Resolution Scaling: When scaled to 7B parameters on 2 trillion multimodal tokens (1T text tokens and 692M caption-image pairs), Transfusion matches standalone diffusion systems like SDXL and DALL-E 2 on GenEval while maintaining Llama-level zero-shot accuracy across standardized NLP reasoning benchmarks.
Transfusion demonstrates that discrete autoregression and continuous diffusion are complementary objectives that can co-exist within a single unified transformer trunk, eliminating the need for quantized visual codebooks in multimodal foundation models.
Sources
- Transfusion: Predict the Next Token and Diffuse Images with One Multi-Modal Model (Zhou et al., 2024 / arXiv:2408.11039)
- Chameleon: Mixed-Modal Early-Fusion Foundation Models (Chameleon Team, 2024 / arXiv:2405.09818)
- High-Resolution Image Synthesis with Latent Diffusion Models (Rombach et al., CVPR 2022 / arXiv:2112.10752)
- Denoising Diffusion Probabilistic Models (Ho et al., NeurIPS 2020 / arXiv:2006.11239)
- Llama 2: Open Foundation and Fine-Tuned Chat Models (Touvron et al., 2023 / arXiv:2307.09288)
