# blaise143/stochastic-interpolant-diffusion architecture

> Architecture diagram of the GitHub repository blaise143/stochastic-interpolant-diffusion, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/blaise143/stochastic-interpolant-diffusion
- Repository: https://github.com/blaise143/stochastic-interpolant-diffusion

## Overview

This repository trains and samples stochastic-interpolant flow/diffusion models for EMNIST digits. The principal path is configuration-driven training or sampling: training loads and preprocesses digits, learns a conditional vector field, and saves a checkpoint; sampling loads that model and integrates it with an ODE or SDE solver to produce images. The graph preserves the documented solver, scheduler, classifier-free-guidance, attention, distributed-training, and logging capabilities. Relationships involving unsampled configuration and model internals are limited to README or source-index evidence.

Main entry points: [`main.py`](https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/main.py) (Run controller), [`training/flow_trainer.py`](https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/training/flow_trainer.py) (Flow trainer), [`models/flow.py`](https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/models/flow.py) (Flow model), [`data/dataset.py`](https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/data/dataset.py) (EMNIST loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Application entry"]
  node_main["Run controller<br/>[main.py]"]
  node_config["Run configuration<br/>[config.yaml]"]
end

subgraph group_data["Digit data"]
  node_dataset["EMNIST loader<br/>[dataset.py]"]
  node_transforms["Image transforms<br/>[transforms.py]"]
  node_data_base["Dataset abstractions<br/>[base.py]"]
end

subgraph group_model["Modeling"]
  node_flow["Flow model<br/>[flow.py]"]
  node_interpolant["Interpolant base"]
  node_unet["U-Net field<br/>[unet.py]"]
  node_embeddings["Time and labels<br/>[embedding.py]"]
  node_attention["Self-attention<br/>[attention.py]"]
  node_schedulers["Path schedulers<br/>[schedulers.py]"]
end

subgraph group_runtime["Training and sampling"]
  node_trainer["Flow trainer<br/>[flow_trainer.py]"]
  node_logger["Experiment logger<br/>[logger.py]"]
  node_solver_base["Solver loop<br/>[base_solver.py]"]
  node_ode["ODE integrators<br/>[ode_solver.py]"]
  node_sde["SDE integrator<br/>[sde_solver.py]"]
  node_checkpoint[("Model checkpoint<br/>[flow_model.pth]")]
  node_samples["Generated images"]
end

node_user(("Research user"))
node_logging_services["Logging backends"]

node_user -->|"runs"| node_main
node_main -->|"loads settings"| node_config
node_main -->|"starts training"| node_trainer
node_main -->|"constructs model"| node_flow
node_main -->|"selects flow solver"| node_ode
node_main -->|"selects diffusion solver"| node_sde
node_main -->|"loads weights"| node_checkpoint
node_main -->|"saves images"| node_samples
node_trainer -->|"loads batches"| node_dataset
node_dataset -->|"applies preprocessing"| node_transforms
node_dataset -->|"extends abstractions"| node_data_base
node_trainer -->|"trains model"| node_flow
node_trainer -->|"samples during training"| node_ode
node_trainer -->|"logs metrics"| node_logger
node_trainer -->|"saves weights"| node_checkpoint
node_flow -->|"extends"| node_interpolant
node_flow -->|"builds field network"| node_unet
node_flow -->|"selects path scheduler"| node_schedulers
node_unet -->|"uses embeddings"| node_embeddings
node_unet -.->|"uses optional attention"| node_attention
node_solver_base -->|"evaluates field"| node_flow
node_ode -->|"inherits loop"| node_solver_base
node_sde -->|"inherits loop"| node_solver_base
node_logger -.->|"optionally reports"| node_logging_services

click node_main "https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/main.py"
click node_config "https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/config/config.yaml"
click node_dataset "https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/data/dataset.py"
click node_transforms "https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/data/transforms.py"
click node_data_base "https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/data/base.py"
click node_flow "https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/models/flow.py"
click node_interpolant "https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/models/stochastic_interpolant_base.py"
click node_unet "https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/models/unet.py"
click node_embeddings "https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/models/embedding.py"
click node_attention "https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/models/attention.py"
click node_schedulers "https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/models/schedulers.py"
click node_trainer "https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/training/flow_trainer.py"
click node_logger "https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/training/logger.py"
click node_solver_base "https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/sampling/base_solver.py"
click node_ode "https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/sampling/ode_solver.py"
click node_sde "https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/sampling/sde_solver.py"
click node_checkpoint "https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/checkpoints/flow_model.pth"
click node_samples "https://github.com/blaise143/stochastic-interpolant-diffusion/tree/main/images"

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_main,node_config,node_user toneBlue
class node_dataset,node_transforms,node_data_base toneAmber
class node_flow,node_interpolant,node_unet,node_embeddings,node_attention,node_schedulers toneMint
class node_trainer,node_logger,node_solver_base,node_ode,node_sde,node_checkpoint,node_samples toneRose
class node_logging_services toneIndigo
```

## Components

### Application entry

- [Run controller](https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/main.py): `main.py`
- [Run configuration](https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/config/config.yaml): `config/config.yaml`

### Digit data

- [EMNIST loader](https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/data/dataset.py): `data/dataset.py`
- [Image transforms](https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/data/transforms.py): `data/transforms.py`
- [Dataset abstractions](https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/data/base.py): `data/base.py`

### Modeling

- [Flow model](https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/models/flow.py): `models/flow.py`
- [Interpolant base](https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/models/stochastic_interpolant_base.py): `models/stochastic_interpolant_base.py`
- [U-Net field](https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/models/unet.py): `models/unet.py`
- [Time and labels](https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/models/embedding.py): `models/embedding.py`
- [Self-attention](https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/models/attention.py): `models/attention.py`
- [Path schedulers](https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/models/schedulers.py): `models/schedulers.py`

### Training and sampling

- [Flow trainer](https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/training/flow_trainer.py): `training/flow_trainer.py`
- [Experiment logger](https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/training/logger.py): `training/logger.py`
- [Solver loop](https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/sampling/base_solver.py): `sampling/base_solver.py`
- [ODE integrators](https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/sampling/ode_solver.py): `sampling/ode_solver.py`
- [SDE integrator](https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/sampling/sde_solver.py): `sampling/sde_solver.py`
- [Model checkpoint](https://github.com/blaise143/stochastic-interpolant-diffusion/blob/main/checkpoints/flow_model.pth): `checkpoints/flow_model.pth`
- [Generated images](https://github.com/blaise143/stochastic-interpolant-diffusion/tree/main/images): `images`

### Other components

- **Research user**
- **Logging backends**

## Connections

- Research user → Run controller: runs (evidence: `README.md`)
- Run controller → Run configuration: loads settings (evidence: `main.py`)
- Run controller → Flow trainer: starts training (evidence: `main.py`)
- Run controller → Flow model: constructs model (evidence: `main.py`)
- Run controller → ODE integrators: selects flow solver (evidence: `README.md`)
- Run controller → SDE integrator: selects diffusion solver (evidence: `README.md`)
- Run controller → Model checkpoint: loads weights (evidence: `main.py`)
- Run controller → Generated images: saves images (evidence: `main.py`)
- Flow trainer → EMNIST loader: loads batches (evidence: `training/flow_trainer.py`)
- EMNIST loader → Image transforms: applies preprocessing (evidence: `data/dataset.py`)
- EMNIST loader → Dataset abstractions: extends abstractions (evidence: `data/dataset.py`)
- Flow trainer → Flow model: trains model (evidence: `training/flow_trainer.py`)
- Flow trainer → ODE integrators: samples during training (evidence: `training/flow_trainer.py`)
- Flow trainer → Experiment logger: logs metrics (evidence: `training/flow_trainer.py`)
- Flow trainer → Model checkpoint: saves weights (evidence: `training/flow_trainer.py`)
- Flow model → Interpolant base: extends (evidence: `models/flow.py`)
- Flow model → U-Net field: builds field network (evidence: `models/flow.py`)
- Flow model → Path schedulers: selects path scheduler (evidence: `models/flow.py`)
- U-Net field → Time and labels: uses embeddings (evidence: `models/unet.py`)
- U-Net field → Self-attention: uses optional attention (evidence: `models/unet.py`)
- Solver loop → Flow model: evaluates field (evidence: `sampling/base_solver.py`)
- ODE integrators → Solver loop: inherits loop (evidence: `sampling/ode_solver.py`)
- SDE integrator → Solver loop: inherits loop (evidence: `sampling/sde_solver.py`)
- Experiment logger → Logging backends: optionally reports (evidence: `training/logger.py`)
