dRAE: Representation Autoencoder with Hyper-Spherical Codes

Tianren Ma, Lin Long, Chuyan Chen, Mu Zhang, Junbo Zhao, Tong Zhang, Qixiang Ye

TL;DR

High-dimensional visual tokenizers often suffer from codebook collapse due to a metric mismatch between Euclidean distance and the anisotropic geometry of representation spaces. This paper introduces Hyper-Spherical Quantization (HSQ), which decouples semantic routing (angular) from magnitude optimization, enabling the discrete Representation Autoencoder (dRAE) to scale its vocabulary up to 131,072 codes with 100% utilization for both visual understanding and generation tasks.

What Problem Does This Paper Address?

To build unified multimodal large language models (MLLMs) that can both "see" (understand) and "draw" (generate), researchers need a unified visual tokenizer. Currently, most models use disjointed pipelines: a Vision Transformer (ViT) for comprehension and an independent Variational Autoencoder (VAE) for pixel-level generation.

Recent attempts to bridge this gap use Representation Autoencoders (RAEs) to quantize high-dimensional features directly from Vision Foundation Models (VFMs). However, these approaches suffer from severe codebook collapse—a phenomenon where the model repeatedly selects only a tiny fraction of available discrete codes, causing performance to plateau at vocabulary sizes larger than 16K.

The authors identify the root cause as a metric mismatch. Standard Vector Quantization (VQ) relies on Euclidean ($\ell_2$) distance for codebook assignment. However, the semantic space of a VFM is anisotropic, meaning meaning is primarily encoded in the orientation (angles) of vectors, while structural details are encoded in their magnitude. Using Euclidean distance allows vectors with large magnitudes to disproportionately dominate and "hijack" codebook assignments, regardless of their actual semantic alignment.

Figure 1: Illustration of the code space defined by VQ (a) and HSQ (b), and distribution of their learned codebook embeddings (c). Sim(·) for cosine similarity, and sg(·) for stop-gradient operation. For the angular analysis in c, we sample features from the central region with similar magnitude ranges and visualize them with PCA dimension reduction [58].

Methods

The authors propose Hyper-Spherical Quantization (HSQ) to explicitly decouple the metric used for codebook routing from the quantization objective. This powers their new tokenizer, the discrete Representation Autoencoder (dRAE).

  1. Angular Codebook Routing: Instead of using Euclidean distance to find the nearest codebook entry, HSQ uses cosine similarity. This ensures that tokens are assigned to codes based purely on their semantic direction.
  2. Spherical Codebook Loss: The codebook update loss is rewritten as a spherical objective, constraining codebook updates to the tangent space of the hyper-sphere.
  3. Magnitude-Aware Commitment Loss: Crucially, the authors retain a standard Euclidean ($\ell_2$) objective for the commitment loss. While the codebook is selected based on angle, this term ensures the model still tracks and preserves the feature magnitudes necessary for high-fidelity image reconstruction.

Unlike previous methods that rely on complex multi-stage training or anti-collapse heuristics, dRAE simplifies the pipeline by training end-to-end in a single stage.

Datasets

The model was trained and evaluated across several diverse benchmarks:

  • Pre-training & Reconstruction: Trained on the 36M open-sourced images from BLIP3-o and evaluated on the ImageNet-1K validation set.
  • Multimodal Understanding: Instruction-tuned using LLaVA-1.5 data and 1M image-text pairs from LLaVA-OneVision. Evaluated on MMBench, TextVQA, POPE, GQA, MME, and SEEDBench-Img.
  • Text-to-Image Generation: Pre-trained on 12M image-text pairs (including Megalith-10M and T2I-2M) and evaluated on GenEval and DPG-Bench.

Key Insights and Ideas

  • The Angle vs. Magnitude Dichotomy: Through diagnostic testing, the authors proved two core hypotheses: normalizing VFM features to a unit hyper-sphere has a negligible (~1%) impact on multimodal understanding, but it severely degrades image reconstruction. Semantics live in the angles; texture and structure live in the magnitudes.
  • Eliminating Magnitude Bias: By shifting codebook routing to cosine similarity, HSQ achieves magnitude homogenization and angular uniformity. It eliminates the high-variance outliers that trigger codebook collapse in vanilla VQ.
  • Stable Training Dynamics: Standard VQ training often exhibits severe loss oscillations and codebook gradient spikes when scaled. HSQ maintains stable gradient norms throughout training, preventing the sudden collapse modes typical of Euclidean VQ.
Figure 2: Left: Training curve under identical set- tings. Right: Gradient norm of codebook during training, where VQ’s collapse mode can be observed.

Key Results

  • Vocabulary Scaling: While standard VQ tokenizers plateau early, dRAE scales successfully up to a massive vocabulary size of 131,072 codes while maintaining >90% global code utilization without any stochastic sampling tricks.
  • Reconstruction Fidelity: At a 131K vocabulary size, dRAE achieves a reconstruction FID (rFID) of 0.42 on ImageNet, vastly outperforming the baseline VQRAE (1.31 rFID) and even beating continuous low-dimensional VAEs like SD-VAE (0.49 rFID).
  • Downstream Performance: When integrated into an MLLM pipeline, dRAE demonstrates strong performance on understanding tasks (achieving an 81.5 MMBench score) and delivers competitive text-to-image generation capabilities on GenEval (0.63 overall score), despite being trained on a fraction of the data used by continuous generation giants like DALL-E 3.

Limitations and Future Work

  • Feature Reconstruction Challenges: The authors note that reconstructing high-dimensional patch embeddings directly is inherently more difficult than reconstructing raw pixels due to intrinsic noise in the frozen encoder and the lack of explicit perceptual supervision.
  • Data Scale: While dRAE shows exceptional data efficiency, the authors leave exhaustive data scaling and larger-scale model curation for text-to-image generation to future work.

Summary updated

BibTeX
@inproceedings{ma2026drae,
  author = {Tianren Ma and Lin Long and Chuyan Chen and Mu Zhang and Junbo Zhao and Tong Zhang and Qixiang Ye},
  title = {{dRAE: Representation Autoencoder with Hyper-Spherical Codes}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=vrjQMuRQQi},
}
Figure