The first stage of the two-stage training pipeline in the DALL·E 1 paper, whose core task is to train a discrete variational autoencoder (dVAE) to create an efficient discrete visual codebook for images. Specifically, this stage aims to compress a 256×256 high-resolution RGB image into a 32×32 grid of discrete tokens, where each token is drawn from a codebook of 8,192 visual vocabulary entries, thereby reducing the sequence length by a factor of 192 and dramatically easing the modeling burden on the subsequent Transformer. In implementation, an encoder converts the image into logits for each grid position, and the Gumbel-Softmax relaxation trick resolves the non-differentiability of discrete token selection, enabling end-to-end training. The decoder then reconstructs the image from these 1,024 visual tokens. The training objective optimizes the evidence lower bound (ELBO), comprising a reconstruction loss and a KL divergence term. The reconstruction term uses a Logit-Laplace distribution, which better matches the bounded nature of pixel values, while the KL weight is increased to 6.6 to promote higher codebook utilization. Ultimately, this stage produces a powerful visual encoder-decoder pair capable of converting images into discrete token sequences that preserve their main structure and content.