Online Finetuning Decision Transformers with Pure RL Gradients

Junkai Luo, Yinglun Zhu

TL;DR

Large Language Models have seen massive breakthroughs in reasoning by ditching supervised fine-tuning in favor of pure reinforcement learning (like GRPO), yet their robotics cousins—Decision Transformers—have stubbornly failed whenever researchers tried the same trick. This paper uncovers the culprit behind those failures: a standard data-relabeling step that secretly breaks the math of on-policy RL. By removing this bottleneck and adapting LLM-style policy optimization to continuous control, the authors unlock pure-RL online fine-tuning for Decision Transformers, achieving state-of-the-art performance across tough robotics benchmarks.

What Problem Does This Paper Address?

Decision Transformers (DTs) reframe offline reinforcement learning as a sequence-modeling problem. Instead of estimating complex value functions, you feed a transformer a desired future score—called a return-to-go (RTG)—alongside past states and actions, and it autoregressively predicts the next action.

While DTs are great at imitating pre-collected offline datasets, we want agents that can keep improving online by interacting with the real world. Existing methods like the Online Decision Transformer (ODT) still rely heavily on supervised imitation losses during online play, or at best sprinkle in tiny amounts of RL gradients (like ODT+TD3). Why? Because supervised losses only teach the model how actions change when you ask for a different score ($\frac{\partial a}{\partial \text{RTG}}$), rather than how to adjust actions to actually get a higher score ($\frac{\partial \text{RTG}}{\partial a}$). Meanwhile, attempts to fine-tune DTs with pure policy-gradient RL algorithms like PPO have notoriously crashed and burned. The authors ask: Can Decision Transformers be fine-tuned online using pure RL gradients?

Methods

First, the authors remove hindsight return relabeling—a standard ODT trick where you tell the agent to aim for a high target score ($g_{\text{online}}$) during exploration, fail to reach it, and then overwrite the training memory with the lower score it actually achieved ($g_{\text{actual}}$) so the supervised loss stays grounded in reality.

