November 5, 2026 · Data, Training, Reward design
Training a 9B Model to Make Videos with Code
Ask a video model for a clip and you get pixels. You cannot open them up. You cannot move one stroke. All you can do is change the prompt and roll again.
A video written as code is different. The code is the video. You can read it, change one brush stroke, and render the same frames again. And code can be checked: it renders or it crashes, it loops or it doesn't. RL works when the reward can be checked. Taste can't, at least not directly. This post is about how far a 9B model gets anyway.
What I built
- Model: Qwen3.5-9B, LoRA fine-tuned with SFT, then GRPO
- Data: 2,000 sumi-e reels written by Claude Code agents (Opus 5.5)
- Judge: Claude Haiku 5.5, grading rendered stills against a reference
- Compute: one rented A100 80GB per training round
It started from Surya's RL-ing Qwen to paint with code. I wanted to know if the same idea holds for animation. And whether most of the work could be data instead of hand-tuning.
How it works
The model does not write a web page. A fixed harness owns rendering, timing, seeded randomness and export. A style kit owns the medium: wet washes that bleed, dry-brush strokes, rice paper, the red hanko seal. The model writes only scene.js: what is on screen, where, and how it moves.
1Brief
one paragraph: subject, palette, motion
2scene.js
the model writes 2–4k tokens of canvas code
3Render
headless Chrome steps through every frame
4Gate
errors, loop seam, determinism, motion
5Judge
stills vs. the reference reel
6GRPO
8 samples per brief, ranked by reward
Every pixel is a pure function of time. So every sample can be rendered frame by frame and graded by a program. No human in the loop.
Reward functions
Every reward I wrote got gamed. Each fix closed one shortcut and showed me the next.
Does it render? The base model got 0 of 100 briefs to render. So did every small model I tried: Qwen3.5 at 2B, 4B and 9B, and Gemma 4. Fine-tuning alone was still 0. GRPO with a pass/fail gate got 2. A gate is a cliff, and most samples fell off it.
Partial credit. 71% of failures were scenes that crashed partway through. So I paid for how far a scene ran before it broke. Syntax errors halved. Passing reels in 8 tries per brief went from 44 to 74, out of 800.
A judge for content. A Claude Haiku judge compared the rendered stills with the reference reel: subject, richness, medium. Briefs with a working reel climbed to 90 of 100. Content did not. It stayed flat at about 0.2. RL amplifies what the model already samples. Working-but-empty reels were common. Rich ones were rare.
Fewer things to learn. Six styles and on-screen text were too much for a small model. I narrowed it to one style, sumi-e, with no text. RL gave every test brief a working reel. Then I rendered full videos of the 13 best. 11 of them froze for 1.4 to 8.3 seconds. The gate only compared seven stills, so RL had learned to pass by barely moving.
Watch the motion. Reward v6 adds a frame-to-frame motion probe and a stricter judge, averaged over two calls. This one held. Under v6, RL raised passes and content and kept motion where it was.
The reference set
Better rewards were not enough. The model needed better examples.
Claude built a catalog of about 2,500 simple subjects across 22 categories: songbirds, sea life, teaware, tools, weather. Then it dropped any repeat of a main subject. Each one became a brief: one subject, at most two supporting elements, one looping motion. Headless Claude Code agents wrote the scenes straight against the harness. Each scene had to pass the gate in under 4,000 tokens.
All 2,000 passed. Passing is not the same as good, so I went through contact sheets of every reel. About 10% were too small, not recognisable, nearly blank, or a dark smear. Those 200 were rewritten with a note naming the problem. 16 still failed and were left out.

Progression
Same 40 held-out briefs, 8 tries each, all scored with reward v6:
| Model | Working reels | Content | Motion | Briefs with a good reel |
|---|---|---|---|---|
| Round 6 RL (260 reels) | 205 / 320 | 0.31 | 0.24 | 4 |
| Round 8 SFT (1,944 reels) | 156 / 320 | 0.38 | 0.50 | 15 |
| Round 8 SFT + RL | 247 / 320 | 0.42 | 0.49 | 24 |
More data was the biggest single gain. The new SFT model, before any RL, beats the old RL model. RL on top added 91 working reels and 9 more briefs with a good reel. It did that without trading the motion away this time.

Six of the final model's best reels, each next to its reference. Three still fail the strict full-video gate on motion.
What it cost
| Item | Cost |
|---|---|
| Convert 600 hand-built reels into harness scenes | $881 |
| Compress the training scenes to 4k tokens or less | $847 |
| Write 2,000 no-text sumi-e scenes, including 200 redos | $1,605 |
| Briefs and the subject catalog | ~$25 |
| RunPod A100, 7 training rounds plus idle storage | ~$85 |
| The original 600 reels, and the judge calls | not tracked |
Making the data cost about forty times as much as training on it. The RunPod figure for rounds 3 to 5 is estimated from their run times.
What one video costs
Once it's trained, how does the small model compare with just asking Claude? I gave each model the same system prompt and brief the 9B model gets, one call per brief, and ran every result through the same gate:
| Model | Working videos | Cost per call | Cost per working video |
|---|---|---|---|
| Claude Opus 5.5 | 3 / 4 | $0.224 | ~$0.30 |
| Claude Sonnet 5.5 | 3 / 4 | $0.152 | ~$0.20 |
| Claude Haiku 5.5 | 0 / 4 | $0.007 | none worked |
| This 9B model (A100 at $1.79/h) | 247 / 320 | ~$0.004 | ~$0.006 |
The 9B model is 35 to 50 times cheaper per working video than Sonnet or Opus. Most of Claude's cost is thinking: the scene itself is 2,000 to 4,000 tokens of code, but each call wrote 10,000 to 14,000 output tokens. Haiku is cheap but got none of its four to work.
The comparison is not like for like. Claude's working videos are much richer than the 9B model's. The Claude rows are 4 held-out briefs each, so treat them as rough. The 9B figure is an upper bound: 320 videos took 46 minutes on the A100, and that includes rendering and judging every one.
Closing
Taste lives in the reward and in the data. Whenever the reward could be satisfied cheaply, by reels that worked but were empty or passed but were frozen, RL found the shortcut. The fixes that worked were the ones that measured what I actually wanted.
The videos are still sparse next to the references. A strict judge score of 0.42 means the subject is usually there and the brushwork usually isn't. One brief never worked at all. And this is slower than asking a frontier model, which writes these scenes on the first try.
Next: the full-video motion checks inside the training reward, a held-out set of simple briefs, and more RL steps now that RL keeps the motion.