# openai/vdvae architecture

> Architecture diagram of the GitHub repository openai/vdvae, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/openai/vdvae
- Repository: https://github.com/openai/vdvae

## Overview

Very Deep VAEs is a research implementation for training, evaluating, restoring, and sampling deep variational autoencoders on image datasets. The principal workflow selects dataset-specific hyperparameters, loads and preprocesses images, trains the VAE, then evaluates likelihoods or generates samples. The graph preserves the dataset, model, training, and distributed/checkpoint-support stages. Edges follow the README or shown calls/imports; unsampled implementation details are not expanded.

Main entry points: [`train.py`](https://github.com/openai/vdvae/blob/main/train.py) (Train and evaluate), [`train_helpers.py`](https://github.com/openai/vdvae/blob/main/train_helpers.py) (Model and optimizer setup), [`vae.py`](https://github.com/openai/vdvae/blob/main/vae.py) (VAE encoder and decoder), [`data.py`](https://github.com/openai/vdvae/blob/main/data.py) (Image datasets)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Image data"]
  node_image_data[("Image datasets<br/>[data.py]")]
  node_preprocessing["Image preprocessing<br/>[data.py]"]
end

subgraph group_model["VAE model"]
  node_vae["VAE encoder and decoder<br/>[vae.py]"]
  node_vae_ops["VAE and image likelihood ops<br/>[vae_helpers.py]"]
end

subgraph group_training["Training and evaluation"]
  node_train_entry["Training entry point<br/>[train.py]"]
  node_training_loop["Train and evaluate<br/>[train.py]"]
  node_samples["Generated image samples<br/>[train.py]"]
end

subgraph group_support["Runtime support"]
  node_config["Dataset configurations<br/>[hps.py]"]
  node_train_support["Model and optimizer setup<br/>[train_helpers.py]"]
  node_distributed["Distributed statistics<br/>[utils.py]"]
  node_checkpoint["Checkpoints and restore<br/>[train_helpers.py]"]
  node_checkpoint_files["Saved model files"]
end

node_researcher(("Researcher"))

node_researcher -->|"starts run"| node_train_entry
node_train_entry -->|"loads options"| node_config
node_train_entry -->|"loads datasets"| node_image_data
node_train_entry -->|"sets up models"| node_train_support
node_image_data -->|"provides examples"| node_preprocessing
node_train_entry -->|"runs workflow"| node_training_loop
node_training_loop -->|"preprocesses batches"| node_preprocessing
node_training_loop -->|"trains and evaluates"| node_vae
node_training_loop -->|"reduces statistics"| node_distributed
node_train_support -->|"parses options"| node_config
node_train_support -->|"constructs models"| node_vae
node_train_support -->|"uses MPI helpers"| node_distributed
node_vae -->|"uses model ops"| node_vae_ops
node_training_loop -->|"saves checkpoints"| node_checkpoint
node_checkpoint -->|"writes and restores"| node_checkpoint_files
node_training_loop -->|"generates visualizations"| node_samples
node_vae -->|"samples images"| node_samples
node_researcher -->|"restores models"| node_checkpoint
node_researcher -->|"requests test evaluation"| node_training_loop

click node_image_data "https://github.com/openai/vdvae/blob/main/data.py"
click node_preprocessing "https://github.com/openai/vdvae/blob/main/data.py"
click node_config "https://github.com/openai/vdvae/blob/main/hps.py"
click node_train_entry "https://github.com/openai/vdvae/blob/main/train.py"
click node_training_loop "https://github.com/openai/vdvae/blob/main/train.py"
click node_vae "https://github.com/openai/vdvae/blob/main/vae.py"
click node_vae_ops "https://github.com/openai/vdvae/blob/main/vae_helpers.py"
click node_train_support "https://github.com/openai/vdvae/blob/main/train_helpers.py"
click node_distributed "https://github.com/openai/vdvae/blob/main/utils.py"
click node_checkpoint "https://github.com/openai/vdvae/blob/main/train_helpers.py"
click node_samples "https://github.com/openai/vdvae/blob/main/train.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_image_data,node_preprocessing toneBlue
class node_vae,node_vae_ops toneAmber
class node_train_entry,node_training_loop,node_samples toneMint
class node_config,node_train_support,node_distributed,node_checkpoint,node_checkpoint_files toneRose
class node_researcher toneIndigo
```

## Components

### Image data

- [Image datasets](https://github.com/openai/vdvae/blob/main/data.py): `data.py`
- [Image preprocessing](https://github.com/openai/vdvae/blob/main/data.py): `data.py`

### VAE model

- [VAE encoder and decoder](https://github.com/openai/vdvae/blob/main/vae.py): `vae.py`
- [VAE and image likelihood ops](https://github.com/openai/vdvae/blob/main/vae_helpers.py): `vae_helpers.py`

### Training and evaluation

- [Training entry point](https://github.com/openai/vdvae/blob/main/train.py): `train.py`
- [Train and evaluate](https://github.com/openai/vdvae/blob/main/train.py): `train.py`
- [Generated image samples](https://github.com/openai/vdvae/blob/main/train.py): `train.py`

### Runtime support

- [Dataset configurations](https://github.com/openai/vdvae/blob/main/hps.py): `hps.py`
- [Model and optimizer setup](https://github.com/openai/vdvae/blob/main/train_helpers.py): `train_helpers.py`
- [Distributed statistics](https://github.com/openai/vdvae/blob/main/utils.py): `utils.py`
- [Checkpoints and restore](https://github.com/openai/vdvae/blob/main/train_helpers.py): `train_helpers.py`
- **Saved model files**

### Other components

- **Researcher**

## Connections

- Researcher → Training entry point: starts run (evidence: `README.md`)
- Training entry point → Dataset configurations: loads options
- Training entry point → Image datasets: loads datasets (evidence: `train.py`)
- Training entry point → Model and optimizer setup: sets up models (evidence: `train.py`)
- Image datasets → Image preprocessing: provides examples (evidence: `data.py`)
- Training entry point → Train and evaluate: runs workflow (evidence: `train.py`)
- Train and evaluate → Image preprocessing: preprocesses batches (evidence: `train.py`)
- Train and evaluate → VAE encoder and decoder: trains and evaluates (evidence: `train.py`)
- Train and evaluate → Distributed statistics: reduces statistics (evidence: `train.py`)
- Model and optimizer setup → Dataset configurations: parses options (evidence: `train_helpers.py`)
- Model and optimizer setup → VAE encoder and decoder: constructs models (evidence: `train_helpers.py`)
- Model and optimizer setup → Distributed statistics: uses MPI helpers (evidence: `train_helpers.py`)
- VAE encoder and decoder → VAE and image likelihood ops: uses model ops (evidence: `vae.py`)
- Train and evaluate → Checkpoints and restore: saves checkpoints (evidence: `train.py`)
- Checkpoints and restore → Saved model files: writes and restores (evidence: `train_helpers.py`)
- Train and evaluate → Generated image samples: generates visualizations (evidence: `train.py`)
- VAE encoder and decoder → Generated image samples: samples images (evidence: `train.py`)
- Researcher → Checkpoints and restore: restores models (evidence: `README.md`)
- Researcher → Train and evaluate: requests test evaluation (evidence: `README.md`)
