Skip to content

Native magma --rl-bin transfer eval (closed and replay) - #6

Open
Infatoshi wants to merge 6 commits into
masterfrom
eval-magma-transfer
Open

Native magma --rl-bin transfer eval (closed and replay)#6
Infatoshi wants to merge 6 commits into
masterfrom
eval-magma-transfer

Conversation

@Infatoshi

@Infatoshi Infatoshi commented Aug 25, 2026

Copy link
Copy Markdown
Owner

Native Magma transfer eval for the spawn-torch policy.

--rl-bin is the Blaze policy camera (oc_pixel 64x36). Magma width/height stay 854x480. Camera size is compile-time. This is not a window/GPU mega-kernel swap and does not add a --rl-bin resolution flag.

What landed

  • blaze/rl/eval_magma.{h,c}: fork/exec magma_game --rl-bin --render off --pace unlimited --mobs off --snapshot-in. BOLR in, JSON act13 out. Look/craft/interact/smelt on sub-tick 0 of action_repeat only.
  • Packed EvalMagmaObs twin, sizeof 14628, _Static_assert 64x36.
  • eval --backend magma --transfer closed|replay (--magma-bin override). Batched N Magma processes.
  • --transfer closed: policy reads Magma BOLR.
  • --transfer replay: policy reads blaze_cpu; same actions on Magma; first gated mismatch or MATCH. Gated fields: pose, inv, hotbar, coal, cam, depth, edge, dead, container (blocks/logs/tick excluded).
  • Harness: make -C blaze/rl test-eval-magma (32 forward ticks, s10 t0). Not on make test.

How to run (from repo root)

make -C blaze/rl test-eval-magma
make -C blaze/rl eval-magma
./out/blaze/rl/eval --checkpoint PATH --backend magma --transfer closed --stage 0
./out/blaze/rl/eval --checkpoint PATH --backend magma --transfer replay --stage 0

Default --tries 5. nn_sample Gumbel is batch-size dependent: n=1, n=13, and n=65 tables are not comparable. Magma RSS is ~193 MB; 65 processes need ~12.5 GB (gamer, not Mac).

Measured (do not treat as Gate 2 accept)

Protocol: 13 seeds, --stage 0, 5 tries x 6000 ticks, rng_seed=0, ni=seed_index*5+attempt, Gumbel n=65.

retrain_0821_best.bin cpu (Mac) == cuda (gamer) seed-by-seed:

seed best
2, 11, 16, 27, 29, 33 t0 (0/5)
3, 10, 14, 20, 32, 44, 46 logs3 (1/5)

full chain (torches): 0/13; histogram t0:6, logs3:7.

ppo_ckpt_best.bin cpu == cuda: t0:13, torches 0/13. Dead net.

Magma tries=1 (Gumbel n=13, not comparable to the table above):

  • seed 10, 6000 ticks, --transfer replay: MATCH, logs3.
  • 13-seed replay: MATCH 12/13. seed 27 DIVERGE step=40 cam 2 px. Not blessed.
  • 13-seed closed: histogram t0:10, logs3:3. Torches 0/13.

Comparable Magma tries=5 n=65 replay then closed is running on gamer (eval-magma-ladder). This PR will get a docs commit when that table prints.

Gate 2 accept stays OPEN. These nets place 0 torches on Magma.

Out of scope

Dragon-fight RL. Magma GPU tick. Changing oc_pixel.


Note

Medium Risk
Introduces a new multi-process eval path that drives live magma_game instances and compares policy observations across backends; correctness and resource usage matter for transfer gates, but no auth or persistence changes.

Overview
Adds native Magma transfer evaluation so checkpoints can be scored against magma_game --rl-bin without the removed Python eval scripts.

New eval_magma.{h,c} spawns one magma_game subprocess per lane (JSON actions in, BOLR 64×36 oc_pixel out), with eval --backend magma --transfer closed|replay. Closed feeds the policy from Magma observations; replay runs the net on blaze_cpu and replays the same actions on Magma, reporting MATCH/DIVERGE on gated fields (pose, inv, hotbar, coal, cam/depth/edge, dead, container). make -C blaze/rl test-eval-magma pins a 32-tick BOLR parity gate vs blaze_emit; eval-magma runs the 13-seed closed ladder.

Docs and ops shift Linux validation to anvil (not gamer for make test, magma CPU, M1/M2, eval), update GATES row 2 with measured 13-seed numbers, and add Spawn → dragon ownership in the OPEN_DIVERGENCES files. Gate 2 accept remains open (0 torches on Magma).

