A New Perspective on Transformers in Online Reinforcement Learning for Continuous Control

Nikita Kachaev, Daniil Zelezetsky, Egor Cherepanov, Alexey K. Kovelev, Aleksandr I. Panov

TL;DR

While transformers excel in offline reinforcement learning (RL), they are notoriously unstable in online, model-free settings. This paper systematically demystifies how to successfully train transformers for online continuous control, providing clear recipes for input conditioning, network sharing, and data slicing. The resulting transformer baselines match or outperform standard MLPs and RNNs across both fully and partially observable tasks.

What Problem Does This Paper Address?

Transformers have revolutionized sequence modeling, but their adoption in fully online, model-free reinforcement learning—especially for continuous control—remains highly limited. Online RL requires an agent to learn directly from ongoing environment interactions, a process plagued by high variance and non-stationary data distributions.

When researchers try to swap standard Multi-Layer Perceptrons (MLPs) or Recurrent Neural Networks (RNNs) for transformers in online settings, they run into severe training instabilities. Key architectural decisions—such as how to format multimodal inputs (states, actions, rewards), whether the actor and critic should share a neural backbone, and how to slice sequential data from a replay buffer—remain poorly understood. This paper systematically evaluates these design choices to establish transformers as a reliable, high-performing baseline for continuous control.

Methods

The authors adopt a standard GPT-2-like transformer decoder as their core backbone, incorporating modern enhancements like pre-layer normalization and FlashAttention-2 for computational efficiency.

Figure 2: Scheme of the GPT-2-like block used as a backbone during all the experiments in this work.

Rather than proposing a radically new architecture, they isolate and systematically benchmark three critical design dimensions across standard online RL algorithms (PPO, TD3, and SAC):

  1. Input Conditioning: How data is fed into the network. They compare feeding observations only (ObsOnly), interleaving actions and observations (Interleaved), and concatenating observation, action, and reward embeddings upfront (EmbedConcat).
  2. Backbone Sharing: Testing whether the actor and critic should use entirely separate networks, share a backbone updated by both, or share a backbone that is frozen during critic updates.
  3. Data Slicing: Evaluating how sequential data is sampled from the replay buffer, specifically comparing within-episode slicing, cross-episode slicing (which spans episode boundaries), and predicting at every token.

Datasets

The unified transformer pipeline was validated across three diverse continuous control environment suites:

  • MuJoCo: Standard fully observable locomotion and control tasks (e.g., HalfCheetah, Ant, Humanoid).
  • MuJoCo-POMDP: Partially observable variants where velocity or position data is masked, forcing the agent to rely on temporal history.
  • ManiSkill3: A modern, GPU-parallelized robotic manipulation benchmark evaluated using both vector states and complex image-based observations (tasks include PushT, PickCube, and PokeCube).

Key Insights and Ideas

  • Fusing Modalities Upfront Stabilizes Attention: In partially observable settings (POMDPs), the EmbedConcat strategy outperforms complex cross-attention mechanisms. Fusing the observation, action, and reward triplet into a single homogeneous embedding vector upfront allows the self-attention mechanism to focus purely on temporal dependencies rather than struggling with modality alignment.
  • Actor-Critic Gradient Conflict Causes Collapse: Sharing a transformer backbone between the actor and critic without constraints causes severe gradient explosion. This happens because the actor (maximizing reward) and the critic (minimizing Temporal Difference error) provide conflicting gradient signals. Freezing the shared backbone during critic updates completely mitigates this interference, offering a stable and computationally efficient compromise.
  • Cross-Episode Slicing Fixes Early-Episode Blindness: When training a transformer to predict actions from only its last token, standard within-episode slicing leaves the agent untrained for the very first steps of an episode (before the context window is full). Slicing data across episode boundaries solves this early-game underperformance without the massive computational overhead of calculating losses on every single token.
  • Robust Parameter Scaling: Unlike MLPs, which degrade significantly in performance when scaled up under fixed RL hyperparameters, transformers demonstrate excellent robustness to parameter scaling, making them far better suited for large-scale model architectures.

Key Results

Enhanced by these design principles, the optimized transformer baseline (GPT(ours)) achieved highly competitive normalized scores across all benchmarks, significantly outperforming prior RL-specific transformer variants like GTrXL.

Figure 1: Transformer baselines enhanced by our findings achieve competitive performance across selected tasks. Aver- age reward is normalized over the specified number of tasks. For MuJoCo-POMDP, we use PPO-GRU from [24].
  • POMDP Superiority: In MuJoCo-POMDP tasks, the transformer baseline significantly outperformed standard MLPs and RNNs, proving its superior capability in handling partial observability.
  • Robotic Manipulation: On ManiSkill3 tasks, SAC-GPT matched or exceeded MLP baselines in vector mode (e.g., achieving a 0.65 success rate on PushT vs. 0.59 for MLP) and substantially outperformed CNN baselines in image-based modes (e.g., a 0.86 success rate on PokeCube vs. 0.61 for CNN).

Limitations and Future Work

The authors note that while cross-episode data slicing with zero or first-observation padding stabilizes early-episode training, alternative masking and attention strategies warrant deeper investigation. Additionally, while this paper establishes strong transformer baselines for single-task continuous control, exploring how these design principles scale to massive multi-task or multi-domain online RL settings remains an open and promising direction for future research.

Summary updated

BibTeX
@misc{kachaev2025new,
  author = {Nikita Kachaev and Daniil Zelezetsky and Egor Cherepanov and Alexey K. Kovelev and Aleksandr I. Panov},
  title = {{A New Perspective on Transformers in Online Reinforcement Learning for Continuous Control}},
  year = {2025},
  eprint = {2510.13367},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.13367},
}
Figure