Design a Text-to-Video Generation System
Understanding the Problem
🎬 What is a text-to-video generation system? A text-to-video system turns a prompt ("a golden retriever surfing a wave at sunset, slow motion, handheld camera") into a short video clip, typically 5-20 seconds, often with matching audio. Sora, Veo, Kling, Runway and open models like HunyuanVideo and Wan are examples. Like image generators, they're diffusion models, but they denoise a whole block of frames at once so that objects, lighting and motion stay consistent over time.
This is usually asked as "design Sora" or "design a video generation service." It shares most of its structure with Design a Text-to-Image Generation System, and the interviewer wants to see what changes when you add time. Three things change a lot. Compute grows by two to three orders of magnitude, so a single clip takes GPU-minutes, not GPU-seconds, and becomes a long-running job spread across several GPUs. Consistency across frames becomes the main quality problem: a face that changes between frames or a hand that melts into the cup is what people notice. And safety and provenance get harder, because realistic video of real people is the most dangerous output a generative system can make.
The job-queue side (accepting jobs, progress, webhooks) is covered in the system design write-up Design an AI Video Generation Service. Here we focus on the model and on the parts of serving that the model shapes.
Functional Requirements
Core Requirements
- Users should be able to generate a video from a text prompt, choosing duration (5-20 seconds), aspect ratio and resolution (up to 1080p).
- Users should be able to animate an image (image-to-video) and extend an existing clip.
- Users should see a quick low-resolution draft before committing to a full render, and progress while it runs.
- The system should block policy-violating prompts and outputs, prevent realistic depictions of real people without their consent, and label every video as AI-generated in a way that survives re-upload.
Below the line (out of scope)
- Video editing tools (cutting, compositing), beyond extending a clip.
- Real-time or interactive generation (world models you can steer live).
- Generated audio in depth. We'll note where it fits.
Non-Functional Requirements
Core Requirements
- Turnaround: a 5-second 720p clip in under 2 minutes at p50 for paid users; a draft preview in under 20 seconds. Free users accept longer waits.
- Quality: smooth, physically plausible motion and stable identities across the clip, measured by human preference.
- Cost: GPU cost per second of output video must be known per request and kept low enough to price the product (credits per second of video).
- Reliability: a job that runs for minutes on 8 GPUs must survive a GPU failure without starting over.
- Safety: zero tolerance for the most severe categories; provenance on 100% of outputs.
Below the line (out of scope)
- Long-form video (minutes) as a single generation.
- Exact frame-level control (like a 3D renderer).
Now the arithmetic, because it drives the whole design. A 5-second clip at 24 frames per second is 120 frames of 1280×720.
- A 3D video autoencoder compresses 8× in each spatial dimension and 4× in time, which is typical for current video VAEs. The latent is 160×90 per latent frame, and about 30 latent frames.
- The denoiser cuts each latent frame into 2×2 patches: 80 × 45 = 3,600 tokens per latent frame, so 3,600 × 30 = 108,000 tokens for the clip. A 1024×1024 image is about 4,096 tokens. The video is ~26× longer, and full attention is quadratic, so attention costs roughly 700× more.
- Take a ~10B-parameter diffusion transformer (hidden size 4,096, 48 layers). One forward pass costs about 2 × 10B × 108K ≈ 2.2 PFLOPs for the linear layers and about 4 × N² × d × L = 4 × (1.08 × 10⁵)² × 4,096 × 48 ≈ 9.2 PFLOPs for attention. Call it 11 PFLOPs per pass.
- 50 sampling steps with classifier-free guidance (two passes per step) is 100 passes ≈ 1.1 × 10¹⁸ FLOPs per clip. At an effective 400 TFLOP/s on an H100, that's about 2,800 GPU-seconds, ~47 GPU-minutes for 5 seconds of video, or ~9 GPU-minutes per second of video.
- At an illustrative $2.50 per GPU-hour, that's about $2 per clip, $0.40 per second of video.
At 200,000 clips a day, the undistilled model would need 200K × 47 GPU-minutes ≈ 157,000 GPU-hours a day, about 6,500 GPUs around the clock. That's not a viable product, which tells us the design must include step and guidance distillation, low-resolution generation with upscaling, and a draft-first flow. We'll come back to each.
Doing this arithmetic out loud is the best way to show you understand video generation. The punchline: video is a sequence-length problem. Doubling the duration roughly quadruples the attention cost, which is why long videos are built by extension, not in one pass.