Control
Finding the upside
Watch a tiny neural torque controller swing a pendulum upright, then disturb its balance. Trained with synthetic expert-policy distillation in tinygrad.
4,481 parameters · entirely local
Run the experiment
Choose a checkpoint and compute backend. Inference stays on your device.
Checked weights · deterministic physics · 20 simulated seconds
02 / Read the controller
- Simulated time
- 0.00 / 20s
- Episode return
- 0.0
- Time upright
- 0.00s
- Angular velocity
- 0.15 rad/s
03 / A path to balance
Try the untrained checkpoint with the same start. Return is better closer to zero; upright means within 0.25 rad of the top and below 1 rad/s.
Learned, not scripted.
tinygrad trained this 3 → 64 → 64 → 1 network on synthetic energy-shaping and balancing expert labels. The expert is used only in training. Every live torque comes from the selected network weights.
Training & source on GitHub ↗Held-out, not a highlight reel.
128 unseen starting states, 400 steps each. Fixed final checkpoint, no best-episode selection.
- Mean return
- -2458 → -146
- Upright time
- 0.4% → 92.2%
A teaching world.
Pendulum-v1 dynamics with a fixed 0.05s step; velocity is normalized by 8. Inspired by LeRobot’s explicit state/action normalization. This is distillation, not PPO, and not a validated robot controller. Software WebGPU proves shader correctness, not physical-GPU performance.
JavaScript CPU is an explicit choice using the same checked weights. Simulation may run slower than wall time.