How toni-sm/skrl works
1. What this repo is
- skrl is a Python reinforcement learning library organized as a modular package.
- The architecture is intentionally split by execution backend: PyTorch, JAX, and NVIDIA Warp. Most major abstractions exist in each backend-specific subtree.
2. Top-level execution pipeline
- The core flow is: environment wrapper/loaders → trainer → agent → model/resources → memory/logging.
- Trainers drive the interaction loop, agents implement learning algorithms, and models provide policy/value function approximators. Memories buffer experience for off-policy or batched updates.
3. Agent subsystem
- skrl/agents/{torch,jax,warp} contains the main single-agent algorithms.
- Torch has the widest algorithm coverage: A2C, AMP, CEM, DDPG, DDQN, DQN, PPO, Q-learning, RPO, SAC, SARSA, TD3, TRPO, plus recurrent variants for some methods.
- JAX and Warp expose a smaller but parallel set of core algorithms, reflecting backend maturity and scope.
4. Multi-agent subsystem
- skrl/multi_agents/{torch,jax} adds coordinated training for multiple agents.
- The main algorithms are IPPO and MAPPO, which sit beside the single-agent APIs rather than replacing them.
- This is the key boundary for environments that expose multiple controlled entities or shared/partitioned scopes.
5. Environment integration layer
- skrl/envs/wrappers and skrl/envs/loaders are the adaptation boundary between the library and external simulators.
- Supported integrations include Gym, Gymnasium, PettingZoo, ManiSkill, Isaac Lab, and MuJoCo Playground.
- Wrappers normalize observations/actions/dones/infos into backend-specific tensor formats; loaders handle environment construction and configuration, especially for Isaac Lab and Playground.
6. Model subsystem
- skrl/models/{torch,jax,warp} provides backend-specific policy/value model classes.
- The library distinguishes common action-distribution styles: deterministic, Gaussian, categorical, multicategorical, multivariate Gaussian, and tabular models.
- These models are the learnable interface consumed by agents; they are not tied to a single environment type.
7. Resources: shared training components
- skrl/resources contains reusable training utilities that algorithms plug into:
- noises for exploration,
- preprocessors such as running standardization,
- schedulers such as KL-adaptive control,
- optimizers where backend-specific implementations are needed.
- This keeps algorithm code focused on learning logic while cross-cutting concerns remain reusable.
8. Memory subsystem
- skrl/memories/{torch,jax,warp} implements experience storage, with a random/replay-style memory being the primary reusable component.
- Memory is the bridge between online environment rollout and gradient updates, especially for off-policy algorithms like DDPG, TD3, SAC, and DQN variants.
9. Training orchestration
- skrl/trainers/{torch,jax,warp} contains the execution controllers: sequential, parallel, and step-based trainers depending on backend.
- Trainers own the rollout/update schedule, coordinate agent calls, and mediate interactions with environments and memories.
- This is the main boundary for “how the system runs” versus “what the algorithm does.”
10. Utility layer
- skrl/utils provides glue code: distributed launching, model instantiation helpers, spaces handling, postprocessing, tensorboard support, huggingface integration, and a small Warp framework utility layer.
- runner and model_instantiators are especially important because they convert high-level configuration into runnable backend objects.
11. Examples as integration references
- examples/ is organized by environment family: Gym, Gymnasium, Isaac Lab, ManiSkill, Playground, Shimmy, and real-world robot setups.
- The examples show the architecture in practice: an environment adapter, a chosen backend, an agent, and a trainer bound together for a specific task.
12. Testing and quality gates
- tests/ mirrors the library structure by backend and subsystem, which is a strong sign of the intended architecture boundaries.
- GitHub Actions run separate test matrices for torch, jax, and warp, plus pre-commit checks, reinforcing backend isolation and contract stability.
13. Documentation and packaging
- docs/ is a full Sphinx documentation site with API pages organized by subsystem, plus runnable snippets.
- The repository is packaged as a Python distribution via pyproject.toml, with PyPI publishing and Read the Docs integration; these are delivery concerns, not runtime dependencies.
14. Key architectural takeaway
- The repo is a backend-agnostic RL framework with backend-specific implementations.
- The main diagram should show shared conceptual layers—environments, trainers, agents, models, memories, and resources—replicated across Torch/JAX/Warp, with wrappers/loaders as the adapter boundary to external simulators and examples/tests/docs as supporting surfaces.
Main entry points: tests Tests · wrappers Env wrappers · examples Examples · torch Torch agents
Components 18
Core RL
Main runtime and learning subsystems
- Multi-agents · IPPO and MAPPO for multi-entity training
skrl/multi_agents - Resources · Exploration noise, preprocessing, schedulers, and backend-specific optimizers
skrl/resources
Backends
Backend-specific implementations replicated across Torch, JAX, and Warp
- Torch trainers · Sequential, parallel, and step-based training loops for PyTorch
skrl/trainers/torch - JAX trainers · Sequential and step-based training loops for JAX
skrl/trainers/jax - Warp trainers · Sequential training loop for Warp
skrl/trainers/warp - Torch agents · Broad algorithm set including PPO, SAC, TD3, DQN, TRPO, and recurrent variants
skrl/agents/torch - JAX agents · Core single-agent algorithms ported to JAX
skrl/agents/jax - Warp agents · Warp implementations of the main policy-gradient and off-policy agents
skrl/agents/warp - Models · Backend-specific model families for deterministic, Gaussian, categorical, multicategorical, multivariate Gaussian, and tabular policies
skrl/models - Memories · Replay and random memory implementations bridging rollout and updates
skrl/memories
Integration
Environment adapters and example entrypoints
- Env wrappers · Normalizes external simulators into backend-ready environment interfaces
skrl/envs/wrappers - Env loaders · Builds configured environments for simulator-specific integrations
skrl/envs/loaders - Examples · Task-oriented runnable references spanning Gym, Gymnasium, Isaac Lab, ManiSkill, Playground, Shimmy, and real-world setups
examples
Support
Reusable utilities, docs, and quality gates
- Runner utils · Configuration-to-runtime helpers for starting backend training jobs
skrl/utils/runner - Model instantiators · Builds backend-specific model objects from configuration
skrl/utils/model_instantiators - Spaces utils · Handles action and observation space translation across backends
skrl/utils/spaces - Docs · Sphinx API and usage documentation
docs - Tests · Backend-separated tests for agents, env wrappers, trainers, multi-agents, utilities, and configs
tests
Connections 35
- Env wrappers → Torch trainers: torch env API · Produces environment interfaces consumed by Torch training loops
- Env wrappers → JAX trainers: jax env API · Produces environment interfaces consumed by JAX training loops
- Env wrappers → Warp trainers: warp env API · Produces environment interfaces consumed by Warp training loops
- Env loaders → Env wrappers: builds · Constructs supported simulator environments before wrapping them
- Torch trainers → Torch agents: drives · Coordinates rollout and update cycles for Torch agents
- JAX trainers → JAX agents: drives · Coordinates rollout and update cycles for JAX agents
- Warp trainers → Warp agents: drives · Coordinates rollout and update cycles for Warp agents
- Torch agents → Models: uses · Consumes Torch models as policy/value approximators
- JAX agents → Models: uses · Consumes JAX models as policy/value approximators
- Warp agents → Models: uses · Consumes Warp models as policy/value approximators
- Torch agents → Memories: stores experience · Uses replay or random memory for batched/off-policy updates
- JAX agents → Memories: stores experience · Uses replay or random memory for batched/off-policy updates
- Warp agents → Memories: stores experience · Uses replay or random memory for batched/off-policy updates
- Multi-agents → Models: uses · Shares the same model interface for coordinated policies
- Multi-agents → Memories: stores experience · Buffers multi-agent rollouts for coordinated updates
- Resources → Torch agents: supports · Provides noise, preprocessing, and schedule utilities used by algorithms
- Resources → JAX agents: supports · Provides noise, preprocessing, and schedule utilities used by algorithms
- Resources → Warp agents: supports · Provides noise, preprocessing, and schedule utilities used by algorithms
- Runner utils → Torch trainers: launches · Turns configuration into runnable Torch training jobs
- Runner utils → JAX trainers: launches · Turns configuration into runnable JAX training jobs
- Runner utils → Warp trainers: launches · Turns configuration into runnable Warp training jobs
- Model instantiators → Models: constructs · Builds backend-specific model instances from config
- Spaces utils → Env wrappers: adapts spaces · Helps normalize observation and action spaces for wrappers
- Examples → Env wrappers: demonstrates · Shows environment adaptation in runnable tasks
- Examples → Torch trainers: demonstrates · Shows Torch execution patterns in practice
- Examples → JAX trainers: demonstrates · Shows JAX execution patterns in practice
- Examples → Warp trainers: demonstrates · Shows Warp execution patterns in practice
- Docs → Examples: documents · Explains usage through API pages and snippets
- Tests → Torch agents: verifies · Covers Torch agent contracts and algorithm behavior
- Tests → JAX agents: verifies · Covers JAX agent contracts and algorithm behavior
- Tests → Warp agents: verifies · Covers Warp agent contracts and algorithm behavior
- Tests → Torch trainers: verifies · Covers Torch training loop behavior
- Tests → JAX trainers: verifies · Covers JAX training loop behavior
- Tests → Warp trainers: verifies · Covers Warp training loop behavior
- Tests → Env wrappers: verifies · Covers adapter behavior across supported simulators