Top
Best
New

Posted by c1b 1 day ago

Show HN: Watch a neural net learn to play Snake(ppo.gradexp.xyz)
In browser PPO training demo, made possible by tinygrad: TinyJit -> WebGPU kernels.

Requires WebGPU.

118 points | 30 commentspage 2
neduma 10 hours ago|
More details and implementation notes please?
cshimmin 6 hours ago|
It's on the page, if you click the little info icon in the upper-right. Here's the text but there's some nice graphics there too:

  Snake Game, training entirely in the browser. Built on tinygrad: the rollout / targets / train graphs are TinyJits authored in Python, then compiled once to WGSL and replayed here under WebGPU.

  Observation: flat 10×10 board (100) + 4-dim prev-action one-hot = 104 dims. fc_pi.weight is zero-init so the opening policy is uniform over the legal actions; fc_v uses tinygrad's default Kaiming init.

  Per rollout: T=24 × N=384 parallel snakes (9,216 transitions), then K=3 epochs × 4 mini-batches of PPO updates. GAE γ=0.99, λ=0.95; AdamW wd=0.01; ratio clip ε=0.1; grad-norm 0.5; Huber value β=1, val_coef=1; entropy bonus 0.008333333333333333.

  Action mask + value clip + KL early stop. The 4-dim prev_a obs tail lets fc_pi zero the U-turn logit (the env silently overrides same-axis reversals anyway). Value loss is max(huber(v_new−td), huber(v_clip−td)) at ε=0.2. Approx-KL is sampled after each epoch and breaks the loop at 1.5·kl_target.
insane_dreamer 2 hours ago||
sound cool; would like to show my kid for education; doesn't work on Mac/Safari though (no webGPU)
LowLevelKernel 8 hours ago||
Link to repo?
bozhark 7 hours ago||
Crashed
th1nhng0 9 hours ago||
cool project
jmclnx 8 hours ago||
> WebGPU not available in this browser

Looks like this is for Linux and Windows, on NetBSD I get this issue :(

NoboruWataya 7 hours ago||
I got this in Firefox on Linux, just had to enable WebGPU in about:config (`dom.webgpu.enabled` = true).
jmclnx 7 hours ago||
Did not know that existed, I enabled it but no luck. Must be a NetBSD thing based upon this new message:

> WebGPU is not yet available in Release or late Beta builds.

redshiftza 8 hours ago||
If you are using brave (which i assume also applies to chrome) , there is a menu at brave://flags , you can enable unsafe web GPU from there
austinthetaco 9 hours ago|
my training on a 10x10 just randomly broke. i got to like 3600 then the graph went flat, the viewer on the left just showed it constantly restarting the game, and the scores in the negative. my average is now -10.