# nv-tlabs/ardy architecture

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

- Interactive diagram: https://gitdiagram.com/nv-tlabs/ardy
- Repository: https://github.com/nv-tlabs/ardy

## Overview

#### Purpose and Entry Points
ARDY is a PyTorch-based autoregressive diffusion system for real-time, text-conditioned humanoid motion generation with optional kinematic constraints. Primary entry points are batch generation in `scripts/generate.py`, the browser-based interactive runtime in `scripts/run_demo.py`, and a reusable text-encoder service in `scripts/run_text_encoder_server.py`. Generated motion can be inspected through `scripts/visualize.py`.

#### Model Loading and Runtime Selection
Model resolution, checkpoint loading, model construction, and text-encoder attachment are centralized in `ardy/model/load_model.py`, `ardy/model/loading.py`, and `ardy/model/registry.py`. The registry maps skeleton/horizon aliases to released checkpoints. Runtime supports ordinary PyTorch inference, optional `torch.compile`, and TensorRT-oriented paths in `ardy/model/trt.py`; checkpoints are obtained from Hugging Face.

#### Core Generative Pipeline
`ardy/model/ardy_model.py` owns the ARDY inference API, notably autoregressive generation over successive motion horizons. Its network stages are implemented by the diffusion and backbone layers in `ardy/model/diffusion.py` and `ardy/model/backbone.py`, with a two-stage latent denoiser in `ardy/model/auto_latent_twostage_denoiser.py`. The pipeline consumes prior generated motion, text features, and optional observed-motion masks, then emits the next motion representation segment.

#### Latent and Motion Representation Boundary
Motion encoding/decoding is separated from model sampling. The learned latent representation uses transformer and finite-scalar-quantization components in `ardy/model/autoencoder/transformer.py` and `ardy/model/autoencoder/fsq.py`. Domain-level motion conversion, normalization, inverse reconstruction, contacts, and constraint conditioning reside in `ardy/motion_rep/reps/ardy_motionrep.py`, `ardy/motion_rep/conditioning.py`, and `ardy/motion_rep/stats.py`. This boundary converts network tensors into skeletal poses, joint rotations, root trajectories, and foot-contact outputs.

#### Text and Constraint Inputs
Text is embedded through the bundled LLM2Vec integration in `ardy/model/text_encoder_api.py` and `ardy/model/llm2vec/llm2vec_wrapper.py`, backed by the gated Hugging Face Meta-Llama model. Constraint data is represented as masked/observed motion and assembled from root, waypoint, keyframe, and sparse-joint inputs. General constraints and geometric handling are in `ardy/constraints.py` and `ardy/geometry.py`; interactive constraint authoring is coordinated by `scripts/interactive_demo/constraints.py` and `scripts/interactive_demo/gen_constraints.py`.

#### Skeleton, Assets, and Outputs
Skeleton definitions, forward kinematics, transforms, and registration are provided by `ardy/skeleton/definitions.py`, `ardy/skeleton/kinematics.py`, and `ardy/skeleton/registry.py`. Packaged assets cover core, SOMA, and Unitree G1 rigs, including G1 MuJoCo XML at `ardy/assets/skeletons/g1skel34/xml/g1.xml`. Batch output and robot-oriented export use `scripts/generate.py` and `ardy/exports/mujoco.py`; BVH/motion import support is in `ardy/data_processing/bvh.py`.

#### Interactive Control and Postprocessing
The demo is a stateful realtime orchestration layer: `scripts/interactive_demo/gui/orchestrator.py` coordinates GUI actions, `scripts/interactive_demo/generation.py` performs buffered autoregressive replanning, and `scripts/interactive_demo/playback.py` consumes generated frames. Viser/Gradio provide the browser UI and visualization. Optional postprocessing reduces skating and improves constraint adherence through `ardy/postprocess.py`, backed by the compiled C++ motion-correction extension exposed at `MotionCorrection/src/cpp/BindingsPython.cpp` and implemented in `MotionCorrection/src/cpp/AnimProcessing/TrajectoryCorrector.cpp`.

