How Much History Should a Sim-to-Real Adapter Remember?

Robots trained only in simulation often reach real hardware through a two-step trick. During training, the simulator's physics (friction, mass, motor strength) is randomly varied, a technique called domain randomization. A small "adapter" network then learns to guess those hidden physics values from the robot's recent sensor history. Every such adapter reads a fixed-length slice of history, and nobody has asked how long that slice should be. Work in vision and forecasting shows that more history is not always better. Past a certain length, extra frames add noise, stale patterns, and drift, a phenomenon called temporal context saturation.

This note argues that in robotics the right history length is not one number. It depends on how long the current physics has been in effect. When a pushed box slides from rubber onto steel, or a foot leaves rock for mud, history from before the change describes the wrong world. History from after the change is still too short to pin down the new world. We propose to measure this effect directly in randomized simulation, then build an adapter that learns to forget at physics changes. The simulator records exactly when the physics switched, so that signal is available for supervision at no extra cost. Finally, we test whether this improves recovery after real-world dynamics changes on hardware.

Core Claim

Our central hypothesis concerns piecewise-stationary dynamics, meaning physics that stays constant for a while and then jumps. Under such dynamics, the error of a history-based physics estimator has two parts that pull in opposite directions. The first part shrinks as more post-change evidence accumulates. The second part grows as the window reaches back across the most recent change. A fixed window is therefore either too short during long steady phases or contaminated just after a switch.

To make this measurable, we adapt the Context Saturation Length of Context Saturation in Zero-Shot Time-Series Foundation Models, which defines it as the shortest window reaching a fixed fraction of peak performance. Our version measures it as a function of $\Delta$, the time elapsed since the last physics change:

$$\mathrm{CSL}_\alpha(\Delta) = \min\{W : \mathrm{err}(W,\Delta) \le \mathrm{err}^*(\Delta)/\alpha\},$$

Here $\mathrm{err}(W,\Delta)$ is the adapter's error in predicting the privileged physics embedding when it reads $W$ steps of history. $\mathrm{err}^*(\Delta)$ is the best error over all $W$, and $\alpha$ is a tolerance such as 0.95.

The claim makes three predictions. First, the error-minimizing window tracks $\Delta$ right after a switch and plateaus at a task-specific saturation length during steady phases. Second, real-world sensor noise pushes that plateau longer than it is in simulation. Third, an adapter supervised to detect the switch (using simulator labels) recovers faster than any single tuned window. It should also recover faster than an LSTM that must discover forgetting on its own.

The new element is not "use a better sequence model." It is turning the switch times that domain randomization already generates into a training signal for when to discard history.

Relation to Prior Work

Three papers motivate the gap, because each found that history matters but held its length fixed.

RMA: Rapid Motor Adaptation for Legged Robots uses a 1D convolutional adapter over a fixed proprioceptive window, running at 10 Hz beside a 100 Hz policy, to estimate terrain physics on a Unitree A1. Rapid Motor Adaptation for Robotic Manipulator Arms extends this to ManiSkill2 manipulation by adding depth features. Can Context Bridge the Reality Gap? Sim-to-Real Transfer of Context-Aware Policies compares supervision objectives for an LSTM context estimator on a real Franka box-pushing task. All three leave a gap to the "oracle" policy that sees true physics. None varies the window, and none trains with physics that changes within an episode. We reuse their adapter designs as our backbones and change only what history they see and how they are told to forget it.

The saturation evidence comes from outside robotics, and it constrains the design. Towards Temporal Fusion Beyond the Field of View for Camera-based Semantic Scene Completion finds scene completion peaks at 4 frames, beyond which depth errors accumulate. The time-series study above finds saturation near two periods for periodic signals but needs windows of at least 32 times the Markov order for autoregressive ones. That second result suggests physics identification from noisy contact data may need long windows during steady phases, so a design that only ever shortens history would be wrong.

LaKD: Length-agnostic Knowledge Distillation for Trajectory Prediction with Any Length Observations documents "temporal interference," where old maneuvers corrupt short-term trajectory prediction. Motion Prediction Using Temporal Inception Module shows longer lookback helps long-horizon forecasts while hurting mid-horizon ones. Both handle interference with architecture alone. We differ by giving the model an explicit, simulator-supplied label for when old history became invalid.

One prior result appears to cut against us. Sim-to-Real Transfer of Robotic Control with Dynamics Randomization found an unbounded LSTM policy (0.89 real puck-pushing success) beat feed-forward policies with stacked history. That suggests learned gating may already handle forgetting. However, its physics were fixed per episode, so forgetting was never tested. Our experiments are built to settle exactly this.

Research Program

The work has three parts.

Part 1: a switching-randomization suite. In simulation, we redraw physics parameters at random times inside an episode while logging the true switch times and physics embeddings. The tasks are ManiSkill2 Peg Insertion and Pick & Place with YCB objects (ManiSkill2: A Unified Benchmark for Generalizable Manipulation Skills). During Pick & Place, table friction or grasped-object mass changes mid-trajectory. We also run a quadruped terrain-transition task modeled on RMA's setup.

