# saurav-34/owl-wms architecture

> Architecture diagram of the GitHub repository saurav-34/owl-wms, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/saurav-34/owl-wms
- Repository: https://github.com/saurav-34/owl-wms

## Overview

#### Purpose and entry points
This is a Python/PyTorch research system for action-conditioned Tekken 8 video world models. It encodes gameplay frames into VAE latents, trains a diffusion-transformer-style world model to predict future latents from history plus player actions, then samples and decodes generated video. Primary entry points are `train.py`, `inference/tekken_inference.py`, and `preproccessing/prepare_latents_owl.py`.

#### 1. Raw gameplay and latent-cache boundary
Raw gameplay is an external/manual NPZ input containing images, actions, states, and valid-frame metadata. Preprocessing loads video/pose inputs, selects a VAE checkpoint, encodes frames, and persists latent-centric training data. This intentionally separates expensive visual encoding from iterative world-model training.
Paths: `preproccessing/prepare_latents_owl.py`, `preproccessing/encoder.py`, `preproccessing/t3_loader.py`.

#### 2. VAE integration layer
The VAE is a separately managed git submodule and checkpoint ecosystem, supporting community and custom DCAE-style backbones. The main code bridges model-facing latent conventions rather than embedding VAE implementation into the world model. Custom checkpoint configs are present for pose and no-pose variants.
Paths: `owl-vaes`, `owl_wms/utils/owl_vae_bridge.py`, `preproccessing/checkpoints/tekken_vae_H200_v6/config.yaml`.

#### 3. Latent data loading and sequence construction
Dataset adapters consume cached local or S3-backed latent stores, including Tekken-specific and mixed datasets. Sequence packing converts variable gameplay segments into model-ready temporal batches with aligned action/state conditioning; this is the main data contract between preprocessing and trainers.
Paths: `owl_wms/data/tekken_latent.py`, `owl_wms/data/tekken_latent_multi.py`, `owl_wms/data/latent_seq_packing.py`.

#### 4. Action-conditioned world-model network
Tekken RFT model variants implement the core transformer world model. Shared neural primitives provide attention, multimodal attention, RoPE, embeddings, modulation, normalization, MLPs, and KV cache support. Model outputs operate in latent space, not directly on pixels.
Paths: `owl_wms/models/tekken_rft.py`, `owl_wms/models/tekken_rft_v2.py`, `owl_wms/nn/mmattn.py`.

#### 5. Configuration-driven distributed training
`train.py` selects architecture, data, optimization, and trainer behavior from YAML. Tekken-specific trainers own the training loop and objective variants; DDP utilities support multi-GPU/multi-node launch via `torchrun`. Recommended experiment definitions are the no-pose and pose large configurations.
Paths: `train.py`, `owl_wms/trainers/tekken_rft_trainer_v2.py`, `configs/tekken_nopose_large.yml`.

#### 6. Sampling and inference pipeline
Inference loads a configured trained checkpoint plus an action sequence, autoregressively/diffusively samples future latents using Tekken samplers and caching strategies, then renders video through the VAE bridge. Inference is explicitly experimental; caching is a key performance/coherence path.
Paths: `inference/tekken_inference.py`, `owl_wms/sampling/t3_action_v2.py`, `owl_wms/sampling/tekken_caching_v2.py`.

#### 7. Runtime and infrastructure
The runtime is Python with PyTorch and GPU/NCCL distributed execution. Docker packaging supports reproducible cluster jobs. SkyPilot launches Kubernetes-based multi-node GPU workloads. Weights & Biases is used for experiment tracking; S3/Tigris-backed latent datasets are supported through environment credentials.
Paths: `Dockerfile`, `skypilot/config.yaml`, `owl_wms/data/s3_cod_latent.py`.

