Skip to main content

Overview

Cosmos3’s generation path turns text into video. When the sound stream is enabled, the same denoising run also produces audio aligned with the frames. T2V produces video only; T2AV advances video latent and sound latent on the same timeline, so the image comes into view while the waveform takes shape beside it. This page is about ws1, meaning world_size=1. There is no tensor parallelism, no continuous batching, and no server-side scheduling in this path. It is the plain single-GPU route: build an engine, tokenize the prompt, assemble a Cosmos3T2VRequest, run the denoising loop, and let VAE / AVAE decode the result into media you can save.
PhyAI has not added special optimization for the Cosmos3 T2V/T2AV path yet. The current implementation favors correctness, reference alignment, and readable control flow: the denoising loop is a Python-driven UniPC loop, and the examples use RuntimeConfig(use_cuda_graph=False). Treat any timing numbers as baseline measurements, not final optimized throughput.

Architecture

The Cosmos3 generation path uses PhyAI’s . The cosmos3 plugin splits the work into a few layers:
phyai/src/phyai/models/cosmos3
main_cosmos3.py
scheduler_ws1_cosmos3.py
model_runner_cosmos3.py
model_runner_vae_cosmos3.py
modeling_cosmos3.py
vae_wan.py
avae_sound.py
sampler_unipc.py
configuration_cosmos3.py
Main components:

Run path

1

Prepare weights

Prepare a Cosmos3-Nano checkpoint. The examples assume this layout:
2

Construct the engine

The plugin name is "cosmos3". T2V needs the transformer and VAE. T2AV also needs AVAE, exposed through sound_tokenizer.
flow_shift=10.0 and use_karras_sigmas=False match the native linear-flow UniPC setup used by the current example script.
3

Tokenize the prompt

Cosmos3T2VScheduler does not run the tokenizer. Chat template handling, eos / <|vision_start|> suffixes, and positive / negative prompt token ids are produced by Cosmos3Processor.
negative_prompt=None uses the built-in Cosmos3 structured negative prompt. Pass negative_prompt="" if you want an empty negative prompt.
4

Build the request

Cosmos3T2VRequest carries tokenized text conditions, the latent grid, sampler settings, CFG scale, and seed.
pixel_to_latent_shape converts pixel dimensions into the VAE latent grid. The default compression is 4 along time and 16 along each spatial axis.
5

Run generation

T2V returns a pixels tensor shaped (B, 3, T, H, W) with values in [0, 1]. T2AV returns a dict:
6

Save media

Cosmos3GenerationPostProcessor moves GPU tensors to CPU, converts video to uint8 RGB frames, and muxes waveform into the same mp4 when audio is present.

End-to-end examples

examples/cosmos3/run_cosmos3.py wires the full path together. T2V:
T2AV:
The defaults are 720x1280, 189 frames, and 35 steps. That is heavy. For a smoke test, shrink the run first:
The script prints phase timings: model_load, preprocess, inference, to_cpu, and encode. inference includes the denoising loop plus VAE / AVAE decode. encode is PyAV mp4 writing time.

Current limitations

  • This is a single-GPU ws1 path. Tensor parallelism, sequence parallelism, continuous batching, and request scheduling are outside its scope.
  • The examples disable CUDA graph. The denoising loop is a Python-level UniPC loop, built for clarity and reference alignment first.
  • T2AV loads sound_tokenizer / AVAE and advances sound latent at every step, so memory use and runtime go up.
  • Prompt tokenization and media saving happen outside the engine. If you are measuring the model itself, separate preprocess, to_cpu, and encode from inference.
  • PhyAI has not yet built dedicated kernels, graph capture, batching, or end-to-end throughput optimization for Cosmos3 T2V/T2AV. This page shows the baseline road, not the performance endpoint.

Full example