Part 11 of 20 in Tools we built and why. Previous: mojo-ablate: turning one model behavior up or down · Next: ABCam: using your Android phone as a webcam
What this is about
A physics engine is a program that computes what happens next to a body. Where does each leg go? How hard does a foot push on the floor? You give it a pose and the forces, and it gives you the next instant. Robots and animated animals are simulated this way.
Most engines move one body at a time, or a few. kinestride moves thousands at once. It assigns one GPU thread to each body, so one launch steps a whole crowd. At 65,536 bodies, each with 74 joint degrees of freedom, contacts and 50 motors, one full step took 84.7 ms on one AMD RX 7900 XTX.
Why it matters
Many questions in science and engineering are answered by running a simulation again and again with small changes. Training a robot to walk takes millions of steps. Studying how a model animal's brain controls its body takes many bodies. If a whole crowd steps in one go, the experiment is shorter.
But fast physics that is wrong is worse than slow physics. The first physics prototype we wrote for our simulated fly passed its gate while the fly was tipped over by 117 degrees. The gate printed PASS because it never measured tilt. That is the story told in We rebuilt MuJoCo for the GPU, and trusted it only after planting bugs in it. kinestride was built so that this cannot happen quietly.
How it works
There are three ideas.
- One thread per body. The GPU does a lot of small jobs at the same time. A thread owns one body and runs its whole step.
- A model file in, compile-time sizes out. You give it a MuJoCo model in MJCF format. A script flattens it into two tables, one of integers and one of floating-point numbers. The sizes become constants when the engine is compiled, so each body runs a kernel shaped for it. A model the engine cannot simulate is refused, not quietly cut down.
- Port one function at a time. MuJoCo is a standard engine for robots and animals, and it is the referee. Each ported function lives in a file named after its original and cites the source it follows.
The checking is the point. For each stage we compare every output field with MuJoCo on random body states. The error, as a fraction of the field's own size, must stay under 1e-5. Then we plant one believable bug, such as a flipped sign or a rotation applied in the wrong frame. The gate must fail. If it does not, the gate is broken and the stage does not count.
The speed numbers
On an actuated fly with 6 feet, 44 servos and 6 adhesion pads, the figures from docs/VS_MUJOCO.md dated 2026-11-18 are:
| bodies in one launch | result |
|---|---|
| 65,536 | 1.29 microseconds per body-step, 11.0 times MuJoCo on six CPU workers |
| 16,384 | 6.0 times MuJoCo |
| 1,024 | 0.65 times MuJoCo, so the CPU wins |
That last row is the honest part. A GPU has a start-up cost for each launch. With only a thousand bodies, six CPU workers are faster. The speed-up appears when the crowd is big.
The repository also says when a speed number is not reported: a speed from an unchecked build never is. Run check.sh first.
How to do it, step by step
You need Linux and an AMD RDNA3 card with ROCm. Only gfx1100 has been run so far.
- Run
tools/smoke.sh. It runs on the CPU, needs no assets, and checks document links, the model export and a full-step build. - Run
kinestride/check.sh stepon the GPU. It checks one stage against MuJoCo and runs that stage's planted mutant. A pass printsPASS. A failure printsFAIL <step>and exits non-zero. - Run
tools/assets.shto fetch test bodies into the.workfolder. - Run
tools/check_all.shto check every stage, one job each. - For speed, run
kinestride/bench.sh build MJCF 7, thenkinestride/bench.sh run MJCF 7.
The checks take a lock for each worktree, so run GPU stages one at a time.
What it does not do
- Not yet ported: noslip, and contact pairs beyond those listed in the README.
- Only the gfx1100 target has been run.
- The speed ratio changes with the number of bodies, as the table shows.
- Speed against MuJoCo depends on what you compare with. The table compares with six CPU workers on one machine.
Words you may not know
- Physics engine: a program that computes how bodies move and touch.
- Degrees of freedom: the number of ways a body can bend and move.
- Contact: a place where two bodies touch and push on each other.
- Actuator: a motor that moves a joint.
- MJCF: the file format MuJoCo uses to describe a body.
- Planted bug: a mistake we add on purpose to see if a check notices.
- GPU thread: one small worker among thousands on a graphics card.
Try it
- Read the README at github.com/amarbarosys/kinestride. Start with the table of what is ported and checked.
- Run
tools/smoke.sh. It needs only a CPU. - Read how the first prototype failed in the MuJoCo post.
- Visit aiazic.com to meet a simulated character. It is a showroom guide, not the physics engine.
Read next
- We rebuilt MuJoCo for the GPU, and trusted it only after planting bugs in it: the full story.
- ABCam: using your Android phone as a webcam: the next tool in the series.

Reacties
Nog geen reacties.
Inloggen om te reageren.