# dreamzero0/dreamzero architecture

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

- Interactive diagram: https://gitdiagram.com/dreamzero0/dreamzero
- Repository: https://github.com/dreamzero0/dreamzero

## Overview

1. **Repository purpose and top-level split**
   - This repo is a research codebase for **DreamZero**, a world-action model that predicts both robot actions and future video.
   - The architecture splits cleanly into four flows: **data preparation**, **training**, **distributed inference**, and **evaluation / serving**.

2. **Core package layout**
   - `groot/vla` is the main library. It contains:
     - `data` for dataset schemas, conversions, registries, and transforms
     - `model` for DreamZero and a smaller `n1_5` policy variant
     - `experiment` for training/evaluation orchestration
     - `utils` and `common/utils` for shared helper code
   - `scripts/` contains runnable entry points for training, data conversion, and TensorRT engine building.
   - `eval_utils/` contains a separate policy server/client and simulation evaluation harness.

3. **Data ingestion and normalization boundary**
   - Raw robotics datasets are not consumed directly by the model.
   - The repo defines a conversion boundary from source formats such as **DROID RLDS/TFDS** into **LeRobot v2.0**-style data.
   - This layer lives under `groot/vla/data/conversion` and `groot/vla/data/dataset`, with dataset metadata and registry support to select the correct loader.

4. **Dataset schema and modality handling**
   - `groot/vla/data/schema` defines embodiment-specific conventions, especially camera names and action/state structure.
   - `groot/vla/data/transform` is the modality pipeline:
     - language processing
     - video frame handling
     - state/action formatting
     - concatenation and common transforms
   - This is where raw episodes become model-ready multimodal samples.

5. **Model architecture boundary**
   - `groot/vla/model/dreamzero` is the primary model stack.
   - It is organized into:
     - `backbone` for the visual/video foundation model
     - `action_head` for action generation
     - `modules` for attention, schedulers, video encoders/decoders, memory/VRAM management, and Wan-specific submodules
     - `transform` for model-side feature adaptation
   - The model is built on **Wan2.1 / Wan2.2 video backbones**, with optional **LoRA** or full fine-tuning.

6. **How perception-to-action works**
   - DreamZero does not just regress actions from observations; it jointly uses a **video generation backbone** and an **action head**.
   - The data flow is: multimodal observations and language prompt → backbone/video-token processing → action head → predicted control sequence, with video generation as an auxiliary or coupled output.
   - This coupling is the main architectural idea of the repo.

7. **Training orchestration**
   - `groot/vla/experiment` manages experiment configuration, lifecycle, and glue between dataset, model, and optimization.
   - Training is launched from `scripts/train/*` and uses:
     - **Hydra** configs under `groot/vla/configs`
     - **DeepSpeed ZeRO** configs under `groot/vla/configs/deepspeed`
     - distributed multi-GPU execution via standard PyTorch launch patterns
   - The repo supports both full fine-tuning and parameter-efficient adaptation.

8. **Configuration structure**
   - Configs are organized by concern:
     - `configs/data/...` for embodiment/dataset-specific settings
     - `configs/model/...` for backbone, action head, and transform variants
     - `configs/deepspeed/...` for memory/distribution strategies
   - This separation suggests the architecture is meant to swap datasets, embodiments, and model backbones without changing code paths.

9. **Inference serving path**
   - Real-time inference is split from training and implemented as a **distributed WebSocket server**.
   - The main runtime entry points are `socket_test_optimized_AR.py` and `eval_utils/policy_server.py`, with clients in `eval_utils/policy_client.py` and `test_client_AR.py`.
   - Inference runs across multiple GPUs using `torch.distributed`, which is an important system boundary: the model is sharded/parallelized for serving, not just for training.

10. **Inference optimization and deployment**
   - `groot/control/tensorrt_utils.py` and `scripts/inference/build_trt_engine.*` provide a TensorRT path for faster generation.
   - The README indicates optional DiT caching and a cached generation path, which means the serving architecture includes both **standard PyTorch execution** and an **accelerated TensorRT execution branch**.
   - This is a meaningful deployment boundary for architecture diagrams.

