Manuscript Offprint

arXiv:2608.25683

psRL: Efficient Training for Agentic AI via Training-Time Prefix Sharing

Mianjie Yu, Zizhao Mo, Huanyu Qu, Zhirong Qian, Huanle Xu, Cen Li, Zifeng Zhao, Zhi Zhou, Jinhua Zhou, Jun Xie, Chengzhong Xu

Abstract

In modern agentic AI training, the system bottleneck is shifting from rollout to update. Emerging sampling strategies such as tree-structured and step-wise RL greatly increase training sample volume while incurring relatively low marginal rollout cost, causing the update phase to dominate the end-to-end execution time. Crucially, this shift exposes a new optimization opportunity, as production traces reveal substantial prefix redundancy across training samples.

In this paper, we propose psRL (prefix sharing for RL), a new training system for agentic AI designed to exploit prefix redundancy among training samples. Leveraging the global visibility and data immutability inherent to the update phase, psRL achieves efficient workload scheduling and memory management for distributed training. Specifically, psRL introduces two novel prefix-sharing mechanisms that enable flexible, fine-grained workload distribution across GPU workers, simultaneously optimizing prefix reuse and achieving load balancing. Moreover, psRL implements a new underlying KV cache manager that facilitates adaptable block-size allocation and dynamic KV caching, maximizing memory utilization while maintaining a high prefix hit rate. Evaluations using production traces demonstrate that psRL outperforms existing systems by up to 5.2×5.2\times in throughput. The source code will be publicly available soon.

1 Introduction

Agentic AI has fundamentally enhanced the reasoning capabilities of Large Language Models (LLMs), enabling them to tackle intricate tasks [1, 2, 7, 12, 28, 46, 60, 63]. Their efficiency stems primarily from advanced Reinforcement Learning (RL) [33, 34, 36, 52]. A standard RL training pipeline comprises three distinct phases: rollout, reward, and update. In the rollout phase, the model interacts with an environment to generate sequences, or trajectories, for a specific task. Subsequently, the reward phase evaluates action quality, assigning scalar scores to these trajectories. Finally, the update phase leverages the generated samples and corresponding reward signals to refine model parameters via gradient descent.

Under traditional linear, trajectory-wise sampling, autoregressive generation dominates end-to-end cost, positioning rollout latency as the primary optimization target. In modern RL training, however, the system bottleneck is shifting from rollout to update due to a rapidly changing workload landscape. Specifically, to improve sample diversity and mitigate reward sparsity, recent RL pipelines have increasingly adopted tree-structured sampling strategies [13, 15, 17, 21] and step-wise RL [8, 11, 25, 40, 45], where parallel exploration is launched from shared decision prefixes. While these approaches significantly increase the number of training samples derived from a single trajectory and often enhance convergence quality—for instance, in industrial Digital Twin Network (DTN) operations agent, step-wise RL achieves nearly 2×2\times higher convergence performance than linear trajectory-wise RL—they expand the solution space and training sample volume at low marginal rollout cost, yet introduce a severe and often overlooked system overhead. Our analysis of production workloads and internal benchmarks reveals a fundamental shift in the bottleneck: update overhead has grown by more than 5×5\times and now accounts for over 50% of end-to-end RL training time, dominating overall system latency.

Fortunately, this algorithmic shift conceals a significant optimization opportunity: generated training samples exhibit high prefix redundancy. This phenomenon is intrinsic to the sampling methodologies themselves. In tree-structured RL, multiple parallel branches diverge from a common parent node, resulting in distinct samples sharing identical extensive prefixes. Similarly, step-wise RL creates a recursive data dependency, where a sample at step t essentially encompasses the token sequence of step t-1. Our analysis of both open-source and industrial production traces reveals that prefix matching rates frequently exceed 90% in agentic workloads. This indicates that current training systems [27, 32, 56] treating samples as isolated sequences incur massive waste by repeatedly calculating and storing identical data segments.

