Abstract
Deep reinforcement learning (RL) models are notoriously slow to train, yet their performance bottlenecks differ significantly from supervised learning (SL). While SL is typically GPU-bound, RL workloads are often limited by CPU-side simulation, high-level language logic, and frequent transitions between Python and C++. We present RL-Scope, a novel cross-stack profiler designed to accurately identify these bottlenecks by mapping low-level resource usage to high-level algorithmic phases. RL-Scope automatically corrects for profiling overhead, revealing that standard tools like nvidia-smi can be highly misleading in RL contexts. Our evaluation shows that language transitions and API calls often dominate training time, with "Eager" execution modes being up to 4.8× slower than compiled "Graph" modes.
The Challenge of Profiling RL
Standard machine learning profilers are optimized for supervised learning, where the primary task is streaming large datasets to the GPU. In contrast, RL involves a complex, iterative loop where the CPU must simulate environments, execute policy logic, and manage data buffers before passing small batches to the neural network.
Existing tools often fail to capture these CPU-centric bottlenecks and introduce significant "book-keeping" overhead, which can inflate training time by nearly 2×. This leads developers to optimize GPU kernels when the real bottleneck lies in the simulator or the framework's internal API overhead.
RL-Scope Methodology
RL-Scope addresses these issues through four key techniques:
- Algorithmic Annotations: Developers use Python
withblocks to label phases likesimulationorinference. - Transparent Interception: Using
LD_PRELOADhooks, the tool intercepts transitions between Python and C++ backends and CUDA API calls without requiring code recompilation. - Cross-Stack Overlap Analysis: The tool calculates the precise overlap between CPU and GPU activity, scoped to specific algorithmic phases.
- Overhead Calibration: RL-Scope measures its own instrumentation overhead and subtracts it from the final results, reducing profiling bias from ~90% to within ±16%.
Key Results and Insights
Our evaluation across various algorithms (DQN, PPO, SAC, etc.) and frameworks (TensorFlow, PyTorch) yielded several critical insights into RL performance.
The "Eager" Execution Penalty
A major finding is the high cost of developer-friendly "Eager" execution modes. As shown in the performance breakdown, Eager modes in both TensorFlow and PyTorch suffer from significant Python-to-Backend transition overhead.
For example, in the TD3 algorithm, PyTorch Eager is 2.3× faster than TensorFlow Eager because it minimizes these transitions more effectively. Converting TensorFlow code to "Autograph" or "Graph" mode can reduce Python-bound time from nearly 60% to under 8%.
The Illusion of GPU Utilization
RL-Scope reveals that standard metrics like nvidia-smi are often deceptive. In the Minigo (AlphaGoZero) workload, nvidia-smi reported 100% GPU utilization. However, RL-Scope's fine-grained tracing showed that the GPU was actually executing kernels for only 20 seconds out of over 5,000 seconds of training. The rest of the time was spent on CPU-side CUDA API calls and data preparation.
Conclusion
RL-Scope provides the first comprehensive view of the RL software stack, from high-level Python logic down to low-level GPU kernels. By identifying that RL is primarily CPU-bound and limited by framework overhead rather than compute, it enables developers to focus optimization efforts where they matter most. Future work includes extending these capabilities to distributed RL clusters.
Summary updated