notes

Policy-First PFNs for In-Context RL

exploring

Core Question

Can we build a Prior-Data Fitted Network (ControlPFN) for few-shot in-context RL without any forward RL/optimal-control solver or behavior cloning—by inverse sampling (sampling a policy/value structure first, then analytically constructing a realistic control problem for which it is exactly optimal)?

Current stance: Pure inverse sampling only—no teacher controllers (no iLQR/PPO/VI cloning). Just like TabPFN’s breakthrough was its SCM prior, ~90% of the research problem is designing a physically realistic, non-leaking sampling schema whose prior transfers zero-shot to real forward environments.

Prior Art & The Open Gap

Work Approach Why Our Gap Remains Open
Ferreira et al. (2024), One-shot World Models (arXiv:2409.14084) PFN trained on synthetic NN/momentum dynamics $\to$ Gym Learns a world model, still runs RL/planning at test time.
Zighem & Vie (2026), RL Foundation Models Should Already Be A Thing (arXiv:2606.18812) Attention network on synthetic tabular MDPs Small discrete tabular MDPs solved forward (VI); hits curse of dimensionality.
ICR-RL / TabPFN-RL (2025) (arXiv:2509.11259) Off-the-shelf TabPFN inside Fitted Q-Iteration Gradient-free iterative FQI, not a single-pass control-prior policy PFN.
DPT (Lee et al., 2023) & Algorithm Distillation (Laskin et al., 2023) Supervised in-context prediction of $\pi^*(s_q \mid \mathcal{H})$ Requires oracle RL solvers on real task families, not synthetic priors.
Bin Mohaya et al. (2026), Generalizable Optimal Control (arXiv:2609.22672) In-context Transformer for LTI systems Linear (LQR) with explicit cost matrices, not nonlinear RL from transitions.

Open gap: Nobody has trained a single-forward-pass nonlinear ControlPFN using inverse-generated (zero-solver) priors that transfers zero-shot to real forward dynamical/MDP benchmarks.

Unifying Principle: Invert for Dynamics, Not Reward

Route A: Singularity-Free Inverse Mechanical Prior (Primary Focus)

For $n$-DOF 2nd-order mechanical systems $\dot{q} = v, \; \dot{v} = a(q, v) + B u$ ($q, v \in \mathbb{R}^n$, $u \in \mathbb{R}^m$ with $m \le n$, including underactuated plants since $B$ is never inverted):

  1. Sample a smooth bowl potential $W(q) \ge 0$ ($W(0) = 0$), target velocity field $v^*(q) = -c\,\nabla W(q)$, SPD matrix $P$, actuation $B \in \mathbb{R}^{n \times m}$, discount $\rho > 0$, skew-symmetric gyroscopic matrix $S = -S^\top$, and velocity cost $R_v \succ 0$.
  2. Exact optimal value & policy (with $e := v - v^(q)$): \(V^*(q, v) = W(q) + \frac{1}{2} e^\top P e, \qquad u^*(q, v) = -R^{-1} B^\top P e\) *(Bounded torque $|u_i| \le u_{\max}$ works identically via the $\log\cosh$ convex conjugate $\implies u^ = -u_{\max}\tanh(\dots)$.)*
  3. Unshaped mechanical cost (no $q \cdot v$ cross-terms): \(\ell(q, v) = \underbrace{\rho W(q) - \nabla W(q)^\top v^*(q) - \frac{1}{2} v^*(q)^\top R_v v^*(q)}_{\ell_q(q) \,\ge\, 0 \text{ for } c R_v \prec 2I} \;+\; \frac{1}{2} v^\top R_v v\)
  4. Singularity-free acceleration ($e$ cancels identically out of HJB): \(a(q, v) = P^{-1}\!\big(-\nabla W + (P J_{v^*} - R_v)v^*\big) + \Big(\frac{\rho}{2}I + J_{v^*} - \frac{1}{2}P^{-1}R_v + \frac{1}{2}B R^{-1} B^\top P + P^{-1}S\Big) e\)

Route B: Discrete $P$-Solving Converse Bellman (Complementary Track)

Fix sparse goal reward ($r = +1$ at goal, $0$ elsewhere), sample a hop-depth $d(s)$ and slipperiness $p^* \in (0, 1]$, and construct transitions without Value Iteration:

Sanity Check Results (Inverse Mechanical Sampler)

Verified via standalone NumPy + RK4 rollout check (100 random 1-DOF quadratic, 100 bounded-$\tanh$, 25 coupled 2-DOF + gyroscopic):

Traps & Subtle Bugs Logged

  1. Reward-shaping inversion (naive $q$/$r$-solving) and transition leakage (unmatched action entropy/self-loop rates in discrete $P$-solving).
  2. 2-DOF gyroscopic bug: Skew-symmetric term in $a(q,v)$ must be $P^{-1} S$ (not $P^{-1} S P$), since $(Pe)^\top (P^{-1} S) e = e^\top S e = 0$.
  3. Bounded-torque divergence: Requires $r_v > \rho p$ (or restricting initial states to the controllable basin).
  4. Context distribution shift: Pretraining context $\mathcal{H}$ must mix exploratory rollouts (OU/random), wrong-plant optimal policies $\pi^_{M’}$ (mimics early online posterior-sampling rollouts), and noisy-optimal $\pi^_M + \epsilon$.

Next Step (Cheapest Decisive Experiment)

Build a minimal 1-DOF Mechanical ControlPFN smoke test (4–6 layer TabPFN-masked Transformer, ~1–2M params, supervised NLL on exact $u^(q_{\text{query}}, v_{\text{query}})$ given $N \in [30, 150]$ transitions, random actuator sign $b \in \pm[0.5, 4]$, random goal offset $q^$, randomized force/time scales):

Key References