11. **Evaluation and simulation integration**
   - `eval_utils/run_sim_eval.py` connects the policy server to external simulation benchmarks, specifically `sim_evals`.
   - This is not part of the training loop; it is a separate evaluation pipeline that treats DreamZero as a remote policy service.
   - The repo also supports saving generated videos and per-request inputs, which is useful for debugging and offline analysis.

12. **Support for new embodiments**
   - The docs and scripts show a second major data/model branch beyond DROID: **AgiBot** and **YAM**.
   - The new-embodiment flow is: convert dataset → align camera/views and action schema → choose the matching config → fine-tune from the AgiBot checkpoint.
   - This indicates the architecture is intentionally embodiment-agnostic at the library level, but embodiment-specific at the dataset/schema/config level.

13. **Utility and shared infrastructure**
   - `groot/vla/common/utils` provides lower-level helpers for IO, tensors, arrays, images, video, JSON/HDF5, and tree/shape utilities.
   - These are foundational support modules used across conversion, preprocessing, training, and inference, but they are not themselves primary application subsystems.

14. **Secondary model path**
   - `groot/vla/model/n1_5` is a smaller policy stack with its own action encoder and simulation policy.
   - It appears to be a sibling model family rather than the main DreamZero path, so in a diagram it should be shown as an alternate policy implementation, not part of the core DreamZero training/inference flow.

15. **Overall architecture summary**
   - The repo is best diagrammed as a pipeline:
     - raw robotics data → dataset conversion/normalization → multimodal transforms → DreamZero model training → distributed WebSocket/TensorRT inference → simulation or real-world evaluation.
   - The key architectural boundaries are **dataset schema**, **model family**, **training vs serving**, and **standard PyTorch vs TensorRT acceleration**.

