High-precision FP16 text encoders for the WAN (Worldly Advanced Network) 2.2 text-to-video generation system. This repository contains the essential text encoding components required for WAN2.2 video generation workflows.
Model Description
This repository provides two specialized text encoder models optimized for video generation tasks:
T5-XXL FP16: Google's T5 (Text-to-Text Transfer Transformer) extra-extra-large encoder in 16-bit floating point precision
UMT5-XXL FP16: Universal Multilingual T5 extra-extra-large encoder in 16-bit floating point precision
These encoders are critical components of the WAN2.2 pipeline, responsible for transforming text prompts into high-dimensional semantic representations that guide the video generation process. The FP16 precision maintains excellent quality while reducing memory requirements compared to FP32 variants.
Key Features
High Precision: FP16 format preserves text encoding quality with 50% memory reduction vs FP32
Multilingual Support: UMT5-XXL provides robust multilingual text understanding
Production Ready: Optimized for inference with safetensors format
WAN2.2 Compatible: Designed specifically for WAN video generation workflows
Disk Space: 25 GB free space (including working directory)
GPU: CUDA-compatible GPU with compute capability 6.0+
Recommended Requirements
VRAM: 16 GB+ GPU memory (for full WAN2.2 pipeline)
RAM: 32 GB system memory
Disk Space: 50 GB+ free space
GPU: NVIDIA RTX 3090, RTX 4090, or A100
Performance Notes
Both encoders can be loaded simultaneously with 24 GB+ VRAM
Text encoding typically takes 1-5 seconds per prompt
CPU offloading available but significantly slower (10-30x)
Usage Examples
Basic Text Encoding with Diffusers
python
1from diffusers import DiffusionPipeline
2import torch
34# Load WAN2.2 pipeline with custom text encoders5pipe = DiffusionPipeline.from_pretrained(6"your-wan22-model",7 text_encoder_path="E:/huggingface/wan22-fp16-encoders/text_encoders/t5-xxl-fp16.safetensors",8 torch_dtype=torch.float16,9 variant="fp16"10).to("cuda")1112# Generate video from text13prompt ="A serene mountain landscape at sunset with flowing clouds"14video = pipe(prompt, num_frames=24, height=512, width=512).frames
1516# Save output17video[0].save("output_video.mp4")
Using UMT5 for Multilingual Prompts
python
1from diffusers import DiffusionPipeline
2import torch
34# Load with multilingual encoder5pipe = DiffusionPipeline.from_pretrained(6"your-wan22-model",7 text_encoder_path="E:/huggingface/wan22-fp16-encoders/text_encoders/umt5-xxl-fp16.safetensors",8 torch_dtype=torch.float16,9).to("cuda")1011# Generate with multilingual prompt12prompt ="東京の夜景、ネオンライトと雨"# Japanese: Tokyo nightscape with neon lights and rain13video = pipe(prompt, num_frames=48, height=768, width=768).frames
Memory-Optimized Loading
python
1from diffusers import DiffusionPipeline
2import torch
34# Enable CPU offloading for lower VRAM systems5pipe = DiffusionPipeline.from_pretrained(6"your-wan22-model",7 text_encoder_path="E:/huggingface/wan22-fp16-encoders/text_encoders/t5-xxl-fp16.safetensors",8 torch_dtype=torch.float16,9).to("cuda")1011# Enable model CPU offload12pipe.enable_model_cpu_offload()1314# Enable attention slicing for further memory reduction15pipe.enable_attention_slicing(1)1617# Generate with reduced memory footprint18video = pipe(prompt, num_frames=16).frames
Direct Encoder Loading
python
1from safetensors.torch import load_file
2import torch
34# Load encoder weights directly5encoder_weights = load_file(6"E:/huggingface/wan22-fp16-encoders/text_encoders/t5-xxl-fp16.safetensors"7)89# Initialize your custom text encoder model10from transformers import T5EncoderModel
1112text_encoder = T5EncoderModel.from_pretrained("google/t5-v1_1-xxl", torch_dtype=torch.float16)13text_encoder.load_state_dict(encoder_weights)14text_encoder = text_encoder.to("cuda")1516# Use encoder for custom workflows17# ... your custom inference code ...
Model Specifications
T5-XXL FP16
Architecture: T5 (Text-to-Text Transfer Transformer)
Model Size: Extra-Extra-Large (XXL)
Parameters: ~11 billion
Precision: FP16 (16-bit floating point)
Format: SafeTensors
Context Length: 512 tokens
Embedding Dimension: 4096
Language Support: English-focused, trained on C4 dataset
UMT5-XXL FP16
Architecture: Universal Multilingual T5
Model Size: Extra-Extra-Large (XXL)
Parameters: ~13 billion
Precision: FP16 (16-bit floating point)
Format: SafeTensors
Context Length: 512 tokens
Embedding Dimension: 4096
Language Support: 100+ languages (multilingual mC4 dataset)
Performance Tips and Optimization
Memory Optimization
Sequential Encoder Loading: Load encoders one at a time if VRAM is limited
CPU Offloading: Use enable_model_cpu_offload() for systems with <16 GB VRAM
Attention Slicing: Enable with enable_attention_slicing() to reduce peak memory
Batch Size: Process multiple prompts together for better GPU utilization
Speed Optimization
TensorRT Compilation: Convert encoders to TensorRT for 2-3x speedup
Flash Attention: Use xformers or flash-attention for faster inference
Model Quantization: Consider INT8 quantization for production deployment
Prompt Caching: Cache encoded prompts for repeated generations
Quality Optimization
Use UMT5 for Non-English: Better results with non-English prompts
Longer Prompts: These XXL models handle detailed descriptions well
Prompt Engineering: Structured, descriptive prompts yield best results
Negative Prompts: Combine with negative prompt encoding for better control
Best Practices
python
1# Optimal configuration for quality and speed2pipe = DiffusionPipeline.from_pretrained(3"wan22-model",4 text_encoder_path="E:/huggingface/wan22-fp16-encoders/text_encoders/t5-xxl-fp16.safetensors",5 torch_dtype=torch.float16,6 variant="fp16",7)89# Enable optimizations10pipe.enable_xformers_memory_efficient_attention()# Flash attention11pipe.enable_attention_slicing(1)# Memory efficiency12pipe.to("cuda")1314# Use compiled model for production (PyTorch 2.0+)15pipe.unet = torch.compile(pipe.unet, mode="reduce-overhead", fullgraph=True)
License
These text encoder models are provided under specific licensing terms. Please refer to the original model sources for detailed license information:
T5-XXL: Apache 2.0 License (Google Research)
UMT5-XXL: Apache 2.0 License (Google Research)
WAN2.2 Pipeline: Please check WAN project license terms
Usage Restrictions: These models are intended for research and development purposes. Commercial usage should comply with respective license terms and any additional WAN project requirements.
Citation
If you use these text encoders in your research or projects, please cite the relevant papers:
T5 Citation
bibtex
1@article{raffel2020exploring,
2 title={Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer},
3 author={Raffel, Colin and Shazeer, Noam and Roberts, Adam and Lee, Katherine and Narang, Sharan and Matena, Michael and Zhou, Yanqi and Li, Wei and Liu, Peter J},
4 journal={Journal of Machine Learning Research},
5 volume={21},
6 number={140},
7 pages={1--67},
8 year={2020}
9}
mT5/UMT5 Citation
bibtex
1@inproceedings{xue2021mt5,
2 title={mT5: A Massively Multilingual Pre-trained Text-to-Text Transformer},
3 author={Xue, Linting and Constant, Noah and Roberts, Adam and Kale, Mihir and Al-Rfou, Rami and Siddhant, Aditya and Barua, Aditya and Raffel, Colin},
4 booktitle={Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies},
5 pages={483--498},
6 year={2021}
7}
WAN Project Citation
Please check the official WAN project repository for citation guidelines and additional references.