# drivevla/opendrivevla architecture

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

- Interactive diagram: https://gitdiagram.com/drivevla/opendrivevla
- Repository: https://github.com/drivevla/opendrivevla

## Overview

#### Purpose and entry points
OpenDriveVLA is a research inference/evaluation repository for end-to-end autonomous driving using a vision-language-action model. The operational entry points are `drivevla/inference_drivevla.py` for prediction and `drivevla/eval_drivevla.py` for benchmark execution; `scripts/eval_drivevla.sh` wraps evaluation. Training support exists in the vendored LLaVA and UniAD-derived code but is not presented as released workflow.

#### Data preparation and sample boundary
nuScenes driving records, multi-camera imagery, map/trajectory context, and driving annotations are transformed into LLaVA-style conversational examples and model-ready batches. `drivevla/data_utils/nuscenes_llava_datacollector.py` collects/serializes samples; `drivevla/data_utils/build_llava_conversation.py` defines the language-facing representation; `drivevla/data_utils/nuscenes_llava_dataset.py` loads it for distributed inference/evaluation. This is the main boundary between autonomous-driving data conventions and multimodal LLM inputs.

#### Driving perception/planning substrate
A customized UniAD/MMDetection3D plugin supplies the structured driving stack and nuScenes integration. The end-to-end detector coordinates tracking, motion, occupancy, segmentation, and planning through `projects/mmdet3d_plugin/uniad/detectors/uniad_e2e.py`; task heads include `projects/mmdet3d_plugin/uniad/dense_heads/track_head.py`, `projects/mmdet3d_plugin/uniad/dense_heads/motion_head.py`, and `projects/mmdet3d_plugin/uniad/dense_heads/planning_head.py`. nuScenes-specific scene loading, map/vector processing, and labels reside in `projects/mmdet3d_plugin/datasets/nuscenes_e2e_dataset.py` and its pipeline package.

#### Vision-language-action model
The local `llava` package is the multimodal model layer. It builds a language model plus vision encoder/projector via `llava/model/builder.py`, `llava/model/llava_arch.py`, and `llava/model/multimodal_encoder/builder.py`. Multiple LLM backends are supported, including Qwen implementations in `llava/model/language_model/llava_qwen.py`; visual tokens are adapted into the LLM embedding space by `llava/model/multimodal_projector/builder.py` and optional resamplers. This is the boundary from camera features and driving prompts to generated action/trajectory-oriented outputs.

#### Inference control flow
Inference loads checkpoint/model/tokenizer components, obtains distributed nuScenes batches, forms multimodal conversations, then runs LLaVA generation and converts results to driving outputs. `drivevla/inference_drivevla.py` orchestrates this path, while `drivevla/utils/trajectory_utils.py` and `drivevla/utils/remove_mmlab_datacontainer.py` bridge generated/model tensors with the MMDetection-style data structures. Checkpoint compatibility and model reconstruction are handled by the LLaVA builder rather than an online serving layer.

#### Evaluation and outputs
`drivevla/eval_drivevla.py` runs predictions against driving references. General result aggregation and metrics live in `drivevla/eval_share/evaluation.py` and `drivevla/eval_share/metric.py`; the UniAD plugin also contains nuScenes motion/planning evaluation adapters under `projects/mmdet3d_plugin/datasets/eval_utils/`. Evaluation is offline and dataset-backed, not a real-time vehicle-control runtime.

#### Runtime and infrastructure
The stack is Python/PyTorch, Hugging Face Transformers, DeepSpeed-compatible, and GPU-oriented. It vendors patched MMDetection3D and MMCV specifically for PyTorch 2.1.2 compatibility: `third_party/mmdetection3d_1_0_0rc6/` and `third_party/mmcv_1_7_2/`, including compiled CUDA operators. External dependencies/material sources are nuScenes data, Hugging Face-hosted OpenDriveVLA checkpoints, and pretrained LLaVA/Qwen/vision-model artifacts. Configuration for the UniAD stage is rooted at `projects/configs/stage1_track_map/base_track_map.py`.

