Skip to navigation

Text-to-Video

Generate videos from text prompts with FastVideo, vLLM-Omni, SGLang, or TensorRT-LLM

View as Markdown

Choose a backend for text-to-video generation. See the Diffusion Overview for installation and shared configuration.

This guide covers deploying FastVideo text-to-video generation on Dynamo using a custom worker (worker.py) exposed through the /v1/videos endpoint.

Dynamo also supports text-to-video through built-in backends: vLLM-Omni, SGLang, and TensorRT-LLM. See the Diffusion Overview for the full support matrix across all modalities.

Overview

  • Default model: FastVideo/FastWan2.1-T2V-1.3B-Diffusers.
  • Typed API: The worker builds GeneratorConfig once at startup and creates a GenerationRequest for each /v1/videos request.
  • Optimized inference: torch.compile and NVFP4 transformer quantization are available through --torch-compile and --fp4-quantization; the legacy --enable-optimizations flag remains as a shortcut for both.
  • Response format: Returns one complete MP4 payload per request as data[0].b64_json (non-streaming).
  • Concurrency: One request at a time per worker (VideoGenerator is not re-entrant). Scale throughput by running multiple workers.

worker.py defaults to --attention-backend VIDEO_SPARSE_ATTN and routes VSA_sparsity=0.8 through FastVideo’s typed PipelineSelection.experimental config. Keep this backend for FastWan 2.1 models; forcing TORCH_SDPA can instantiate a non-VSA Wan block and fail checkpoint loading. Use --attention-backend TORCH_SDPA for the LTX-2 compatibility path validated by the B300 smoke test.

Kubernetes Deployment

Kubernetes is the recommended path for running FastVideo on Dynamo. The steps below build and push the runtime image, deploy the aggregated worker, and send a first request. For a single-node development workflow, see Local Deployment at the bottom of this page.

Deployment Files

FileDescription
agg.yamlBase aggregated deployment (Frontend + FastVideoWorker)
agg_user_workload.yamlSame deployment with user-workload tolerations and imagePullSecrets
huggingface-cache-pvc.yamlShared HF cache PVC for model weights
dynamo-platform-values-user-workload.yamlOptional Helm values for clusters with tainted user-workload nodes

Prerequisites

  • Dynamo Kubernetes Platform installed
  • GPU-enabled Kubernetes cluster
  • A container registry you can push the FastVideo runtime image to
  • Optional HF token secret (for gated models)
1

Build and push the FastVideo runtime image

The runtime image is built from the Dockerfile:

  • Base image: nvidia/cuda:13.1.1-devel-ubuntu24.04
  • Installs FastVideo 0.2.0 from PyPI, which provides the fastvideo.api typed surface and NVFP4 transformer quantization support
  • Installs the ai-dynamo package with /v1/videos support

Build and push the image:

docker build examples/diffusers/ -t <my-registry/fastvideo-runtime:my-tag>
docker push <my-registry/fastvideo-runtime:my-tag>

A from-source flash-attention (FA4) build is deferred. The worker runs on FastVideo’s default attention backends without it.

2

Create the Hugging Face token secret (optional)

Only required for gated models:

export NAMESPACE=<your-namespace>
export HF_TOKEN=<your-hf-token>
kubectl create secret generic hf-token-secret \
--from-literal=HF_TOKEN=${HF_TOKEN} \
-n ${NAMESPACE}
3

Apply the cache PVC and deployment

Mounting a shared Hugging Face cache PVC means model weights are downloaded once and reused across pod restarts.

cd <dynamo-root>/examples/diffusers/deploy
export NAMESPACE=<your-namespace>
kubectl apply -f huggingface-cache-pvc.yaml -n ${NAMESPACE}
kubectl apply -f agg.yaml -n ${NAMESPACE}

For clusters with tainted user-workload nodes and private registry pulls, set your pull secret name and image in agg_user_workload.yaml, then apply that variant instead:

kubectl apply -f huggingface-cache-pvc.yaml -n ${NAMESPACE}
kubectl apply -f agg_user_workload.yaml -n ${NAMESPACE}