Part 2: diagnostic sweeps. We train RMA-style convolutional, LSTM, and causal-transformer adapters with each fixed window from very short to very long. We measure $\mathrm{err}(W,\Delta)$ and the saturation curve. This alone answers the open question the research file flags: whether these adapters saturate at all, and where.

Part 3: the switch-aware adapter. We add a small head that predicts time-since-switch, supervised by the simulator's logged switch times. Its output sets a soft recency mask over the history window. Shortly after a predicted switch, the mask contracts to recent steps. In steady phases, it relaxes toward the measured plateau length. The physics-embedding regression loss and the policy are kept identical to the RMA² recipe. To keep the method honest, the mask has one learned scale parameter beyond the switch head. Any gain therefore comes from the switch signal, not added capacity.

Baselines

Do nothing. The naive reference is context-agnostic domain randomization with a memoryless policy. On the real Franka pushing task it reaches 32% success, against 63% for the policy-loss context-aware variant, per Can Context Bridge the Reality Gap?. On ManiSkill2 Pick & Place YCB it reaches 0.3%, against 73.8% for RMA², per Rapid Motor Adaptation for Robotic Manipulator Arms. This baseline mainly confirms that history helps on our modified tasks.

Strongest existing method. The strongest competitor in simulation is RMA² with its published fixed window, which reports 73.8% on Pick & Place YCB and 51.6% on 3 mm Peg Insertion. Those numbers are for stationary physics. For physics that switches mid-episode, no reported result was found on Lacuna, so we re-run RMA² ourselves. On hardware, the strongest is the policy-loss LSTM estimator from Iannotta et al. at 63%.

Fairness. All adapters share the same base policy and privileged encoder, the same switching-randomization data, the same number of simulation steps, and the same hyperparameter search budget. Critically, the fixed-window baselines get their window tuned on the switching suite with the same budget we spend on the switch head.

Ablation. The key ablation trains our exact architecture with the switch head's loss removed, so the mask must be learned from the policy and regression losses alone. This isolates whether the simulator's switch labels, rather than the masking architecture, carry the gain.

What counts as winning. Beating the baselines means two things on the switching suite. First, lower physics-embedding error in the window from 0 to 1 s after a switch. Second, a statistically clear task-success gain over the best tuned fixed window and the best LSTM. At the same time, steady-phase error must be no worse.

Why not just…?

Why not just tune the window length as a hyperparameter? If saturation is the whole story, one swept window suffices. Our model predicts that this works for stationary episodes but not switching ones. Part 2 measures the best fixed window per regime directly. If a single tuned window matches the switch-aware adapter on both post-switch error and steady-phase error, we will report that the adaptive mechanism is unnecessary. That outcome alone would be a useful, citable result, given that no adapter paper in the file has done this sweep.

Why not just use an LSTM trained on switching randomization? This is the real threat. Peng et al.'s LSTM beat stacked history (Sim-to-Real Transfer of Robotic Control with Dynamics Randomization), and switching data might teach its gates to reset. Against it, gated recurrent models still drift over long sequences (Recurrent Neural Networks for Aortic Image Sequence Segmentation with Sparse Annotations). Training only on the policy loss also gives a weak, delayed signal for when to forget. The decisive test is the LSTM's post-switch recovery curve versus ours. We also train an LSTM given the same switch-label auxiliary loss. If that LSTM matches us, the contribution is the supervision signal rather than the masking, and we will say so.

Why not just let a transformer attend over the full history? Attention can in principle learn recency. However, the time-series study found error spikes past saturation in TimeMoE (Context Saturation in Zero-Shot Time-Series Foundation Models), which shows that attention does not automatically ignore excess context. The causal-transformer adapter is included in every sweep, with and without the switch head.

Why not just calibrate the simulator offline? Offline calibration addresses a fixed gap. It cannot follow a box crossing between surfaces within one push, which is precisely the regime studied here.

Proposed Experiments and Decisive Checks

Simulation. On the switching versions of Peg Insertion and Pick & Place YCB, we report task success, embedding error versus $\Delta$, and $\mathrm{CSL}_{0.95}(\Delta)$ for every adapter. The first decisive check is whether optimal windows actually track $\Delta$. If the saturation curve is flat in $\Delta$, the core claim is false and the proposal reduces to a window sweep.

Hardware. On a Franka pushing setup mirroring Iannotta et al., boxes of known mass (283 g to 824 g) are pushed across a boundary between two surfaces with different friction. This creates a real, repeatable switch with known timing. Because the masses are known, we can measure two things. One is the stability of the estimated physics embedding during steady phases at each window length, which tests the prediction that real noise lengthens the plateau. The other is success and steps-to-recover after the boundary.

Decisive checks. The proposal succeeds only if three things hold. First, real steady-phase saturation length exceeds the simulated one. Second, the switch-aware adapter recovers faster after the boundary than both the tuned fixed window and the label-free ablation. Third, overall success exceeds the 63% policy-loss reference rebuilt on our setup.