How nv-tlabs/ardy works
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: load_model.py Model loading · ardy_model.py ARDY generator · ardy_motionrep.py Motion representation · generation.py Buffered replanning
Components 22
Entry points
- Batch generation
scripts/generate.py - Demo runtime
scripts/run_demo.py - Text encoder server
scripts/run_text_encoder_server.py - Motion visualizer
scripts/visualize.py
Model runtime
- Model loading · Resolves aliases, builds models, loads checkpoints, and attaches text encoding.
ardy/model/load_model.py - Release registry · Maps skeleton and horizon aliases to released checkpoints.
ardy/model/registry.py - Checkpoint loading · Obtains and restores Hugging Face checkpoints.
ardy/model/loading.py - Compiled inference · Selects eager, torch.compile, or TensorRT-oriented execution.
ardy/model/trt.py - ARDY generator · Generates successive motion horizons from history, text, and observations.
ardy/model/ardy_model.py - Diffusion backbone
ardy/model/diffusion.py - Two-stage latent denoiser
ardy/model/auto_latent_twostage_denoiser.py - LLM2Vec text encoder · Uses the gated Meta-Llama-backed LLM2Vec integration.
ardy/model/text_encoder_api.py
Motion representation
- Motion representation · Normalizes and reconstructs poses, rotations, root trajectories, and contacts.
ardy/motion_rep/reps/ardy_motionrep.py - Latent codec · Encodes and decodes the learned motion latent representation.
ardy/model/autoencoder/transformer.py - Constraint conditioning · Assembles masked root, waypoint, keyframe, and sparse-joint observations.
ardy/motion_rep/conditioning.py - Skeleton runtime · Provides skeleton definitions, transforms, registration, and forward kinematics.
ardy/skeleton/kinematics.py - MuJoCo export
ardy/exports/mujoco.py
Interactive demo
- GUI orchestrator · Coordinates browser actions and stateful generation.
scripts/interactive_demo/gui/orchestrator.py - Buffered replanning · Performs buffered autoregressive generation.
scripts/interactive_demo/generation.py - Interactive constraints
scripts/interactive_demo/constraints.py - Frame playback · Consumes generated motion frames for the UI.
scripts/interactive_demo/playback.py
Postprocessing
- Motion correction · Reduces skating and improves constraint adherence.
MotionCorrection/src/cpp/AnimProcessing/TrajectoryCorrector.cpp
Connections 26
- 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