Main entry points: [`owl_wms/utils/owl_vae_bridge.py`](https://github.com/saurav-34/owl-wms/blob/main/owl_wms/utils/owl_vae_bridge.py) (VAE bridge), [`owl_wms/trainers/tekken_rft_trainer_v2.py`](https://github.com/saurav-34/owl-wms/blob/main/owl_wms/trainers/tekken_rft_trainer_v2.py) (Tekken RFT trainer), [`preproccessing/prepare_latents_owl.py`](https://github.com/saurav-34/owl-wms/blob/main/preproccessing/prepare_latents_owl.py) (Latent preparation), [`owl_wms/sampling/t3_action_v2.py`](https://github.com/saurav-34/owl-wms/blob/main/owl_wms/sampling/t3_action_v2.py) (Action latent sampler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_prep["Latent Preparation"]
  node_raw_gameplay["Raw gameplay NPZ<br/>external input"]
  node_latent_prepare["Latent preparation<br/>preprocessing entry point"]
  node_input_loaders["Video and pose loaders<br/>preprocessing adapters<br/>[t3_loader.py]"]
  node_vae_bridge["VAE bridge<br/>latent convention adapter<br/>[owl_vae_bridge.py]"]
  node_vae_ecosystem["Owl VAE submodule<br/>external model ecosystem"]
  node_latent_cache[("Latent cache<br/>training data store")]
end

subgraph group_data["Training Data"]
  node_latent_datasets["Tekken latent datasets<br/>dataset adapters<br/>[tekken_latent.py]"]
  node_s3_latent_store[("S3/Tigris latent store<br/>remote data backend<br/>[s3_cod_latent.py]")]
  node_sequence_packing["Sequence packing<br/>temporal batch builder"]
end

subgraph group_model["World Model"]
  node_rft_model["Tekken RFT model<br/>diffusion transformer<br/>[tekken_rft_v2.py]"]
  node_multimodal_attention["Multimodal attention<br/>neural primitive<br/>[mmattn.py]"]
end

subgraph group_train["Training"]
  node_train_entry["Training entry point<br/>Python entry point<br/>[train.py]"]
  node_experiment_config["No-pose large config<br/>experiment configuration"]
  node_tekken_trainer["Tekken RFT trainer<br/>training loop"]
  node_model_checkpoint[("Trained checkpoint<br/>model artifact")]
end

subgraph group_infer["Inference"]
  node_inference_entry["Tekken inference<br/>Python entry point"]
  node_latent_sampler["Action latent sampler<br/>sampling pipeline<br/>[t3_action_v2.py]"]
  node_sampling_cache["Tekken sampling cache<br/>KV/cache strategy"]
  node_rendered_video["Generated video<br/>output artifact"]
end

subgraph group_infra["Runtime &amp; Infrastructure"]
  node_docker_runtime["Docker runtime<br/>container packaging"]
  node_skypilot_jobs{{"SkyPilot Kubernetes jobs<br/>GPU job launcher<br/>[config.yaml]"}}
end

node_raw_gameplay -->|"source frames and metadata"| node_latent_prepare
node_input_loaders -->|"loads inputs"| node_latent_prepare
node_vae_ecosystem -->|"VAE backbone"| node_vae_bridge
node_vae_bridge -->|"encodes frames"| node_latent_prepare
node_latent_prepare -->|"writes latents and conditioning"| node_latent_cache
node_latent_cache -->|"local cached data"| node_latent_datasets
node_s3_latent_store -->|"remote cached data"| node_latent_datasets
node_latent_datasets -->|"latent segments"| node_sequence_packing
node_sequence_packing -->|"conditioned temporal batches"| node_tekken_trainer
node_multimodal_attention -->|"network primitive"| node_rft_model
node_experiment_config -->|"selects run"| node_train_entry
node_train_entry -->|"constructs trainer"| node_tekken_trainer
node_tekken_trainer -->|"optimizes"| node_rft_model
node_tekken_trainer -->|"saves"| node_model_checkpoint
node_model_checkpoint -->|"loads"| node_inference_entry
node_inference_entry -->|"runs generation"| node_latent_sampler
node_rft_model -->|"predicts latent updates"| node_latent_sampler
node_sampling_cache -->|"cached context"| node_latent_sampler
node_latent_sampler -->|"generated latents"| node_vae_bridge
node_vae_bridge -->|"decodes frames"| node_rendered_video
node_docker_runtime -.->|"packages job runtime"| node_skypilot_jobs
node_skypilot_jobs -.->|"launches distributed training"| node_train_entry

click node_latent_prepare "https://github.com/saurav-34/owl-wms/blob/main/preproccessing/prepare_latents_owl.py"
click node_input_loaders "https://github.com/saurav-34/owl-wms/blob/main/preproccessing/t3_loader.py"
click node_vae_bridge "https://github.com/saurav-34/owl-wms/blob/main/owl_wms/utils/owl_vae_bridge.py"
click node_vae_ecosystem "https://github.com/saurav-34/owl-wms/tree/main/owl-vaes"
click node_latent_datasets "https://github.com/saurav-34/owl-wms/blob/main/owl_wms/data/tekken_latent.py"
click node_s3_latent_store "https://github.com/saurav-34/owl-wms/blob/main/owl_wms/data/s3_cod_latent.py"
click node_sequence_packing "https://github.com/saurav-34/owl-wms/blob/main/owl_wms/data/latent_seq_packing.py"
click node_rft_model "https://github.com/saurav-34/owl-wms/blob/main/owl_wms/models/tekken_rft_v2.py"
click node_multimodal_attention "https://github.com/saurav-34/owl-wms/blob/main/owl_wms/nn/mmattn.py"
click node_train_entry "https://github.com/saurav-34/owl-wms/blob/main/train.py"
click node_experiment_config "https://github.com/saurav-34/owl-wms/blob/main/configs/tekken_nopose_large.yml"
click node_tekken_trainer "https://github.com/saurav-34/owl-wms/blob/main/owl_wms/trainers/tekken_rft_trainer_v2.py"
click node_inference_entry "https://github.com/saurav-34/owl-wms/blob/main/inference/tekken_inference.py"
click node_latent_sampler "https://github.com/saurav-34/owl-wms/blob/main/owl_wms/sampling/t3_action_v2.py"
click node_sampling_cache "https://github.com/saurav-34/owl-wms/blob/main/owl_wms/sampling/tekken_caching_v2.py"
click node_docker_runtime "https://github.com/saurav-34/owl-wms/blob/main/Dockerfile"
click node_skypilot_jobs "https://github.com/saurav-34/owl-wms/blob/main/skypilot/config.yaml"

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_raw_gameplay,node_latent_prepare,node_input_loaders,node_vae_bridge,node_vae_ecosystem,node_latent_cache toneBlue
class node_latent_datasets,node_s3_latent_store,node_sequence_packing toneAmber
class node_rft_model,node_multimodal_attention toneMint
class node_train_entry,node_experiment_config,node_tekken_trainer,node_model_checkpoint toneRose
class node_inference_entry,node_latent_sampler,node_sampling_cache,node_rendered_video toneIndigo
class node_docker_runtime,node_skypilot_jobs toneTeal
```

## Components

### Latent Preparation

Encodes gameplay once into reusable latent stores.

- **Raw gameplay NPZ**: external input · Manual input with frames, actions, states, and valid-frame metadata.
- [Latent preparation](https://github.com/saurav-34/owl-wms/blob/main/preproccessing/prepare_latents_owl.py): preprocessing entry point · `preproccessing/prepare_latents_owl.py`
- [Video and pose loaders](https://github.com/saurav-34/owl-wms/blob/main/preproccessing/t3_loader.py): preprocessing adapters · `preproccessing/t3_loader.py`
- [VAE bridge](https://github.com/saurav-34/owl-wms/blob/main/owl_wms/utils/owl_vae_bridge.py): latent convention adapter · Connects external VAE backbones to world-model latent conventions. · `owl_wms/utils/owl_vae_bridge.py`
- [Owl VAE submodule](https://github.com/saurav-34/owl-wms/tree/main/owl-vaes): external model ecosystem · Separately managed DCAE-style VAE backbones and checkpoints. · `owl-vaes`
- **Latent cache**: training data store · Persisted latent-centric gameplay data.

### Training Data

Builds conditioned temporal batches from latent caches.

- [Tekken latent datasets](https://github.com/saurav-34/owl-wms/blob/main/owl_wms/data/tekken_latent.py): dataset adapters · Reads local, mixed, and remote latent stores. · `owl_wms/data/tekken_latent.py`
- [S3/Tigris latent store](https://github.com/saurav-34/owl-wms/blob/main/owl_wms/data/s3_cod_latent.py): remote data backend · `owl_wms/data/s3_cod_latent.py`
- [Sequence packing](https://github.com/saurav-34/owl-wms/blob/main/owl_wms/data/latent_seq_packing.py): temporal batch builder · Aligns variable gameplay segments with action and state conditioning. · `owl_wms/data/latent_seq_packing.py`

### World Model

Action-conditioned latent prediction network.

- [Tekken RFT model](https://github.com/saurav-34/owl-wms/blob/main/owl_wms/models/tekken_rft_v2.py): diffusion transformer · Predicts future gameplay latents from history and actions. · `owl_wms/models/tekken_rft_v2.py`
- [Multimodal attention](https://github.com/saurav-34/owl-wms/blob/main/owl_wms/nn/mmattn.py): neural primitive · Shared attention and conditioning machinery. · `owl_wms/nn/mmattn.py`

### Training

Configuration-driven distributed optimization.

- [Training entry point](https://github.com/saurav-34/owl-wms/blob/main/train.py): Python entry point · `train.py`
- [No-pose large config](https://github.com/saurav-34/owl-wms/blob/main/configs/tekken_nopose_large.yml): experiment configuration · Selects model, data, optimization, and trainer behavior. · `configs/tekken_nopose_large.yml`
- [Tekken RFT trainer](https://github.com/saurav-34/owl-wms/blob/main/owl_wms/trainers/tekken_rft_trainer_v2.py): training loop · Owns distributed optimization and objective variants. · `owl_wms/trainers/tekken_rft_trainer_v2.py`
- **Trained checkpoint**: model artifact

### Inference

Samples future latents and renders video.

- [Tekken inference](https://github.com/saurav-34/owl-wms/blob/main/inference/tekken_inference.py): Python entry point · Experimental action-conditioned video generation. · `inference/tekken_inference.py`
- [Action latent sampler](https://github.com/saurav-34/owl-wms/blob/main/owl_wms/sampling/t3_action_v2.py): sampling pipeline · Autoregressively/diffusively generates future latents. · `owl_wms/sampling/t3_action_v2.py`
- [Tekken sampling cache](https://github.com/saurav-34/owl-wms/blob/main/owl_wms/sampling/tekken_caching_v2.py): KV/cache strategy · Improves generation performance and coherence. · `owl_wms/sampling/tekken_caching_v2.py`
- **Generated video**: output artifact

### Runtime & Infrastructure

- [Docker runtime](https://github.com/saurav-34/owl-wms/blob/main/Dockerfile): container packaging · `Dockerfile`
- [SkyPilot Kubernetes jobs](https://github.com/saurav-34/owl-wms/blob/main/skypilot/config.yaml): GPU job launcher · Launches multi-node GPU workloads. · `skypilot/config.yaml`

## Connections

- Raw gameplay NPZ → Latent preparation: source frames and metadata
- Video and pose loaders → Latent preparation: loads inputs
- Owl VAE submodule → VAE bridge: VAE backbone
- VAE bridge → Latent preparation: encodes frames
- Latent preparation → Latent cache: writes latents and conditioning
- Latent cache → Tekken latent datasets: local cached data
- S3/Tigris latent store → Tekken latent datasets: remote cached data
- Tekken latent datasets → Sequence packing: latent segments
- Sequence packing → Tekken RFT trainer: conditioned temporal batches
- Multimodal attention → Tekken RFT model: network primitive
- No-pose large config → Training entry point: selects run
- Training entry point → Tekken RFT trainer: constructs trainer
- Tekken RFT trainer → Tekken RFT model: optimizes
- Tekken RFT trainer → Trained checkpoint: saves
- Trained checkpoint → Tekken inference: loads
- Tekken inference → Action latent sampler: runs generation
- Tekken RFT model → Action latent sampler: predicts latent updates
- Tekken sampling cache → Action latent sampler: cached context
- Action latent sampler → VAE bridge: generated latents
- VAE bridge → Generated video: decodes frames
- Docker runtime → SkyPilot Kubernetes jobs: packages job runtime
- SkyPilot Kubernetes jobs → Training entry point: launches distributed training