Main entry points: [`projects/mmdet3d_plugin/uniad/detectors/uniad_e2e.py`](https://github.com/drivevla/opendrivevla/blob/main/projects/mmdet3d_plugin/uniad/detectors/uniad_e2e.py) (UniAD E2E detector), [`llava/model/builder.py`](https://github.com/drivevla/opendrivevla/blob/main/llava/model/builder.py) (LLaVA model builder), [`drivevla/inference_drivevla.py`](https://github.com/drivevla/opendrivevla/blob/main/drivevla/inference_drivevla.py) (Prediction runner), [`drivevla/data_utils/nuscenes_llava_dataset.py`](https://github.com/drivevla/opendrivevla/blob/main/drivevla/data_utils/nuscenes_llava_dataset.py) (Distributed dataset)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_nuscenes[("nuScenes data<br/>external dataset")]
  node_collector["Sample collector<br/>data serializer"]
  node_conversation["Conversation builder<br/>prompt representation"]
  node_dataset["Distributed dataset<br/>batch loader"]
end

subgraph group_driving["Driving substrate"]
  node_nuscenes_adapter["nuScenes E2E adapter<br/>dataset integration"]
  node_uniad["UniAD E2E detector<br/>driving coordinator<br/>[uniad_e2e.py]"]
  node_tracking["Tracking head<br/>task head<br/>[track_head.py]"]
  node_motion["Motion head<br/>task head<br/>[motion_head.py]"]
  node_planning["Planning head<br/>task head<br/>[planning_head.py]"]
  node_stage_config["Track/map config<br/>UniAD configuration<br/>[base_track_map.py]"]
end

subgraph group_vla["VLA model"]
  node_checkpoints[("Model artifacts<br/>external checkpoints")]
  node_llava_builder["LLaVA model builder<br/>model reconstruction<br/>[builder.py]"]
  node_vision_encoder["Vision encoder<br/>multimodal encoder<br/>[builder.py]"]
  node_projector["Visual projector<br/>embedding adapter<br/>[builder.py]"]
  node_qwen["Qwen backend<br/>language model backend<br/>[llava_qwen.py]"]
end

subgraph group_runtime["Inference and evaluation"]
  node_inference["Prediction runner<br/>inference entry point"]
  node_trajectory_bridge["Trajectory bridge<br/>output conversion"]
  node_evaluation["Benchmark runner<br/>evaluation entry point<br/>[eval_drivevla.py]"]
  node_metrics["Metrics and aggregation<br/>evaluation metrics<br/>[evaluation.py]"]
  node_mmdet3d{{"Patched MMDetection3D<br/>vendored framework"}}
end

node_nuscenes -->|"source records"| node_collector
node_collector -->|"serialized samples"| node_conversation
node_conversation -->|"conversational examples"| node_dataset
node_nuscenes -->|"scenes and labels"| node_nuscenes_adapter
node_stage_config -.->|"configures"| node_uniad
node_nuscenes_adapter -->|"driving context"| node_uniad
node_tracking -->|"tracking task"| node_uniad
node_motion -->|"motion task"| node_uniad
node_planning -->|"planning task"| node_uniad
node_mmdet3d -.->|"framework runtime"| node_uniad
node_checkpoints -->|"weights"| node_llava_builder
node_vision_encoder -->|"visual tokens"| node_projector
node_projector -->|"visual embeddings"| node_qwen
node_llava_builder -->|"builds"| node_vision_encoder
node_llava_builder -->|"builds"| node_qwen
node_dataset -->|"distributed batches"| node_inference
node_uniad -->|"structured driving context"| node_inference
node_llava_builder -->|"loaded multimodal model"| node_inference
node_inference -->|"generated tensors"| node_trajectory_bridge
node_trajectory_bridge -->|"driving predictions"| node_evaluation
node_dataset -->|"reference batches"| node_evaluation
node_evaluation -->|"results"| node_metrics

click node_collector "https://github.com/drivevla/opendrivevla/blob/main/drivevla/data_utils/nuscenes_llava_datacollector.py"
click node_conversation "https://github.com/drivevla/opendrivevla/blob/main/drivevla/data_utils/build_llava_conversation.py"
click node_dataset "https://github.com/drivevla/opendrivevla/blob/main/drivevla/data_utils/nuscenes_llava_dataset.py"
click node_nuscenes_adapter "https://github.com/drivevla/opendrivevla/blob/main/projects/mmdet3d_plugin/datasets/nuscenes_e2e_dataset.py"
click node_uniad "https://github.com/drivevla/opendrivevla/blob/main/projects/mmdet3d_plugin/uniad/detectors/uniad_e2e.py"
click node_tracking "https://github.com/drivevla/opendrivevla/blob/main/projects/mmdet3d_plugin/uniad/dense_heads/track_head.py"
click node_motion "https://github.com/drivevla/opendrivevla/blob/main/projects/mmdet3d_plugin/uniad/dense_heads/motion_head.py"
click node_planning "https://github.com/drivevla/opendrivevla/blob/main/projects/mmdet3d_plugin/uniad/dense_heads/planning_head.py"
click node_stage_config "https://github.com/drivevla/opendrivevla/blob/main/projects/configs/stage1_track_map/base_track_map.py"
click node_llava_builder "https://github.com/drivevla/opendrivevla/blob/main/llava/model/builder.py"
click node_vision_encoder "https://github.com/drivevla/opendrivevla/blob/main/llava/model/multimodal_encoder/builder.py"
click node_projector "https://github.com/drivevla/opendrivevla/blob/main/llava/model/multimodal_projector/builder.py"
click node_qwen "https://github.com/drivevla/opendrivevla/blob/main/llava/model/language_model/llava_qwen.py"
click node_inference "https://github.com/drivevla/opendrivevla/blob/main/drivevla/inference_drivevla.py"
click node_trajectory_bridge "https://github.com/drivevla/opendrivevla/blob/main/drivevla/utils/trajectory_utils.py"
click node_evaluation "https://github.com/drivevla/opendrivevla/blob/main/drivevla/eval_drivevla.py"
click node_metrics "https://github.com/drivevla/opendrivevla/blob/main/drivevla/eval_share/evaluation.py"
click node_mmdet3d "https://github.com/drivevla/opendrivevla/tree/main/third_party/mmdetection3d_1_0_0rc6"

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_nuscenes,node_collector,node_conversation,node_dataset toneBlue
class node_nuscenes_adapter,node_uniad,node_tracking,node_motion,node_planning,node_stage_config toneAmber
class node_checkpoints,node_llava_builder,node_vision_encoder,node_projector,node_qwen toneMint
class node_inference,node_trajectory_bridge,node_evaluation,node_metrics,node_mmdet3d toneRose
```

## Components

### Data preparation

nuScenes records are converted to conversational, distributed model batches.

- **nuScenes data**: external dataset · Images, scenes, maps, trajectories, and driving annotations.
- [Sample collector](https://github.com/drivevla/opendrivevla/blob/main/drivevla/data_utils/nuscenes_llava_datacollector.py): data serializer · Collects and serializes nuScenes LLaVA samples. · `drivevla/data_utils/nuscenes_llava_datacollector.py`
- [Conversation builder](https://github.com/drivevla/opendrivevla/blob/main/drivevla/data_utils/build_llava_conversation.py): prompt representation · Defines LLaVA-style driving conversations. · `drivevla/data_utils/build_llava_conversation.py`
- [Distributed dataset](https://github.com/drivevla/opendrivevla/blob/main/drivevla/data_utils/nuscenes_llava_dataset.py): batch loader · Loads serialized examples for inference and evaluation. · `drivevla/data_utils/nuscenes_llava_dataset.py`

### Driving substrate

Customized UniAD/MMDetection3D stack provides structured driving tasks.

- [nuScenes E2E adapter](https://github.com/drivevla/opendrivevla/blob/main/projects/mmdet3d_plugin/datasets/nuscenes_e2e_dataset.py): dataset integration · Loads scenes, maps, vectors, and labels for UniAD. · `projects/mmdet3d_plugin/datasets/nuscenes_e2e_dataset.py`
- [UniAD E2E detector](https://github.com/drivevla/opendrivevla/blob/main/projects/mmdet3d_plugin/uniad/detectors/uniad_e2e.py): driving coordinator · Coordinates perception, prediction, and planning tasks. · `projects/mmdet3d_plugin/uniad/detectors/uniad_e2e.py`
- [Tracking head](https://github.com/drivevla/opendrivevla/blob/main/projects/mmdet3d_plugin/uniad/dense_heads/track_head.py): task head · `projects/mmdet3d_plugin/uniad/dense_heads/track_head.py`
- [Motion head](https://github.com/drivevla/opendrivevla/blob/main/projects/mmdet3d_plugin/uniad/dense_heads/motion_head.py): task head · `projects/mmdet3d_plugin/uniad/dense_heads/motion_head.py`
- [Planning head](https://github.com/drivevla/opendrivevla/blob/main/projects/mmdet3d_plugin/uniad/dense_heads/planning_head.py): task head · `projects/mmdet3d_plugin/uniad/dense_heads/planning_head.py`
- [Track/map config](https://github.com/drivevla/opendrivevla/blob/main/projects/configs/stage1_track_map/base_track_map.py): UniAD configuration · `projects/configs/stage1_track_map/base_track_map.py`

### VLA model

Local LLaVA converts visual context and prompts into action-oriented outputs.

- **Model artifacts**: external checkpoints · OpenDriveVLA and pretrained LLaVA, Qwen, and vision weights.
- [LLaVA model builder](https://github.com/drivevla/opendrivevla/blob/main/llava/model/builder.py): model reconstruction · Loads checkpoints, tokenizer, language model, and vision components. · `llava/model/builder.py`
- [Vision encoder](https://github.com/drivevla/opendrivevla/blob/main/llava/model/multimodal_encoder/builder.py): multimodal encoder · Produces visual tokens from camera imagery. · `llava/model/multimodal_encoder/builder.py`
- [Visual projector](https://github.com/drivevla/opendrivevla/blob/main/llava/model/multimodal_projector/builder.py): embedding adapter · Maps visual tokens into LLM embedding space. · `llava/model/multimodal_projector/builder.py`
- [Qwen backend](https://github.com/drivevla/opendrivevla/blob/main/llava/model/language_model/llava_qwen.py): language model backend · One supported LLM implementation for generation. · `llava/model/language_model/llava_qwen.py`

### Inference and evaluation

Offline GPU prediction and benchmark workflow.

- [Prediction runner](https://github.com/drivevla/opendrivevla/blob/main/drivevla/inference_drivevla.py): inference entry point · Orchestrates batches, generation, and driving-output conversion. · `drivevla/inference_drivevla.py`
- [Trajectory bridge](https://github.com/drivevla/opendrivevla/blob/main/drivevla/utils/trajectory_utils.py): output conversion · Bridges generated tensors and MMDetection-style driving outputs. · `drivevla/utils/trajectory_utils.py`
- [Benchmark runner](https://github.com/drivevla/opendrivevla/blob/main/drivevla/eval_drivevla.py): evaluation entry point · Runs offline predictions against driving references. · `drivevla/eval_drivevla.py`
- [Metrics and aggregation](https://github.com/drivevla/opendrivevla/blob/main/drivevla/eval_share/evaluation.py): evaluation metrics · Aggregates benchmark results and driving metrics. · `drivevla/eval_share/evaluation.py`
- [Patched MMDetection3D](https://github.com/drivevla/opendrivevla/tree/main/third_party/mmdetection3d_1_0_0rc6): vendored framework · PyTorch 2.1.2-compatible framework with CUDA operators. · `third_party/mmdetection3d_1_0_0rc6`

## Connections

- nuScenes data → Sample collector: source records
- Sample collector → Conversation builder: serialized samples
- Conversation builder → Distributed dataset: conversational examples
- nuScenes data → nuScenes E2E adapter: scenes and labels
- Track/map config → UniAD E2E detector: configures
- nuScenes E2E adapter → UniAD E2E detector: driving context
- Tracking head → UniAD E2E detector: tracking task
- Motion head → UniAD E2E detector: motion task
- Planning head → UniAD E2E detector: planning task
- Patched MMDetection3D → UniAD E2E detector: framework runtime
- Model artifacts → LLaVA model builder: weights
- Vision encoder → Visual projector: visual tokens
- Visual projector → Qwen backend: visual embeddings
- LLaVA model builder → Vision encoder: builds
- LLaVA model builder → Qwen backend: builds
- Distributed dataset → Prediction runner: distributed batches
- UniAD E2E detector → Prediction runner: structured driving context
- LLaVA model builder → Prediction runner: loaded multimodal model
- Prediction runner → Trajectory bridge: generated tensors
- Trajectory bridge → Benchmark runner: driving predictions
- Distributed dataset → Benchmark runner: reference batches
- Benchmark runner → Metrics and aggregation: results