Reviewed by Cursor Bugbot for commit 479a2c4. Bugbot is set up for automated code reviews on this repo. Configure here.

eval --backend magma reads BOLR and writes JSON actions. Replay locksteps
blaze_cpu and Magma on the gated BOLR fields. test-eval-magma is the 32-tick
harness. Camera stays compile-time 64x36 oc_pixel. 13-seed ladder not measured
in this commit.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c01cf9b. Configure here.

Comment thread blaze/rl/eval.c
if (!replay)
magma_lane_fill(eval_magma_obs(mag[i]), i, cam, depth, edge, scal6,
pose, status, done_buf);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replay ticks Magma after Blaze idles

High Severity

Replay still sends actions to Magma after a lane is finished or Blaze has set done. Blaze then idles while Magma keeps ticking, so the next gated compare reports DIVERGE even when the two sides matched until success, death, or the region-envelope stop. Batched seeds make this fire as soon as any sibling episode ends early.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c01cf9b. Configure here.

Comment thread blaze/rl/eval.c
if (replay) {
if (fns.step_full(env, act_rows, cfg->action_repeat, cam, depth, edge,
scal6, rew, done_buf, pose, status) != 0)
die("burn-in blaze step failed");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

die() orphans Magma child processes

Medium Severity

After Magma processes are spawned, several failures call die() instead of the fail cleanup that runs magma_close_n. Children inherit sibling pipe fds (no CLOEXEC) and SIGPIPE=IGN, so they do not exit when the parent vanishes. A failed nn_create, checkpoint load, or post-spawn alloc can leave dozens of ~193 MB magma_game processes hung.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c01cf9b. Configure here.

@Infatoshi

Copy link
Copy Markdown
Owner Author

Magma --transfer replay tries=5 n=65 on gamer, retrain_0821_best.bin, replay_rc=0 2026-08-25T19:19:21-06:00.

MATCH 56/65. Nine DIVERGE, all cam 1-5 px. Not blessed.

seed try DIVERGE
3 4 step=160 cam 2 px
10 4 step=147 cam 3 px
16 3 step=407 cam 1 px
27 0 step=137 cam 1 px
27 1 step=38 cam 1 px
32 1 step=1007 cam 2 px
44 0 step=146 cam 5 px
44 3 step=361 cam 4 px
46 0 step=422 cam 2 px

Replay milestones equal cpu==cuda (policy reads blaze_cpu): t0:6, logs3:7, torches 0/13.

Closed tries=5 is running on the same tmux chain.

retrain_0821_best.bin closed Magma matches cpu and cuda (0/13
torches, t0:6 logs3:7). Replay MATCH 56/65; nine cam-px DIVERGE
are not blessed. Gate 2 accept stays open.
@Infatoshi

Copy link
Copy Markdown
Owner Author

Magma --transfer closed tries=5 n=65 on gamer, retrain_0821_best.bin, closed_rc=0 2026-08-25T23:09:04-06:00.

Side-by-side vs cpu (Mac) and cuda (gamer). Same protocol. Seed-by-seed match.

seed best
2, 11, 16, 27, 29, 33 t0 (0/5)
3, 10, 14, 20, 32, 44, 46 logs3 (1/5)

full chain (torches): 0/13. histogram t0:6, logs3:7.

Replay (earlier): MATCH 56/65, 9 cam 1-5 px DIVERGE, not blessed.

Gate 2 accept stays OPEN (0 torches). Docs: 358ea70.

ppo_ckpt_best.bin magma replay+closed still running on gamer.

Anvil is the faster CPU. Magma CPU, make test, tape replay, blaze
M1/M2, and eval run there. Do not stage that work on gamer. Mac
stays control plane and Metal.
Gamer ladder ALL_DONE. Dead net magma closed matches cpu and cuda.
Replay MATCH 45/65. Gate 2 accept stays open.
@Infatoshi

Copy link
Copy Markdown
Owner Author

Gamer ladder ALL_DONE 2026-08-26T05:54:10-06:00. best_closed_rc=0.

ppo_ckpt_best.bin magma closed == cpu == cuda: t0:13, torches 0/13.
Replay MATCH 45/65 (cam-px DIVERGE, not blessed).

Full four-eval chain:

ckpt transfer result
retrain_0821_best.bin replay MATCH 56/65
retrain_0821_best.bin closed magma == cpu == cuda, 0/13, t0:6 logs3:7
ppo_ckpt_best.bin replay MATCH 45/65
ppo_ckpt_best.bin closed magma == cpu == cuda, 0/13, t0:13

Gate 2 accept stays OPEN.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant