zymera.rollout
rollout
rollout(env, policy, n_steps, key) — the scan rollout primitive.
JIT-pure, vmap-friendly. The key protocol is FROZEN (identical to
zymera v0, so trajectories are reproducible across the migration):
reset_key, scan_key = split(key); per step
k, action_key, step_key = split(k, 3).
Memory profile is opt-in:
keep="lean"(default) — the stacked trajectory drops thechannelandmissionslots fromWorld(the comm ring buffer is the first thing to blow device memory on multi-seed runs). The live scan carry is always the full state; only the recorded snapshot is filtered.keep="all"— record everything (use for viz / re-simulation).collect=("reward_terms", ...)— additionally stack the namedinfokeys (leadingTaxis, no initial entry).
rollout
rollout(env, policy, n_steps, key, *, keep='lean', collect=())
Roll env forward n_steps ticks under policy.
Returns a dict with keys:
"world"— stacked World pytree, leaves(T+1, ...)(filtered perkeep)"obs"—(T+1, N, ...)"action"/"reward"/"done"—(T, N)"info"— only whencollectis non-empty:{k: (T, ...)}
Vmap over the key arg for free seed-parallelism::
trajs = jax.vmap(lambda k: rollout(env, policy, 100, k))(jax.random.split(key, 32))
Source code in zymera/rollout.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
random_policy
random_policy(obs, key)
Uniform random actions — (obs, key) -> (N,) int32.
Source code in zymera/rollout.py
98 99 100 101 102 | |