Drawing inspiration from the success of prefix sharing in inference systems [19, 22, 50, 59], we propose to adapt and extend these primitives to the training domain. However, realizing this optimization within existing infrastructures presents two primary challenges. First, efficient workload scheduling requires increasing the prefix match rate while simultaneously achieving load balancing—a fundamentally difficult combination. Disparities in workload across micro-batches, driven by varying sequence lengths and the extent of prefix sharing, introduce severe pipeline bubbles.

†^{\dagger}Corresponding authors: Huanle Xu (huanlexu@um.edu.mo) and Chengzhong Xu (czxu@um.edu.mo).

Second, traditional memory management poses a critical bottleneck. Allocating KV states with fixed-size blocks fundamentally mismatches the highly variable lengths of reused prefixes, forcing a strict trade-off between memory access overhead and memory consumption overhead. Moreover, existing caching policies struggle to balance minimizing the KV state footprint with maintaining a high prefix hit rate.

In this paper, we introduce psRL to enable effective prefix sharing and address the challenges in agentic RL training. The architecture of psRL leverages a fundamental characteristic of training: the training phase exhibits two key properties—Global Visibility and Data Immutability. Since the entire input dataset is known upfront and its distribution remains static within each iteration, psRL unlocks a broad design space for optimization across the system stack.

To tackle the challenges of workload scheduling, psRL proposes two novel prefix-sharing mechanisms: inter-batch and self-sequence sharing. Inter-batch sharing allows sequences with shared prefixes to be distributed across different micro-batches while reusing the computed KV states, thereby providing high scheduling flexibility. Self-sequence sharing partitions a single long sequence into multiple contiguous chunks assigned to different micro-batches. By ensuring that suffix tokens reuse the KV states of prefix tokens, this mechanism facilitates fine-grained distribution of the computational load. Building on these two mechanisms, psRL implements a hierarchical workload distribution strategy. Globally, psRL constructs semantic groups consolidating sequences with identical prefixes, employing efficient algorithms to partition them into evenly distributed workloads across training workers. Within each worker, psRL utilizes token-wise micro-batching to slice sequences at the token level, significantly reducing pipeline bubbles caused by internal workload imbalances.

psRL also designs an adaptive KV cache manager with two new mechanisms that effectively overcome the bottlenecks of traditional memory management. Specifically, the Adaptive Block Allocation mechanism allocates variable-sized contiguous memory blocks via analyzing the precise lengths of shared prefixes, thereby eradicating internal fragmentation [19, 59] and improving memory access efficiency. Furthermore, to reduce the KV cache memory footprint while maintaining a high prefix sharing rate, the Dynamic Block Caching mechanism employs a strict Just-in-Time policy. By analyzing the prefix tree constructed during rollout, this policy proactively caches KV blocks required for future operations and promptly evicts unreferenced blocks, maximizing system throughput and computational efficiency.

We implement psRL on top of veRL [38], with the primary modifications made to Megatron-LM [27], the underlying training engine used in the RL update phase. Notably, we extend the scope of our prefix sharing and optimization to accelerate the reference model forward passes and the computation of old policy log-probabilities, both of which are critical in RL pipelines. We also conduct evaluations using real-world production traces from industry agentic workloads, comparing psRL against state-of-the-art training systems. Experimental results demonstrate that psRL achieves up to 5.2×5.2\times improvement in training throughput. To summarize, we have made the following contributions in this paper:

• We identify the fundamental shift in Agentic AI training towards update-bound workloads and quantitatively demonstrate the high prefix redundancy inherent in tree-structured and step-wise RL.

• We design two novel prefix-sharing mechanisms that enable flexible, fine-grained workload distribution across GPU workers, simultaneously optimizing prefix reuse and achieving load balancing.

• We implement a new underlying KV cache manager that facilitates adaptable block-size allocation and dynamic KV caching, maximizing memory utilization while maintaining a high prefix hit rate.

References (44)