WanVideoModel<T>

Models & Types · AiDotNet.Diffusion.Video

Wan video model for Alibaba’s scalable DiT video generation with full 3D attention.

Inheritance: DiffusionModelBase<T> → LatentDiffusionModelBase<T> → VideoDiffusionModelBase<T> → WanVideoModel<T>

For Beginners

Wan generates high-quality videos with multiple size variants.

How Wan works:

  1. Text prompt is encoded by T5-XXL into 4096-dim embeddings
  2. Video is compressed by WanVAE into 16-channel latent with causal temporal compression
  3. The scalable DiT processes all patches with full 3D attention (no shortcuts)
  4. Full 3D attention captures all spatial-temporal relationships simultaneously
  5. Flow matching denoises the video over scheduled timesteps
  6. WanVAE decodes the latent back to video frames

Key characteristics:

  • Three scale variants: 1.3B (fast), 5B (balanced), 14B (highest quality)
  • Full 3D attention (no factorization) for maximum quality at each scale
  • WanVAE: specialized causal 3D VAE with 3 temporal layers
  • Text-to-video and image-to-video support
  • Open-source weights available
  • 81 frames at 16 FPS by default (~5 seconds)

When to use Wan:

  • Scalable video generation (choose variant for quality/speed trade-off)
  • High-quality text-to-video generation
  • Image animation (image-to-video)
  • Research on scalable video architectures

Limitations:

  • 14B variant requires significant GPU memory
  • 1.3B variant sacrifices quality for speed
  • Full 3D attention is O(n^2) in sequence length
  • Limited video duration compared to cascaded models

How It Works

Wan by Alibaba uses a scalable DiT architecture with full 3D attention (no factorization) and a specialized WanVAE for temporally compressed video generation. The model supports multiple scale variants: 1.3B, 5B, and 14B parameters.

Architecture components:

  • Scalable DiT with full 3D attention (no spatial-temporal factorization)
  • 1.3B variant: 1536 hidden, 30 layers, 12 heads
  • 5B variant: 2560 hidden, 36 layers, 20 heads
  • 14B variant: 3072 hidden, 40 layers, 24 heads (default)
  • WanVAE: specialized causal 3D VAE with 16 latent channels
  • T5-XXL text encoder for 4096-dim context embeddings
  • Flow matching training objective

Technical specifications:

  • Architecture: Scalable DiT with full 3D attention
  • 1.3B: 1536 hidden, 30 layers, 12 heads (~1.3B parameters)
  • 5B: 2560 hidden, 36 layers, 20 heads (~5B parameters)
  • 14B: 3072 hidden, 40 layers, 24 heads (~14B parameters)
  • Patch size: 2 (all variants)
  • Latent channels: 16 (WanVAE)
  • Context dimension: 4096 (T5-XXL)
  • WanVAE: causal 3D VAE, 3 temporal layers, kernel size 3
  • Default: 81 frames at 16 FPS (~5 seconds)
  • Training objective: Flow matching
  • Open-source: Yes

Reference: Alibaba, “Wan: Open and Advanced Large-Scale Video Generative Models”, 2025

Example

var referenceFrame = Tensor<float>.CreateRandom(1, 3, 32, 32);
// Create default 14B variant
var wan = new WanVideoModel<float>();
            
// Create lightweight 1.3B variant
var wanLight = WanVideoModel<float>.Create1_3B();
            
// Create balanced 5B variant
var wanMedium = WanVideoModel<float>.Create5B();
            
// Generate video from text
var video = wan.GenerateFromText(
    prompt: "A traditional Chinese ink painting coming to life with gentle motion",
    width: 1280,
    height: 720,
    numFrames: 81,
    fps: 16,
    numInferenceSteps: 50,
    guidanceScale: 7.5);
            
// Generate video from an image
var animated = wan.GenerateFromImage(
    inputImage: referenceFrame,
    numFrames: 81,
    numInferenceSteps: 50);

Constructors

Constructor Summary
WanVideoModel(NeuralNetworkArchitecture<T> architecture, DiffusionModelOptions<T> options, INoiseScheduler<T> scheduler, DiTNoisePredictor<T> dit, TemporalVAE<T> temporalVAE, IConditioningModule<T> conditioner, string variant, int defaultNumFrames, int defaultFPS, int? seed) Initializes a new instance of WanVideoModel with full customization support.

Properties

Property Summary
IConditioningModule<T> Conditioner { get; }
INoisePredictor<T> NoisePredictor { get; }
IVAEModel<T> TemporalVAE { get; }
IVAEModel<T> VAE { get; }
bool SupportsImageToVideo { get; }
bool SupportsTextToVideo { get; }
bool SupportsVideoToVideo { get; }
int LatentChannels { get; }
string Variant { get; } Gets the model variant identifier (1.3B, 5B, or 14B).

Methods

Method Summary
ModelMetadata<T> GetModelMetadata()
WanVideoModel<T> Create1_3B(IConditioningModule<T> conditioner) Creates a 1.3B lightweight variant for fast generation.
WanVideoModel<T> Create5B(IConditioningModule<T> conditioner) Creates a 5B medium variant balancing quality and speed.