Robot learning · world models
Inside Cosmo: one small network that imagines the future and acts on it
How a 51M-parameter world-action model is put together and trained: from compressing camera frames, through a single diffusion transformer that generates frames, robot states and actions at once, to the loop that runs it on a real arm.
A robot policy answers one question: what should I do now? A world model answers another: what will I see if I do this? A world-action model (WAM) answers both with one network. That forces it to learn how the scene moves, not only which action usually comes next, and it makes the model inspectable: you can watch what it expects to happen. Here is how Cosmo does it, piece by piece.
1Seeing in latents
Diffusion on raw 256×256 images would be far too expensive for one GPU, so a convolutional VAE first compresses every camera frame into a small latent grid. Everything the WAM sees and generates lives in this space, and the VAE decoder turns generated latents back into images.
One lesson from tuning it: with a standard KL weight the latents collapsed and carried almost no information. Weighting KL a thousand times less kept them informative, and using the mean rather than a random sample removed noise the WAM would otherwise have to model.
2Everything becomes one token sequence
The WAM is a transformer, so frames, actions and robot states all have to become tokens. The trick is to give the network the noisy versions of what it must generate, next to the clean context it can rely on.
Why DINOv2 too? The VAE latents are trained to reconstruct pixels, not to say where the cube is, and on the robot the policy turned out to be very sensitive to the setup. Features from DINOv2, a frozen vision model pretrained on a huge image collection, describe objects and their positions robustly. Added to the frame tokens (with a projection that starts at zero, so fine-tuning starts from the pretrained model), they made the policy work in conditions where it had failed.
Stacking the 8 future frames as channels of one token, instead of giving each frame its own tokens, keeps the sequence at 80 tokens and lets the model generate a whole chunk of the future in one pass. After the last block, small heads map each token group back: frame tokens to latent patches, action tokens to joint commands, state tokens to joint positions.
3Inside a block: conditioning with adaLN-Zero
Information that is not being generated, such as the instruction, the current joint state, the last actions and the noise levels, enters through conditioning rather than as tokens. It is all summed into one vector that steers every block, the design used by the Diffusion Transformer (DiT).
"Adaptive layer norm" means the conditioning decides how each layer's activations are scaled and shifted, for every token at once. It is a cheap and very stable way to inject global information. (I also tried feeding the state and past actions as tokens instead. Losses improved but the policy got worse: the model started copying its own recent motion instead of looking at the scene.)
4One network, three jobs: two noise levels
Diffusion trains a network to remove noise of a given strength. Cosmo uses two independent noise levels: one for the frames and states, one for the actions (the idea comes from Unified World Models). Which job the network does depends only on where in this square you sample.
Because every combination is seen in training, the same weights can be asked a different question at inference time just by choosing the two noise levels. Nothing about the architecture changes between "world model", "policy" and "both".
5One training step
The design choices that made the difference, each found the hard way:
- Velocity (v) instead of noise as the target. Predicting the noise is standard, but it amplifies small errors at high noise levels. When the model fed on its own generated frames, rollouts blew up. Predicting v fixed it immediately.
- A corrupted history. At run time the model conditions on frames it generated itself, which are never perfect. Training on noisy, partly missing history (the trick from GameNGen and DIAMOND) teaches it not to trust the past blindly.
- Chunks of 8 frames at once. Generating one frame per call meant 8 chances to compound errors. Chunks roughly halved the drift over long imagined rollouts.
- Start padding. Windows that begin before the first frame (repeating it, with "no action" as the past) so that a robot standing still at the start of an episode is not out of distribution.
6The control loop on a real arm
On the SO-101 arm, with only a wrist camera, the model runs in joint mode: every plan contains 8 actions and the 8 frames it expects to see, which are shown next to the live camera.
The final model stacks the cube in about half of the attempts. Replanning every 4 actions keeps the arm reacting to fresh frames. Averaging the overlapping parts of consecutive plans (temporal ensembling, from ACT) helped earlier models, whose plans jittered because they read the scene poorly. For the final model it made things worse: once the plans are good, mixing in a plan made from an older frame only adds lag.
7Pretrain broadly, fine-tune narrowly
Two details matter when fine-tuning. Keep the pretrained model's normalization statistics: recomputing them from a few dozen demonstrations rescaled the joint inputs by about 10×, which the pretrained weights would first have had to unlearn. And scale the training steps with the data: with 91 instead of 61 demonstrations at the same step budget, the model was under-trained and grasped worse.
Where this goes next. The weak spot is stability: two plans made a few steps apart still disagree more than they should, and the imagination is not yet reliable enough to plan with. Building on a large pretrained video model, consistent per-step noise levels, and choosing among several imagined futures with a learned value are the natural next steps.