# kevinghst/h-jepa architecture

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

- Interactive diagram: https://gitdiagram.com/kevinghst/h-jepa
- Repository: https://github.com/kevinghst/h-jepa

## Overview

H-JEPA trains hierarchical visual world models and evaluates them through planning, probing, and decoding; it also supports DROID workflows. The runtime combines model code with stable-worldmodel’s datasets, environments, policies, and solvers. The README documents the main training/evaluation workflows and model capabilities; source excerpts and the index support only the specific internal links shown below, so unsampled integrations are omitted.

Main entry points: [`h_jepa/planning_eval.py`](https://github.com/kevinghst/h-jepa/blob/main/h_jepa/planning_eval.py) (Planning Evaluation), [`stable_worldmodel/world.py`](https://github.com/kevinghst/h-jepa/blob/main/stable_worldmodel/world.py) (Environment Manager), [`h_jepa/main_hjepa.py`](https://github.com/kevinghst/h-jepa/blob/main/h_jepa/main_hjepa.py) (Training), [`h_jepa/final_probing_decoding_eval.py`](https://github.com/kevinghst/h-jepa/blob/main/h_jepa/final_probing_decoding_eval.py) (Probe and Decode)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Workflows"]
  node_training["Training<br/>[main_hjepa.py]"]
end

subgraph group_model["JEPA Models"]
  node_jepa["JEPA Levels<br/>[jepa.py]"]
  node_hierarchical_jepa["Hierarchical JEPA<br/>[hjepa.py]"]
  node_encoders["Visual Encoders"]
  node_transformer["Transformer Blocks<br/>[module.py]"]
  node_predictors["Predictors<br/>[predictors.py]"]
  node_loss["Training Loss<br/>[loss.py]"]
end

subgraph group_eval["Evaluation"]
  node_planning_eval["Planning Evaluation<br/>[planning_eval.py]"]
  node_hierarchical_solver["Hierarchical Planner"]
  node_probe_eval["Probe and Decode"]
  node_droid_eval["DROID Evaluation<br/>[droid_eval.py]"]
end

subgraph group_runtime["Worldmodel Runtime"]
  node_datasets["Dataset Loading<br/>[data.py]"]
  node_world["Environment Manager<br/>[world.py]"]
  node_policy["Planning Policies<br/>[policy.py]"]
  node_solver["Solver Interface<br/>[solver.py]"]
  node_wrappers["Environment Wrappers<br/>[wrapper.py]"]
end

subgraph group_envs["Environments"]
  node_fourroom["FourRoom<br/>[env.py]"]
  node_fourroom_explore["Explore Policy<br/>[explore_policy.py]"]
  node_cube["Cube Tasks<br/>[cube_env.py]"]
  node_pusht["Push-T Tasks<br/>[env.py]"]
end

node_researcher(("Researcher"))

node_researcher -->|"trains"| node_training
node_training -->|"loads data"| node_datasets
node_training -->|"runs evaluation"| node_planning_eval
node_training -->|"runs evaluation"| node_probe_eval
node_researcher -->|"evaluates checkpoint"| node_planning_eval
node_researcher -->|"evaluates checkpoint"| node_probe_eval
node_researcher -->|"evaluates DROID"| node_droid_eval
node_datasets -.->|"provides trajectories"| node_world
node_planning_eval -->|"loads tasks"| node_datasets
node_planning_eval -->|"configures planner"| node_hierarchical_solver
node_planning_eval -->|"builds policy"| node_policy
node_hierarchical_solver -->|"uses solver protocol"| node_solver
node_probe_eval -->|"loads examples"| node_datasets
node_probe_eval -->|"encodes batches"| node_transformer
node_encoders -->|"builds blocks"| node_transformer
node_predictors -->|"uses blocks"| node_transformer
node_transformer -->|"initializes weights"| node_loss
node_world -->|"runs policies"| node_policy
node_world -->|"wraps environments"| node_wrappers
node_fourroom -->|"uses for exploration"| node_fourroom_explore
node_fourroom_explore -->|"extends base policy"| node_policy
node_cube -.->|"runs in manager"| node_world
node_pusht -.->|"runs in manager"| node_world

click node_training "https://github.com/kevinghst/h-jepa/blob/main/h_jepa/main_hjepa.py"
click node_datasets "https://github.com/kevinghst/h-jepa/blob/main/h_jepa/data.py"
click node_jepa "https://github.com/kevinghst/h-jepa/blob/main/h_jepa/models/jepa.py"
click node_hierarchical_jepa "https://github.com/kevinghst/h-jepa/blob/main/h_jepa/models/hjepa.py"
click node_encoders "https://github.com/kevinghst/h-jepa/tree/main/h_jepa/models/encoders"
click node_transformer "https://github.com/kevinghst/h-jepa/blob/main/h_jepa/models/module.py"
click node_predictors "https://github.com/kevinghst/h-jepa/blob/main/h_jepa/models/predictors/predictors.py"
click node_loss "https://github.com/kevinghst/h-jepa/blob/main/h_jepa/loss.py"
click node_planning_eval "https://github.com/kevinghst/h-jepa/blob/main/h_jepa/planning_eval.py"
click node_hierarchical_solver "https://github.com/kevinghst/h-jepa/blob/main/h_jepa/hierarchical_solver.py"
click node_probe_eval "https://github.com/kevinghst/h-jepa/blob/main/h_jepa/final_probing_decoding_eval.py"
click node_droid_eval "https://github.com/kevinghst/h-jepa/blob/main/h_jepa/droid_eval.py"
click node_world "https://github.com/kevinghst/h-jepa/blob/main/stable_worldmodel/world.py"
click node_policy "https://github.com/kevinghst/h-jepa/blob/main/stable_worldmodel/policy.py"
click node_solver "https://github.com/kevinghst/h-jepa/blob/main/stable_worldmodel/solver/solver.py"
click node_wrappers "https://github.com/kevinghst/h-jepa/blob/main/stable_worldmodel/wrapper.py"
click node_fourroom "https://github.com/kevinghst/h-jepa/blob/main/stable_worldmodel/envs/four_room/env.py"
click node_fourroom_explore "https://github.com/kevinghst/h-jepa/blob/main/stable_worldmodel/envs/four_room/explore_policy.py"
click node_cube "https://github.com/kevinghst/h-jepa/blob/main/stable_worldmodel/envs/ogbench/cube_env.py"
click node_pusht "https://github.com/kevinghst/h-jepa/blob/main/stable_worldmodel/envs/pusht/env.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_training toneBlue
class node_jepa,node_hierarchical_jepa,node_encoders,node_transformer,node_predictors,node_loss toneAmber
class node_planning_eval,node_hierarchical_solver,node_probe_eval,node_droid_eval toneMint
class node_datasets,node_world,node_policy,node_solver,node_wrappers toneRose
class node_fourroom,node_fourroom_explore,node_cube,node_pusht,node_researcher toneIndigo
```

## Components

### Workflows

- [Training](https://github.com/kevinghst/h-jepa/blob/main/h_jepa/main_hjepa.py): `h_jepa/main_hjepa.py`

### JEPA Models

- [JEPA Levels](https://github.com/kevinghst/h-jepa/blob/main/h_jepa/models/jepa.py): `h_jepa/models/jepa.py`
- [Hierarchical JEPA](https://github.com/kevinghst/h-jepa/blob/main/h_jepa/models/hjepa.py): `h_jepa/models/hjepa.py`
- [Visual Encoders](https://github.com/kevinghst/h-jepa/tree/main/h_jepa/models/encoders): `h_jepa/models/encoders`
- [Transformer Blocks](https://github.com/kevinghst/h-jepa/blob/main/h_jepa/models/module.py): `h_jepa/models/module.py`
- [Predictors](https://github.com/kevinghst/h-jepa/blob/main/h_jepa/models/predictors/predictors.py): `h_jepa/models/predictors/predictors.py`
- [Training Loss](https://github.com/kevinghst/h-jepa/blob/main/h_jepa/loss.py): `h_jepa/loss.py`

### Evaluation

- [Planning Evaluation](https://github.com/kevinghst/h-jepa/blob/main/h_jepa/planning_eval.py): `h_jepa/planning_eval.py`
- [Hierarchical Planner](https://github.com/kevinghst/h-jepa/blob/main/h_jepa/hierarchical_solver.py): `h_jepa/hierarchical_solver.py`
- [Probe and Decode](https://github.com/kevinghst/h-jepa/blob/main/h_jepa/final_probing_decoding_eval.py): `h_jepa/final_probing_decoding_eval.py`
- [DROID Evaluation](https://github.com/kevinghst/h-jepa/blob/main/h_jepa/droid_eval.py): `h_jepa/droid_eval.py`

### Worldmodel Runtime

- [Dataset Loading](https://github.com/kevinghst/h-jepa/blob/main/h_jepa/data.py): `h_jepa/data.py`
- [Environment Manager](https://github.com/kevinghst/h-jepa/blob/main/stable_worldmodel/world.py): `stable_worldmodel/world.py`
- [Planning Policies](https://github.com/kevinghst/h-jepa/blob/main/stable_worldmodel/policy.py): `stable_worldmodel/policy.py`
- [Solver Interface](https://github.com/kevinghst/h-jepa/blob/main/stable_worldmodel/solver/solver.py): `stable_worldmodel/solver/solver.py`
- [Environment Wrappers](https://github.com/kevinghst/h-jepa/blob/main/stable_worldmodel/wrapper.py): `stable_worldmodel/wrapper.py`

### Environments

- [FourRoom](https://github.com/kevinghst/h-jepa/blob/main/stable_worldmodel/envs/four_room/env.py): `stable_worldmodel/envs/four_room/env.py`
- [Explore Policy](https://github.com/kevinghst/h-jepa/blob/main/stable_worldmodel/envs/four_room/explore_policy.py): `stable_worldmodel/envs/four_room/explore_policy.py`
- [Cube Tasks](https://github.com/kevinghst/h-jepa/blob/main/stable_worldmodel/envs/ogbench/cube_env.py): `stable_worldmodel/envs/ogbench/cube_env.py`
- [Push-T Tasks](https://github.com/kevinghst/h-jepa/blob/main/stable_worldmodel/envs/pusht/env.py): `stable_worldmodel/envs/pusht/env.py`

### Other components

- **Researcher**

## Connections

- Researcher → Training: trains (evidence: `README.md`)
- Training → Dataset Loading: loads data (evidence: `h_jepa/main_hjepa.py`)
- Training → Planning Evaluation: runs evaluation (evidence: `README.md`)
- Training → Probe and Decode: runs evaluation (evidence: `README.md`)
- Researcher → Planning Evaluation: evaluates checkpoint (evidence: `README.md`)
- Researcher → Probe and Decode: evaluates checkpoint (evidence: `README.md`)
- Researcher → DROID Evaluation: evaluates DROID (evidence: `README.md`)
- Dataset Loading → Environment Manager: provides trajectories
- Planning Evaluation → Dataset Loading: loads tasks (evidence: `h_jepa/planning_eval.py`)
- Planning Evaluation → Hierarchical Planner: configures planner (evidence: `h_jepa/planning_eval.py`)
- Planning Evaluation → Planning Policies: builds policy (evidence: `h_jepa/planning_eval.py`)
- Hierarchical Planner → Solver Interface: uses solver protocol (evidence: `h_jepa/hierarchical_solver.py`)
- Probe and Decode → Dataset Loading: loads examples (evidence: `h_jepa/final_probing_decoding_eval.py`)
- Probe and Decode → Transformer Blocks: encodes batches (evidence: `h_jepa/final_probing_decoding_eval.py`)
- Visual Encoders → Transformer Blocks: builds blocks (evidence: `h_jepa/models/encoders/encoders.py`)
- Predictors → Transformer Blocks: uses blocks (evidence: `h_jepa/models/predictors/predictors.py`)
- Transformer Blocks → Training Loss: initializes weights (evidence: `h_jepa/models/module.py`)
- Environment Manager → Planning Policies: runs policies (evidence: `stable_worldmodel/world.py`)
- Environment Manager → Environment Wrappers: wraps environments (evidence: `stable_worldmodel/world.py`)
- FourRoom → Explore Policy: uses for exploration (evidence: `stable_worldmodel/envs/four_room/env.py`)
- Explore Policy → Planning Policies: extends base policy (evidence: `stable_worldmodel/envs/four_room/explore_policy.py`)
- Cube Tasks → Environment Manager: runs in manager
- Push-T Tasks → Environment Manager: runs in manager