Main entry points: [`ardy/model/load_model.py`](https://github.com/nv-tlabs/ardy/blob/main/ardy/model/load_model.py) (Model loading), [`ardy/model/ardy_model.py`](https://github.com/nv-tlabs/ardy/blob/main/ardy/model/ardy_model.py) (ARDY generator), [`ardy/motion_rep/reps/ardy_motionrep.py`](https://github.com/nv-tlabs/ardy/blob/main/ardy/motion_rep/reps/ardy_motionrep.py) (Motion representation), [`scripts/interactive_demo/generation.py`](https://github.com/nv-tlabs/ardy/blob/main/scripts/interactive_demo/generation.py) (Buffered replanning)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entrypoints["Entry points"]
  node_batch_generate["Batch generation<br/>Python CLI<br/>[generate.py]"]
  node_demo_entry["Demo runtime<br/>Python CLI<br/>[run_demo.py]"]
  node_text_server["Text encoder server<br/>Python service"]
  node_visualize["Motion visualizer<br/>Python CLI<br/>[visualize.py]"]
end

subgraph group_runtime["Model runtime"]
  node_model_loader["Model loading<br/>loader<br/>[load_model.py]"]
  node_model_registry["Release registry<br/>checkpoint registry<br/>[registry.py]"]
  node_checkpoint_loading["Checkpoint loading<br/>loader<br/>[loading.py]"]
  node_trt_runtime["Compiled inference<br/>PyTorch/TensorRT runtime<br/>[trt.py]"]
  node_ardy_model{{"ARDY generator<br/>autoregressive diffusion model<br/>[ardy_model.py]"}}
  node_diffusion_backbone["Diffusion backbone<br/>denoising network<br/>[diffusion.py]"]
  node_latent_denoiser["Two-stage latent denoiser<br/>denoiser stage"]
  node_text_encoder["LLM2Vec text encoder<br/>text embedding"]
end

subgraph group_representation["Motion representation"]
  node_motion_rep["Motion representation<br/>motion codec boundary<br/>[ardy_motionrep.py]"]
  node_latent_codec["Latent codec<br/>transformer + FSQ<br/>[transformer.py]"]
  node_constraint_conditioning["Constraint conditioning<br/>observed-motion masks<br/>[conditioning.py]"]
  node_skeleton_runtime["Skeleton runtime<br/>kinematics<br/>[kinematics.py]"]
  node_mujoco_export["MuJoCo export<br/>robot export<br/>[mujoco.py]"]
end

subgraph group_interactive["Interactive demo"]
  node_demo_orchestrator["GUI orchestrator<br/>realtime controller<br/>[orchestrator.py]"]
  node_demo_generation["Buffered replanning<br/>interactive generator<br/>[generation.py]"]
  node_demo_constraints["Interactive constraints<br/>constraint authoring<br/>[constraints.py]"]
  node_playback["Frame playback<br/>browser playback<br/>[playback.py]"]
end

subgraph group_postprocessing["Postprocessing"]
  node_motion_correction["Motion correction<br/>native postprocessor"]
end

node_batch_generate -->|"loads"| node_model_loader
node_demo_entry -->|"starts"| node_demo_orchestrator
node_text_server -->|"serves"| node_text_encoder
node_model_loader -->|"resolves"| node_model_registry
node_model_loader -->|"restores"| node_checkpoint_loading
node_model_loader -->|"configures"| node_trt_runtime
node_model_loader -->|"constructs"| node_ardy_model
node_model_loader -->|"attaches"| node_text_encoder
node_ardy_model -->|"samples with"| node_diffusion_backbone
node_diffusion_backbone -->|"denoises latents"| node_latent_denoiser
node_ardy_model -->|"uses"| node_latent_codec
node_ardy_model -->|"conditions on text"| node_text_encoder
node_ardy_model -->|"accepts observations"| node_constraint_conditioning
node_latent_codec -->|"decodes"| node_motion_rep
node_constraint_conditioning -->|"masks representation"| node_motion_rep
node_motion_rep -->|"reconstructs poses with"| node_skeleton_runtime
node_demo_orchestrator -->|"authors"| node_demo_constraints
node_demo_orchestrator -->|"requests"| node_demo_generation
node_demo_generation -->|"replans with"| node_ardy_model
node_demo_constraints -->|"builds"| node_constraint_conditioning
node_demo_generation -.->|"optionally postprocesses"| node_motion_correction
node_motion_correction -->|"corrected frames"| node_playback
node_demo_generation -->|"generated frames"| node_playback
node_batch_generate -.->|"exports robot motion"| node_mujoco_export
node_motion_rep -->|"provides motion"| node_mujoco_export
node_motion_rep -.->|"inspects"| node_visualize

click node_batch_generate "https://github.com/nv-tlabs/ardy/blob/main/scripts/generate.py"
click node_demo_entry "https://github.com/nv-tlabs/ardy/blob/main/scripts/run_demo.py"
click node_text_server "https://github.com/nv-tlabs/ardy/blob/main/scripts/run_text_encoder_server.py"
click node_visualize "https://github.com/nv-tlabs/ardy/blob/main/scripts/visualize.py"
click node_model_loader "https://github.com/nv-tlabs/ardy/blob/main/ardy/model/load_model.py"
click node_model_registry "https://github.com/nv-tlabs/ardy/blob/main/ardy/model/registry.py"
click node_checkpoint_loading "https://github.com/nv-tlabs/ardy/blob/main/ardy/model/loading.py"
click node_trt_runtime "https://github.com/nv-tlabs/ardy/blob/main/ardy/model/trt.py"
click node_ardy_model "https://github.com/nv-tlabs/ardy/blob/main/ardy/model/ardy_model.py"
click node_diffusion_backbone "https://github.com/nv-tlabs/ardy/blob/main/ardy/model/diffusion.py"
click node_latent_denoiser "https://github.com/nv-tlabs/ardy/blob/main/ardy/model/auto_latent_twostage_denoiser.py"
click node_text_encoder "https://github.com/nv-tlabs/ardy/blob/main/ardy/model/text_encoder_api.py"
click node_motion_rep "https://github.com/nv-tlabs/ardy/blob/main/ardy/motion_rep/reps/ardy_motionrep.py"
click node_latent_codec "https://github.com/nv-tlabs/ardy/blob/main/ardy/model/autoencoder/transformer.py"
click node_constraint_conditioning "https://github.com/nv-tlabs/ardy/blob/main/ardy/motion_rep/conditioning.py"
click node_skeleton_runtime "https://github.com/nv-tlabs/ardy/blob/main/ardy/skeleton/kinematics.py"
click node_demo_orchestrator "https://github.com/nv-tlabs/ardy/blob/main/scripts/interactive_demo/gui/orchestrator.py"
click node_demo_generation "https://github.com/nv-tlabs/ardy/blob/main/scripts/interactive_demo/generation.py"
click node_demo_constraints "https://github.com/nv-tlabs/ardy/blob/main/scripts/interactive_demo/constraints.py"
click node_playback "https://github.com/nv-tlabs/ardy/blob/main/scripts/interactive_demo/playback.py"
click node_motion_correction "https://github.com/nv-tlabs/ardy/blob/main/MotionCorrection/src/cpp/AnimProcessing/TrajectoryCorrector.cpp"
click node_mujoco_export "https://github.com/nv-tlabs/ardy/blob/main/ardy/exports/mujoco.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_batch_generate,node_demo_entry,node_text_server,node_visualize toneBlue
class node_model_loader,node_model_registry,node_checkpoint_loading,node_trt_runtime,node_ardy_model,node_diffusion_backbone,node_latent_denoiser,node_text_encoder toneAmber
class node_motion_rep,node_latent_codec,node_constraint_conditioning,node_skeleton_runtime,node_mujoco_export toneMint
class node_demo_orchestrator,node_demo_generation,node_demo_constraints,node_playback toneRose
class node_motion_correction toneIndigo
```

## Components

### Entry points

- [Batch generation](https://github.com/nv-tlabs/ardy/blob/main/scripts/generate.py): Python CLI · `scripts/generate.py`
- [Demo runtime](https://github.com/nv-tlabs/ardy/blob/main/scripts/run_demo.py): Python CLI · `scripts/run_demo.py`
- [Text encoder server](https://github.com/nv-tlabs/ardy/blob/main/scripts/run_text_encoder_server.py): Python service · `scripts/run_text_encoder_server.py`
- [Motion visualizer](https://github.com/nv-tlabs/ardy/blob/main/scripts/visualize.py): Python CLI · `scripts/visualize.py`

### Model runtime

- [Model loading](https://github.com/nv-tlabs/ardy/blob/main/ardy/model/load_model.py): loader · Resolves aliases, builds models, loads checkpoints, and attaches text encoding. · `ardy/model/load_model.py`
- [Release registry](https://github.com/nv-tlabs/ardy/blob/main/ardy/model/registry.py): checkpoint registry · Maps skeleton and horizon aliases to released checkpoints. · `ardy/model/registry.py`
- [Checkpoint loading](https://github.com/nv-tlabs/ardy/blob/main/ardy/model/loading.py): loader · Obtains and restores Hugging Face checkpoints. · `ardy/model/loading.py`
- [Compiled inference](https://github.com/nv-tlabs/ardy/blob/main/ardy/model/trt.py): PyTorch/TensorRT runtime · Selects eager, torch.compile, or TensorRT-oriented execution. · `ardy/model/trt.py`
- [ARDY generator](https://github.com/nv-tlabs/ardy/blob/main/ardy/model/ardy_model.py): autoregressive diffusion model · Generates successive motion horizons from history, text, and observations. · `ardy/model/ardy_model.py`
- [Diffusion backbone](https://github.com/nv-tlabs/ardy/blob/main/ardy/model/diffusion.py): denoising network · `ardy/model/diffusion.py`
- [Two-stage latent denoiser](https://github.com/nv-tlabs/ardy/blob/main/ardy/model/auto_latent_twostage_denoiser.py): denoiser stage · `ardy/model/auto_latent_twostage_denoiser.py`
- [LLM2Vec text encoder](https://github.com/nv-tlabs/ardy/blob/main/ardy/model/text_encoder_api.py): text embedding · Uses the gated Meta-Llama-backed LLM2Vec integration. · `ardy/model/text_encoder_api.py`

### Motion representation

- [Motion representation](https://github.com/nv-tlabs/ardy/blob/main/ardy/motion_rep/reps/ardy_motionrep.py): motion codec boundary · Normalizes and reconstructs poses, rotations, root trajectories, and contacts. · `ardy/motion_rep/reps/ardy_motionrep.py`
- [Latent codec](https://github.com/nv-tlabs/ardy/blob/main/ardy/model/autoencoder/transformer.py): transformer + FSQ · Encodes and decodes the learned motion latent representation. · `ardy/model/autoencoder/transformer.py`
- [Constraint conditioning](https://github.com/nv-tlabs/ardy/blob/main/ardy/motion_rep/conditioning.py): observed-motion masks · Assembles masked root, waypoint, keyframe, and sparse-joint observations. · `ardy/motion_rep/conditioning.py`
- [Skeleton runtime](https://github.com/nv-tlabs/ardy/blob/main/ardy/skeleton/kinematics.py): kinematics · Provides skeleton definitions, transforms, registration, and forward kinematics. · `ardy/skeleton/kinematics.py`
- [MuJoCo export](https://github.com/nv-tlabs/ardy/blob/main/ardy/exports/mujoco.py): robot export · `ardy/exports/mujoco.py`

### Interactive demo

- [GUI orchestrator](https://github.com/nv-tlabs/ardy/blob/main/scripts/interactive_demo/gui/orchestrator.py): realtime controller · Coordinates browser actions and stateful generation. · `scripts/interactive_demo/gui/orchestrator.py`
- [Buffered replanning](https://github.com/nv-tlabs/ardy/blob/main/scripts/interactive_demo/generation.py): interactive generator · Performs buffered autoregressive generation. · `scripts/interactive_demo/generation.py`
- [Interactive constraints](https://github.com/nv-tlabs/ardy/blob/main/scripts/interactive_demo/constraints.py): constraint authoring · `scripts/interactive_demo/constraints.py`
- [Frame playback](https://github.com/nv-tlabs/ardy/blob/main/scripts/interactive_demo/playback.py): browser playback · Consumes generated motion frames for the UI. · `scripts/interactive_demo/playback.py`

### Postprocessing

- [Motion correction](https://github.com/nv-tlabs/ardy/blob/main/MotionCorrection/src/cpp/AnimProcessing/TrajectoryCorrector.cpp): native postprocessor · Reduces skating and improves constraint adherence. · `MotionCorrection/src/cpp/AnimProcessing/TrajectoryCorrector.cpp`

## Connections

- Batch generation → Model loading: loads
- Demo runtime → GUI orchestrator: starts
- Text encoder server → LLM2Vec text encoder: serves
- Model loading → Release registry: resolves
- Model loading → Checkpoint loading: restores
- Model loading → Compiled inference: configures
- Model loading → ARDY generator: constructs
- Model loading → LLM2Vec text encoder: attaches
- ARDY generator → Diffusion backbone: samples with
- Diffusion backbone → Two-stage latent denoiser: denoises latents
- ARDY generator → Latent codec: uses
- ARDY generator → LLM2Vec text encoder: conditions on text
- ARDY generator → Constraint conditioning: accepts observations
- Latent codec → Motion representation: decodes
- Constraint conditioning → Motion representation: masks representation
- Motion representation → Skeleton runtime: reconstructs poses with
- GUI orchestrator → Interactive constraints: authors
- GUI orchestrator → Buffered replanning: requests
- Buffered replanning → ARDY generator: replans with
- Interactive constraints → Constraint conditioning: builds
- Buffered replanning → Motion correction: optionally postprocesses
- Motion correction → Frame playback: corrected frames
- Buffered replanning → Frame playback: generated frames
- Batch generation → MuJoCo export: exports robot motion
- Motion representation → MuJoCo export: provides motion
- Motion representation → Motion visualizer: inspects