To swap the image on an existing deployment quickly:

export DEPLOYMENT_FILE=agg.yaml
export FASTVIDEO_IMAGE=<my-registry/fastvideo-runtime:my-tag>
yq '(.spec.components[].podTemplate.spec.containers[] | select(.name == "main") | .image) = env(FASTVIDEO_IMAGE)' \
${DEPLOYMENT_FILE} > ${DEPLOYMENT_FILE}.generated
kubectl apply -f ${DEPLOYMENT_FILE}.generated -n ${NAMESPACE}
4

Verify and access the deployment

kubectl get dgd -n ${NAMESPACE}
kubectl get pods -n ${NAMESPACE}
kubectl logs -n ${NAMESPACE} -l nvidia.com/dynamo-component=FastVideoWorker

Port-forward the Frontend Service:

kubectl port-forward -n ${NAMESPACE} svc/fastvideo-agg-frontend 8000:8000
5

Send a test request

If this is the first request after startup, expect it to take longer while warmup completes. See Warmup Time for details.

curl -s -X POST http://localhost:8000/v1/videos \
-H 'Content-Type: application/json' \
-d '{
"model": "FastVideo/FastWan2.1-T2V-1.3B-Diffusers",
"prompt": "A cinematic drone shot over a snowy mountain range at sunrise",
"size": "256x256",
"response_format": "b64_json",
"nvext": {
"fps": 8,
"num_frames": 8,
"num_inference_steps": 1,
"guidance_scale": 1.0,
"seed": 10
}
}' > response.json
# Linux
jq -r '.data[0].b64_json' response.json | base64 --decode > output.mp4
# macOS
jq -r '.data[0].b64_json' response.json | base64 -D > output.mp4

FullHD Video with Audio (LTX-2)

LTX-2 models support native audio generation alongside video. LTX-2 requires width and height divisible by 32, so FullHD requests use 1920x1088 rather than 1920x1080.

Start the local example with an LTX-2 model:

cd <dynamo-root>/examples/diffusers/local
MODEL=FastVideo/LTX2-Distilled-Diffusers \
WORKER_EXTRA_ARGS="--attention-backend TORCH_SDPA --fp4-quantization" \
./run_local.sh

Send the request from another terminal:

curl -s -X POST http://localhost:8000/v1/videos \
-H 'Content-Type: application/json' \
-d '{
"model": "FastVideo/LTX2-Distilled-Diffusers",
"prompt": "A waterfall cascading into a forest pool, birds singing",
"size": "1920x1088",
"response_format": "b64_json",
"nvext": {
"fps": 24,
"num_frames": 121,
"num_inference_steps": 5,
"guidance_scale": 1.0,
"seed": 42
}
}'

FastVideo exposes generated audio and audio_sample_rate on its Python result object. This Dynamo worker returns the saved MP4 in data[0].b64_json, with FastVideo muxing the generated 24 kHz audio into the MP4 output.

LTX-2 refine pipeline flags such as ltx2_refine_enabled, ltx2_refine_upsampler_path, and per-component compile settings are not yet exposed through FastVideo’s typed API config.

Warmup Time

On first start, workers download model weights. When --torch-compile is enabled, compile/warmup steps can push the first ready time to roughly 10–20 minutes (hardware-dependent). After the first successful compiled response, the second request can still take around 35 seconds while runtime caches finish warming up; steady-state performance is typically reached from the third request onward.

The shared Hugging Face cache PVC applied in the Kubernetes Deployment steps means weights are downloaded once and reused across pod restarts, so warmup is only paid in full on the very first start.

Worker Configuration Reference

Flags passed to worker.py:

--model, --model-path
stringDefaults to FastVideo/FastWan2.1-T2V-1.3B-Diffusers

HuggingFace model path.

--num-gpus
intDefaults to 1

Number of GPUs for distributed inference.

--discovery-backend
string

Dynamo discovery backend. Choices: etcd, file, mem, and kubernetes. Defaults to the environment, then Kubernetes or file discovery.

--attention-backend
stringDefaults to VIDEO_SPARSE_ATTN

