TL;DR
This paper introduces SRT, a novel method to significantly speed up reinforcement learning (RL) for large language models (LLMs) by using a cache of past generated sequences to perform speculative decoding. This approach reduces training time and cost without compromising the correctness of the RL process, achieving up to 2.08x speedup.
What Problem Does This Paper Address?
Training large language models with reinforcement learning (RL) is crucial for tasks requiring complex reasoning and interaction. However, a major bottleneck in this process is the "rollout" phase, where the model generates responses to prompts. This phase can consume over 70% of the total training time. This inefficiency stems from the auto-regressive nature of token generation and the "long-tail" distribution of response lengths, where a few very long responses can stall entire batches of computations, leaving valuable GPU resources idle. Existing methods to mitigate this often sacrifice the "on-policy" nature of the training, which can lead to convergence issues.
Methods
SRT tackles this problem by introducing a Speculative Rollout with Tree-Structured Cache (SRT). The core idea is to leverage the observation that for the same prompt, subsequent training steps often generate similar continuations.
Here's how it works:
- Per-Prompt Tree-Structured Cache: For each unique prompt, SRT maintains a cache (
Tp) that stores previously generated token subsequences in a tree structure. Each node in the tree represents a context (a sequence of tokens), and edges represent the next possible tokens. This cache is model-free and can be stored in CPU memory. - Speculative Decoding: During the rollout phase, instead of generating tokens one by one with the current policy, SRT uses the tree-structured cache as a "draft model." It greedily assembles a sequence of "draft tokens" that are likely to be accepted based on the cache's historical data. The current policy then verifies these draft tokens. If the draft is correct, multiple tokens are accepted in a single step. If a mismatch occurs, decoding reverts to standard generation from that point. This ensures that the on-policy distribution is preserved.
- Cache Maintenance: To keep the cache fresh and improve draft quality, SRT employs two strategies:
- Online Updates: Tokens generated during ongoing rollouts are immediately inserted into the cache, benefiting subsequent rollouts within the same batch and across training steps.
- Run-Ahead Generation: During idle GPU "bubbles" (when some computations finish early), SRT proactively generates rollouts for future prompts and inserts them into the cache. These run-ahead tokens are never used for learning but serve as valuable hints for future speculative decoding.
SRT is designed to be integrated into standard RL pipelines like PPO, GRPO, and DAPO, and also works in multi-turn settings.
Datasets
The paper mentions using the following datasets for evaluation:
- Math dataset (for PPO and GRPO)
- DAPO-Math-17k dataset (for DAPO and ReTool)
The models used were Qwen2.5-1.5B.
Key Insights and Ideas
- Exploiting Rollout Similarity: The fundamental insight is that LLM rollouts for the same prompt are not entirely random; they exhibit significant empirical similarity across training steps. This redundancy is a prime target for optimization.
- Cache as a "Draft Model": Using a tree-structured cache of past rollouts as a draft model for speculative decoding is a novel way to accelerate generation without needing a separate, smaller draft model.
- Proactive Cache Enrichment: The combination of online updates and run-ahead generation is crucial. It ensures the cache is not just a static history but a dynamic, actively maintained resource that continuously improves draft quality.
- On-Policy Correctness: A key achievement is that SRT accelerates training without sacrificing the on-policy nature of RL, which is critical for stable and correct learning.
Key Results
- Significant Speedup: SRT achieves up to 2.08x wall-clock time speedup during the rollout phase.
- Reduced Latency and Cost: The method consistently reduces generation and step latency, leading to lower per-token inference costs.
- Broad Applicability: SRT demonstrates effectiveness across various standard RL algorithms (PPO, GRPO, DAPO) and in multi-turn scenarios (ReTool).
- Improved Accepted Tokens: In ablation studies, SRT (especially with run-ahead generation) significantly increases the mean number of accepted tokens per decoding step compared to a history-only baseline.
Limitations and Future Work
- Cache Size and Management: While the paper doesn't explicitly detail limitations related to cache size, managing a per-prompt cache for a large number of unique prompts could become a memory challenge. Future work might explore more sophisticated cache eviction or compression strategies.
- Cold-Start Mitigation: While SRT's online updates and run-ahead generation help mitigate cold-start issues compared to purely offline caching, the initial performance might still be suboptimal until the cache is sufficiently populated.
- Generalization to Diverse Tasks: The experiments focus on mathematical reasoning tasks. Further exploration into the effectiveness of SRT on a wider range of RL tasks for LLMs would be valuable.
The authors suggest that SRT offers a practical and efficient path to scaling RL for LLMs, implying that further research could build upon this framework for even greater efficiency gains.
Summary updated