Learning Structured World Models

Nobody can write the equations of a pile of beans. So the robot learns one rule for how a particle pushes its neighbours, and runs that rule on every particle. A model trained on 40 particles then predicts a pile of 200.

Pick a model and drag the pile size past 40. Count the particles each model places right. Then we build it piece by piece: particles, the graph, message passing, why it scales, and how a robot plans with it.

You need vectors, a little Python and the idea of a learned dynamics model (Lecture 15). We build the rest from zero.

Lecture 16 of 25 in Introduction to Robot Learning, CMU 16-831 (Spring 2024), taught by Guanya Shi, with guest lecturer Yunzhu Li. Slides on the course lectures page. Every idea is re-taught here in our own words and devices.

Push a pile bigger than the training pile

120

Illustrative toy in an 80 cm by 50 cm box. Both models trained on piles of 40. The fixed-size model has 40 input slots, so it leaves particles past slot 40 where they started. The graph model runs one local rule with a small 4 mm error to stand for a learned fit. A particle counts as right within 2 cm.

Chapter 0

How Do You Model a Blob of Dough?

Find where hand-written physics stops, and poke a blob that moves by local pushes alone

A person rolls dough into a snake, cuts it and presses it into a disc without a thought. A robot cannot. The lecture asks why.

A mug is easy. It is one rigid body: three numbers for its position, three for its angle. Newton's laws move it, as in Lectures 12 to 14.

Dough has no single position. It squishes, folds and sticks. A pile of coffee beans flows like a liquid, then jams like a solid. Nobody can write these equations down.

To plan a press, the robot needs a world model: a function that takes the scene and an action and predicts the next scene. For dough we must learn it. The lecture's bet: treat the dough as many small particles, and learn one rule for how a particle pushes the particles that touch it.

Poke the blob

Each particle feels only the neighbours it touches. Press Poke and watch the ripple spread one contact at a time. Raise the stiffness to make it springy.

120

Illustrative toy. A damped spring joins each particle to the particles within 1.1 spacings. No line of code says "dough". The shape change comes from the springs alone.

Work the count. The blob is about 13 particles across. A push crosses one contact per step of the rule, so it needs about 12 steps to reach the far side. Local rules are slow to carry news. Chapter 6 fixes that.

The thesis. The right structure is an inductive bias: an assumption built into the model. "The world is made of parts that push their neighbours" makes the learned model work on new scenes and learn from little data.

The failure, as symptom, measurement and fix

The symptom is a planner that works on the mug and fails on the dough. To measure it, compare predicted and real shapes after one press. The fix is a model whose structure matches the material: particles and their contacts.

