# gynjn/mvp architecture

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

- Interactive diagram: https://gitdiagram.com/gynjn/mvp
- Repository: https://github.com/gynjn/mvp

## Overview

MVP is a multi-view reconstruction system: it accepts posed image views, runs a pyramid-transformer model, and produces rendered results that can be exported and evaluated. It also supports staged model training and optional faster attention and CUDA spherical-harmonics computation. The graph follows documented inference and training entry points and source-index references; training internals and some rendering details were not sampled, so those connections are omitted where their callers are unclear.

Main entry points: [`model/mvp.py`](https://github.com/gynjn/mvp/blob/main/model/mvp.py) (MVP model), [`inference.py`](https://github.com/gynjn/mvp/blob/main/inference.py) (Inference runner), [`train.py`](https://github.com/gynjn/mvp/blob/main/train.py) (Distributed training), [`train_single.py`](https://github.com/gynjn/mvp/blob/main/train_single.py) (Single-GPU training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["View data"]
  node_dataset["Scene dataset<br/>[dataset.py]"]
  node_base["Dataset base<br/>[base_dataset.py]"]
  node_sampler["Dynamic sampler<br/>[batched_sampler.py]"]
end

subgraph group_model["Reconstruction model"]
  node_mvp["MVP model<br/>[mvp.py]"]
  node_transformer["Transformer blocks<br/>[transformer.py]"]
  node_camera["Camera geometry<br/>[camera_utils.py]"]
  node_dpt["DPT head<br/>[dpt_head.py]"]
  node_modelutils["Model utilities<br/>[utils.py]"]
  node_prope["PRoPE attention<br/>[prope_custom.py]"]
  node_propefa["Flash attention PRoPE<br/>[prope_custom_fa.py]"]
  node_loss["Loss computer<br/>[loss.py]"]
  node_sh["SH opacity kernel"]
end

subgraph group_runtime["Inference and evaluation"]
  node_inference["Inference runner<br/>[inference.py]"]
  node_metrics["Result export and metrics<br/>[metric_utils.py]"]
end

subgraph group_training["Training"]
  node_train["Distributed training<br/>[train.py]"]
  node_train_single["Single-GPU training<br/>[train_single.py]"]
  node_train_stage3["Stage-three training<br/>[train_stage3.py]"]
  node_trainingutils["Training utilities<br/>[training_utils.py]"]
  node_setup["Runtime configuration<br/>[setup.py]"]
end

node_user(("User"))

node_user -->|"runs inference"| node_inference
node_inference -->|"loads batches"| node_dataset
node_inference -->|"runs model"| node_mvp
node_inference -->|"exports results"| node_metrics
node_base -->|"creates sampler"| node_sampler
node_dataset -->|"inherits"| node_base
node_mvp -->|"uses blocks"| node_transformer
node_mvp -->|"uses geometry"| node_camera
node_mvp -->|"uses head"| node_dpt
node_mvp -->|"uses utilities"| node_modelutils
node_mvp -->|"uses attention"| node_prope
node_mvp -->|"uses attention"| node_propefa
node_mvp -->|"creates loss"| node_loss
node_mvp -->|"uses opacity kernel"| node_sh
node_user -->|"starts training"| node_train
node_user -->|"starts training"| node_train_single
node_train -->|"configures runtime"| node_setup
node_train -->|"uses utilities"| node_trainingutils
node_train_single -->|"configures runtime"| node_setup
node_train_single -->|"uses utilities"| node_trainingutils
node_train_stage3 -->|"configures runtime"| node_setup
node_train_stage3 -->|"uses utilities"| node_trainingutils

click node_inference "https://github.com/gynjn/mvp/blob/main/inference.py"
click node_dataset "https://github.com/gynjn/mvp/blob/main/data/dataset.py"
click node_base "https://github.com/gynjn/mvp/blob/main/data/base_dataset.py"
click node_sampler "https://github.com/gynjn/mvp/blob/main/data/batched_sampler.py"
click node_mvp "https://github.com/gynjn/mvp/blob/main/model/mvp.py"
click node_transformer "https://github.com/gynjn/mvp/blob/main/model/transformer.py"
click node_camera "https://github.com/gynjn/mvp/blob/main/model/camera_utils.py"
click node_dpt "https://github.com/gynjn/mvp/blob/main/model/dpt_head.py"
click node_modelutils "https://github.com/gynjn/mvp/blob/main/model/utils.py"
click node_prope "https://github.com/gynjn/mvp/blob/main/model/prope_custom.py"
click node_propefa "https://github.com/gynjn/mvp/blob/main/model/prope_custom_fa.py"
click node_loss "https://github.com/gynjn/mvp/blob/main/model/loss.py"
click node_sh "https://github.com/gynjn/mvp/blob/main/sh_cuda/mvp_cuda/spherical_harmonics.py"
click node_metrics "https://github.com/gynjn/mvp/blob/main/metric_utils.py"
click node_train "https://github.com/gynjn/mvp/blob/main/train.py"
click node_train_single "https://github.com/gynjn/mvp/blob/main/train_single.py"
click node_train_stage3 "https://github.com/gynjn/mvp/blob/main/train_stage3.py"
click node_trainingutils "https://github.com/gynjn/mvp/blob/main/training_utils.py"
click node_setup "https://github.com/gynjn/mvp/blob/main/setup.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_dataset,node_base,node_sampler,node_user toneBlue
class node_mvp,node_transformer,node_camera,node_dpt,node_modelutils,node_prope,node_propefa,node_loss,node_sh toneAmber
class node_inference,node_metrics toneMint
class node_train,node_train_single,node_train_stage3,node_trainingutils,node_setup toneRose
```

## Components

### View data

- [Scene dataset](https://github.com/gynjn/mvp/blob/main/data/dataset.py): `data/dataset.py`
- [Dataset base](https://github.com/gynjn/mvp/blob/main/data/base_dataset.py): `data/base_dataset.py`
- [Dynamic sampler](https://github.com/gynjn/mvp/blob/main/data/batched_sampler.py): `data/batched_sampler.py`

### Reconstruction model

- [MVP model](https://github.com/gynjn/mvp/blob/main/model/mvp.py): `model/mvp.py`
- [Transformer blocks](https://github.com/gynjn/mvp/blob/main/model/transformer.py): `model/transformer.py`
- [Camera geometry](https://github.com/gynjn/mvp/blob/main/model/camera_utils.py): `model/camera_utils.py`
- [DPT head](https://github.com/gynjn/mvp/blob/main/model/dpt_head.py): `model/dpt_head.py`
- [Model utilities](https://github.com/gynjn/mvp/blob/main/model/utils.py): `model/utils.py`
- [PRoPE attention](https://github.com/gynjn/mvp/blob/main/model/prope_custom.py): `model/prope_custom.py`
- [Flash attention PRoPE](https://github.com/gynjn/mvp/blob/main/model/prope_custom_fa.py): `model/prope_custom_fa.py`
- [Loss computer](https://github.com/gynjn/mvp/blob/main/model/loss.py): `model/loss.py`
- [SH opacity kernel](https://github.com/gynjn/mvp/blob/main/sh_cuda/mvp_cuda/spherical_harmonics.py): `sh_cuda/mvp_cuda/spherical_harmonics.py`

### Inference and evaluation

- [Inference runner](https://github.com/gynjn/mvp/blob/main/inference.py): `inference.py`
- [Result export and metrics](https://github.com/gynjn/mvp/blob/main/metric_utils.py): `metric_utils.py`

### Training

- [Distributed training](https://github.com/gynjn/mvp/blob/main/train.py): `train.py`
- [Single-GPU training](https://github.com/gynjn/mvp/blob/main/train_single.py): `train_single.py`
- [Stage-three training](https://github.com/gynjn/mvp/blob/main/train_stage3.py): `train_stage3.py`
- [Training utilities](https://github.com/gynjn/mvp/blob/main/training_utils.py): `training_utils.py`
- [Runtime configuration](https://github.com/gynjn/mvp/blob/main/setup.py): `setup.py`

### Other components

- **User**

## Connections

- User → Inference runner: runs inference (evidence: `README.md`)
- Inference runner → Scene dataset: loads batches (evidence: `inference.py`)
- Inference runner → MVP model: runs model (evidence: `inference.py`)
- Inference runner → Result export and metrics: exports results (evidence: `inference.py`)
- Dataset base → Dynamic sampler: creates sampler (evidence: `data/base_dataset.py`)
- Scene dataset → Dataset base: inherits (evidence: `data/dataset.py`)
- MVP model → Transformer blocks: uses blocks (evidence: `model/mvp.py`)
- MVP model → Camera geometry: uses geometry (evidence: `model/mvp.py`)
- MVP model → DPT head: uses head (evidence: `model/mvp.py`)
- MVP model → Model utilities: uses utilities (evidence: `model/mvp.py`)
- MVP model → PRoPE attention: uses attention (evidence: `model/mvp.py`)
- MVP model → Flash attention PRoPE: uses attention (evidence: `model/mvp.py`)
- MVP model → Loss computer: creates loss (evidence: `model/mvp.py`)
- MVP model → SH opacity kernel: uses opacity kernel (evidence: `model/mvp.py`)
- User → Distributed training: starts training (evidence: `README.md`)
- User → Single-GPU training: starts training (evidence: `README.md`)
- Distributed training → Runtime configuration: configures runtime (evidence: `train.py`)
- Distributed training → Training utilities: uses utilities (evidence: `train.py`)
- Single-GPU training → Runtime configuration: configures runtime (evidence: `train_single.py`)
- Single-GPU training → Training utilities: uses utilities (evidence: `train_single.py`)
- Stage-three training → Runtime configuration: configures runtime (evidence: `train_stage3.py`)
- Stage-three training → Training utilities: uses utilities (evidence: `train_stage3.py`)