Sets FASTVIDEO_ATTENTION_BACKEND. Choices: FLASH_ATTN, TORCH_SDPA, SAGE_ATTN, SAGE_ATTN_THREE, VIDEO_SPARSE_ATTN, VMOBA_ATTN, SLA_ATTN, SAGE_SLA_ATTN.

--vsa-sparsity
floatDefaults to 0.8 for VIDEO_SPARSE_ATTN

Sets PipelineSelection.experimental["VSA_sparsity"]. The worker omits this value for other attention backends unless explicitly set.

--torch-compile
flagDefaults to off

Enables FastVideo CompileConfig.

--torch-compile-backend
stringDefaults to inductor

Sets the torch.compile backend.

--torch-compile-mode
stringDefaults to max-autotune-no-cudagraphs

Sets the torch.compile mode. Choices: default, reduce-overhead, max-autotune, and max-autotune-no-cudagraphs.

--torch-compile-fullgraph, --no-torch-compile-fullgraph
flagDefaults to on

Controls fullgraph mode.

--torch-compile-dynamic, --no-torch-compile-dynamic
flagDefaults to off

Controls dynamic shapes.

--fp4-quantization
flagDefaults to off

Requests NVFP4 transformer quantization through QuantizationConfig(transformer_quant="NVFP4"). Confirm activation in worker logs before reporting FP4 results.

--enable-optimizations
flagDefaults to off

Backward-compatible shortcut for --torch-compile --fp4-quantization.

--use-fsdp-inference, --no-use-fsdp-inference
flagDefaults to off

Controls FastVideo Fully Sharded Data Parallel (FSDP) inference.

--dit-cpu-offload, --no-dit-cpu-offload
flagDefaults to on

Controls Diffusion Transformer (DiT) CPU offload.

--dit-layerwise-offload, --no-dit-layerwise-offload
flagDefaults to on

Controls layerwise DiT CPU offload.

--vae-cpu-offload, --no-vae-cpu-offload
flagDefaults to on

Controls variational autoencoder (VAE) CPU offload.

--image-encoder-cpu-offload, --no-image-encoder-cpu-offload
flagDefaults to on

Controls image encoder CPU offload.

--text-encoder-cpu-offload, --no-text-encoder-cpu-offload
flagDefaults to on

Controls text encoder CPU offload.

--pin-cpu-memory, --no-pin-cpu-memory
flagDefaults to on

Controls pinned host memory for CPU offload transfers.

--disable-autocast, --no-disable-autocast
flagDefaults to off

Controls autocast in FastVideo denoising and decoding paths.

--default-size
stringDefaults to 1280x720

Default request dimensions.

--default-seconds
intDefaults to 5

Default request duration in seconds.

--default-fps
intDefaults to 24

Default request frame rate.

--default-num-frames
intDefaults to 125

Default frame count.

--default-num-inference-steps
intDefaults to 50

Default diffusion inference steps.

--default-guidance-scale
floatDefaults to 1.0

Default classifier-free guidance scale.

--default-seed
int

Default random-number-generator seed. When unset, FastVideo uses its preset.

--max-video-width
intDefaults to 4096

Rejects wider requests before calling FastVideo.

--max-video-height
intDefaults to 4096

Rejects taller requests before calling FastVideo.

--max-num-frames
intDefaults to 1024

Rejects requests whose resolved frame count exceeds this cap.

--max-num-inference-steps
intDefaults to 200

Rejects requests whose inference-step count exceeds this cap.

--output-dir
stringDefaults to $XDG_RUNTIME_DIR/dynamo-fastvideo/outputs or ~/.cache/dynamo/fastvideo/outputs

Directory for generated MP4 staging files.

Troubleshooting

Hardware Support

The worker checks the GPU compute capability at startup and fails fast when the selected attention backend cannot run on the detected hardware:

ConfigurationMinimum compute capabilityNotes
FastWan 2.1 + VIDEO_SPARSE_ATTN (default)9.0fastvideo-kernel compiles its Video Sparse Attention (VSA) kernels for sm90a and falls back to a Triton implementation on other architectures. Pre-Hopper GPUs, such as sm86, fail at runtime. FastWan 2.1 checkpoints contain VSA-specific layers, so TORCH_SDPA is not a fallback for this model. Validated on B300 (sm103) and RTX 5090 (sm120)
LTX-2 + TORCH_SDPANone specificCompatibility path for GPUs below compute capability 9.0
--fp4-quantization (NVFP4)10.0On older GPUs, the worker logs a warning and continues without NVFP4 quantization
SymptomCauseFix
10–20 min wait on first start with --torch-compile enabledModel download + torch.compile warmupExpected behavior; subsequent starts are faster if weights are cached
~35 s second requestRuntime caches still warmingSteady-state performance from third request onward
Lower throughput than expected on Blackwell GPUsNVFP4 and compile are opt-inPass --fp4-quantization and, if needed, --torch-compile; confirm NVFP4 activation in worker logs
FastWan startup fails with a missing to_gate_compress checkpoint parameterFastWan 2.1 checkpoints expect the VSA Wan blockUse --attention-backend VIDEO_SPARSE_ATTN --vsa-sparsity 0.8; do not force TORCH_SDPA for FastWan 2.1
Startup or import failure after enabling FP4, compile, or another attention backendNVFP4 and some attention backends depend on specific hardware and software supportRe-run worker.py without --torch-compile --fp4-quantization; for LTX-2, use --attention-backend TORCH_SDPA

Local Deployment

For single-node development you can run FastVideo directly with Docker Compose or a host-local script instead of Kubernetes.

Prerequisites

For Docker Compose:

  • Docker Engine 26.0+
  • Docker Compose v2
  • NVIDIA Container Toolkit

For host-local script:

  • Python environment with Dynamo + FastVideo dependencies installed
  • CUDA-compatible GPU runtime available on host

Option 1: Docker Compose

The Compose file builds from the same Dockerfile used for the Kubernetes runtime image and exposes the API on http://localhost:8000.

cd <dynamo-root>/examples/diffusers/local
# Start 4 workers on GPUs 0..3
COMPOSE_PROFILES=4 docker compose up --build

Option 2: Host-Local Script

cd <dynamo-root>/examples/diffusers/local
./run_local.sh

Environment variables:

VariableDefaultDescription
PYTHON_BINpython3Python interpreter
MODELFastVideo/FastWan2.1-T2V-1.3B-DiffusersHuggingFace model path
NUM_GPUS1Number of GPUs
DYN_HTTP_PORT8000Frontend HTTP port
WORKER_EXTRA_ARGS—Extra flags for worker.py (for example, --attention-backend VIDEO_SPARSE_ATTN --vsa-sparsity 0.8)
FRONTEND_EXTRA_ARGS—Extra flags for dynamo.frontend

Example:

MODEL=FastVideo/FastWan2.1-T2V-1.3B-Diffusers \
NUM_GPUS=1 \
DYN_HTTP_PORT=8000 \
WORKER_EXTRA_ARGS="--attention-backend VIDEO_SPARSE_ATTN --vsa-sparsity 0.8" \
./run_local.sh

FastVideo worker flags are not dynamo.frontend flags, so pass non-default worker configuration through WORKER_EXTRA_ARGS.

Validated B300 smoke-test worker configurations:

ModelBase worker flagsFP4 worker flags
FastVideo/FastWan2.1-T2V-1.3B-Diffusers--attention-backend VIDEO_SPARSE_ATTN --vsa-sparsity 0.8--attention-backend VIDEO_SPARSE_ATTN --vsa-sparsity 0.8 --fp4-quantization
FastVideo/LTX2-Distilled-Diffusers--attention-backend TORCH_SDPA--attention-backend TORCH_SDPA --fp4-quantization

The FastWan FP4 configuration completed the smoke request, but the worker log did not show the NVFP4 weight-conversion marker. Treat --fp4-quantization as requested, not independently confirmed, for FastWan until the FastVideo logs expose that confirmation.

The script writes logs to:

  • .runtime/logs/worker.log
  • .runtime/logs/frontend.log

Source Code

The example source lives at examples/diffusers/ in the Dynamo repository.

See Also