With relabeling gone, the authors adapt Group Relative Policy Optimization (GRPO)—a critic-free RL algorithm popularized in LLM reasoning—into GRPO-DT through three clever modifications:

  1. Sub-trajectory Rollouts: Standard GRPO gives one single reward to an entire LLM response. In robotics, one bad twitch ruins a maze run, requiring finer credit assignment. GRPO-DT samples intermediate "reset points," branches out a group of short sub-trajectories of length $L_{\text{traj}}$ for optimization, and rolls them out further ($L_{\text{eval}}$ steps) using expected actions to cleanly estimate their advantage. (When environment resetting isn't possible, they introduce a Q-guided variant using an auxiliary critic).
  2. Sequence-Level Importance Ratios: Instead of calculating importance weights token-by-token (action-by-action), they compute the probability ratio over the entire sub-trajectory, aligning the update weight directly with the sub-trajectory advantage.
  3. Active State Sampling: Rather than picking reset points randomly, the model measures the variance of its own action predictions and actively resets to states where it feels most uncertain, turbocharging exploration.
Ablation studies showing the critical impact of sub-trajectories, state consistency, sequence likelihoods, active sampling, and removing geometric mean normalization in GRPO-DT.

They also introduce PPO-DT, showing standard PPO works out-of-the-box on DTs once hindsight relabeling is stripped away.

Datasets

The authors evaluate offline-to-online adaptation across three standard continuous control and manipulation suites from the D4RL benchmark (no new datasets are introduced):

  • MuJoCo (Hopper, Walker2d, Ant): Dense-reward locomotion tasks pretrained on random (stress-testing recovery from terrible initialization), medium, and medium-replay datasets.
  • Adroit (Door, Hammer, Pen): High-dimensional robotic hand manipulation tasks using human and cloned datasets.
  • AntMaze (UMaze, UMaze-Diverse): Navigation tasks with sparse rewards (1 for reaching the goal, 0 otherwise).

Key Insights and Ideas

  • Why Hindsight Relabeling Breaks RL: On-policy RL algorithms like PPO and GRPO rely on importance sampling—comparing the probability of taking an action under the new policy versus the old policy ($\frac{\pi_{\theta}(a|s,g)}{\pi_{\theta_{\text{old}}}(a|s,g)}$). If an action was sampled aiming for an optimistic score $g_{\text{online}}$, but relabeled to $g_{\text{actual}}$ during training, the denominator evaluates a distribution the action was never actually drawn from! Importance ratios explode into the thousands, destabilizing training.
Removing hindsight return relabeling stabilizes wild spikes in importance-sampling ratios and prevents policy collapse.
  • Skip the Geometric Mean: Concurrent LLM research suggests normalizing sequence-level importance ratios with a geometric mean. In short robotic sub-trajectories, removing this normalization works much better—allowing clipping to aggressively squash outdated trajectories while letting on-policy updates move faster.
  • Drop-in Compatibility: Unlike ODT+TD3, which forces you to alter offline pretraining to jointly learn Q-functions, critic-free GRPO-DT can grab any off-the-shelf pretrained DT architecture (like Reinformer) and start fine-tuning immediately.

Key Results

GRPO-DT sets a new state-of-the-art across almost every benchmark block:

  • Recovering from Garbage Data: When pretrained on random MuJoCo data, purely supervised ODT stalls at an average normalized return of 20.13. Pure RL shines here: PPO-DT hits 107.70 and GRPO-DT hits 106.71 (beating ODT+TD3's 82.28).
  • Mastering Complex Control: On medium MuJoCo tasks, GRPO-DT averages 129.61 (vs. ODT+TD3's 111.18). On high-dimensional Adroit manipulation—where ODT (8.06) and IQL (25.15) collapse—GRPO-DT scores 109.18, beating ODT+TD3 (97.93) across every single task.
  • Sparse Rewards: On AntMaze, GRPO-DT achieves 96.89, right on the heels of ODT+TD3 (99.53).
  • Massive Compute Savings: GRPO-DT needs roughly $8 \times 256$ gradient updates per outer iteration compared to $256 \times 300$ for ODT and ODT+TD3—nearly two orders of magnitude less optimization compute.

Limitations and Future Work

  • Sample Efficiency Trade-off: While GRPO-DT uses far fewer gradient updates, on-policy methods cannot endlessly recycle old replay-buffer experiences like off-policy TD3 or IQL. Consequently, GRPO-DT requires several to tens of times more online environment interactions.
  • Resetting Constraints: Standard GRPO-DT assumes you can reset simulator states to arbitrary points to generate consistent rollout groups. While their Q-guided variant bypasses this for real-world scenarios where resetting is impossible, it reintroduces an auxiliary TD3 critic network.
  • Critic Fragility in PPO-DT: PPO-DT fails completely on certain tasks (scoring 0.19 on Door-cloned and 0.00 on AntMaze-umaze), where poor initial rollouts and bad value-critic estimates trap the agent in a negative feedback loop—further motivating GRPO-DT's critic-free design.
  • Future Directions: Scaling DT-based foundation agents further via pure RL-driven post-training.

Summary updated

Abstract

Decision Transformers (DTs) have emerged as a powerful framework for sequential decision making by formulating offline reinforcement learning (RL) as a sequence modeling problem. However, extending DTs to online settings with pure RL gradients remains largely unexplored, as existing approaches continue to rely heavily on supervised sequence-modeling objectives during online finetuning. We identify hindsight return relabeling---a standard component in online DTs---as a critical obstacle to RL-based finetuning: while beneficial for supervised learning, it is fundamentally incompatible with importance sampling-based RL algorithms such as GRPO, leading to unstable training. Building on this insight, we propose new algorithms that enable online finetuning of Decision Transformers using pure reinforcement learning gradients. We adapt GRPO to DTs and introduce several key modifications, including sub-trajectory optimization for improved credit assignment, sequence-level likelihood objectives for enhanced stability and efficiency, and active sampling to encourage exploration in uncertain regions. Through extensive experiments, we demonstrate that our methods outperform existing online DT baselines and achieve new state-of-the-art performance across multiple benchmarks, highlighting the effectiveness of pure-RL-based online finetuning for DTs.
BibTeX
@inproceedings{luo2026online,
  author = {Junkai Luo and Yinglun Zhu},
  title = {{Online Finetuning Decision Transformers with Pure RL Gradients}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=lKf0a3wiQx},
}

Loading related content...

Figure