Text to video in a browser tab, on your own GPU
You can now type a sentence into freegen.ai/video and get a short video back, made on your own graphics card, inside the browser tab. Nothing goes to a server. On an RTX 5090 a two-second clip takes about 11 seconds, and five seconds at 832 by 480 takes about a minute and a half.
We are not the only people who have tried this. Karume, a custom WebGPU runtime, has run Wan 2.2 in Chrome and published the conversion. As far as we can find, though, this is the first time it is a web page anyone can open and use, rather than a library you have to set up. Here is how it works and what broke along the way.
Why this model
Most open video models generate a whole clip at once: every frame, denoised together, over 30 to 50 steps. That is a lot of work to hold in a browser at the same time, and a lot of steps to wait through.
Self-Forcing, by Xun Huang and colleagues, retrains Wan 2.1's 1.3 billion parameter text-to-video model to work differently. It draws a clip a few frames at a time, left to right. Each chunk of three latent frames (twelve video frames) takes four denoising steps, and then one more pass whose keys and values are saved. Every later chunk attends to everything saved so far, the same way a language model attends to the text it has already written. Fewer steps, smaller pieces, and the work arrives in order. That shape fits a browser well.
For turning the result into pixels we use TAEHV, Ollin Boer Bohan's tiny decoder for Wan's latents. It is about 20 MB, against the full decoder's much larger appetite for memory. All three pieces are open: Wan and Self-Forcing under Apache 2.0, TAEHV under MIT.
The cache is the whole problem
The saved keys and values are the interesting part. For a five-second clip at 480p they come to about 5 GB, spread across 60 tensors, two for each of the model's 30 layers. Copying that to the CPU and back between calls would take longer than running the model. It has to stay on the GPU.
ONNX Runtime Web can hand outputs back as GPU buffers instead of arrays, and accept GPU buffers as inputs, so the plan was simple: keep the buffers in the worker and feed them back on the next call. The first version did exactly that, and the graph returned the old cache with the new chunk joined on the end. It worked. It also got slower with every chunk, and by the end of a five-second clip it was using 28.7 GB of the card's 32 and spilling the rest into system memory.
The cause was that every chunk produced a slightly bigger cache, which meant 60 new, slightly bigger buffers, while the runtime held on to the old sizes in case it needed them again. The fix was to stop the graph returning the cache at all. It now returns only the new chunk's keys and values. The worker sets aside buffers big enough for the whole clip before the first chunk, copies each new piece in after the last, and passes the same buffers back each time with dimensions that cover only the filled part.
That ran into one more surprise. Buffers we created ourselves were destroyed after the first run: ONNX Runtime releases an input buffer when it is done with it, and for a buffer the page made, releasing it destroys it. Buffers the runtime allocated as its own outputs are never released that way. So the cache now comes from a tiny graph whose only job is to output a block of zeros of the size we ask for. It is 138 bytes.
Attention, two ways
Late in a clip, each new chunk attends to tens of thousands of earlier positions. Written out as ordinary matrix multiplications, that means building the full score matrix, and for the last chunk of a 480p clip one denoising pass took 6 seconds and 15 GB. ONNX Runtime's fused attention kernel never builds that matrix. The same pass took 3.75 seconds and 4 GB.
The fused kernel is slower when there is little to attend to, though, about a fifth of a second per pass on short clips. So we ship both versions of the graph. They read the same weights file, differ by about 3 MB, and the page picks one per clip.
Update: since publishing we moved the site to a newer ONNX Runtime, whose fused kernel is faster again. The same late pass now takes 2.76 seconds instead of 3.75, the fused graph ties the other at 240p and wins everywhere else, and a five-second 480p clip takes about 73 seconds instead of 90, in about the same memory. The page now uses the fused graph for everything.
Decoding
TAEHV decoding a whole 480p clip at once runs into the browser's 2 GB limit on a single buffer. We decode three latent frames at a time, with the three before them included for context and then thrown away, because the decoder looks back in time and needs that history to stay smooth. With three frames of context the result matches decoding the whole clip at 51 dB. With one frame it was 28, which you can see.
Even windowed, a 480p window held 24 full-size frames of intermediate values and added about 10 GB at the end of a run. Above 256 by 448 each window is now also split into overlapping tiles, blended at the edges. On real footage the tiles match whole frames at 53 dB, and the decoding overhead dropped to about 1.3 GB.
Two bugs that made good-looking garbage
The first clips were sharp, smooth and completely unrelated to the prompt. The current version of the transformers library loads Wan's text encoder, umT5, without its word embeddings: the checkpoint stores them once under a different name, and the link between the two was not restored. Every prompt went through a random table. The model then did what video models do with a meaningless prompt, which is make something pleasant.
The text encoder also has a safety check for overflow in 16-bit floats that uses an operation the WebGPU backend does not implement, so the session refused to load at all. That one at least failed loudly. We rewrote the check as a plain comparison against the largest 16-bit value.
Where it stands
| RTX 5090, model loaded | Time | Peak GPU memory |
|---|---|---|
| 2 s at 416 x 240 | about 11 s | 7.5 GB |
| 5 s at 832 x 480, first working version | about 150 s | 28.7 GB |
| 5 s at 832 x 480, now | about 90 s | 13.2 GB |
The page starts everyone on two seconds at 416 by 240, which needs about 7.5 GB and runs on far more cards than a 5090. 480p is offered when the device check suggests the card can take it.
One more thing we learned the hard way: we crashed our own test machine running 480p benchmarks back to back near the 32 GB limit. The benchmark harness now kills the test browser the moment its GPU memory passes a ceiling. If you are pushing WebGPU this hard, build that in before you need it.
The biggest remaining cost is attention. The fused kernel runs at about 9 trillion operations a second, where plain matrix multiplication on the same card reaches about 30, so an attention kernel of our own is the next thing to try. That is also what longer and larger clips need.
Update: we wrote it. It is a flash-attention kernel in WGSL that runs the largest call at about 26 trillion operations a second, against about 10 for the runtime's fused kernel. ONNX Runtime cannot run a custom kernel inside a graph, so the model is now cut into 31 pieces at its attention layers, with our kernel running between them over the cache. A five-second 480p clip now takes about 55 seconds, down from 90 when this post went up, and peaks at 12.4 GB.
Try it at freegen.ai/video. The first visit downloads 4.6 GB, which your browser keeps. The converted models are on Hugging Face as cgb/wan21-self-forcing-onnx-webgpu if you want to build on them.