Walking, Reaching and Not Falling Over: Fast Humanoid Control with Flow Matching
We took a humanoid controller that writes out its own future motion with a diffusion model, swapped the diffusion model for flow matching, and got a controller that needs four times fewer network calls per step, falls less when pushed, and can reach for things it never saw anyone reach for.
Table of contents
TL;DR
- The setting: a simulated humanoid whose controller is a generative model. At every control step it writes out the next few actions and the states they should lead to, and test-time "guidance" can steer that plan toward a goal without retraining. This follows BeyondMimic, which uses a diffusion model (DDPM).
- The problem: DDPM needs 20–50 denoising steps, each a full pass through the network, for every control step. That caps control at around 10 Hz on edge hardware.
- The change: train the same kind of model with flow matching instead. It learns to move noise toward a real trajectory along a straight line, so a handful of big steps is enough.
- Speed and robustness: DDPM needs about 20 network calls per control step to walk stably (about 20 ms); flow matching does as well or better with 5, about 4× faster. When the robot is shoved every second, at 5 calls flow matching survives about 820 simulation steps on average against DDPM's 280.
- Reaching for free: the training data contains only walking. Guided toward a hand target at test time, the model still tracks it (RMSE ≈ 1.1), and it follows joystick velocity commands with RMSE ≈ 0.55. Longer planning horizons help both.
1. Walking and reaching at once
A humanoid is attractive because the world is built for human bodies: it fits through our doors, reaches our shelves and climbs our stairs. The hard part is that for a humanoid, moving and manipulating are the same problem. This is called loco-manipulation.
A robot arm bolted to a table can reach without thinking about its feet. A humanoid can't. Reaching forward shifts its center of mass, so the legs have to compensate. Carrying something changes how the whole body swings while walking. The controller has to plan for the whole body at once, across 20 to 30 motors, while respecting joint limits, torque limits and balance.
Hand-built controllers and trajectory optimizers can do impressive things, but they need accurate models and lots of task-specific tuning, and they tend to break when reality doesn't match the model. Reinforcement learning on human motion-capture clips produces very natural motion, but usually one policy per task.
2. Why diffusion controllers are slow
A newer idea treats control as generation. Instead of mapping the current state straight to an action, a generative model writes out a short plan: the next action, and the next few states and actions after it. BeyondMimic showed that if the model predicts states as well as actions, you can steer it toward a goal at test time (walk to this waypoint, follow this joystick, avoid this obstacle) with no retraining. One model, many tasks.
The catch is speed. BeyondMimic uses a diffusion model (DDPM). Diffusion models generate by starting from pure noise and removing a little of it at a time, over 20 to 50 steps. Each step is a full forward pass through the network, and all of them have to happen inside every control step. On edge hardware that works out to roughly 10 Hz, which is too slow for fast, reactive moves like catching yourself while reaching mid-stride.
So the question for this project was simple: can we keep everything good about the diffusion controller, including the test-time steering, but make each plan much cheaper to produce?
3. Flow matching in one picture
Flow matching is a different way to train the same kind of generative model, and in image generation it has shown better quality with far fewer steps than diffusion.
The intuition: take a real trajectory from the training data and a random noise sample of the same shape. Draw a straight line from the noise to the data. Pick a random point along that line, and train the network to answer one question there: which direction, and how fast, should I move to get to the data? For a straight line, the answer is just the difference between the two endpoints.
Here τ0 is the noise, τ1 is the real trajectory, τt is the in-between point, Ot is the robot's recent history, and vθ is the network's predicted velocity. To generate, you start from fresh noise and follow the predicted velocity in a few steps. Each step is one network call, so the number of steps is the "number of function evaluations", or NFE.
Diffusion (DDPM)
Flow matching
That is the whole trick. Nothing about the network architecture changes. What changes is what it is trained to predict, and therefore how many steps you need at run time.
4. From motion capture to a trajectory model
Motion-capture data tells you how a person's body moved, but not which motor commands would make a robot move that way. So, following BeyondMimic, we build the training data in stages.
- Walking clipsThe walking sequences from the LAFAN1 motion-capture dataset. No reaching, no grasping.
- One expert per clipAn RL policy (PPO) per walking clip, rewarded for tracking the clip's poses and velocities in physics simulation.
- Noisy rolloutsRun each expert with noise added to its actions, and record what it does to recover.
- One generative modelA flow-matching transformer trained on all of it, then steered at test time.
Teaching the model to recover
If you only ever show a model perfect demonstrations, it has no idea what to do once it drifts off them. A trick from PDP fixes this: perturb the expert while recording, but store the clean action the expert would have taken from each perturbed state. The data then contains a "noise band" around every demonstration, full of corrective moves.
We push this further by recording at several noise levels at once. For every motion clip we run 40 simulated environments, most of them with gentle noise and a few with heavy noise:
That comes to roughly 40 rollouts, about 3.5 hours of data, per motion sequence.
What the model sees and predicts
The body is the SMPL skeleton with 23 ball joints. Rather than describe the body by its joint angles, we run forward kinematics and describe it by where each body part is in space and how fast it is moving, all in a "character frame" that moves and turns with the robot. That makes goals like "put the hand here" easy to express, and avoids small angle errors piling up along the chain from hip to hand.
- State (165 numbers): the root's position, velocity and rotation, the Cartesian positions and velocities of the bodies, and the rotations of the hands and ankles.
- Action (69 numbers): target joint positions, which a low-level PD controller turns into motor torques.
Given the last 4 steps of history (about 0.13 s), the model writes out a plan: the action to take now, followed by H future states and actions.
The network itself is small: a 6-layer transformer decoder with 8 heads and 512-dimensional embeddings, about 20M parameters and about 1 GB of GPU memory at inference. We trained a DDPM version (as in BeyondMimic) and a flow-matching version with the same architecture, each for about 24 hours on 32 TPU v4 cores, and measured inference on an RTX 4060 and an A6000 with TensorRT. The DDPM-versus-flow-matching comparison uses a horizon of H = 4; the steering experiments use H = 16.
5. Steering at test time
Here is where predicting the future pays off. Suppose we want the robot to walk at a certain velocity, or put its right hand at a point in space. We write that wish as a cost G on the planned trajectory: zero if the plan does what we want, larger the further off it is. Then, at every generation step, we nudge the model's velocity downhill on that cost:
The model's own velocity vθ keeps the plan looking like realistic walking; the gradient term pulls it toward the goal; w sets how hard we pull. Change the cost and the same model does a different task. This is called classifier guidance, and the paper shows it carries over from diffusion to flow matching.
Two practical details. First, following earlier work on diffusion, we switch guidance off for the last 5 of 20 steps when generating with NFE = 20; guiding only over an interval made things much more stable. Second, for reaching we compute the hand position from the planned joint angles with forward kinematics, so the cost is just the distance between the hand and the target:
Nothing in the model knows about reaching. It only knows how walking bodies move. The cost asks for a reach, and the model finds the most walking-like way to deliver one.
6. Result: fewer steps, fewer falls
The first experiment asks how robust each controller is, and how that changes as we cut the number of generation steps. The robot walks with no goal while being shoved: every second its root gets a random velocity kick of up to 0.5 m/s. We count simulation steps until it falls (its head drops below 0.2 m), averaged over 50 trials.
At 20 steps the two are tied, at about 470 steps each. Below that they split:
- NFE = 5: flow matching about 820, DDPM about 280.
- NFE = 2: flow matching about 450, DDPM about 150.
- NFE = 1: flow matching about 280, DDPM about 30.
Two caveats are visible in the chart itself. The bands are wide, so individual trials vary a lot. And at 10 steps DDPM's mean is actually higher than flow matching's; the gap only opens up in the few-step regime. That regime is exactly the one that matters for real-time control.
The motion looks different too. DDPM with few steps produces unnatural poses and jerky movement that drift away from anything in the training data. Flow matching still produces smooth, natural walking at a single step.
7. Result: steering with a joystick
Next, a steering task. A "joystick" issues four commands in turn, forward, backward, turn left and turn right, each held for 3 seconds. The guidance cost is the squared gap between the plan's horizontal root velocity and the commanded velocity, summed over the plan. We score the root-mean-square error (RMSE) between achieved and commanded velocity.
Two knobs matter. The planning horizon H: going from H = 2 to H = 16 lowers RMSE from about 1.05 to 0.70, a 33% drop. A longer plan gives guidance room to change speed gradually rather than all at once. The guidance strength w: going from w = 10 to w = 40 lowers RMSE from about 0.725 to 0.55, a 24% improvement.
Joystick RMSE vs horizon H
Joystick RMSE vs guidance scale w
Stronger isn't always better, though. Above w = 40 the walking gait starts to destabilize and the robot falls more often, so the sweet spot for velocity control is around w = 30 to 40.
8. Result: reaching without a reaching demo
This is the result we find most striking. The robot has to move its hand to randomly placed targets while keeping its balance and walking. The training set contains no reaching, grasping or manipulation at all, only walking. The only thing asking for a reach is the forward-kinematics cost from section 5.
It works. At the best settings, hand-tracking RMSE is about 1.1. The same two knobs behave as before, with a twist:
- Horizon: RMSE falls to about 1.15 at H = 16, from around 1.4–1.5 at the short horizons; the paper reports a 24% improvement from H = 2 to H = 16. The curve isn't perfectly monotonic: it gets slightly worse at H = 4 before improving.
- Guidance strength: RMSE drops from 1.49 at w = 20 to about 1.11 at its best, around w = 100, then creeps back up as guidance gets stronger still.
Hand-target RMSE vs horizon H
Hand-target RMSE vs guidance scale w
Reaching wants much stronger guidance than velocity control (around w ≈ 100 versus w ≈ 40). Our guess is that hand targets sit further from where arms naturally are during walking, so the model has to be pulled harder to get there.
The takeaway: flow matching gives you the steerable, generate-a-plan controller of BeyondMimic at a fraction of the cost per control step, and it degrades gracefully when you cut steps instead of falling apart. And a model that has only ever seen walking can be steered into reaching.
9. Why it works
Why flow matching survives with few steps
DDPM learns a reverse process in discrete steps, each removing a fixed amount of noise, with a schedule tuned for a particular step count. Cut the step count and each step has to jump further than it was trained for. Errors compound, because each step builds on the last, and the result lands off the data. At a single step, DDPM's samples are far from anything realistic.
Flow matching learns a continuous velocity field along straight paths. Straight paths are easy to follow with a few big steps; even one Euler step lands roughly on the data. That is where the 4× speedup comes from.
Why reaching emerges from walking
We think three things combine. Walking already contains a lot of arm motion: arms swing and posture shifts, covering a good part of the arm's reachable space. The model learns a smooth "surface" of physically plausible poses that can be bent toward new ones. And guidance supplies the push along that surface toward the target. The practical upshot: walking data is far easier to come by than manipulation demos or teleoperation, and it may be enough to bootstrap reaching.
Horizon and strength trade off
A longer horizon gives better tracking but costs more compute, roughly linearly in H. Since flow matching does well at low NFE, a good operating point is a moderate horizon (H ≈ 16) with few steps (NFE ≈ 5). Guidance strength is a different trade: more of it improves tracking until it pushes the plan into poses the model has never seen, and then the robot falls.
10. What we don't claim
- Simulation only. Every experiment is in simulation. Real hardware brings state-estimation noise, latency and unmodeled dynamics; the perturbation results are encouraging but are not a sim-to-real test.
- Walking only. Reaching emerges, but the model can't produce motions far from walking, such as crouching, jumping or turning in place.
- Hand-tuned guidance. The best guidance strength differs by task and was found by sweeping. Something that adapts it automatically would help.
- Distribution shift. Like all imitation learning, the policy can wander into states it never saw, and errors compound over long rollouts. The noise-band data helps but doesn't fix it; collecting data from the deployed policy (DAgger) is the obvious next step.
- Switching skills. When the goal changes abruptly, for example from walking forward to reaching for a distant target, the model can stay stuck in its current mode instead of transitioning smoothly.
- Fewer metrics than planned. Our setup also describes FID for motion quality and a combined walk-and-reach success rate, but the paper doesn't report numbers for them. "Same motion quality" rests on the survival test and on watching the motion, and survival varies widely across the 50 trials.
Next steps we'd like to try: training on more varied motion (running, jumping, dancing, manipulation), putting a higher-level planner on top to hand the controller waypoints, online data collection to fight distribution shift, and of course a real robot.
The paper
Fast Humanoid Loco-Manipulation via Flow Matching
Zehua Wang, Videet Mehta, Qiao Sun · MIT
- Replacing DDPM with flow matching in a BeyondMimic-style trajectory controller gives about 4× faster inference (5 vs 20 network calls per control step) without losing motion quality.
- Under random pushes at NFE = 5, flow matching survives about 820 steps on average against DDPM's 280; at NFE = 1, about 280 against 30.
- Trained only on LAFAN1 walking, the model tracks hand targets (RMSE ≈ 1.1) and joystick velocities (RMSE ≈ 0.55) through test-time guidance; longer horizons cut RMSE by 24–33%.
Acknowledgements
This was a project for MIT's 6.4210; thanks to the teaching staff for their guidance and feedback. It builds directly on BeyondMimic (Liao et al.), PDP's noise-band data collection (Truong et al.), the flow matching and rectified flow papers (Lipman et al.; Liu et al.), and the LAFAN1 motion-capture dataset.