Open the Dreamer modal on Room 0 (100 m) in Celeste RL, jump right toward the first ledge, and ask the neural world model to imagine the next 30 frames with its eyes closed. Until this week, the chasm smeared into dark blue streaks and Madeline vanished by frame +5.
I already knew a full-scale world model could master the level: the site also replays a 10.5M-parameter DreamerV3 (ratio32) policy that cleared 100 m 50 out of 50 times (and exited greedily in 192 actions). What puzzled me was why the live world model running right inside the browser — a 602K-parameter (601,709) educational Recurrent State-Space Model (RSSM) in celeste-model.js — lost Madeline almost instantly.
The turning point for understanding why came from putting Ishan Shah’s TinyDreamer write-up and code side-by-side with my own browser weights (learned.js, rl-arcade.js, and train_celeste.py). Conveniently, TinyDreamer lives at almost the exact same ~550K-parameter budget. Auditing every tensor shape, loss term, and inference call against that reference turned “world models” from a box diagram in a paper into something I could break, measure, and rebuild on one 64×64 game screen.
What a world model actually is (and why one frame is not a state)
A game engine updates pixels deterministically from hidden simulator state. When Madeline jumps toward the first ledge in 100 m, a single frozen 64×64×3 RGB frame x_t does not tell you what happens next: rising toward the ledge and falling past it look nearly identical in one still picture, and invisible counters — velocity (vx, vy), coyote-jump grace ticks, jump buffer, and dash cooldown — govern the very next physics step.
An RSSM splits that hidden state into two pieces so a neural network can simulate physics from pixels alone:
h_t(deterministic recurrent working memory): a continuous GRU vector that integrates past frames and button pressesa_tacross time, holding velocity(vx, vy)and jump/dash timers.z_t(stochastic discrete scene tokens): a compact categorical bottleneck (Ggroups ×Cchoices) capturing what is on screen right now and any multimodal uncertainty when looking ahead.
From (h_t, z_t), small decoder heads reconstruct the imagined frame x̂_t, predicted reward r̂_t, and episode-alive probability ĉ_t. Crucially, the same model runs in two distinct regimes:
q(z_t | h_t, e_t) so h_0 captures motion. Once dreaming starts at t = 0, the encoder turns off and any error in p(ẑ_t | h_t) feeds directly back into the GRU.Debugging the 602K model: half the drift was the input, half was the bottleneck
When I probed the original 601,709-parameter browser model directly in Node and Chrome, the failure split cleanly into inference bugs on the page and structural bugs inside the weights.
On the browser side, the default live observation mode passed one single frame into model.initial() (h_0 = 0) and immediately closed its eyes. Because t === 0, the code skipped the GRU update entirely and tried to predict the jump with zero velocity memory. On Scenario 0 (Rising after a jump), starting from 1 frame instead of 5 nearly tripled player-region MSE even at +1 (0.0299 vs 0.0103) and +5 (0.0705 vs 0.0264, PSNR dropping from 22.05 dB to 17.89 dB).
Two rendering mismatches compounded that cold start:
- Dashing in Celeste triggers 6 frames of random
±2 pxscreen shake (cameraX/Y), shifting every terrain pixel at once and crashing PSNR from24 dBdown to11.2 dB. - Room 0 had a fallback (
skipDecordisabled on100 m) leaving PRNG clouds and snow rendered in front of a model trained on clean terrain, while the modal’s dashed comparison curve was a static placeholder instead of the live PSNR of copying the last observed frame.
Before retraining a single weight, I wired a rolling 5-frame observation warmup (observeContext) into the live arena and modal, added a camera shake off option (stabilizeCamera), cleaned Room 0’s observations, and replaced the placeholder curve with real copy-last PSNR. On an 8-trace Room 0 benchmark across jump and dash starts, just feeding those five real frames cut +5 clean error from 17.22 px (2/8) to 11.32 px (3/8 visible). On jump starts, +5 error plummeted from 23.26 px (2/4) to 4.34 px (3/4). With decorations on, +5 error fell from 13.34 px to 7.49 px.
Yet by +15 frames, the old 602K model still collapsed to 0 of 8 traces (8.71 px). Probing its weights over 300 teacher-forced gameplay steps explained why:
- 76.3% of the model sat in two flat linear layers:
encoder.weight(2048 → 128,262,144params) anddecoder1.weight(192 → 1024,196,608params) ate three-quarters of the601,709budget, leaving12.9%(77,184) for an unnormalizedGRUCell,2.4%(14,192) for all six convolutions,1.4%(8,192) for a single-linearprior, and2.0%(12,288) for a hardcoded Room-0backgroundtensor baked into the decoder. - Prior-posterior collapse: Even on 1-step teacher-forced checks, the prior
p(z_t | h_t)only agreed with the posteriorq(z_t | h_t, x_t)46.9% of the time (6.09 natsKL). Because flipping a singlezgroup perturbedh_tbydH = 0.885— nearly as much as pressing Jump (0.912) or Right (0.925) — wrong discrete guesses on step 1 drowned out the action signal and smeared the walls by+15.
602K weights 5 frames of motion history immediately cuts jump error from 23.26 px to 4.34 px. Right: three-quarters of its parameters sat in two flat linear projections, leaving 1.4% for the prior.Rebuilding the RSSM (730K): the DreamerV3 pieces that actually mattered
Fixing the input only proved that the dynamics model itself had to be rebuilt. I trained a 729,557-parameter RSSM v2 for 20,000 steps (52.1 min on an RTX 3060) over 425 clean PPO episodes (350 train, 75 dev; 140,979 frames across rooms 0..4, 9 discrete actions, with clouds, snow, and camera shake stripped so every bit went toward gameplay physics).
Five architectural and objective choices from DreamerV3 and TinyDreamer turned out to do almost all the heavy lifting:
- Overlapping strided CNN + nearest-upsample decoder: Four stride-2
4×4convolutions (64→32→16→8→4, channels3→16→24→32→48withChannelNormandSiLU) encode the frame to160dims; the decoder mirrors that with nearest-neighbor2×upsampling plus3×3convolutions (4→8→16→32→64) and drops the hardcoded Room-0 background bias so one compact model spans five rooms without block seams. - Normalized GRU with momentum bias (
h_t ∈ ℝ¹⁶⁰): AddingLayerNorminside the reset, update, and candidate gates plus a-1.0bias on the update gate (u_t = σ(LN(update) − 1)) keepsh_tbiased toward preserving velocity unless new evidence arrives. 16 × 8categorical bottleneck with1%unimix: Each state holds16independent 8-way categoricals (48bits/frame). During training, posterior samples use straight-through gradients so discrete picks remain differentiable, while mixing1%uniform mass keeps probabilities away from zero so KL never spikes to infinity on a rare dash frame:
- Asymmetric balanced KL with free nats: A tiny
0.008KL weight let the old posterior encode private frame details the prior could never guess (46.9%agreement). Balanced KL fixes the asymmetry directly:
- ROI/motion/edge weighting + open-loop rollout curriculum: On a
64×64screen, Madeline is roughly3×4pixels (<0.3%of the image). Uniform RGB MSE gets a great score by painting the stone walls accurately while erasing the player completely. Weighting pixels around Madeline41×(w = 1 + 40·1_ROI + 6·1_moved), adding a spatial edge gradient term (0.25 · edge_L1), and unrolling open-loop dreams during training (+5steps after step3,000,+10after8,000,+15after14,000) forces the GRU and prior to recover from their own mistakes over long horizons:
729,557-parameter RSSM v2. Moving capacity out of flat linear bottlenecks into strided convolutions, a normalized GRU, and 1.0 / 0.1 balanced KL lifted 1-step code agreement from 46.9% to 69.6% and closed-loop tracking far past +15.Why 1-step PSNR lies — and how I evaluated the model instead
Another lesson from comparing tiny world models: never pick a checkpoint on 1-step MSE or full-frame PSNR alone. A model that simply copies the previous frame gets great PSNR because 99% of the background walls do not move. Instead, I tracked four checks at every 2,000-step checkpoint:
- Multi-horizon sprite recovery (
±4 pxtemplate localization) out to+30frames. - Full-frame and player-ROI MSE vs. copying the last real frame.
- All-wait control sensitivity (
wait_roi_mae): running real actions vs. pressing nothing from the same 5-frame prefix (0.0948MAE difference in the player box at+5,0.1416at+15). - Counterfactual action forks: starting from the exact same 5-frame history, branching two different future action sequences, and testing whether the dreamed frames match the real branch outcome better than the wrong branch.
20,000-step RTX 3060 run. Stepping open-loop supervision from +5 to +10 and +15 pushes long-horizon recovery upward without hurting counterfactual branch accuracy.On 75 held-out dev windows, Madeline’s sprite recovery jumped to 97.3% (0.79 px) at +1, 89.3% (2.47 px) at +5, 70.7% (4.26 px) at +15, 54.7% (5.39 px) at +20, and 50.7% (7.18 px) at +30. Full-frame RGB MSE beat copying the last real frame at every multi-step horizon (0.00369 vs 0.00407 at +5; 0.00392 vs 0.00624 at +15; 0.00489 vs 0.00656 at +30), and player-region MSE fell well below copy-last (0.0815 vs 0.1459 at +5; 0.0984 vs 0.1670 at +15). On counterfactual forks, the 730K model picked the true future action branch 82.8% of the time (53 of 64, zero ties).
On the external 8-trace clean benchmark, +5 error dropped from 11.32 px (3/8) to 2.31 px (6/8 visible; 4/4 jumps at 1.83 px, 2/4 dashes at 2.80 px), and +15 rose from 0/8 to 3/8 (11.08 px in JS; 2/4 jumps at 6.39 px). Packing the weights as Float16 base64 shrank celeste-model.js from 6.0 MiB to 1.86 MiB, and over 30-frame open-loop rollouts JavaScript matched PyTorch within 0.0047 max pixel difference (0.00075 mean).
Continuous latents: Shortcut Diffusion vs. Diffusion Forcing
Once the discrete RSSM worked in the browser, I wanted to understand its remaining blur. Compressing 64×64×3 = 12,288 channels down to 48 discrete bits/frame under an MSE pixel loss softens sharp pixel-art stone edges whenever the model hedges its bets.
Following TinyDreamer’s Dreamer-4-style recipe, I tested whether a continuous spatial latent + Shortcut Diffusion Transformer would keep sharper bricks over 30 frames on the exact same clean rooms 0..4 dataset (after fixing an interleaved train/dev split leak):
- Stage 1 Spatial CNN Autoencoder (
600,723params): maps[3, 64, 64]frames to a standardized[8, 8, 8]continuous tensor (512floats that preserve 2D spatial layout). Across23,772dev frames it hit 0.00416 RGB MAE (10×sharper than an earlier0.0427patch-MLP attempt) and 99.21% sprite recovery (0.175 px), while a 3-layer convolutional readout extracted(x, y)from the latent to0.882 px(99.45%visibility accuracy). - Stage 2 Causal Shortcut Transformer (
1,207,528params): splits each[8, 8, 8]latent into4×4 = 16spatial tokens processed by4Pre-RMSNorm blocks with QK-Norm, 3D RoPE across(t, y, x), SwiGLU, and AdaLN (0.25gate-bias init so residual blocks don’t start muted). Instead of taking dozens of denoising steps per frame, Shortcut Diffusion predicts cleanx_0directly while training three losses together:
To isolate why diffusion rollouts break in open loop, I trained two 15,000-step arms under identical data and GPU budget:
- Clean History (
Tier3 Clean): history context tokens stay noise-free (σ_hist = 0) during training. - Diffusion Forcing (
Tier3 DF): each of the 5 history frames receives an independent noise level (40%clean,45%light[0, 0.25],15%moderate[0.25, 0.65]) during training so the transformer learns not to trust imperfect autoregressive history blindly.
1.81M-parameter continuous Shortcut Diffusion pipeline. Right: adding 0.0625 history noise collapses a clean-trained transformer (20.1% → 1.3%), whereas Diffusion Forcing stays completely stable — though still trailing the 730K RSSM on 15-frame lock.Evaluated across 224 dev clips, the clean-history transformer looked competitive when history stayed noiseless (hn = 0.0): 93.8% sprite recovery at +1 (1.56 px), 71.0% at +5 (4.00 px), 20.1% at +15 (11.34 px), and 58.3% counterfactual fork accuracy (111/194). Add hn = 0.0625 noise to history, however, and it collapsed: +15 dropped to 1.3%, RGB MAE exploded from 0.0189 to 0.1969, and position error hit 23.99 px.
Diffusion Forcing absorbed that noise cleanly (0.0145 RGB MAE at hn = 0.0625 vs 0.0139 at hn = 0.0), posted the best pooled diffusion position error (12.53 px) and +15 dev recovery (23.2%, 10.64 px), and jumped from 1 of 8 (7.29 px) to 5 of 8 (3.82 px; 4/4 jumps at 3.19 px) on the 8-trace clean +5 benchmark (hn = 0.0). Even exported to ONNX (encoder.onnx 1.24 MiB + step.onnx 6.30 MiB, 7.54 MiB total), though, it costs 4× the browser budget of the 1.86 MiB RSSM.
Side-by-side over 30 imagined frames
The five-row strips below run the exact same Room 0 action sequence across every model in open loop (Real game, Tier1 5f = old 602K RSSM with 5-frame warmup, Tier2 RSSM = new 730K RSSM, Tier3 Clean = Shortcut Diffusion clean history, Tier3 DF = Shortcut Diffusion + Diffusion Forcing).
jump-0). Tier1 5f smears into dark streaks while holding an outdated silhouette. Tier2 RSSM tracks Madeline across the chasm through +30. Both Tier 3 diffusion rows render sharper rock and hair early on at +5, then drift or fragment around the player by +30.
dash-0). Tier2 RSSM keeps the dash plume and post-dash climb aligned with the real frame through +30. Tier3 DF stays cleaner than Tier3 Clean through +15 before artifacts gather below the ledge at +30.| Model | +1 dev |
+5 dev |
+5 8-trace |
+15 dev |
+15 8-trace |
Fork acc. | Browser size |
|---|---|---|---|---|---|---|---|
Live baseline (602K, 1f) |
— | — | 1/8 (13.34 px dec.) |
— | 0/8 (17.61 px clean) |
— | 6.0 MiB |
+ 5f context (602K) |
— | — | 3/8 (11.32 px) |
— | 0/8 (8.71 px) |
— | 6.0 MiB |
RSSM v2 (730K) |
97.3% (0.79 px) |
89.3% (2.47 px) |
6/8 (2.31 px) |
70.7% (4.26 px) |
3/8 (11.08 px) |
82.8% (53/64) |
1.86 MiB |
Diffusion Clean (hn=0.0) |
93.8% (1.56 px) |
71.0% (4.00 px) |
1/8 (7.29 px) |
20.1% (11.34 px) |
1/8 (11.20 px) |
58.3% (111/194) |
7.54 MiB ONNX |
Diffusion Forcing (hn=0.0 / 0.0625) |
88.4% (2.96 px) |
59.4% / 58.0% |
5/8 (3.82 px @0) |
21.0% / 23.2% |
0/8 / 1/8 |
59.5% / 57.5% |
— |
The contrast is clear: continuous spatial diffusion preserves high-frequency pixel edges early and Diffusion Forcing stops autoregressive noise collapse from blowing up a rollout, yet at under 2 MiB in the browser a compact recurrent discrete bottleneck (730K RSSM) still leads by nearly 50 percentage points on 15-frame sprite tracking (70.7% vs 23.2%) and 23 points on counterfactual action forks (82.8% vs 59.5%).
The generalization cliff: what happens on 800 m
Once the 730K RSSM went live, I clicked over to 800 m in the arena — and immediately saw the world model hallucinate a completely different room layout.
Measuring 1-step reconstruction PSNR across all 12 playable rooms explained why: the model had only trained on clean rooms 0..4 (100 m – 500 m). Inside that training slice, reconstruction PSNR sits between 24.9 dB and 27.7 dB. Outside it (600 m – Summit), PSNR drops straight off a cliff to 7.0 – 8.0 dB. Specifically, 800 m scores 8.0 dB against itself and snaps to memorized 400 m at 21.4 dB.
48-bit discrete bottleneck has no spatial skip connections from input tiles, unseen rooms snap to whichever seen layout in 100 m – 500 m looks closest.Technically, that makes complete sense: without local spatial skip connections or patch-wise conditioning from the input frame, a 48-bit bottleneck maps the 64×64 image to an associative index of seen room layouts. Give it an unfamiliar level (800 m) or draw a wall across 100 m, and the decoder reconstructs the nearest memorized attractor instead of true tile-by-tile physics.
Poke the failure modes yourself
The nicest part of debugging this in the browser is that every failure mode above is now an interactive button in Celeste RL:
- Toggle
◎ Trackand drag▥ Split A|Bacrossx̂_tto watch Madeline's real and dreamed crosshairs separate while MSE softens brick edges. - Click
👁 Peek (q)mid-dream to open the model's eyes for one frame and watch the posterior snapz_tright back onto Madeline. - Switch
🎲 mode: argmaxtosample zand watch the liveH(p) ent.meter rise as prior uncertainty branches across jumps. - Hit
⚡ Fork Testto runWait,Jump+Right, andDash Upside-by-side from the exact same 5-frame prefix, or click◈ Wipe h_t = 0to induce single-frame velocity amnesia on demand. - Switch from
100 mto800 mto watch the livefit dBreadout drop off the generalization cliff into memorized400 m.
Explore the live 730K RSSM modal, diagnostics, and 12-room comparison in Celeste RL.
References
- TinyDreamer: Ishan Shah (2026), TinyDreamer: What I learned building a minimal version of Dreamer and source code — the
~550Karchitecture audit, Diffusion Forcing ablation, and long-horizon evaluation framing that guided these fixes. - DreamerV3: Danijar Hafner, Jurgis Pasukonis, Jimmy Ba, and Timothy Lillicrap (2023/2025), Mastering Diverse Control Tasks through World Models (
danijar/dreamerv3) — the categorical RSSM (1%unimix, straight-through gradients, balanced KL with free nats) and the recorded10.5Mratio32Room 0 policy. - Dreamer 4: Danijar Hafner, Wilson Yan, and Timothy Lillicrap (2025), Training Agents Inside of Scalable World Models — inspiration for the continuous spatial latent, causal QK-Norm / 3D-RoPE Transformer, and shortcut-forcing setup tested alongside the RSSM.
- Diffusion Forcing: Boyuan Chen, Diego Martí Monsó, Yilun Du, Max Simchowitz, Russ Tedrake, and Vincent Sitzmann (2024), Diffusion Forcing: Next-token Prediction Meets Full-Sequence Diffusion — independent per-frame history noise levels (
σ_0..σ_4) used to prevent autoregressive noise collapse. - Shortcut Models: Kevin Frans, Danijar Hafner, Sergey Levine, and Pieter Abbeel (2024), One Step Diffusion via Shortcut Models — step-size conditioning and
dt = 2dself-consistency enabling 2-step (dt = 0.5) sampling. - Celeste Classic (PICO-8): Maddy Thorson and Noel Berry, original PICO-8 release and NoelFB/Celeste PICO-8 source (MIT-licensed mechanics, sprites, and room maps powering Celeste RL).