History Encoder for Robust Humanoid Locomotion
Explicitly compressing the policy's history input into a task-aware latent for more robust locomotion policies
Reinforcement Learning
Overview
Humanoid locomotion policies condition on a history of past observations and actions to cope with changing dynamics and sensor noise during training. Combined with domain randomization, using history like this lets a policy achieve one-shot deployment to environments it has never seen.
But relying on history also means a large share of the policy's input dimensionality is history, not the current state. I measured how much the policy actually relies on that history, and found it was skewed further than expected.
Based on that, I built a History Encoder that compresses history into a compact latent — training the resulting policy end-to-end with no extra data collection or fine-tuning step.
Prior work typically estimates environment information that's hard to observe directly — contact, friction, the robot's base height — which makes it difficult to train purely on data collected in the real world. By designing a structure that uses only real-world-collected data, I made the History Encoder fine-tunable.
History Encoder
1 — Problem: How much does policy rely on history?
To quantify this instead of assuming it, I ran an input-perturbation sensitivity analysis — gradient norms with respect to each input group, current observation vs. historical joint position / velocity.

hist dof_vel/hist dof_posaccounted for roughly 45% of total gradient-norm sensitivity.- The policy was about 20% more sensitive to historical joint state than to the current observation.
- One reason the policy might lean heavily on history is that when the current input is corrupted, referencing past input can dilute that corruption — letting the policy behave more robustly.
- But I thought robustness to input noise could already be handled well enough by domain randomization. History's real role, I believed, was to give the policy two other kinds of information:
- Information about transitions: understanding of the environment's dynamics (from a world-model perspective, information for predicting the future)
- Information for estimating the current state: understanding of state variables that are hard to observe directly, such as the robot's linear velocity
Replace the raw history buffer with a compressed representation, so the policy weighs current state and history more evenly and learns a more robust gait.
2 — Architecture: MLP-Mixer + Student-Teacher

- Backbone. Instead of attention, I used an MLP-Mixer for the time-series history — token-mixing (time axis) and channel-mixing (feature axis) are factored into separate MLPs, which is more data- and compute-efficient for this input size and trained more stably than a small transformer.
- Training signal. A Teacher encoder encodes future observations into a target representation; a Student encoder predicts that target from history alone. Negatives are sampled from a replay buffer and the student/teacher pair is trained with an InfoNCE contrastive loss.


- Troubleshooting — When training the latent with MSE Loss, the representation tended to stagnate (latent_match loss did not decrease) because the Teacher latent is a constantly changing target and the pressure to get the scale and axis alignment exactly right due to the nature of MSE loss. Adding contrastive loss (InfoNCE) and a linear projection head to remove the scale constraint and require only relative alignment resulted in a significant reduction in latent_match - a classic solution in SimSiam / VAE-like representation learning.
3 — Training and platforms

Policies were trained in Isaac Lab (via the HumanoidVerse framework) and evaluated sim-to-sim in MuJoCo.
- The History Encoder policy escaped a local minimum that the baseline got stuck in, converging to a higher mean reward.
- Domain randomization (base pose, external pushes, friction, Kp/Kd) plus a command curriculum (progressively widening vx/vy/yaw ranges) kept training stable.
- Validated across three platforms: Robotis K1, Unitree G1, and KIST Kapex.
4 — Does the latent actually encode task information?


A t-SNE projection of the latent shows clean separation by command (stand / forward / turn-left / turn-right) once training converges — evidence the encoder is genuinely compressing task-relevant information, not just noise.
5 — Robustness evaluation
I ran four stress tests to check whether the compressed latent trades away robustness for efficiency.
A) External pushes vs. B) joint-observation loss


- A) Strong disturbances: Compared to Baseline, the History Encoder policy improves survival by approximately 10% under disturbances in the direction of travel and about 20% under disturbances in the opposite direction.
- B) Joint observation loss: when a single joint's input (ankle/knee) is dropped, the History Encoder policy actually falls more than the baseline.
C) Continuous noise vs. D) intermittent noise


- C) Continuous noise: both policies perform similarly.
- D) Intermittent noise: the baseline is actually more robust here.
6 — Conclusion
The History Encoder is more robust to strong, sudden external disturbances, but not uniformly better — it is more fragile to intermittent sensor corruption and to losing a single joint's history. My read: the baseline still carries an uncompressed raw observation inside its history buffer, which naturally dilutes brief, spiky corruption; the compressed latent has no such slack. Compression buys robustness against large, structured disturbances at the cost of resilience to unstructured, transient noise — a trade-off worth stating explicitly rather than claiming a strict win.