Anytime Sampling for Autoregressive Models via Ordered Autoencoding

Yilun Xu, Yang Song, Sahaj Garg, Linyuan Gong, Rui Shu, Aditya Grover, Stefano Ermon

TL;DR

Autoregressive models are the gold standard for high-quality generation but are notoriously slow and "all-or-nothing"—you cannot stop the process halfway and get a usable result. This paper introduces Anytime Sampling, a method that allows these models to produce a complete, coarse-to-fine output at any point during the generation process, enabling a graceful trade-off between sample quality and computational budget.

The Bottleneck of Autoregressive Generation

Autoregressive (AR) models, such as PixelCNN or Transformers, generate data sequentially (e.g., one pixel or one word at a time). This creates two major bottlenecks for real-world deployment:

  1. Linear Scaling: The time to generate a sample grows linearly with the data dimension. For high-resolution images or audio, this sequential process is painfully slow.
  2. Non-Interruptibility: Because the model generates data in a fixed spatial order (like top-left to bottom-right), interrupting the process leaves you with a half-finished, useless fragment.

In practice, computational resources vary. A mobile phone might need a quick, low-fidelity preview, while a powerful server can afford full-quality generation. Standard AR models cannot adapt to these "anytime" constraints without training separate models for every possible budget.

Methods: Ordered Autoencoders

To solve this, the authors propose a new family of models called Ordered Autoencoders (specifically Ordered VQ-VAEs or OVQ-VAEs). The core idea is to move the AR generation from the high-dimensional pixel space into a structured, lower-dimensional latent space.

  • Ordered Latent Space: Inspired by Principal Component Analysis (PCA), the authors use a "nested dropout" objective during training. This forces the encoder to pack the most important information for reconstruction into the first few dimensions of the latent code.
  • Channel-wise Quantization: A key technical contribution is the move from spatial-wise to channel-wise quantization. In standard VQ-VAEs, latent codes represent specific grid locations. If you stop early, you only get a spatial crop of the image. By quantizing across channels instead, each latent code contains global information about the entire image, just at a lower level of detail.
Ordered Autoencoder Architecture
  • Latent Autoregressive Modeling: A Transformer is trained to predict these ordered latent codes. Because the codes are ordered by importance, the Transformer naturally learns to generate a "coarse" version of the data first, then progressively refines it with "fine" details.

Key Insights and Results

The authors evaluated their approach on standard benchmarks including MNIST, CIFAR-10, CelebA, and the VCTK audio dataset.

Coarse-to-Fine is the Key to Anytime

By ordering the latent space, the model mimics the behavior of a "progressive JPEG." The first few bits give you the "gist" of the image (global structure), and subsequent bits fill in the textures and sharp edges.

Coarse-to-fine generation across datasets

Graceful Quality Decay and Inference Speedup

In image tasks, the model suffers almost no loss in sample quality (measured by FID) using only 60% to 80% of the latent dimensions. This translates to a significant reduction in sampling time without a perceptible drop in quality. On CelebA, the model can save roughly 40% of run-time by truncating the generation early while still producing high-quality faces.

For the VCTK dataset, the model captures the global structure of the audio waveform with as little as 6.25% of the full code length, gradually refining the high-frequency components as more codes are sampled.

The "Free Lunch" of Regularization

Surprisingly, forcing an order on the latent space acts as a useful regularizer. On CIFAR-10, the Ordered VQ-VAE actually achieved better FID scores than a standard unordered VQ-VAE, even when using the full code length. Furthermore, while PCA provides a theoretical foundation, the authors found that AR models perform much better on discrete latent codes (VQ-VAE) than on continuous PCA projections.

Limitations and Future Work

While the method allows for early stopping, the underlying generation is still autoregressive. The "anytime" nature helps manage budgets, but it doesn't fundamentally change the sequential scaling nature of the latent model itself. Additionally, the model is sensitive to the sampling distribution used during training (e.g., uniform vs. geometric distributions for the truncation index).

Future directions could include integrating this approach with more advanced AR architectures or exploring different types of "importance" (e.g., semantic importance rather than just reconstruction importance).

Summary updated

BibTeX
@inproceedings{xu2021anytime,
  author = {Yilun Xu and Yang Song and Sahaj Garg and Linyuan Gong and Rui Shu and Aditya Grover and Stefano Ermon},
  title = {{Anytime Sampling for Autoregressive Models via Ordered Autoencoding}},
  booktitle = {International Conference on Learning Representations},
  year = {2021},
  url = {https://openreview.net/forum?id=TSRTzJnuEBS},
}
Figure