Main entry points: [`groot/vla/model/dreamzero`](https://github.com/dreamzero0/dreamzero/tree/main/groot/vla/model/dreamzero) (DreamZero), [`eval_utils/policy_server.py`](https://github.com/dreamzero0/dreamzero/blob/main/eval_utils/policy_server.py) (Policy server), [`groot/vla/experiment/experiment.py`](https://github.com/dreamzero0/dreamzero/blob/main/groot/vla/experiment/experiment.py) (Experiment runtime), [`groot/vla/common/utils`](https://github.com/dreamzero0/dreamzero/tree/main/groot/vla/common/utils) (Shared utils)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_g_data["Data pipeline"]
  node_n_raw[("Raw robotics data<br/>source datasets")]
  node_n_convert["Conversion"]
  node_n_registry["Dataset registry<br/>dataset selection<br/>[registry.py]"]
  node_n_schema["Embodiment schema<br/>schema conventions"]
  node_n_transform["Modal transforms<br/>multimodal preprocessing"]
  node_n_lerobot[("LeRobot dataset<br/>dataset loader<br/>[lerobot.py]")]
end

subgraph group_g_model["Models"]
  node_n_dreamzero["DreamZero<br/>world-action model"]
  node_n_backbone["Video backbone<br/>Wan video model"]
  node_n_action_head["Action head<br/>control decoder"]
  node_n_dream_mods["Dream modules<br/>attention/scheduling"]
  node_n_dream_tf["Model transforms<br/>feature adaptation"]
  node_n_n15["N1.5 policy<br/>alternate policy"]
end

subgraph group_g_train["Training"]
  node_n_experiment["Experiment runtime<br/>training orchestration<br/>[experiment.py]"]
  node_n_cfg_data["Data configs<br/>hydra config"]
  node_n_cfg_model["Model configs<br/>hydra config"]
  node_n_cfg_ds["DeepSpeed configs<br/>distribution config"]
end

subgraph group_g_serve["Serving"]
  node_n_server["Policy server<br/>distributed websocket serving<br/>[policy_server.py]"]
  node_n_trt["TensorRT engine<br/>inference acceleration<br/>[tensorrt_utils.py]"]
end

subgraph group_g_eval["Evaluation"]
  node_n_client["Policy client<br/>remote inference client<br/>[policy_client.py]"]
  node_n_sim_eval["Sim eval<br/>simulation benchmark<br/>[run_sim_eval.py]"]
end

subgraph group_g_shared["Shared utils"]
  node_n_shared["Shared utils<br/>common helpers"]
end

node_n_raw -->|"normalize"| node_n_convert
node_n_convert -->|"register"| node_n_registry
node_n_registry -->|"bind schema"| node_n_schema
node_n_schema -->|"format samples"| node_n_transform
node_n_transform -->|"load"| node_n_lerobot
node_n_cfg_data -.->|"select data"| node_n_registry
node_n_cfg_model -.->|"configure model"| node_n_dreamzero
node_n_cfg_ds -.->|"memory plan"| node_n_experiment
node_n_lerobot -->|"batch data"| node_n_experiment
node_n_experiment -->|"train"| node_n_dreamzero
node_n_dreamzero -->|"uses"| node_n_backbone
node_n_dreamzero -->|"predicts"| node_n_action_head
node_n_dreamzero -->|"supports"| node_n_dream_mods
node_n_dreamzero -->|"adapts"| node_n_dream_tf
node_n_dreamzero -->|"serve"| node_n_server
node_n_server -->|"accelerate"| node_n_trt
node_n_server -->|"remote calls"| node_n_client
node_n_client -->|"evaluate"| node_n_sim_eval
node_n_server -->|"policy service"| node_n_sim_eval
node_n_n15 -.->|"alternate policy"| node_n_server
node_n_shared -->|"helpers"| node_n_convert
node_n_shared -->|"helpers"| node_n_experiment
node_n_shared -->|"helpers"| node_n_server

click node_n_convert "https://github.com/dreamzero0/dreamzero/tree/main/groot/vla/data/conversion"
click node_n_registry "https://github.com/dreamzero0/dreamzero/blob/main/groot/vla/data/dataset/registry.py"
click node_n_schema "https://github.com/dreamzero0/dreamzero/tree/main/groot/vla/data/schema"
click node_n_transform "https://github.com/dreamzero0/dreamzero/tree/main/groot/vla/data/transform"
click node_n_lerobot "https://github.com/dreamzero0/dreamzero/blob/main/groot/vla/data/dataset/lerobot.py"
click node_n_experiment "https://github.com/dreamzero0/dreamzero/blob/main/groot/vla/experiment/experiment.py"
click node_n_cfg_data "https://github.com/dreamzero0/dreamzero/tree/main/groot/vla/configs/data"
click node_n_cfg_model "https://github.com/dreamzero0/dreamzero/tree/main/groot/vla/configs/model"
click node_n_cfg_ds "https://github.com/dreamzero0/dreamzero/tree/main/groot/vla/configs/deepspeed"
click node_n_dreamzero "https://github.com/dreamzero0/dreamzero/tree/main/groot/vla/model/dreamzero"
click node_n_backbone "https://github.com/dreamzero0/dreamzero/tree/main/groot/vla/model/dreamzero/backbone"
click node_n_action_head "https://github.com/dreamzero0/dreamzero/tree/main/groot/vla/model/dreamzero/action_head"
click node_n_dream_mods "https://github.com/dreamzero0/dreamzero/tree/main/groot/vla/model/dreamzero/modules"
click node_n_dream_tf "https://github.com/dreamzero0/dreamzero/tree/main/groot/vla/model/dreamzero/transform"
click node_n_n15 "https://github.com/dreamzero0/dreamzero/tree/main/groot/vla/model/n1_5"
click node_n_server "https://github.com/dreamzero0/dreamzero/blob/main/eval_utils/policy_server.py"
click node_n_trt "https://github.com/dreamzero0/dreamzero/blob/main/groot/control/tensorrt_utils.py"
click node_n_client "https://github.com/dreamzero0/dreamzero/blob/main/eval_utils/policy_client.py"
click node_n_sim_eval "https://github.com/dreamzero0/dreamzero/blob/main/eval_utils/run_sim_eval.py"
click node_n_shared "https://github.com/dreamzero0/dreamzero/tree/main/groot/vla/common/utils"

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_n_raw,node_n_convert,node_n_registry,node_n_schema,node_n_transform,node_n_lerobot toneBlue
class node_n_dreamzero,node_n_backbone,node_n_action_head,node_n_dream_mods,node_n_dream_tf,node_n_n15 toneAmber
class node_n_experiment,node_n_cfg_data,node_n_cfg_model,node_n_cfg_ds toneMint
class node_n_server,node_n_trt toneRose
class node_n_client,node_n_sim_eval toneIndigo
class node_n_shared toneTeal
```

## Components

### Data pipeline

Dataset conversion, schema, and sample transforms.

- **Raw robotics data**: source datasets · Input datasets such as DROID, AgiBot, and YAM before normalization.
- [Conversion](https://github.com/dreamzero0/dreamzero/tree/main/groot/vla/data/conversion): dataset conversion · Dataset-specific conversion scripts and normalization boundary into repo-friendly formats. · `groot/vla/data/conversion`
- [Dataset registry](https://github.com/dreamzero0/dreamzero/blob/main/groot/vla/data/dataset/registry.py): dataset selection · Dataset metadata and registry used to choose loaders and sharded variants. · `groot/vla/data/dataset/registry.py`
- [Embodiment schema](https://github.com/dreamzero0/dreamzero/tree/main/groot/vla/data/schema): schema conventions · Embodiment tags and LeRobot-style action/state conventions. · `groot/vla/data/schema`
- [Modal transforms](https://github.com/dreamzero0/dreamzero/tree/main/groot/vla/data/transform): multimodal preprocessing · Language, video, state/action, and concatenation transforms that build model-ready samples. · `groot/vla/data/transform`
- [LeRobot dataset](https://github.com/dreamzero0/dreamzero/blob/main/groot/vla/data/dataset/lerobot.py): dataset loader · Main dataset implementation for normalized LeRobot-style data, including sharded loading. · `groot/vla/data/dataset/lerobot.py`

### Models

DreamZero and alternate policy family.

- [DreamZero](https://github.com/dreamzero0/dreamzero/tree/main/groot/vla/model/dreamzero): world-action model · Primary model family that couples video generation with action prediction. · `groot/vla/model/dreamzero`
- [Video backbone](https://github.com/dreamzero0/dreamzero/tree/main/groot/vla/model/dreamzero/backbone): Wan video model · Wan2.1/Wan2.2-based visual-video foundation stack. · `groot/vla/model/dreamzero/backbone`
- [Action head](https://github.com/dreamzero0/dreamzero/tree/main/groot/vla/model/dreamzero/action_head): control decoder · Generates control sequences from backbone features. · `groot/vla/model/dreamzero/action_head`
- [Dream modules](https://github.com/dreamzero0/dreamzero/tree/main/groot/vla/model/dreamzero/modules): attention/scheduling · Attention, flow scheduling, VRAM management, and Wan-specific submodules. · `groot/vla/model/dreamzero/modules`
- [Model transforms](https://github.com/dreamzero0/dreamzero/tree/main/groot/vla/model/dreamzero/transform): feature adaptation · Model-side adaptation layers for co-training and common feature formatting. · `groot/vla/model/dreamzero/transform`
- [N1.5 policy](https://github.com/dreamzero0/dreamzero/tree/main/groot/vla/model/n1_5): alternate policy · Smaller sibling policy stack with its own action encoder and simulation policy. · `groot/vla/model/n1_5`

### Training

Experiment orchestration and launch configs.

- [Experiment runtime](https://github.com/dreamzero0/dreamzero/blob/main/groot/vla/experiment/experiment.py): training orchestration · Lifecycle glue between data, model, optimization, and evaluation hooks. · `groot/vla/experiment/experiment.py`
- [Data configs](https://github.com/dreamzero0/dreamzero/tree/main/groot/vla/configs/data): hydra config · Embodiment and dataset-specific configuration presets. · `groot/vla/configs/data`
- [Model configs](https://github.com/dreamzero0/dreamzero/tree/main/groot/vla/configs/model): hydra config · Backbone, action head, and transform configuration presets. · `groot/vla/configs/model`
- [DeepSpeed configs](https://github.com/dreamzero0/dreamzero/tree/main/groot/vla/configs/deepspeed): distribution config · ZeRO and offload settings for memory/distribution strategy. · `groot/vla/configs/deepspeed`

### Serving

Distributed inference and acceleration path.

- [Policy server](https://github.com/dreamzero0/dreamzero/blob/main/eval_utils/policy_server.py): distributed websocket serving · Real-time inference service that exposes the policy over sockets. · `eval_utils/policy_server.py`
- [TensorRT engine](https://github.com/dreamzero0/dreamzero/blob/main/groot/control/tensorrt_utils.py): inference acceleration · Optional accelerated execution path for faster generation. · `groot/control/tensorrt_utils.py`

### Evaluation

Remote policy evaluation and simulation harness.

- [Policy client](https://github.com/dreamzero0/dreamzero/blob/main/eval_utils/policy_client.py): remote inference client · Client-side caller for the distributed policy service. · `eval_utils/policy_client.py`
- [Sim eval](https://github.com/dreamzero0/dreamzero/blob/main/eval_utils/run_sim_eval.py): simulation benchmark · Connects the remote policy to simulation evaluation harnesses. · `eval_utils/run_sim_eval.py`

### Shared utils

Common helpers used across the repo.

- [Shared utils](https://github.com/dreamzero0/dreamzero/tree/main/groot/vla/common/utils): common helpers · IO, tensor, image, video, and data-structure utilities reused across the repo. · `groot/vla/common/utils`

## Connections

- Raw robotics data → Conversion: normalize · Convert raw robotics data into repository-supported formats.
- Conversion → Dataset registry: register · Register dataset variants and metadata for loader selection.
- Dataset registry → Embodiment schema: bind schema · Use embodiment conventions to interpret actions, states, and cameras.
- Embodiment schema → Modal transforms: format samples · Apply multimodal transforms to produce model-ready inputs.
- Modal transforms → LeRobot dataset: load · Feed normalized transformed samples into dataset implementations.
- Data configs → Dataset registry: select data · Hydra presets choose dataset/embodiment settings.
- Model configs → DreamZero: configure model · Hydra presets choose backbone, action head, and transform variants.
- DeepSpeed configs → Experiment runtime: memory plan · DeepSpeed settings control distributed training strategy.
- LeRobot dataset → Experiment runtime: batch data · Dataset loaders feed the training runtime.
- Experiment runtime → DreamZero: train · Experiment runtime orchestrates DreamZero optimization.
- DreamZero → Video backbone: uses · DreamZero builds on the Wan video backbone.
- DreamZero → Action head: predicts · The action head maps backbone features to controls.
- DreamZero → Dream modules: supports · Shared attention, scheduling, and VRAM modules support the model stack.
- DreamZero → Model transforms: adapts · Model-side transforms align features for co-training and inference.
- DreamZero → Policy server: serve · Trained policy is exposed through the distributed server path.
- Policy server → TensorRT engine: accelerate · Server can switch to TensorRT-accelerated execution.
- Policy server → Policy client: remote calls · Clients send observations and receive predicted actions.
- Policy client → Sim eval: evaluate · Remote policy is evaluated inside simulation benchmarks.
- Policy server → Sim eval: policy service · Simulation evaluation treats the server as a remote policy backend.
- N1.5 policy → Policy server: alternate policy · Smaller policy family can also participate in serving/evaluation flows.
- Shared utils → Conversion: helpers · Shared utilities support conversion and normalization code.
- Shared utils → Experiment runtime: helpers · Shared utilities support orchestration and runtime glue.
- Shared utils → Policy server: helpers · Shared utilities support socket serving and request handling.
