hybrid_aif.reference.raif.world

hybrid_aif.reference.raif.world#

Reference world models as declared Systems: R-AIF’s tiny RSSM and its CRSPP.

The placement of tiny_core()’s parts into slots:

state factors  deter  = the Deterministic GRU carry   (controlled: the action)
               stoch  = the 32x32 categorical code    (parent: deter, same step)
transition     transition:deter  GRU(deter, flat stoch_{t-1}, action)
               transition:stoch  p(stoch | deter_t)
initial priors initial_state_prior:deter  LearnedVector
               initial_state_prior:stoch  DerivedInitial()
modalities     likelihood:state   symlog_mse over [deter, flat stoch]
               likelihood:reward  symlog_disc, 255 bins over [-20, 20]
               likelihood:cont    binary (continuation, not termination)
recognition    recognition:embed  MLP over the state observation (symlog inputs)
               recognition:stoch  q(stoch | deter_t, embed)

deter is declared first because stoch’s transition parent is the carry at the same step. The G side is not part of the world model; the agent mounts it (hybrid_aif.reference.raif.agent.raif_mountain_car()).

Design: docs/design/amortization-p0-addendum.md §§1–3.

Functions

control_name(factor)

The name of the control node the sugar creates for factor: "u_<factor>", namespaced like any node ("world.u_location" for "world.location").

crspp_rssm(*, key[, policy_len, deter, ...])

R-AIF's CRSPP prior-preference model: tiny_rssm without the action or the heads.

init_of(winit)

The engine's init= for their winit ("default" | "normal").

tiny_core(obs_dim, action_dim, *, key[, ...])

R-AIF's tiny world model as an RSSMCore, state-based.

tiny_rssm(obs_dim, action_dim, *, key[, ...])

R-AIF's tiny world model as a (System, SystemParams) pair.

Classes

Array

Array base class for JAX

Box

A continuous control node's support: dim numbers in [low, high] elementwise.

DerivedInitial

"This state factor's initial belief is its own transition, at the episode start."

Deterministic

A deterministic node: a pure map, optionally with trainable parameters.

LearnedVector

A trainable vector behind an activation: a parametrized constant, with no parents.

MLPCategorical

MLP over concatenated parents → a factored categorical child.

MLPPredictor

MLP over concatenated parents → a raw output vector, with no density of its own.

PredictorHead

An MLPPredictor plus the name of the loss that reads its output.

RSSMCore

An RSSM world model: GRU carry, categorical prior/posterior, three heads.

Recognition

One amortized variable's structural declaration: its recognition slot.

System

Static structure of a System: discrete, continuous or mixed.

SystemParams

All numeric state of a System: generative tensors, designations and the closed-loop factors.

hybrid_aif.reference.raif.world.init_of(winit)[source]#

The engine’s init= for their winit ("default" | "normal").

hybrid_aif.reference.raif.world.tiny_core(
obs_dim,
action_dim,
*,
key,
deter=128,
num_vars=32,
num_classes=32,
units=32,
mlp_units=64,
mlp_layers=2,
embed=64,
unimix=0.01,
num_bins=255,
bin_low=-20.0,
bin_high=20.0,
activation='silu',
norm=True,
winit='default',
)[source]#

R-AIF’s tiny world model as an RSSMCore, state-based.

rssm {deter 128, stoch 32, classes 32}, units 32 inside the RSSM and on the reward/continuation heads, mlp_units 64 / 2 layers on the encoder and decoder, unimix 0.01, a 255-bin symlog_disc reward over [-20, 20]. winit reaches every block: "normal" is their winit: normal, fan: avg with no bias where a layer is normed; "default" is eqx’s initializer with every bias kept.

Design: docs/experiments/raif-mountain-car/divergence-register.md (divergences 17, 26).

hybrid_aif.reference.raif.world.tiny_rssm(
obs_dim,
action_dim,
*,
key,
action_low=-1.0,
action_high=1.0,
policy_len=8,
learned_initial=True,
**tiny,
)[source]#

R-AIF’s tiny world model as a (System, SystemParams) pair.

obs_dim/action_dim are the environment’s (Mountain Car: 2 and 1). key and the extra keyword arguments (deter, num_vars, units, unimix, …) go to tiny_core(). learned_initial=False freezes the initial carry at zero (their initial: 'zeros'). policy_len is their imag_horizon: the explicit rollout steps before the g_tail critic closes the horizon. The carry reads a continuous control node, its box [action_low, action_high] in params.control; its action node emits the value to the env. The G side is mounted on the returned pair by the agent.

hybrid_aif.reference.raif.world.crspp_rssm(
*,
key,
policy_len=8,
deter=128,
num_vars=32,
num_classes=32,
units=32,
embed=64,
unimix=0.01,
activation='silu',
norm=True,
winit='default',
)[source]#

R-AIF’s CRSPP prior-preference model: tiny_rssm without the action or the heads.

A separate parameter set with its own GRU and prior and no modality, so it is only rolled forward, never observed. Its recognition:stoch conditions on (deter, external:embed): embed’s width is declared in System.external_inputs and must match the agent’s encoder (tiny_rssm’s embed, 64 by default); its value is supplied per call by hybrid_aif.reference.raif.crspp.crspp_recognize(). The cosine_sim_to_pref_rollout row owns it through System.scoring and SystemParams.scoring. policy_len is carried but unused: the row rolls the agent’s horizon.

Design: docs/design/amortization-debt-ledger.md entry 5.