Abstract
The training, testing, and deployment of autonomous vehicles requires realistic and efficient simulators. Moreover, because of the high variability between different problems presented in different autonomous systems, these simulators need to be easy to use and easy to modify. To address these problems, we introduce TorchDriveSim and its benchmark extension TorchDriveEnv. TorchDriveEnv is a lightweight reinforcement learning benchmark programmed entirely in Python, which can be modified to test a number of different factors in learned vehicle behavior, including the effect of varying kinematic models, agent types, and traffic control patterns. Most importantly, unlike many replay-based simulation approaches, TorchDriveEnv is fully integrated with a state-of-the-art behavioral simulation API. This allows users to train and evaluate driving models alongside data-driven Non-Playable Characters (NPCs) whose initializations and driving behavior are reactive, realistic, and diverse. We illustrate the efficiency and simplicity of TorchDriveEnv by evaluating common reinforcement learning baselines in both training and validation environments. Our experiments show that TorchDriveEnv is easy to use but difficult to solve.
1. Introduction
Training autonomous vehicles (AVs) in real-world settings is fraught with safety risks and high costs, necessitating robust simulation environments. However, researchers often face a "Goldilocks" dilemma with current simulators: high-fidelity platforms like CARLA are computationally intensive and difficult to customize, while lightweight alternatives often rely on "zombie" NPCs that follow rigid, non-reactive paths. Furthermore, the lack of differentiability in many existing simulators prevents the use of gradient-based optimization through the simulation itself. TorchDriveEnv addresses these issues by providing a fast, Python-native, and differentiable 2D environment where traffic agents exhibit realistic, reactive human-like behaviors.
2. System Architecture
The framework consists of two primary layers:
- TorchDriveSim: A 2D simulation engine built natively in PyTorch. Its differentiable nature allows for gradient propagation through the entire computation graph, from kinematic transitions to rendering. It supports efficient batch processing, which is critical for high-throughput reinforcement learning (RL) training.
- TorchDriveEnv: An RL benchmark extension that adheres to the Gymnasium standard. This ensures compatibility with popular RL libraries such as Stable Baselines3, facilitating "plug-and-play" experimentation.
3. Reactive NPC Simulation
A distinguishing feature of TorchDriveEnv is its integration with a behavioral simulation API. Unlike traditional simulators that simply replay recorded traffic data, TorchDriveEnv utilizes generative models (based on conditional diffusion) to control NPCs. During both initialization and runtime, the environment queries these models to ensure NPCs react dynamically to the ego vehicle's actions. This reactivity prevents the "zombie" behavior common in simpler simulators and provides a more authentic challenge for learning agents.
4. Benchmark Scenarios and Datasets
The benchmark leverages road maps from the CARLA simulator, re-rendered into a lightweight 2D bird's-eye view (BEV) format. The scenarios are categorized into training and validation sets to test both core driving capabilities and out-of-distribution generalization.
Training scenarios include diverse road geometries such as highways and roundabouts. Validation scenarios introduce specific challenges like navigating around parked vehicles, yielding at three-way intersections, and handling oncoming traffic in "chicken" scenarios.
5. Experimental Results
The authors evaluated four standard RL algorithms: SAC, PPO, TD3, and A2C. Key findings include:
- The Multi-Agent Challenge: Learning in environments with reactive NPCs is significantly more difficult than in single-agent settings. Survival horizons are markedly lower when agents must contend with dynamic traffic.
- Generalization Gap: Agents trained in isolation (single-agent) fail when introduced to multi-agent traffic. Conversely, training with reactive NPCs improves generalization to simpler scenarios.
- Performance Baselines: SAC and PPO emerged as the most robust performers. However, even the best agents maintained non-trivial collision and infraction rates, indicating that the benchmark remains a significant challenge for current RL methods.
6. Conclusion and Future Work
TorchDriveEnv provides a lightweight yet challenging platform for AV research. While its 2D BEV focus precludes 3D sensor modeling, it offers a high-fidelity behavioral environment for planning and control. Future work will explore constrained RL to minimize infractions and the integration of imitation learning baselines using human expert data.
Summary updated