Variable-Length Tokenization via Learnable Global Merging for Diffusion Transformers

Dong Hoon Lee, Seunghoon Hong

Introduction

Latent Diffusion Models (LDMs) have established themselves as the dominant architecture for visual synthesis. However, their practical deployment is often constrained by a rigid quality-compute trade-off dictated by the tokenizer's fixed compression ratio. Traditionally, generating an image requires a fixed number of tokens (e.g., 256). If a user or system requires a faster, lower-compute generation—such as a quick preview—a completely separate model trained at a higher compression ratio is typically required.

Variable-Length Tokenizers (VLTs) promise to resolve this inefficiency by enabling a single diffusion model to dynamically adjust its token count, seamlessly scaling between rapid, low-fidelity outputs and slower, high-fidelity generations. Yet, realizing this promise has proven difficult due to the architectural limitations of conventional VLTs.

The Problem: Truncation and Cross-Length Shift

Current VLTs typically modulate sequence length using techniques like "nested dropout," which simply truncates the end of an ordered token sequence. While computationally straightforward, truncation introduces a critical flaw: cross-length shift.

Because truncation-based tokenizers learn to pack high-level semantics into the beginning of the sequence and fine details into the tail, the fundamental "meaning" of a token becomes dependent on its position. Consequently, a 32-token sequence appears as a fundamentally different distribution to the diffusion model than a 256-token sequence. This broken representational alignment across lengths makes it nearly impossible for a single diffusion model's score function to generalize effectively across all compression levels.

Methodology: Learnable Global Merging (LGM)

To address the cross-length shift, the authors propose replacing sequence truncation with Learnable Global Merging (LGM). This approach modulates sequence length without fracturing the latent distribution.

  1. Token Merging over Truncation: Instead of discarding "tail" tokens, LGM groups semantically similar tokens together. This ensures that no broad semantic information is entirely lost, only compressed.
  2. Proportional Attention: To process these merged tokens accurately, the diffusion transformer employs an attention mechanism weighted by cluster size—the number of original tokens merged into a single new token. Mathematically, this makes a short, merged sequence directly comparable to a full-length sequence where certain tokens are simply averaged.
  3. Data-Independent Global Patterns: Standard token merging is "data-dependent," meaning it analyzes the input image to decide which tokens to merge. This is impossible during generation, as the image does not yet exist. LGM solves this by utilizing learnable embeddings to define a fixed, global merging pattern. Optimized during training, this pattern remains constant for every image during inference, ensuring full compatibility with diffusion transformers.
  4. Alignment Loss: A specialized loss function guarantees that the global merging pattern groups tokens that share semantic similarity across the entire dataset, actively minimizing representation shift between different token lengths.

Experimental Results

The authors evaluated LGM on the standard ImageNet-1k benchmark at 256×256 and 512×512 resolutions, comparing it against existing VLT baselines such as Semanticist, FlexTok, and One-D-Piece.

  • Superior Quality-Compute Trade-offs: On ImageNet 256×256, the LGM-equipped model achieved a significantly better generation Frechet Inception Distance (gFID) relative to its computational cost. At a highly compressed 32-token length, the LGM model achieved a gFID of ~3.19, drastically outperforming the nested dropout baseline's ~5.21.
  • Representational Consistency: Using Centered Kernel Nearest-Neighbor Alignment (CKNNA) to measure structural similarity across lengths, LGM maintained a high consistency score of 0.76, compared to just 0.34 for truncation methods.
  • Efficiency: When adjusted for computational cost (TFLOPs), the LGM-integrated Diffusion Transformer outperformed fixed-length tokenizers, proving that variable-length flexibility does not inherently compromise peak performance.

Key Insights

The success of LGM highlights that representational alignment is the primary bottleneck in variable-length generation. The failure of previous VLTs was less about the raw information lost during truncation and more about the shifting latent space. By using merging as a mathematical proxy for full-length representations, LGM stabilizes the target for the diffusion model. Furthermore, the success of LGM proves that a fixed, global merging pattern—while not adapting to specific image content—can successfully capture the general structural priors of images well enough to enable high-quality compression.

Limitations and Future Directions

While LGM represents a significant step forward, the authors note a few limitations:

  • 1D vs. 2D Tokenization: The current study focuses on 1D sequence tokenizers. While efficient, 1D tokenizers still exhibit a slight performance gap compared to 2D (spatial) tokenizers in absolute reconstruction quality. Hybrid VLT architectures remain an open area for exploration.
  • LoRA Overhead: To achieve absolute peak performance across all lengths, the authors utilized lightweight, length-specific Low-Rank Adaptation (LoRA) post-training. While adding only ~2.5% extra training overhead, it introduces slight complexity to the deployment pipeline.
  • The Limits of Data-Independence: While necessary for generation, global merging is inherently less efficient at compressing highly specific, fine-grained image details than data-dependent merging. Discovering methods to introduce "safe" data-dependency during the generation phase is a compelling challenge for future research.

Summary updated

BibTeX
@inproceedings{lee2026variable,
  author = {Dong Hoon Lee and Seunghoon Hong},
  title = {{Variable-Length Tokenization via Learnable Global Merging for Diffusion Transformers}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=6ER1mP51np},
}
Figure