Is Mamba Compatible with Trajectory Optimization in Offline Reinforcement Learning?

Yang Dai, Oubo Ma, Longfei Zhang, Xingxing Liang, Shengchao Hu, Mengzhu Wang, Shouling Ji, Jincai Huang, Li Shen · DOI

Introduction

In recent years, the paradigm of Offline Reinforcement Learning (RL) has shifted toward "Trajectory Optimization," where the RL problem is reframed as a sequence modeling task. This approach, popularized by the Decision Transformer (DT), leverages the power of self-attention to predict future actions based on historical sequences of states, actions, and rewards-to-go. However, the Transformer architecture brings significant computational overhead due to its quadratic scaling with sequence length and high parameter counts, which pose challenges for deployment on resource-constrained hardware.

This paper investigates whether Mamba, a selective State Space Model (SSM) known for linear-time scaling and high efficiency in natural language processing, can be effectively adapted for trajectory optimization. The researchers introduce Decision Mamba (DeMa), a streamlined architecture that achieves state-of-the-art performance in offline RL benchmarks while significantly reducing the model's footprint.

Methodology

Decision Mamba (DeMa) replaces the multi-head attention layers of the Decision Transformer with Mamba blocks. During development, the authors identified several critical design choices necessary to optimize Mamba for the RL domain:

1. Temporal Concatenation (B3LD)

The researchers compared two methods for feeding data into the model: BL3D (concatenating state, action, and reward in the embedding dimension) and B3LD (concatenating them temporally as separate tokens). They found that temporal concatenation is superior, as it allows the model's selective mechanism to distinguish between different data types and perform more granular credit assignment.

2. Redundancy of Position Embeddings

Unlike Transformers, which are permutation-invariant and require position embeddings to understand sequence order, Mamba is inherently recurrent. The authors demonstrated that adding position embeddings to DeMa not only increases parameter count but actually degrades performance. Consequently, DeMa operates without explicit positional encoding.

3. Sliding-Window Trajectories

While Mamba is capable of processing extremely long sequences, the authors found that a "Transformer-like" approach—using truncated, sliding-window sequences—performed better than feeding in entire trajectories. This suggests that the most relevant information for decision-making in standard RL tasks remains localized within a specific temporal window.

Experimental Results

DeMa was evaluated against the Decision Transformer and other baselines across standard benchmarks, including Atari 1% DQN-replay datasets and MuJoCo (D4RL) locomotion tasks.

Performance and Efficiency

  • Atari: DeMa achieved an average score of 111.8, more than doubling the performance of the Decision Transformer (62.2). Crucially, it achieved this while using 30% fewer parameters and reducing Multiply-Accumulate operations (MACs) from 12.1G to 8.8G.
  • MuJoCo: In locomotion tasks, DeMa matched or exceeded DT's performance with a staggering 75% reduction in parameters. In these environments, MACs were reduced from 2.5G to just 0.7G, highlighting DeMa's suitability for edge computing.

Hidden Attention Mechanism

A key contribution of the paper is the analysis of Mamba’s S6 layer as a "hidden attention" mechanism. The researchers observed that this mechanism exhibits an exponential decay, naturally focusing on recent tokens. This "forgetting" property aligns with the Markovian nature of many RL tasks, where the immediate past is more informative than distant history. Ablation studies confirmed that these hidden attention weights are highly specialized to specific tasks; zeroing them out leads to a total collapse in performance.

Discussion and Limitations

Decision Mamba proves that the selective SSM architecture is not only compatible with trajectory optimization but is often superior to Transformers in terms of efficiency and parameter density. By leveraging "hidden attention," DeMa performs effective credit assignment without the quadratic cost of standard attention.

However, the authors note that further research is required in specific areas:

  • POMDPs: The model's performance in Partially Observable Markov Decision Processes, which require longer-term memory, remains an open question.
  • Interpretability: While hidden attention provides some insight, the causal relationship between Mamba’s internal state and its output requires more robust explanatory tools.
  • Generalization: Future work should explore DeMa's capabilities in multi-task learning and online fine-tuning.

Conclusion

Decision Mamba (DeMa) represents a significant step toward "Green AI" in reinforcement learning. By delivering high performance with a fraction of the computational and memory requirements of Transformers, DeMa opens new possibilities for deploying sophisticated RL agents on robots, drones, and other hardware where efficiency is paramount.

Summary updated

BibTeX
@inproceedings{dai2024is,
  author = {Yang Dai and Oubo Ma and Longfei Zhang and Xingxing Liang and Shengchao Hu and Mengzhu Wang and Shouling Ji and Jincai Huang and Li Shen},
  title = {{Is Mamba Compatible with Trajectory Optimization in Offline Reinforcement Learning?}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=yWSxjlFsmX},
}
Figure