The road

  1. Three world models: hand-written physics, one latent vector, a particle graph.
  2. Particles: the scene as a table of N rows.
  3. The graph: an edge for every pair closer than a radius.
  4. Message passing: message, sum, update.
  5. Why it scales: one shared rule, any number of particles.
  6. Materials: rigid, deformable and fluid on one engine.
  7. Planning: MPC through the learned model, as in RoboCook.
  8. Resolution: how many particles the task needs.
  9. The sandbox: watch message passing step by step (the hero's engine).
  10. The field guide: terms, numbers, code, links and credit.
Why can a robot not use a hand-written rigid-body model to shape dough?

Chapter 1

Three Kinds of World Model

Compare hand-written physics, one latent vector and a particle graph, then nudge one bean and see what each one notices

A planning robot runs three boxes in a loop. Perception turns camera images into a state. Dynamics predicts the next state from the state and an action. Control picks the action.

This lesson lives in the dynamics box. Perception and control can borrow from vision and from MPC. For dough, dynamics has no off-the-shelf answer.

The lecture lists three ways to fill the dynamics box.

ModelLearns from images?Unknown systems?Structured?Generalizes
Hand-written physicsNo, needs the full stateNoYesWell, where it applies
One latent vectorYesYesNoPoorly
Particles and a graphYesYesYesWell, and from little data

A latent vector model encodes the whole image into one list of numbers, rolls that list forward and decodes it. Lecture 15 builds these. The list has no slots for objects. A structured model keeps one row per part of the scene.

Nudge one bean

Choose a state. Press Nudge to move one bean 1 cm. Changed numbers light up. Then add beans and watch the size of each state.

12

Illustrative. The vector is a fixed random encoder: 16 numbers, each a mix of every bean's position. A real encoder learns its weights, but it shares this property: every number depends on the whole scene.

The vector mixes every bean into every number. Move one bean and all 16 change. Add beans and it stays 16 long, so "more beans" has no place to go. The table changes one row and grows one row per bean. Physics is local in the same way.

The failure, as symptom, measurement and fix

The symptom is a latent model that predicts 5 objects well and 50 badly. To measure it, train on small scenes and test on larger ones. The fix is a state with one entry per part, and a model that treats every entry the same.

A latent model encodes a scene into 256 numbers. Why does it struggle when trained on 5 objects and tested on 50?

Chapter 2

Particles: the Scene as a Table

Turn dough and a tool into N rows of numbers, and count what the model reads

Why particles and not a mesh? Particles are the finest and most general unit. A splash, a collapsing pile and folding dough are all clouds of moving points. One representation covers all three.

Each particle i carries a short list of numbers, its feature vector. Call the particle's position p-i, its velocity v-i, and its material flags c-i. Call the whole list z-i.

Say it aloud

z-i equals the list p-i, v-i, c-i.

zi
z-i the feature vector of particle i: one row of the state table.
pi
p-i the position of particle i: x, y, z in metres. 3 numbers.
vi
v-i the velocity of particle i, in m/s. 3 numbers.
ci
c-i the material flags: "dough" or "tool", one flag each. 2 numbers.
In plain words

Write the position p-i, then the velocity v-i, then the flags c-i, side by side. That row is z-i. Stack one row per particle and you have the state.

With numbers

With made-up numbers: p-i = (0.42, 0.10, 0.03), v-i = (0, 0, −0.05), c-i = (1, 0) for dough. z-i has 3 + 3 + 2 = 8 numbers. With N = 500 particles the state is a 500 by 8 table: 4,000 numbers.

Sample the scene into a table

Warm dots are dough, teal dots are the press. Slide the spacing to sample finer or coarser. The table below the scene shows the first rows.

4.0 cm

Illustrative 2D slice of a 60 cm scene, so z is 0 in every row. The tool flag marks the press. The robot drives the press particles; the model moves the dough particles.

The tool is more particles, flagged as tool. That is how an action enters the model. The robot moves the tool particles. They push the dough particles through the same rule. The dough deforms.

Where do the particles come from? Perception samples them from a 3D reconstruction, such as a depth-camera point cloud. That step is not free, and Chapter 10 points to tools that make it sturdier. Here we assume perception hands us the table.

The failure, as symptom, measurement and fix

The symptom is a model that confuses the tool with the dough. To measure it, check that every row has the right flag. The fix is to put the material in the row, so the rule can treat each kind differently.

In the particle representation, what is the state of the scene?

Chapter 3

The Graph: Who Pushes Whom

Join every pair of particles closer than a radius, and find the radius that matches the material

A grain of rice nudges the grains it touches. It does not push a grain across the bowl. Force travels through contact. So we join each particle only to its near neighbours.

The result is a graph. Its nodes V are the particles. Its edges E are pairs close enough to touch. Call the interaction radius r. Write (j, i) for an edge that carries a push from particle j to particle i.

Say it aloud

E is the set of pairs j, i such that the distance between p-i and p-j is at most r.

E
E the edge set: every pair the model lets interact.
(j, i)
j, i one directed edge, from sender j to receiver i. Each touching pair gives two edges, one each way.
‖pi − pj‖
the distance between p-i and p-j the straight-line gap between the two particles, in metres.
≤
is at most less than or equal to.
r
r the interaction radius: a design choice, here 0.06 m.
In plain words

For every pair of particles, measure the gap between p-i and p-j. If the gap is at most r, add the edge j to i. Otherwise, leave them unjoined.

With numbers

With made-up numbers: p-i = (0.40, 0.10) and p-j = (0.43, 0.14). The gap is the square root of 0.03 squared plus 0.04 squared, which is 0.05 m. With r = 0.06 m, that is an edge. A third particle at (0.48, 0.10) is 0.08 m away: no edge.

Drag the radius

The ring shows the radius around one particle. Slide r. Too small, and particles sit alone in red. Too large, and every particle joins everything.

0.14

Illustrative. 50 particles in a unit square. Edges count both directions.

For a fluid, neighbours change every frame. So the model rebuilds the edges from the current positions at every step. The lecture calls this dynamic graph building. For a rigid object, neighbours never change, so the edges stay fixed.

The failure, as symptom, measurement and fix

The symptom is dough that tears in the model but not in the world. To measure it, count particles with no edges. The fix is a larger r, but stop before the average neighbour count climbs into the dozens, because cost grows with the edge count.

Why join each particle only to particles within a small radius?

Chapter 4

Message Passing: One Step of Dynamics

Send a message along every edge, sum them at each particle, update each particle, and follow the tensor shapes

A graph neural network (GNN) predicts every particle's next state in three moves. It learns two small networks. The edge function f-edge turns a pair of particles into a message: how hard, and which way, the sender pushes the receiver. The node function f-node turns a particle and its total push into its next state. Each is an MLP, a small stack of fully connected layers.

Call the neighbours of particle i N(i): every j with an edge (j, i). Call the sum of their messages h-i.

Say it aloud

h-i equals the sum over j in N of i of f-edge of z-j and z-i.

hi
h-i the felt push on particle i: one vector, here 64 numbers.
Σj ∈ N(i)
the sum over j in N of i add one term for each neighbour j of particle i. Order does not matter, and any count works.
fedge
f-edge the learned edge MLP. The same weights run on every edge.
zj
z-j the sender's row: 8 numbers.
zi
z-i the receiver's row: 8 numbers.
In plain words

For each neighbour j of particle i, feed the rows z-j and z-i to f-edge. It returns a message. Add up all the messages. The total is h-i.

With numbers

With made-up 2D messages: neighbour A sends (0.20, 0), neighbour B sends (−0.05, 0.10). h-i = (0.15, 0.10). A third neighbour adds a third term.

Call the particle's next row z-i at step t plus 1.

Say it aloud

z-i at t-plus-one equals f-node of z-i at t and h-i.

zit+1
z-i at t-plus-one the predicted row of particle i one step later.
fnode
f-node the learned node MLP. The same weights run on every particle.
zit
z-i at t the particle's row now.
hi
h-i the felt push from the first equation.
In plain words

Feed the particle's own row z-i and its felt push h-i to f-node. Read off the next row. Do it for every particle, rebuild the edges, and repeat to roll forward.

With numbers

Suppose f-node has learned "speed up by the push, then move", with a step of 0.1 s. The new velocity v-i is (0, 0) plus h-i × 0.1, which is (0.015, 0.010) m/s. The new position p-i is (0.40, 0.10) plus v-i × 0.1, which is (0.4015, 0.1010) m.

Step one message pass

Press Next move to walk the three moves for the ringed particle. Slide the rest spacing to flip pulls into pushes.

5.0 cm

Illustrative. Here f-edge is a hand-set spring, 1 per s² times the gap minus the rest spacing, and the step is 0.5 s. A trained f-edge is an MLP that learns its own version from data.

Follow the shapes. Take N = 500 particles with 8 numbers each, and 3,000 edges. f-edge reads two rows, 16 numbers, and returns 64. That makes a 3,000 by 64 table of messages. Adding them per receiver gives 500 by 64. f-node reads 8 plus 64 = 72 numbers per particle and returns the next 500 by 8. The edge count vanishes at the sum, and N never appears inside an MLP.

The failure, as symptom, measurement and fix

The symptom is a model whose output changes when you list the same particles in a new order. To measure it, shuffle the rows and compare. The fix is a sum over neighbours, because a sum ignores order.

Why does each particle sum its neighbours' messages, rather than join them into one long list?

Chapter 5

Why Structure Generalizes

Count the weights and the training examples of each model as the scene grows, and see where both gains come from

The lecture's claim: a graph model trained on small scenes predicts larger ones it never saw. Nothing in the network changes. Two facts from Chapter 4 do the work.

  1. Shared weights. One f-edge runs on every edge, one f-node on every particle. The model learns a local rule, not a scene. Its weight count does not depend on N.
  2. A sum over neighbours. It takes any number of neighbours in any order. Shuffle the rows and the predictions come back shuffled the same way. This is permutation equivariance.

Grow the scene, count the cost

Slide the particle count. The left bars count weights. The right bars count training examples one 50-step episode gives. The axis is logarithmic.

500

Both models have one hidden layer of 64. The fixed-size model reads all 8N numbers and writes 6N. The graph model's f-edge is 16 to 64 to 64 and f-node is 72 to 64 to 6. Real GNNs are deeper; the scaling is the same.

Shared weights also buy sample efficiency. Every particle at every step is one example of the same rule. Training minimizes the gap between predicted and true positions. Call the predicted position of particle i at step t plus 1 p-hat, and the true one p. Call the episode length T and the particle count N.

Say it aloud

L equals one over T N, times the sum over t and i of the squared distance between p-hat-i-t-plus-one and p-i-t-plus-one.

L
L the training loss: the mean squared position error, in cm².
1/(TN)
one over T N divide by the number of terms, so L is an average. T steps times N particles.
Σt Σi
the sum over t and i one term for every step and every particle.
‖p̂ − p‖2
the squared distance between p-hat and p how far the model's guess for particle i landed from the truth, squared.
In plain words

For every step t and particle i, measure how far p-hat landed from p. Square it. Average over all T times N terms. Push the weights of f-edge and f-node to make L smaller.

With numbers

With made-up numbers: two particles, one step. Errors of (0.3, 0.4) cm and (0, 0.1) cm square to 0.25 and 0.01. L = 0.26 / 2 = 0.13 cm². One real episode of 50 steps and 300 particles gives 15,000 such terms, all teaching the same rule.

A fixed-size model sees that whole episode as 50 examples of one big function. The graph model sees 15,000 examples of one small rule. That is why RoboCook, in Chapter 7, learns each tool from about 20 minutes of data.

The failure, as symptom, measurement and fix

The symptom is a model that needs new weights when the scene grows. To measure it, count its weights at two scene sizes. If the count changes, the model is not sharing its rule.

A graph model trained on 200 particles predicts a 400-particle scene with no retraining. What makes that possible?

Chapter 6

One Engine, Different Materials

Keep message, sum and update fixed, change the graph per material, and send news across a rigid bar in two hops

A rigid box, a sloshing fluid and a lump of plasticine move nothing alike. The lecture's answer, from DPI-Net (Li and others, ICLR 2019): keep the engine and change the graph.

MaterialGraphMotion
Rigid objectHierarchy; fixed edgesGlobal: the whole body moves together
Plasticine, doughHierarchyLocal: parts move against each other
Fluid, grainsEdges rebuilt every stepLocal, always rearranging

Why a hierarchy? One message pass moves news one contact. Push one end of a rigid bar and the far end must move at once. Call the bar's length L and the radius r. Call k the number of passes the push needs to cross the bar.

Say it aloud

k equals the ceiling of L over r.

k
k the number of message passes before the far end feels the push.
⌈  ⌉
the ceiling of round up to the next whole number. Half a pass is still a pass.
L
L the length of the object, in metres.
r
r the interaction radius: the most one pass can carry news.
L / r
L over r how many radius-lengths fit along the bar.
In plain words

Divide the length L by the radius r. Round up. That count k is the number of passes the push needs on a flat graph.

With numbers

With made-up numbers: a 0.30 m bar and r = 0.02 m. L / r = 15, so k = 15 passes. Add one summary node joined to every particle: up in one pass, down in the next. k drops to 2.

Send a push down the bar

Press Run. Lit particles have heard the push. Switch on the summary node and run again. Lengthen the bar.

16

Illustrative. Particles sit one radius apart, so a bar of n particles has length (n − 1) × r.

The graph also carries edge types. Dough-to-dough edges say how the material holds together. Tool-to-dough edges say how the tool shoves it. A flag on the edge tells f-edge which one it reads. Sum and update stay shared.

The failure, as symptom, measurement and fix

The symptom is a rigid box that bends in the model when pushed at one corner. To measure it, compare k with the number of passes per step. If k is larger, add a hierarchy.

Why does a rigid object need a hierarchy in a particle GNN?

Chapter 7

Planning: the Model Becomes a Controller

Imagine many presses, pick the one whose predicted dough is closest to the goal, do one, and look again

A world model only predicts. To shape dough, the robot plans through it with model predictive control (MPC), the method of Lectures 13 and 14. The learned GNN replaces hand-written physics. Call a candidate action sequence a, and the scene the model predicts after H steps s-hat-H. Call the goal shape s-goal, and a distance between two shapes D.

Say it aloud

a-star equals the argmin over a of D of s-hat-H of a, and s-goal.

a*
a-star the chosen action sequence.
argmina
the argmin over a the candidate a that makes what follows smallest.
D
D the shape distance, such as the Chamfer distance: the average gap from each particle to the nearest particle of the other shape.
ŝH(a)
s-hat-H of a the particle scene the GNN predicts after running a for H steps.
sgoal
s-goal the target shape, as particles.
In plain words

For each candidate a, roll the GNN forward to get s-hat-H. Measure D to s-goal. Keep the a with the smallest D. Do only its first action, sense the real dough, and plan again.

With numbers

With made-up numbers: three candidate presses predict D = 4.1, 2.3 and 3.0 cm. a-star is the second press. The robot does it, sees the real D is 2.6 cm, and plans the next press from there.

Push the dough with a wrong model

The model thinks each push moves the dough its full length. The real dough sticks and moves less. Raise the model error, pick a planner, and press Run.

0.60

Illustrative. The goal is 40 cm away and one push moves at most 15 cm. Each push, the planner picks the push the model says lands closest to the goal. The real dough moves 1 − 0.7 × error of each push.

The search can sample: draw many action sequences and weight the best, as CEM and MPPI do. Or it can follow gradients, because a GNN is differentiable: it says which way to change the push. A GPU runs thousands of imagined rollouts at once.

RoboCook (CoRL 2023) shapes real dough with many tools; the lecture shows a kit of 15. A classifier picks the tool from the current and goal shapes. A GNN for that tool predicts the dough under candidate motions, and the planner picks the motion. Each tool's GNN learns from about 20 minutes of random pokes. The lecture reports that this learned model can beat a physics model tuned with system identification, because real dough breaks the textbook.

The failure, as symptom, measurement and fix

The symptom is a plan that looks perfect in imagination and misses on the robot. To measure it, compare predicted and real D after each action. The fix is to replan from the sensed state after every action.

MPC picks the best imagined sequence but runs only its first action. Why not run the whole sequence?

Chapter 8

How Many Particles? Dynamic Resolution

Trade shape detail against planning time, and see the best particle count move with the goal

A robot pushes a pile of rice into a letter. How many particles should stand for the pile? Too few, and the model cannot draw the letter's corners. Too many, and each plan takes too long. The right count is the smallest one that is still good enough.

That count depends on the task. A plain circle needs fewer particles than a letter with sharp corners. The same goal can need different counts from different starting piles. So the lecture argues that resolution must be dynamic: chosen per situation.

Pick the particle count

Choose a goal. Slide the particle count. The left panel shows the shape the particles can draw. The right panel shows the error curve and the goal's tolerance.

100

Illustrative cost model: shape error 30 / √N cm, planning time proportional to N. We made up the tolerances. The real method learns these trade-offs from data.

Work the numbers. With error 30 divided by the square root of N, the circle's 3 cm needs N = (30 / 3)² = 100. The letter's 1 cm needs N = (30 / 1)² = 900. That is 9 times the planning time, spent only when the goal needs it.

Dynamic-Resolution Model Learning (RSS 2023) does this for real piles of granola, rice, carrots and candy. One GNN works at any particle count. At each MPC step, a resolution regressor reads the scene and the goal and proposes a count. The lecture explains its labels with Bayesian optimization: a search that tries a few counts and keeps the one that plans best. Then the GNN and planner run at that count.

The failure, as symptom, measurement and fix

The symptom is a planner that is fast on easy goals and fails on detailed ones, or slow on all of them. To measure it, log task reward and planning time against particle count. The fix is to pick the count per scene and goal.

Why does dynamic resolution refuse to fix one particle count?

Chapter 9

Showcase: Message Passing, Live

Run the engine one move at a time, push a tool into the cloud, and break it with the radius and the coupling

Here is the whole engine on a small cloud. Each Step plays the three moves. Edges light as messages flow. Each particle glows by the size of its felt push h-i. Then every particle moves. Your controls, each from an earlier chapter:

Run the engine, then break it

Press Step to watch one pass. Press Push to drive the teal tool in. Turn on Auto-roll. Then raise the radius until the graph saturates, or the coupling until the cloud shakes apart.

0.16
0.20

Illustrative. f-edge is a spring toward a rest spacing of 0.6 r, times the coupling; f-node adds the push to the velocity with damping 0.6. Tool edges only repel.

Nothing in this loop knows the size or shape of the scene. The same per-edge and per-node code runs for 25 particles or 25,000. That is Chapter 5, visible.

Two breaks to try. At a large radius, every particle joins most others and the cloud moves as one blob. Locality is gone. At a high coupling, each step overshoots, the felt pushes grow, and the read-out turns red. A learned f-edge can fail the same way when a rollout leaves the training data.

Chapter 10

The Field Guide

Keep the terms and numbers, a checklist, the core step in code, and the open problems

The recipe has five steps. Sample the scene into particles. Join near pairs into a graph. Learn one local rule by message passing. Roll it forward, and plan through it with MPC.

Terms and numbers

TermOne lineNumber to remember
Structured world modelThe scene as particles and relations, not one latent vector.Nudge one bean: 1 row changes, not 16 of 16
Particle rowz-i = (p-i, v-i, c-i).8 numbers; 500 particles: 4,000
GraphAn edge j to i when the gap is at most r.0.05 m gap, r 0.06: edge
Message passingh-i = sum of f-edge over neighbours; z-i next = f-node(z-i, h-i).(0.20, 0) + (−0.05, 0.10) = (0.15, 0.10)
GeneralizationShared weights plus a sum: same model at any N.10,310 weights at every N
LossMean squared position error over steps and particles.50 steps, 300 particles: 15,000 terms
Hierarchyk = L / r rounded up; a summary node makes it 2.0.30 m bar, r 0.02 m: 15 passes
MPCPick the action with the smallest predicted D; run one; replan.RoboCook: about 20 min of data per tool
Dynamic resolutionThe smallest particle count that is good enough for this goal.Toy: 100 for a circle, 900 for a letter

Before you build a particle world model

  1. Is the material made of many parts that touch? If it is one rigid body, write the physics.
  2. Can perception give you particles? Check the point cloud before the model.
  3. Does the radius match the contact range? Count particles with no edges.
  4. Does a push cross the object in one step? If not, add a hierarchy.
  5. Do you replan after every action? A learned model is never exact.

The core step in code

pythondef gnn_step(Z, pos, r, f_edge, f_node):
    # Z: (N, D) particle rows.  pos: (N, 3) positions.
    N = len(Z)
    d = np.linalg.norm(pos[:, None] - pos[None], axis=-1)
    recv, send = np.nonzero((d <= r) & (d > 0))           # edges j -> i within radius r
    msg = f_edge(np.concatenate([Z[send], Z[recv]], 1))  # (E, 16) -> (E, M)
    h = np.zeros((N, msg.shape[1]))
    np.add.at(h, recv, msg)                                # sum per receiver: (N, M)
    return f_node(np.concatenate([Z, h], 1))            # (N, D + M) -> next rows

Open problems the lecture names

BoxProblemDirection
PerceptionGetting particles from pixels in clutterVision foundation models (Segment Anything, DINOv2), descriptor fields (D³Fields), 3D keypoint tracking
DynamicsMore data efficiency and generalizationPhysics joined to the representation (PhysGaussian)
ControlGuarantees on safety and optimalitySparse neural dynamics for tractable planning; CoVO-MPC

Keep going on this site

The takeaway. Do not model the dough. Model a particle and its neighbours, share that rule everywhere, and the dough comes out of it.

This lesson follows Lecture 16, "Learning Structured World Models", of CMU 16-831 Introduction to Robot Learning, Spring 2024. Guanya Shi teaches the course; Yunzhu Li gave this lecture as a guest. The slides are on the lectures page. The works named are DPI-Net (Li and others, ICLR 2019), RoboCook (Shi and others, CoRL 2023) and Dynamic-Resolution Model Learning (Wang and others, RSS 2023).

Now press Present or Teach and explain from memory. Why does dough defeat hand-written physics? What are the three moves of message passing, with their shapes? Why do shared weights scale? Then go back to the pile, set 200 particles, and say why only one model keeps up.

Introduction to Robot Learning · CMU 16-831 · Lecture 16: Learning Structured World Models (guest: Yunzhu Li)
Previous: Deep Model-Based RL · Next: Offline RL · Back to Gleams