What is Cosmos-CUDA
maincuda extra components are installed in the environment. It serves as a check to ensure the necessary CUDA extensions are present for the DreamDojo ecosystem.repository·main·Indexed 21 days ago
https://github.com/nvidia/dreamdojoAn interactive robot world model trained on 44,000 hours of human egocentric video. It features a foundation for robot learning via pretraining, post-training, and a distillation pipeline for real-time, long-horizon video generation. The ecosystem includes the cosmos-predict2 World Foundation Model, the Imaginaire Attention API, and cosmos-gradio for model deployment.
cuda extra components are installed in the environment. It serves as a check to ensure the necessary CUDA extensions are present for the DreamDojo ecosystem.DreamDojo provides a foundation robot world model with the following key features:
Multi-Dimensional Attention requires a specific tensor layout. In addition to the standard contiguous heads-last layout, the "sequence length" dimension must be unrolled into its original spatial/temporal representation.
Important Requirements:
query, key, and value must match exactly along all dimensions of the token layout shape. This is because the API assumes query and context coordinate spaces are identical.(batch, X, heads, head_dim)(batch, X, Y, heads, head_dim)(batch, X, Y, Z, heads, head_dim)# 1-D case: language, audio
batch, X, heads, head_dim = query_1d.shape
# 2-D case: images
batch, X, Y, heads, head_dim = query_2d.shape
# 3-D case: videos / 3-D images
batch, X, Y, Z, heads, head_dim = query_3d.shape
# Requirement: query, key, and value must match on layout dimensions
assert query_2d.shape[1:3] == key_2d.shape[1:3] == value_2d.shape[1:3]Imaginaire Attention requires input tensors (query, key, and value) to follow a specific memory layout: heads-last torch contiguous (torch.contiguous_format).
Tensor Shape Requirements: Inputs must be rank-4 tensors with the following dimensions:
Memory Layout Details:
This layout is consistent with PyTorch's contiguous_format, where the right-most dimension (head dimension) is the major dimension (stride 1). Tokens from different heads are interleaved in memory.
To ensure your tensors are correctly formatted, you can use the following verification logic:
def verify_heads_last_contig_tensor(x: Tensor):
assert x.shape[0] == batch
assert x.shape[1] == seqlen
assert x.shape[2] == heads
assert x.shape[3] == head_dim
assert x.stride(3) == 1
assert x.stride(2) == head_dim
assert x.stride(1) == heads * head_dim
assert x.stride(0) == heads * head_dim * seqlenTo implement Grouped-Query Attention (GQA) or Multi-Query Attention (MQA), pass the key and value tensors without repeating the attention heads.
Requirements and Behavior:
key/value heads must evenly divide the number of query heads.repeat_interleave rather than a standard repeat operation.The distillation pipeline converts a post-trained DreamDojo teacher model into a fast, causal student model. This student model is optimized for long-horizon autoregressive generation at 10 FPS. The process follows three distinct stages:
Once distillation is complete, the student model can be used for either offline video generation or real-time interactive teleoperation.
The flash3 backend provides access to the original Flash Attention v3 C++ kernels.
Requirements:
flash_attn_3 package.3.0.0.b*.Note: torch.compile is NOT supported for this backend.
Feature Support (Ampere/RTX):
Use uv to manage the environment. Note that Blackwell architecture users must use Docker; virtual environment support for Blackwell is currently in development.
sudo apt install git-lfs
git lfs install
git clone git@github.com:nvidia-cosmos/<repository_name>.git
cd <repository_name>
git lfs pullsudo apt install curl ffmpeg tree wgetuv:curl -LsSf https://astral.sh/uv/install.sh | sh
source $HOME/.local/bin/env--extra=cu128--extra=cu130To create a new environment:
uv sync --extra=cu128
source .venv/bin/activateTo install into an existing active environment (like Conda):
uv sync --extra=cu128 --active --inexactImaginaire Attention supports variable length sequences via two methods.
Pass seqlens_Q and seqlens_KV directly as tensors. This method is less efficient because it manually computes maximum sequence lengths and cumulative sums (including additional padding) during every call.
For better performance, compute the cumulative sequence lengths and maximums once using generate_varlen_parameters and pass these pre-computed values to the attention layer. This avoids redundant computations in subsequent layers.
from cosmos_predict2._src.imaginaire.attention.varlen import generate_varlen_parameters
# Pre-compute parameters once
(
cumulative_seqlen_Q,
cumulative_seqlen_KV,
max_seqlen_Q,
max_seqlen_KV,
) = generate_varlen_parameters(query, key, value, seqlens_Q, seqlens_KV)
# Use pre-computed parameters in attention layers
output = attention(
query=query,
key=key,
value=value,
cumulative_seqlen_Q=cumulative_seqlen_Q,
cumulative_seqlen_KV=cumulative_seqlen_KV,
max_seqlen_Q=max_seqlen_Q,
max_seqlen_KV=max_seqlen_KV,
)Generate denoising targets from the teacher model at few-step noise levels. This step is required to pre-compute the supervision needed for the Warmup training stage.
bash launch_teacher_gen.shCheckpoints are automatically downloaded during inference and post-training. To access them, follow these steps:
Read permission.uv:uv tool install -U "huggingface_hub[cli]"hf auth loginTo change where checkpoints are stored, set the HF_HOME environment variable.
uv tool install -U "huggingface_hub[cli]"
hf auth loginOnce you have built the distributions in the dist/ directory, you can publish them to PyPI using one of the following methods:
justIf the just command is available in your environment, use the project's built-in command:
just publish <pypi_token>twinetwine:pip install twinetwine upload dist/*# Using twine
pip install twine
twine upload dist/*