Sana

Framework

NVlabs/Sana

Efficient high-resolution image and video synthesis with linear diffusion transformer.

Overview

SANA is an efficiency-oriented codebase for high-resolution image and video generation. It provides complete training and inference pipelines with linear diffusion transformers. Supports text-to-image, text-to-video, and world modeling tasks.

README Preview

\n  \n\n\n\n📚 Docs | SANA | SANA-1.5 | SANA-Sprint | SANA-Video | SANA-WM | Sol-RL\n  \nDemo | 🤗 HuggingFace | ComfyUI | SGLang | Cosmos-RL\n\n\n\n\n    \n    \n    \n    \n    \n\n\n\n    \n    \n\n\nICLR 2025 Oral | ICML 2025 | ICCV 2025 Highlight | ICLR 2026 Oral \n\n**SANA** is an efficiency-oriented codebase for high-resolution image and video generation, providing complete training and inference pipelines. This repository contains code for [SANA](https://nvlabs.github.io/Sana/), [SANA-1.5](https://nvlabs.github.io/Sana/Sana-1.5/), [SANA-Sprint](https://nvlabs.github.io/Sana/Sprint/), [SANA-Video](https://nvlabs.github.io/Sana/Video/), [SANA-WM](https://nvlabs.github.io/Sana/WM/), and [Sol-RL](https://nvlabs.github.io/Sana/Sol-RL/). More details can be found in our [📚 documentation](https://nvlabs.github.io/Sana/docs/).\n\nJoin our [Discord](https://discord.gg/rde6eaE5Ta) to engage in discussions with the community! If you have any questions, run into issues, or are interested in contributing, don't hesitate to reach out!\n\n\n  \n\n\n## News\n\n- 🔥 [2026/05] 🌍 **SANA-WM: 2.6B Controllable World Model** is released! Supports 720p, 1-min video generation with 6-DoF camera control. A new baseline for World Modeling and Embodied AI. See [Project](https://nvlabs.github.io/Sana/WM/) | [Paper](https://huggingface.co/papers/2605.15178).\n- 🔥 [2026/04] ⚡ **Sol-RL: NVFP4 Rollout, BF16 Training RL** is available! All training recipes for **SANA**, **FLUX.1**, and **SD3.5-L**, together with bundled post-training datasets, are released. See [Sol-RL doc](https://nvlabs.github.io/Sana/docs/sol_rl/) | [Page](https://nvlabs.github.io/Sana/Sol-RL/) | [Paper](https://arxiv.org/abs/2604.06916).\n- 🔥 [2026/03] 📺 **SANA-Video 720p model with LTX-VAE** is released. Use it with LTX2 Refiner to upscale the videos to 2K resolution! See [Model Zoo](https://nvlabs.github.io/Sana/docs/model_zoo/#sana-video), [SANA-Video doc](https://nvlabs.github

FAQ (4)

Troubleshooting
How to convert a custom-trained base diffusion model to diffusers format for Dreambooth + LoRA fine-tuning?

Use the provided script: python tools/convert_sana_to_diffusers.py. This script converts non-diffusers weights into the expected diffusers state dict format, making the model compatible with Dreambooth and LoRA training scripts.

GitHub Issue #278
Troubleshooting
Why does Sol-H3 Stage 2 produce bad lip sync, with lips moving when nobody is speaking, and how do I fix it?

In Sol-H3-Spark / Sol-H3-RTX5090, Stage 2 encodes the H3 audio, re-noises it to the first Stage-2 sigma (0.909375), and denoises it jointly with the video, then discards that audio and muxes the original H3 PCM. The lips are refined against the regenerated track — which is English-sounding babble that can even contain speech in silent pauses — so lip sync drifts (SyncNet LSE-C drops from ~8.2 to ~4.4) and mouths can move during room tone. Fix (merged in PR #543): keep the audio clean and frozen during the Stage-2 refine, exactly as LTX-2's a2vid_two_stage.py does — pass it as ModalitySpec(frozen=True, noise_scale=0.0, initial_latent=encoded_audio_latent) instead of noising it. This restores lip sync (LSE-C ~4.4 → 7.8) with identical render time and unchanged output audio. Update past commit 62da34b to get the fix.

GitHub Issue #535
Troubleshooting
How to fix LongSana crashing on Ascend NPU with 'Torch not compiled with CUDA enabled' or NCCL error?

LongSana hardcodes CUDA/NCCL for distributed init and FSDP device, so it fails on non-CUDA accelerators (e.g. Ascend NPU 910B with torch_npu). Fixed by PR #514. Apply these changes: (1) In diffusion/longsana/utils/distributed.py, add device/backend resolution helpers: get_device_type(), get_current_device(), get_default_dtype(), set_device(), and get_distributed_backend() which return npu/hccl on Ascend, cuda/nccl on CUDA, and cpu/gloo on CPU-only. (2) Replace the hardcoded calls: change launch_distributed_job(backend="nccl") (line 83) to use get_distributed_backend(); replace torch.cuda.set_device(local_rank) (line 97) with set_device(local_rank); replace device_id=torch.cuda.current_device() in the FSDP wrap (line 69) with get_current_device(). (3) In diffusion/longsana/trainer/ode.py:41 and trainer/self_forcing_trainer.py:47, replace self.device = torch.cuda.current_device() with the resolver. (4) In the pipeline files (sana_training_pipeline.py, sana_inference_pipeline.py, sana_inference_interactive_pipeline.py, sana_inference_interactive_pipeline_long_chunk.py), replace torch.device("cuda" if torch.cuda.is_available() else "cpu") and the fp32 fallback dtype with get_device_type()/get_default_dtype() so NPU is detected instead of silently falling back to CPU/fp32. After patching, torchrun --nproc_per_node=N longsana_trainer.py initializes HCCL correctly and FSDP wraps parameters on npu:<rank>. CUDA behavior is unchanged.

GitHub Issue #513
Troubleshooting
Why is LongSanaVideoPipeline missing from diffusers and how can I run LongSana?

The LongSanaVideoPipeline is not yet implemented in the diffusers library (even in the latest dev version). The Hugging Face model page states it's 'coming soon'. As a workaround, clone the official Sana repository: git clone https://github.com/nvlabs/Sana.git and follow its inference guide. You can also try the already available SANA-Video pipeline if you need video generation.

GitHub Issue #354