Harryis commited on
Commit
358dd8b
·
verified ·
1 Parent(s): dd58921

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. cleanrl/docs/benchmark/ppo_atari_multigpu_runtimes.md +5 -0
  2. cleanrl/docs/benchmark/ppo_continuous_action.md +11 -0
  3. cleanrl/docs/benchmark/ppo_envpool.md +5 -0
  4. cleanrl/docs/benchmark/ppo_envpool_runtimes.md +5 -0
  5. cleanrl/docs/benchmark/ppo_procgen.md +5 -0
  6. cleanrl/docs/benchmark/sac.md +8 -0
  7. cleanrl/docs/benchmark/td3.md +8 -0
  8. cleanrl/docs/get-started/CleanRL_Huggingface_Integration_Demo.ipynb +0 -0
  9. cleanrl/docs/rl-algorithms/c51.md +354 -0
  10. cleanrl/docs/rl-algorithms/ddpg.md +375 -0
  11. cleanrl/docs/rl-algorithms/dqn.md +396 -0
  12. cleanrl/docs/rl-algorithms/ppg.md +158 -0
  13. cleanrl/docs/rl-algorithms/ppo-isaacgymenvs.md +259 -0
  14. cleanrl/docs/rl-algorithms/ppo-rnd.md +111 -0
  15. cleanrl/docs/rl-algorithms/ppo-trxl.md +184 -0
  16. cleanrl/docs/rl-algorithms/ppo/ppo_atari_envpool_xla_jax/atari_hns.md +59 -0
  17. cleanrl/docs/rl-algorithms/ppo/ppo_atari_envpool_xla_jax/atari_returns.md +59 -0
  18. cleanrl/docs/rl-algorithms/ppo/ppo_atari_envpool_xla_jax/hms_each_game.svg +0 -0
  19. cleanrl/docs/rl-algorithms/ppo/ppo_atari_envpool_xla_jax/hns_ppo_vs_baselines.svg +0 -0
  20. cleanrl/docs/rl-algorithms/ppo/ppo_atari_envpool_xla_jax/hns_ppo_vs_baselines2.svg +0 -0
  21. cleanrl/docs/rl-algorithms/ppo/ppo_atari_envpool_xla_jax/hns_ppo_vs_r2d2.svg +0 -0
  22. cleanrl/docs/rl-algorithms/ppo/ppo_atari_envpool_xla_jax/runset_0_hms_bar.svg +0 -0
  23. cleanrl/docs/rl-algorithms/ppo/ppo_atari_envpool_xla_jax/runset_1_hms_bar.svg +0 -0
  24. cleanrl/docs/rl-algorithms/rpo.md +389 -0
  25. cleanrl/docs/rl-algorithms/sac.md +413 -0
  26. cleanrl/docs/rl-algorithms/td3.md +260 -0
  27. cleanrl/docs/stylesheets/extra.css +6 -0
  28. cleanrl/envs/__init__.py +4 -0
  29. cleanrl/envs/common.py +11 -0
  30. cleanrl/requirements/requirements-atari.txt +295 -0
  31. cleanrl/requirements/requirements-cloud.txt +291 -0
  32. cleanrl/requirements/requirements-dm_control.txt +315 -0
  33. cleanrl/requirements/requirements-docs.txt +365 -0
  34. cleanrl/requirements/requirements-envpool.txt +309 -0
  35. cleanrl/requirements/requirements-jax.txt +358 -0
  36. cleanrl/requirements/requirements-memory_gym.txt +180 -0
  37. cleanrl/requirements/requirements-mujoco.txt +275 -0
  38. cleanrl/requirements/requirements-optuna.txt +316 -0
  39. cleanrl/requirements/requirements-pettingzoo.txt +280 -0
  40. cleanrl/requirements/requirements-procgen.txt +287 -0
  41. cleanrl/requirements/requirements.txt +264 -0
  42. cleanrl/runs/Ultrahorizon-v0__ppo_ultrahorizon__1_EASY__1761810199/test_iter_732.json +0 -0
  43. cleanrl/tests/test_atari.py +17 -0
  44. cleanrl/tests/test_atari_gymnasium.py +73 -0
  45. cleanrl/tests/test_atari_jax_gymnasium.py +49 -0
  46. cleanrl/tests/test_atari_multigpu.py +9 -0
  47. cleanrl/tests/test_classic_control.py +9 -0
  48. cleanrl/tests/test_classic_control_gymnasium.py +25 -0
  49. cleanrl/tests/test_classic_control_jax_gymnasium.py +25 -0
  50. cleanrl/tests/test_enjoy.py +25 -0
cleanrl/docs/benchmark/ppo_atari_multigpu_runtimes.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ | | openrlbenchmark/cleanrl/ppo_atari_multigpu ({'tag': ['pr-424']}) |
2
+ |:------------------------|-------------------------------------------------------------------:|
3
+ | PongNoFrameskip-v4 | 276.599 |
4
+ | BeamRiderNoFrameskip-v4 | 280.902 |
5
+ | BreakoutNoFrameskip-v4 | 270.532 |
cleanrl/docs/benchmark/ppo_continuous_action.md ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ | | openrlbenchmark/cleanrl/ppo_continuous_action ({'tag': ['pr-424']}) |
2
+ |:-------------------------------------|:----------------------------------------------------------------------|
3
+ | HalfCheetah-v4 | 1442.64 ± 46.03 |
4
+ | Walker2d-v4 | 2287.95 ± 571.78 |
5
+ | Hopper-v4 | 2382.86 ± 271.74 |
6
+ | InvertedPendulum-v4 | 963.09 ± 22.20 |
7
+ | Humanoid-v4 | 716.11 ± 49.08 |
8
+ | Pusher-v4 | -40.38 ± 7.15 |
9
+ | dm_control/acrobot-swingup-v0 | 25.60 ± 6.30 |
10
+ | dm_control/acrobot-swingup_sparse-v0 | 1.35 ± 0.27 |
11
+ | dm_control/ball_in_cup-catch-v0 | 619.26 ± 278.67 |
cleanrl/docs/benchmark/ppo_envpool.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ | | openrlbenchmark/cleanrl/ppo_atari_envpool_xla_jax ({'tag': ['pr-424']}) | openrlbenchmark/cleanrl/ppo_atari_envpool_xla_jax_scan ({'tag': ['pr-424']}) | openrlbenchmark/cleanrl/ppo_atari_envpool ({'tag': ['pr-424']}) |
2
+ |:-------------|:--------------------------------------------------------------------------|:-------------------------------------------------------------------------------|:------------------------------------------------------------------|
3
+ | Pong-v5 | 20.82 ± 0.21 | 20.52 ± 0.32 | 20.45 ± 0.09 |
4
+ | BeamRider-v5 | 2678.73 ± 426.42 | 2860.61 ± 801.30 | 2501.85 ± 210.52 |
5
+ | Breakout-v5 | 420.92 ± 16.75 | 423.90 ± 5.49 | 211.24 ± 151.84 |
cleanrl/docs/benchmark/ppo_envpool_runtimes.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ | | openrlbenchmark/cleanrl/ppo_atari_envpool_xla_jax ({'tag': ['pr-424']}) | openrlbenchmark/cleanrl/ppo_atari_envpool_xla_jax_scan ({'tag': ['pr-424']}) | openrlbenchmark/cleanrl/ppo_atari_envpool ({'tag': ['pr-424']}) |
2
+ |:-------------|--------------------------------------------------------------------------:|-------------------------------------------------------------------------------:|------------------------------------------------------------------:|
3
+ | Pong-v5 | 34.3237 | 34.701 | 178.375 |
4
+ | BeamRider-v5 | 37.1076 | 37.2449 | 182.944 |
5
+ | Breakout-v5 | 39.576 | 39.775 | 151.384 |
cleanrl/docs/benchmark/ppo_procgen.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ | | openrlbenchmark/cleanrl/ppo_procgen ({'tag': ['pr-424']}) |
2
+ |:----------|:------------------------------------------------------------|
3
+ | starpilot | 30.99 ± 1.96 |
4
+ | bossfight | 8.85 ± 0.33 |
5
+ | bigfish | 16.46 ± 2.71 |
cleanrl/docs/benchmark/sac.md ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ | | openrlbenchmark/cleanrl/sac_continuous_action ({'tag': ['pr-424']}) |
2
+ |:--------------------|:----------------------------------------------------------------------|
3
+ | HalfCheetah-v4 | 9634.89 ± 1423.73 |
4
+ | Walker2d-v4 | 3591.45 ± 911.33 |
5
+ | Hopper-v4 | 2310.46 ± 342.82 |
6
+ | InvertedPendulum-v4 | 909.37 ± 55.66 |
7
+ | Humanoid-v4 | 4996.29 ± 686.40 |
8
+ | Pusher-v4 | -22.45 ± 0.51 |
cleanrl/docs/benchmark/td3.md ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ | | openrlbenchmark/cleanrl/td3_continuous_action ({'tag': ['pr-424']}) | openrlbenchmark/cleanrl/td3_continuous_action_jax ({'tag': ['pr-424']}) |
2
+ |:--------------------|:----------------------------------------------------------------------|:--------------------------------------------------------------------------|
3
+ | HalfCheetah-v4 | 9583.22 ± 126.09 | 9345.93 ± 770.54 |
4
+ | Walker2d-v4 | 4057.59 ± 658.78 | 3686.19 ± 141.23 |
5
+ | Hopper-v4 | 3134.61 ± 360.18 | 2940.10 ± 655.63 |
6
+ | InvertedPendulum-v4 | 968.99 ± 25.80 | 988.94 ± 8.86 |
7
+ | Humanoid-v4 | 5035.36 ± 21.67 | 5033.22 ± 122.14 |
8
+ | Pusher-v4 | -30.92 ± 1.05 | -29.18 ± 1.02 |
cleanrl/docs/get-started/CleanRL_Huggingface_Integration_Demo.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
cleanrl/docs/rl-algorithms/c51.md ADDED
@@ -0,0 +1,354 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Categorical DQN (C51)
2
+
3
+ ## Overview
4
+
5
+ C51 introduces a distributional perspective for DQN: instead of learning a single value for an action, C51 learns to predict a distribution of values for the action. Empirically, C51 demonstrates impressive performance in ALE.
6
+
7
+
8
+ Original papers:
9
+
10
+ * [A Distributional Perspective on Reinforcement Learning](https://arxiv.org/abs/1707.06887)
11
+
12
+ ## Implemented Variants
13
+
14
+
15
+ | Variants Implemented | Description |
16
+ | ----------- | ----------- |
17
+ | :material-github: [`c51_atari.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/c51_atari.py), :material-file-document: [docs](/rl-algorithms/c51/#c51_ataripy) | For playing Atari games. It uses convolutional layers and common atari-based pre-processing techniques. |
18
+ | :material-github: [`c51.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/c51.py), :material-file-document: [docs](/rl-algorithms/c51/#c51py) | For classic control tasks like `CartPole-v1`. |
19
+ | :material-github: [`c51_atari_jax.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/c51_atari_jax.py), :material-file-document: [docs](/rl-algorithms/c51/#c51_atari_jaxpy) | For playing Atari games. It uses convolutional layers and common atari-based pre-processing techniques. |
20
+ | :material-github: [`c51_jax.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/c51_jax.py), :material-file-document: [docs](/rl-algorithms/c51/#c51_jaxpy) | For classic control tasks like `CartPole-v1`. |
21
+
22
+ Below are our single-file implementations of C51:
23
+
24
+
25
+ ## `c51_atari.py`
26
+
27
+ The [c51_atari.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/c51_atari.py) has the following features:
28
+
29
+ * For playing Atari games. It uses convolutional layers and common atari-based pre-processing techniques.
30
+ * Works with the Atari's pixel `Box` observation space of shape `(210, 160, 3)`
31
+ * Works with the `Discrete` action space
32
+
33
+ ### Usage
34
+
35
+
36
+ === "poetry"
37
+
38
+ ```bash
39
+ uv pip install ".[atari]"
40
+ uv run python cleanrl/c51_atari.py --env-id BreakoutNoFrameskip-v4
41
+ uv run python cleanrl/c51_atari.py --env-id PongNoFrameskip-v4
42
+ ```
43
+
44
+ === "pip"
45
+
46
+ ```bash
47
+ pip install -r requirements/requirements-atari.txt
48
+ python cleanrl/c51_atari.py --env-id BreakoutNoFrameskip-v4
49
+ python cleanrl/c51_atari.py --env-id PongNoFrameskip-v4
50
+ ```
51
+
52
+
53
+ ### Explanation of the logged metrics
54
+
55
+ Running `python cleanrl/c51_atari.py` will automatically record various metrics such as actor or value losses in Tensorboard. Below is the documentation for these metrics:
56
+
57
+ * `charts/episodic_return`: episodic return of the game
58
+ * `charts/SPS`: number of steps per second
59
+ * `losses/loss`: the cross entropy loss between the $t$ step state value distribution and the projected $t+1$ step state value distribution
60
+ * `losses/q_values`: implemented as `(old_pmfs * q_network.atoms).sum(1)`, which is the sum of the probability of getting returns $x$ (`old_pmfs`) multiplied by $x$ (`q_network.atoms`), averaged over the sample obtained from the replay buffer; useful when gauging if under or over estimation happens
61
+
62
+
63
+ ### Implementation details
64
+
65
+ [c51_atari.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/c51_atari.py) is based on (Bellemare et al., 2017)[^1] but presents a few implementation differences:
66
+
67
+ 1. (Bellemare et al., 2017)[^1] injects stochaticity by doing "on each frame the environment rejects the agent’s selected action with probability $p = 0.25$", but `c51_atari.py` does not do this
68
+ 1. `c51_atari.py` use a self-contained evaluation scheme: `c51_atari.py` reports the episodic returns obtained throughout training, whereas (Bellemare et al., 2017)[^1] is trained with `--end-e=0.01` but reported episodic returns using a separate evaluation process with `--end-e=0.001` (See "5.2. State-of-the-Art Results" on page 7).
69
+
70
+
71
+ ### Experiment results
72
+
73
+ To run benchmark experiments, see :material-github: [benchmark/c51.sh](https://github.com/vwxyzjn/cleanrl/blob/master/benchmark/c51.sh). Specifically, execute the following command:
74
+
75
+ <script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fvwxyzjn%2Fcleanrl%2Fblob%2Fmaster%2Fbenchmark%2Fc51.sh%23L8-L13&style=github&showBorder=on&showLineNumbers=on&showFileMeta=on&showCopy=on"></script>
76
+
77
+ Below are the average episodic returns for `c51_atari.py`.
78
+
79
+
80
+ | Environment | `c51_atari.py` 10M steps | (Bellemare et al., 2017, Figure 14)[^1] 50M steps | (Hessel et al., 2017, Figure 5)[^3]
81
+ | ----------- | ----------- | ----------- | ---- |
82
+ | BreakoutNoFrameskip-v4 | 461.86 ± 69.65 | 748 | ~500 at 10M steps, ~600 at 50M steps
83
+ | PongNoFrameskip-v4 | 19.46 ± 0.70 | 20.9 | ~20 10M steps, ~20 at 50M steps
84
+ | BeamRiderNoFrameskip-v4 | 9592.90 ± 2270.15 | 14,074 | ~12000 10M steps, ~14000 at 50M steps
85
+
86
+
87
+ Note that we save computational time by reducing timesteps from 50M to 10M, but our `c51_atari.py` scores the same or higher than (Mnih et al., 2015)[^1] in 10M steps.
88
+
89
+
90
+ Learning curves:
91
+
92
+ <div class="grid-container">
93
+ <img src="../c51/BeamRiderNoFrameskip-v4.png">
94
+
95
+ <img src="../c51/BreakoutNoFrameskip-v4.png">
96
+
97
+ <img src="../c51/PongNoFrameskip-v4.png">
98
+ </div>
99
+
100
+
101
+ Tracked experiments and game play videos:
102
+
103
+ <iframe src="https://wandb.ai/openrlbenchmark/openrlbenchmark/reports/Atari-CleanRL-s-C51--VmlldzoxNzI0NzQ0" style="width:100%; height:500px" title="CleanRL C51 Tracked Experiments"></iframe>
104
+
105
+
106
+
107
+ ## `c51.py`
108
+
109
+ The [c51.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/c51.py) has the following features:
110
+
111
+ * Works with the `Box` observation space of low-level features
112
+ * Works with the `Discrete` action space
113
+ * Works with envs like `CartPole-v1`
114
+
115
+
116
+ ### Usage
117
+
118
+ === "poetry"
119
+
120
+ ```bash
121
+ uv run python cleanrl/c51.py --env-id CartPole-v1
122
+ ```
123
+
124
+ === "pip"
125
+
126
+ ```bash
127
+ python cleanrl/c51.py --env-id CartPole-v1
128
+ ```
129
+
130
+
131
+ ### Explanation of the logged metrics
132
+
133
+ See [related docs](/rl-algorithms/c51/#explanation-of-the-logged-metrics) for `c51_atari.py`.
134
+
135
+ ### Implementation details
136
+
137
+ The [c51.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/c51.py) shares the same implementation details as [`c51_atari.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/c51_atari.py) except the `c51.py` runs with different hyperparameters and neural network architecture. Specifically,
138
+
139
+ 1. `c51.py` uses a simpler neural network as follows:
140
+ ```python
141
+ self.network = nn.Sequential(
142
+ nn.Linear(np.array(env.single_observation_space.shape).prod(), 120),
143
+ nn.ReLU(),
144
+ nn.Linear(120, 84),
145
+ nn.ReLU(),
146
+ nn.Linear(84, env.single_action_space.n),
147
+ )
148
+ ```
149
+ 2. `c51.py` runs with different hyperparameters:
150
+
151
+ ```bash
152
+ python c51.py --total-timesteps 500000 \
153
+ --learning-rate 2.5e-4 \
154
+ --buffer-size 10000 \
155
+ --gamma 0.99 \
156
+ --target-network-frequency 500 \
157
+ --max-grad-norm 0.5 \
158
+ --batch-size 128 \
159
+ --start-e 1 \
160
+ --end-e 0.05 \
161
+ --exploration-fraction 0.5 \
162
+ --learning-starts 10000 \
163
+ --train-frequency 10
164
+ ```
165
+
166
+
167
+ ### Experiment results
168
+
169
+ To run benchmark experiments, see :material-github: [benchmark/c51.sh](https://github.com/vwxyzjn/cleanrl/blob/master/benchmark/c51.sh). Specifically, execute the following command:
170
+
171
+ <script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fvwxyzjn%2Fcleanrl%2Fblob%2Fmaster%2Fbenchmark%2Fc51.sh%23L2-L6&style=github&showBorder=on&showLineNumbers=on&showFileMeta=on&showCopy=on"></script>
172
+
173
+
174
+ Below are the average episodic returns for `c51.py`.
175
+
176
+
177
+ | Environment | `c51.py` |
178
+ | ----------- | ----------- |
179
+ | CartPole-v1 | 481.20 ± 20.53 |
180
+ | Acrobot-v1 | -87.70 ± 5.52 |
181
+ | MountainCar-v0 | -166.38 ± 27.94 |
182
+
183
+
184
+ Note that the C51 has no official benchmark on classic control environments, so we did not include a comparison. That said, our `c51.py` was able to achieve near perfect scores in `CartPole-v1` and `Acrobot-v1`; further, it can obtain successful runs in the sparse environment `MountainCar-v0`.
185
+
186
+
187
+ Learning curves:
188
+
189
+ <div class="grid-container">
190
+ <img src="../c51/CartPole-v1.png">
191
+
192
+ <img src="../c51/Acrobot-v1.png">
193
+
194
+ <img src="../c51/MountainCar-v0.png">
195
+ </div>
196
+
197
+
198
+ Tracked experiments and game play videos:
199
+
200
+ <iframe src="https://wandb.ai/openrlbenchmark/openrlbenchmark/reports/Classic-Control-CleanRL-s-C51--VmlldzoxODIwMTE4" style="width:100%; height:500px" title="CleanRL C51 Tracked Experiments"></iframe>
201
+
202
+
203
+ ## `c51_atari_jax.py`
204
+
205
+ The [c51_atari_jax.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/c51_atari_jax.py) has the following features:
206
+
207
+ * Uses [Jax](https://github.com/google/jax), [Flax](https://github.com/google/flax), and [Optax](https://github.com/deepmind/optax) instead of `torch`. [c51_atari_jax.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/c51_atari_jax.py) is roughly 25% faster than [c51_atari.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/c51_atari.py)
208
+ * For playing Atari games. It uses convolutional layers and common atari-based pre-processing techniques.
209
+ * Works with the Atari's pixel `Box` observation space of shape `(210, 160, 3)`
210
+ * Works with the `Discrete` action space
211
+
212
+ ### Usage
213
+
214
+
215
+ === "poetry"
216
+
217
+ ```bash
218
+ uv pip install ".[atari, jax]"
219
+ uv pip install --upgrade "jax[cuda11_cudnn82]==0.4.8" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
220
+ uv run python cleanrl/c51_atari_jax.py --env-id BreakoutNoFrameskip-v4
221
+ uv run python cleanrl/c51_atari_jax.py --env-id PongNoFrameskip-v4
222
+ ```
223
+
224
+ === "pip"
225
+
226
+ ```bash
227
+ pip install -r requirements/requirements-atari.txt
228
+ pip install -r requirements/requirements-jax.txt
229
+ pip install --upgrade "jax[cuda]==0.3.17" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
230
+ python cleanrl/c51_atari_jax.py --env-id BreakoutNoFrameskip-v4
231
+ python cleanrl/c51_atari_jax.py --env-id PongNoFrameskip-v4
232
+ ```
233
+
234
+
235
+ ### Explanation of the logged metrics
236
+ See [related docs](/rl-algorithms/c51/#explanation-of-the-logged-metrics) for `c51_atari.py`.
237
+
238
+
239
+ ### Implementation details
240
+ See [related docs](/rl-algorithms/c51/#implementation-details) for `c51_atari.py`.
241
+
242
+
243
+ ### Experiment results
244
+
245
+ To run benchmark experiments, see :material-github: [benchmark/c51.sh](https://github.com/vwxyzjn/cleanrl/blob/master/benchmark/c51.sh). Specifically, execute the following command:
246
+
247
+ <script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fvwxyzjn%2Fcleanrl%2Fblob%2Fmaster%2Fbenchmark%2Fc51.sh%23L23-L29&style=github&showBorder=on&showLineNumbers=on&showFileMeta=on&showCopy=on"></script>
248
+
249
+ Below are the average episodic returns for `c51_atari_jax.py`.
250
+
251
+
252
+ | Environment | `c51_atari_jax.py` 10M steps | `c51_atari.py` 10M steps | (Bellemare et al., 2017, Figure 14)[^1] 50M steps | (Hessel et al., 2017, Figure 5)[^3] |
253
+ | ----------------------- | ---------------------------- | ------------------------ | ------------------------------------------------- | ------------------------------------- |
254
+ | BreakoutNoFrameskip-v4 | 448.56 ± 17.02 | 461.86 ± 69.65 | 748 | ~500 at 10M steps, ~600 at 50M steps |
255
+ | PongNoFrameskip-v4 | 19.88 ± 0.31 | 19.46 ± 0.70 | 20.9 | ~20 10M steps, ~20 at 50M steps |
256
+ | BeamRiderNoFrameskip-v4 | 9504.91 ± 709.69 | 9592.90 ± 2270.15 | 14,074 | ~12000 10M steps, ~14000 at 50M steps |
257
+
258
+
259
+
260
+ Learning curves:
261
+ <div class="grid-container">
262
+ <img src="../c51/jax/BeamRiderNoFrameskip-v4.png">
263
+ <img src="../c51/jax/BeamRiderNoFrameskip-v4-time.png">
264
+
265
+ <img src="../c51/jax/BreakoutNoFrameskip-v4.png">
266
+ <img src="../c51/jax/BreakoutNoFrameskip-v4-time.png">
267
+
268
+ <img src="../c51/jax/PongNoFrameskip-v4.png">
269
+ <img src="../c51/jax/PongNoFrameskip-v4-time.png">
270
+ </div>
271
+
272
+ Tracked experiments and game play videos:
273
+
274
+ <iframe src="https://wandb.ai/openrlbenchmark/openrlbenchmark/reports/Atari-CleanRL-s-C51-JAX--VmlldzozMjM4MTIy" style="width:100%; height:500px" title="CleanRL C51 Tracked Experiments"></iframe>
275
+
276
+
277
+ ## `c51_jax.py`
278
+
279
+ The [c51_jax.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/c51_jax.py) has the following features:
280
+
281
+ * Uses [Jax](https://github.com/google/jax), [Flax](https://github.com/google/flax), and [Optax](https://github.com/deepmind/optax) instead of `torch`. [c51_jax.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/c51_jax.py) is roughly 55% faster than [c51.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/c51.py)
282
+ * Works with the `Box` observation space of low-level features
283
+ * Works with the `Discrete` action space
284
+ * Works with envs like `CartPole-v1`
285
+
286
+
287
+ ### Usage
288
+
289
+
290
+ === "poetry"
291
+
292
+ ```bash
293
+ uv pip install ".[jax]"
294
+ uv pip install --upgrade "jax[cuda11_cudnn82]==0.4.8" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
295
+ uv run python cleanrl/c51_jax.py --env-id CartPole-v1
296
+ ```
297
+
298
+ === "pip"
299
+
300
+ ```bash
301
+ pip install -r requirements/requirements-jax.txt
302
+ pip install --upgrade "jax[cuda]==0.3.17" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
303
+ python cleanrl/c51_jax.py --env-id CartPole-v1
304
+ ```
305
+
306
+
307
+ ### Explanation of the logged metrics
308
+
309
+ See [related docs](/rl-algorithms/c51/#explanation-of-the-logged-metrics) for `c51_atari.py`.
310
+
311
+ ### Implementation details
312
+
313
+ See [related docs](/rl-algorithms/c51/#implementation-details_1) for `c51.py`.
314
+
315
+
316
+ ### Experiment results
317
+
318
+ To run benchmark experiments, see :material-github: [benchmark/c51.sh](https://github.com/vwxyzjn/cleanrl/blob/master/benchmark/c51.sh). Specifically, execute the following command:
319
+
320
+ <script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fvwxyzjn%2Fcleanrl%2Fblob%2Fmaster%2Fbenchmark%2Fc51.sh%23L15-L21&style=github&showBorder=on&showLineNumbers=on&showFileMeta=on&showCopy=on"></script>
321
+
322
+
323
+ Below are the average episodic returns for `c51_jax.py`.
324
+
325
+
326
+ | Environment | `c51_jax.py` | `c51.py` |
327
+ | -------------- | --------------- | --------------- |
328
+ | CartPole-v1 | 491.07 ± 9.70 | 481.20 ± 20.53 |
329
+ | Acrobot-v1 | -86.74 ± 2.19 | -87.70 ± 5.52 |
330
+ | MountainCar-v0 | -174.30 ± 36.35 | -166.38 ± 27.94 |
331
+
332
+
333
+ Learning curves:
334
+
335
+ <div class="grid-container">
336
+ <img src="../c51/jax/CartPole-v1.png">
337
+ <img src="../c51/jax/CartPole-v1-time.png">
338
+
339
+ <img src="../c51/jax/Acrobot-v1.png">
340
+ <img src="../c51/jax/Acrobot-v1-time.png">
341
+
342
+ <img src="../c51/jax/MountainCar-v0.png">
343
+ <img src="../c51/jax/MountainCar-v0-time.png">
344
+ </div>
345
+
346
+
347
+ Tracked experiments and game play videos:
348
+
349
+ <iframe src="https://wandb.ai/openrlbenchmark/openrlbenchmark/reports/Classic-Control-CleanRL-s-C51-JAX--VmlldzozMjM4MTM4" style="width:100%; height:500px" title="CleanRL C51 Tracked Experiments"></iframe>
350
+
351
+
352
+ [^1]:Bellemare, M.G., Dabney, W., & Munos, R. (2017). A Distributional Perspective on Reinforcement Learning. ICML.
353
+ [^2]:\[Proposal\] Formal API handling of truncation vs termination. https://github.com/openai/gym/issues/2510
354
+ [^3]: Hessel, M., Modayil, J., Hasselt, H.V., Schaul, T., Ostrovski, G., Dabney, W., Horgan, D., Piot, B., Azar, M.G., & Silver, D. (2018). Rainbow: Combining Improvements in Deep Reinforcement Learning. AAAI.
cleanrl/docs/rl-algorithms/ddpg.md ADDED
@@ -0,0 +1,375 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Deep Deterministic Policy Gradient (DDPG)
2
+
3
+
4
+ ## Overview
5
+
6
+ DDPG is a popular DRL algorithm for continuous control. It extends DQN to work with the continuous action space by introducing a deterministic actor that directly outputs continuous actions. DDPG also combines techniques from DQN, such as the replay buffer and target network.
7
+
8
+
9
+ Original paper:
10
+
11
+ * [Continuous control with deep reinforcement learning](https://arxiv.org/abs/1509.02971)
12
+
13
+ Reference resources:
14
+
15
+ * :material-github: [sfujim/TD3](https://github.com/sfujim/TD3)
16
+ * [Deep Deterministic Policy Gradient | Spinning Up in Deep RL](https://spinningup.openai.com/en/latest/algorithms/ddpg.html)
17
+ * :material-github: [ikostrikov/jaxrl](https://github.com/ikostrikov/jaxrl) (helpful reference when implemented [`ddpg_continuous_action_jax.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ddpg_continuous_action_jax.py))
18
+
19
+ ## Implemented Variants
20
+
21
+
22
+ | Variants Implemented | Description |
23
+ | ----------- | ----------- |
24
+ | :material-github: [`ddpg_continuous_action.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ddpg_continuous_action.py), :material-file-document: [docs](/rl-algorithms/ddpg/#ddpg_continuous_actionpy) | For continuous action space |
25
+ | :material-github: [`ddpg_continuous_action_jax.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ddpg_continuous_action_jax.py), :material-file-document: [docs](/rl-algorithms/ddpg/#ddpg_continuous_action_jaxpy) | For continuous action space |
26
+
27
+ Below is our single-file implementation of DDPG:
28
+
29
+ ## `ddpg_continuous_action.py`
30
+
31
+ The [ddpg_continuous_action.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ddpg_continuous_action.py) has the following features:
32
+
33
+ * For continuous action space
34
+ * Works with the `Box` observation space of low-level features
35
+ * Works with the `Box` (continuous) action space
36
+
37
+ ### Usage
38
+
39
+ === "poetry"
40
+
41
+ ```bash
42
+ uv pip install .
43
+ uv run python cleanrl/ddpg_continuous_action.py --help
44
+ uv pip install ".[mujoco]"
45
+ uv run python cleanrl/ddpg_continuous_action.py --env-id Hopper-v4
46
+ ```
47
+
48
+ === "pip"
49
+
50
+ ```bash
51
+ python cleanrl/ddpg_continuous_action.py --help
52
+ pip install -r requirements/requirements-mujoco.txt
53
+ python cleanrl/ddpg_continuous_actions.py --env-id Hopper-v4
54
+ ```
55
+
56
+ ### Explanation of the logged metrics
57
+
58
+ Running `python cleanrl/ddpg_continuous_action.py` will automatically record various metrics such as actor or value losses in Tensorboard. Below is the documentation for these metrics:
59
+
60
+ * `charts/episodic_return`: episodic return of the game
61
+ * `charts/SPS`: number of steps per second
62
+ * `losses/qf1_loss`: the mean squared error (MSE) between the Q values at timestep $t$ and the Bellman update target estimated using the reward $r_t$ and the Q values at timestep $t+1$, thus minimizing the *one-step* temporal difference. Formally, it can be expressed by the equation below.
63
+ $$
64
+ J(\theta^{Q}) = \mathbb{E}_{(s,a,r,s') \sim \mathcal{D}} \big[ (Q(s, a) - y)^2 \big],
65
+ $$
66
+ with the Bellman update target $y = r + \gamma \, Q^{'}(s', a')$, where $a' \sim \mu^{'}(s')$, and the replay buffer $\mathcal{D}$.
67
+
68
+ * `losses/actor_loss`: implemented as `-qf1(data.observations, actor(data.observations)).mean()`; it is the *negative* average Q values calculated based on the 1) observations and the 2) actions computed by the actor based on these observations. By minimizing `actor_loss`, the optimizer updates the actors parameter using the following gradient (Lillicrap et al., 2016, Algorithm 1)[^1]:
69
+
70
+ $$ \nabla_{\theta^{\mu}} J \approx \frac{1}{N}\sum_i\left.\left.\nabla_{a} Q\left(s, a \mid \theta^{Q}\right)\right|_{s=s_{i}, a=\mu\left(s_{i}\right)} \nabla_{\theta^{\mu}} \mu\left(s \mid \theta^{\mu}\right)\right|_{s_{i}} $$
71
+
72
+ * `losses/qf1_values`: implemented as `qf1(data.observations, data.actions).view(-1)`, it is the average Q values of the sampled data in the replay buffer; useful when gauging if under or over estimation happens.
73
+
74
+
75
+ ### Implementation details
76
+
77
+ Our [`ddpg_continuous_action.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ddpg_continuous_action.py) is based on the [`OurDDPG.py`](https://github.com/sfujim/TD3/blob/master/OurDDPG.py) from :material-github: [sfujim/TD3](https://github.com/sfujim/TD3), which presents the the following implementation difference from (Lillicrap et al., 2016)[^1]:
78
+
79
+ 1. [`ddpg_continuous_action.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ddpg_continuous_action.py) uses a gaussian exploration noise $\mathcal{N}(0, 0.1)$, while (Lillicrap et al., 2016)[^1] uses Ornstein-Uhlenbeck process with $\theta=0.15$ and $\sigma=0.2$.
80
+
81
+ 1. [`ddpg_continuous_action.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ddpg_continuous_action.py) runs the experiments using the `openai/gym` MuJoCo environments, while (Lillicrap et al., 2016)[^1] uses their proprietary MuJoCo environments.
82
+
83
+ 1. [`ddpg_continuous_action.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ddpg_continuous_action.py) uses the following architecture:
84
+ ```python
85
+ class QNetwork(nn.Module):
86
+ def __init__(self, env):
87
+ super().__init__()
88
+ self.fc1 = nn.Linear(np.array(env.single_observation_space.shape).prod() + np.prod(env.single_action_space.shape), 256)
89
+ self.fc2 = nn.Linear(256, 256)
90
+ self.fc3 = nn.Linear(256, 1)
91
+
92
+ def forward(self, x, a):
93
+ x = torch.cat([x, a], 1)
94
+ x = F.relu(self.fc1(x))
95
+ x = F.relu(self.fc2(x))
96
+ x = self.fc3(x)
97
+ return x
98
+
99
+
100
+ class Actor(nn.Module):
101
+ def __init__(self, env):
102
+ super().__init__()
103
+ self.fc1 = nn.Linear(np.array(env.single_observation_space.shape).prod(), 256)
104
+ self.fc2 = nn.Linear(256, 256)
105
+ self.fc_mu = nn.Linear(256, np.prod(env.single_action_space.shape))
106
+ # action rescaling
107
+ self.register_buffer(
108
+ "action_scale", torch.tensor((env.action_space.high - env.action_space.low) / 2.0, dtype=torch.float32)
109
+ )
110
+ self.register_buffer(
111
+ "action_bias", torch.tensor((env.action_space.high + env.action_space.low) / 2.0, dtype=torch.float32)
112
+ )
113
+
114
+ def forward(self, x):
115
+ x = F.relu(self.fc1(x))
116
+ x = F.relu(self.fc2(x))
117
+ x = torch.tanh(self.fc_mu(x))
118
+ return x * self.action_scale + self.action_bias
119
+ ```
120
+ while (Lillicrap et al., 2016, see Appendix 7 EXPERIMENT DETAILS)[^1] uses the following architecture (difference highlighted):
121
+
122
+ ```python hl_lines="4-6 9-11 19-21"
123
+ class QNetwork(nn.Module):
124
+ def __init__(self, env):
125
+ super(QNetwork, self).__init__()
126
+ self.fc1 = nn.Linear(p.array(env.single_observation_space.shape).prod() + np.prod(env.single_action_space.shape), 400)
127
+ self.fc2 = nn.Linear(400 + np.prod(env.single_action_space.shape), 300)
128
+ self.fc3 = nn.Linear(300, 1)
129
+
130
+ def forward(self, x, a):
131
+ x = F.relu(self.fc1(x))
132
+ x = torch.cat([x, a], 1)
133
+ x = F.relu(self.fc2(x))
134
+ x = self.fc3(x)
135
+ return x
136
+
137
+
138
+ class Actor(nn.Module):
139
+ def __init__(self, env):
140
+ super(Actor, self).__init__()
141
+ self.fc1 = nn.Linear(np.array(env.single_observation_space.shape).prod(), 400)
142
+ self.fc2 = nn.Linear(400, 300)
143
+ self.fc_mu = nn.Linear(300, np.prod(env.single_action_space.shape))
144
+ # action rescaling
145
+ self.register_buffer(
146
+ "action_scale", torch.tensor((env.action_space.high - env.action_space.low) / 2.0, dtype=torch.float32)
147
+ )
148
+ self.register_buffer(
149
+ "action_bias", torch.tensor((env.action_space.high + env.action_space.low) / 2.0, dtype=torch.float32)
150
+ )
151
+
152
+ def forward(self, x):
153
+ x = F.relu(self.fc1(x))
154
+ x = F.relu(self.fc2(x))
155
+ x = torch.tanh(self.fc_mu(x))
156
+ return x * self.action_scale + self.action_bias
157
+ ```
158
+
159
+ 1. [`ddpg_continuous_action.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ddpg_continuous_action.py) uses the following learning rates:
160
+
161
+ ```python
162
+ q_optimizer = optim.Adam(list(qf1.parameters()), lr=3e-4)
163
+ actor_optimizer = optim.Adam(list(actor.parameters()), lr=3e-4)
164
+ ```
165
+ while (Lillicrap et al., 2016, see Appendix 7 EXPERIMENT DETAILS)[^1] uses the following learning rates:
166
+
167
+ ```python
168
+ q_optimizer = optim.Adam(list(qf1.parameters()), lr=1e-4)
169
+ actor_optimizer = optim.Adam(list(actor.parameters()), lr=1e-3)
170
+ ```
171
+
172
+ 1. [`ddpg_continuous_action.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ddpg_continuous_action.py) uses `--batch-size=256 --tau=0.005`, while (Lillicrap et al., 2016, see Appendix 7 EXPERIMENT DETAILS)[^1] uses `--batch-size=64 --tau=0.001`
173
+
174
+ 1. [`ddpg_continuous_action.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ddpg_continuous_action.py) also adds support for handling continuous environments where the lower and higher bounds of the action space are not $[-1,1]$, or are asymmetric.
175
+ The case where the bounds are not $[-1,1]$ is handled in [`DDPG.py`](https://github.com/sfujim/TD3/blob/385b33ac7de4767bab17eb02ade4a268d3e4e24f/DDPG.py#L15) (Fujimoto et al., 2018)[^2] as follows:
176
+ ```python
177
+ class Actor(nn.Module):
178
+
179
+ ...
180
+
181
+ def forward(self, state):
182
+ a = F.relu(self.l1(state))
183
+ a = F.relu(self.l2(a))
184
+ return self.max_action * torch.tanh(self.l3(a)) # Scale from [-1,1] to [-action_high, action_high]
185
+ ```
186
+ On the other hand, in [`CleanRL's ddpg_continuous_action.py`](https://github.com/dosssman/cleanrl/blob/10b606e7bd9bd1b06e455e8ef542df2b7699a20c/cleanrl/ddpg_continuous_action.py#L98), the mean and the scale of the the action space are computed as `action_bias` and `action_scale` respectively.
187
+ Those scalars are in turn used to scale the output of a `tanh` activation function in the actor to the original action space range:
188
+ ```python
189
+ class Actor(nn.Module):
190
+ def __init__(self, env):
191
+ ...
192
+ # action rescaling
193
+ self.register_buffer(
194
+ "action_scale", torch.tensor((env.action_space.high - env.action_space.low) / 2.0, dtype=torch.float32)
195
+ )
196
+ self.register_buffer(
197
+ "action_bias", torch.tensor((env.action_space.high + env.action_space.low) / 2.0, dtype=torch.float32)
198
+ )
199
+
200
+ def forward(self, x):
201
+ x = F.relu(self.fc1(x))
202
+ x = F.relu(self.fc2(x))
203
+ x = torch.tanh(self.fc_mu(x))
204
+ return x * self.action_scale + self.action_bias # Scale from [-1,1] to [-action_low, action_high]
205
+ ```
206
+
207
+ Additionally, when drawing exploration noise that is added to the actions produced by the actor, [`CleanRL's ddpg_continuous_action.py`](https://github.com/dosssman/cleanrl/blob/10b606e7bd9bd1b06e455e8ef542df2b7699a20c/cleanrl/ddpg_continuous_action.py#L175) centers the distribution the sampled from at `action_bias`, and the scale of the distribution is set to `action_scale * exploration_noise`.
208
+
209
+ ???+ info
210
+
211
+ Note that `Humanoid-v2`, `InvertedPendulum-v2`, `Pusher-v2` have action space bounds that are not the standard `[-1, 1]`. See below.
212
+
213
+ ```
214
+ Ant-v2 Observation space: Box(-inf, inf, (111,), float64) Action space: Box(-1.0, 1.0, (8,), float32)
215
+ HalfCheetah-v2 Observation space: Box(-inf, inf, (17,), float64) Action space: Box(-1.0, 1.0, (6,), float32)
216
+ Hopper-v2 Observation space: Box(-inf, inf, (11,), float64) Action space: Box(-1.0, 1.0, (3,), float32)
217
+ Humanoid-v2 Observation space: Box(-inf, inf, (376,), float64) Action space: Box(-0.4, 0.4, (17,), float32)
218
+ InvertedDoublePendulum-v2 Observation space: Box(-inf, inf, (11,), float64) Action space: Box(-1.0, 1.0, (1,), float32)
219
+ InvertedPendulum-v2 Observation space: Box(-inf, inf, (4,), float64) Action space: Box(-3.0, 3.0, (1,), float32)
220
+ Pusher-v2 Observation space: Box(-inf, inf, (23,), float64) Action space: Box(-2.0, 2.0, (7,), float32)
221
+ Reacher-v2 Observation space: Box(-inf, inf, (11,), float64) Action space: Box(-1.0, 1.0, (2,), float32)
222
+ Swimmer-v2 Observation space: Box(-inf, inf, (8,), float64) Action space: Box(-1.0, 1.0, (2,), float32)
223
+ Walker2d-v2 Observation space: Box(-inf, inf, (17,), float64) Action space: Box(-1.0, 1.0, (6,), float32)
224
+ ```
225
+
226
+
227
+ ### Experiment results
228
+
229
+ To run benchmark experiments, see :material-github: [benchmark/ddpg.sh](https://github.com/vwxyzjn/cleanrl/blob/master/benchmark/ddpg.sh). Specifically, execute the following command:
230
+
231
+
232
+ ``` title="benchmark/ddpg.sh" linenums="1"
233
+ --8<-- "benchmark/ddpg.sh::7"
234
+ ```
235
+
236
+
237
+ Below are the average episodic returns for [`ddpg_continuous_action.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ddpg_continuous_action.py) (3 random seeds). To ensure the quality of the implementation, we compared the results against (Fujimoto et al., 2018)[^2].
238
+
239
+ | Environment | [`ddpg_continuous_action.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ddpg_continuous_action.py) | [`OurDDPG.py`](https://github.com/sfujim/TD3/blob/master/OurDDPG.py) (Fujimoto et al., 2018, Table 1)[^2] | [`DDPG.py`](https://github.com/sfujim/TD3/blob/master/DDPG.py) using settings from (Lillicrap et al., 2016)[^1] in (Fujimoto et al., 2018, Table 1)[^2] |
240
+ | ----------- | ----------- | ----------- | ----------- |
241
+ | HalfCheetah-v4 | 10374.07 ± 157.37 |8577.29 | 3305.60|
242
+ | Walker2d-v4 | 1240.16 ± 390.10 | 3098.11 | 1843.85 |
243
+ | Hopper-v4 | 1576.78 ± 818.98 | 1860.02 | 2020.46 |
244
+ | InvertedPendulum-v4 | 642.68 ± 69.56 | 1000.00 ± 0.00 |
245
+ | Humanoid-v4 | 1699.56 ± 694.22 | not available |
246
+ | Pusher-v4 | -77.30 ± 38.78 | not available |
247
+
248
+
249
+
250
+ ???+ info
251
+
252
+ Note that [`ddpg_continuous_action.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ddpg_continuous_action.py) uses gym MuJoCo v4 environments while [`OurDDPG.py`](https://github.com/sfujim/TD3/blob/master/OurDDPG.py) (Fujimoto et al., 2018)[^2] uses the gym MuJoCo v1 environments.
253
+
254
+ Also note the performance of our `ddpg_continuous_action.py` seems to be worse than the reference implementation on Walker2d and Hopper. This is likely due to :material-github: [openai/gym#938](https://github.com/openai/baselines/issues/938). We would have a hard time reproducing gym MuJoCo v1 environments because they have been long deprecated.
255
+
256
+ One other thing could cause the performance difference: the original code reported the average episodic return using determinisitc evaluation (i.e., without exploration noise), see [`sfujim/TD3/main.py#L15-L32`](https://github.com/sfujim/TD3/blob/385b33ac7de4767bab17eb02ade4a268d3e4e24f/main.py#L15-L32), whereas we reported the episodic return during training and the policy gets updated between environments steps.
257
+
258
+ Learning curves:
259
+
260
+ ``` title="benchmark/ddpg_plot.sh" linenums="1"
261
+ --8<-- "benchmark/ddpg_plot.sh::9"
262
+ ```
263
+
264
+ <img loading="lazy" src="https://huggingface.co/datasets/cleanrl/benchmark/resolve/main/benchmark/pr-424/ddpg.png">
265
+ <img loading="lazy" src="https://huggingface.co/datasets/cleanrl/benchmark/resolve/main/benchmark/pr-424/ddpg-time.png">
266
+
267
+ <iframe loading="lazy" src="https://wandb.ai/openrlbenchmark/openrlbenchmark/reports/MuJoCo-CleanRL-s-DDPG--VmlldzoxNjkyMjc1" style="width:100%; height:500px" title="MuJoCo: CleanRL's DDPG"></iframe>
268
+
269
+
270
+
271
+ ## `ddpg_continuous_action_jax.py`
272
+
273
+ The [ddpg_continuous_action_jax.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ddpg_continuous_action_jax.py) has the following features:
274
+
275
+ * Uses [Jax](https://github.com/google/jax), [Flax](https://github.com/google/flax), and [Optax](https://github.com/deepmind/optax) instead of `torch`. [ddpg_continuous_action_jax.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ddpg_continuous_action_jax.py) is roughly 2.5-4x faster than [ddpg_continuous_action.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ddpg_continuous_action.py)
276
+ * For continuous action space
277
+ * Works with the `Box` observation space of low-level features
278
+ * Works with the `Box` (continuous) action space
279
+
280
+ ### Usage
281
+
282
+ === "poetry"
283
+
284
+ ```bash
285
+ uv pip install ".[mujoco, jax]"
286
+ uv run python cleanrl/ddpg_continuous_action_jax.py --help
287
+ uv run python cleanrl/ddpg_continuous_action_jax.py --env-id Hopper-v4
288
+ ```
289
+
290
+ === "pip"
291
+
292
+ ```bash
293
+ pip install -r requirements/requirements-mujoco.txt
294
+ pip install -r requirements/requirements-jax.txt
295
+ python cleanrl/ddpg_continuous_action_jax.py --help
296
+ python cleanrl/ddpg_continuous_action_jax.py --env-id Hopper-v4
297
+ ```
298
+
299
+
300
+ ???+ warning
301
+
302
+ Note that JAX does not work in Windows :fontawesome-brands-windows:. The official [docs](https://github.com/google/jax#installation) recommends using Windows Subsystem for Linux (WSL) to install JAX.
303
+
304
+ ### Explanation of the logged metrics
305
+
306
+ See [related docs](/rl-algorithms/ddpg/#explanation-of-the-logged-metrics) for `ddpg_continuous_action.py`.
307
+
308
+
309
+ ### Implementation details
310
+
311
+ See [related docs](/rl-algorithms/ddpg/#implementation-details) for `ddpg_continuous_action.py`.
312
+
313
+
314
+ ### Experiment results
315
+
316
+ To run benchmark experiments, see :material-github: [benchmark/ddpg.sh](https://github.com/vwxyzjn/cleanrl/blob/master/benchmark/ddpg.sh). Specifically, execute the following command:
317
+
318
+
319
+ ``` title="benchmark/ddpg.sh" linenums="1"
320
+ --8<-- "benchmark/ddpg.sh:12:19"
321
+ ```
322
+
323
+ Below are the average episodic returns for [`ddpg_continuous_action_jax.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ddpg_continuous_action_jax.py) (3 random seeds).
324
+
325
+
326
+ {!benchmark/ddpg.md!}
327
+
328
+ Learning curves:
329
+
330
+
331
+ ``` title="benchmark/ddpg_plot.sh" linenums="1"
332
+ --8<-- "benchmark/ddpg_plot.sh:11:20"
333
+ ```
334
+
335
+ <img loading="lazy" src="https://huggingface.co/datasets/cleanrl/benchmark/resolve/main/benchmark/pr-424/ddpg_jax.png">
336
+ <img loading="lazy" src="https://huggingface.co/datasets/cleanrl/benchmark/resolve/main/benchmark/pr-424/ddpg_jax-time.png">
337
+
338
+
339
+ ???+ info
340
+
341
+ These are some previous experiments with TPUs. Note the results are very similar to the ones above, but the runtime can be different due to different hardware used.
342
+
343
+
344
+ Note that the experiments were conducted on different hardwares, so your mileage might vary. This inconsistency is because 1) re-running expeirments on the same hardware is computationally expensive and 2) requiring the same hardware is not inclusive nor feasible to other contributors who might have different hardwares.
345
+
346
+ That said, we roughly expect to see a 2-4x speed improvement from using [`ddpg_continuous_action_jax.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ddpg_continuous_action_jax.py) under the same hardware. And if you disable the `--capture_video` overhead, the speed improvement will be even higher.
347
+
348
+
349
+ | Environment | [`ddpg_continuous_action_jax.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ddpg_continuous_action_jax.py) (RTX 3060 TI) | [`ddpg_continuous_action_jax.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ddpg_continuous_action_jax.py) (VM w/ TPU) | [`ddpg_continuous_action.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ddpg_continuous_action.py) (RTX 3060 TI) | [`OurDDPG.py`](https://github.com/sfujim/TD3/blob/master/OurDDPG.py) (Fujimoto et al., 2018, Table 1)[^2] |
350
+ | ----------- | ----------- | ----------- | ----------- | ----------- |
351
+ | HalfCheetah | 9592.25 ± 135.10 | 9125.06 ± 1477.58 | 10210.57 ± 196.22 |8577.29 |
352
+ | Walker2d | 1083.15 ± 567.65 | 1303.82 ± 448.41 | 1661.14 ± 250.01 | 3098.11 |
353
+ | Hopper | 1275.28 ± 209.60 | 1145.05 ± 41.95 | 1007.44 ± 148.29 | 1860.02 |
354
+
355
+ Learning curves:
356
+
357
+ <div class="grid-container">
358
+ <img loading="lazy" src="../ddpg-jax/HalfCheetah-v2.png">
359
+ <img loading="lazy" src="../ddpg-jax/HalfCheetah-v2-time.png">
360
+
361
+ <img loading="lazy" src="../ddpg-jax/Walker2d-v2.png">
362
+ <img loading="lazy" src="../ddpg-jax/Walker2d-v2-time.png">
363
+
364
+ <img loading="lazy" src="../ddpg-jax/Hopper-v2.png">
365
+ <img loading="lazy" src="../ddpg-jax/Hopper-v2-time.png">
366
+ </div>
367
+
368
+ Tracked experiments and game play videos:
369
+
370
+ <iframe loading="lazy" src="https://wandb.ai/openrlbenchmark/openrlbenchmark/reports/MuJoCo-CleanRL-s-DDPG-JAX--VmlldzoyMjQxMjE2" style="width:100%; height:500px" title="MuJoCo: CleanRL's DDPG + JAX"></iframe>
371
+
372
+
373
+ [^1]:Lillicrap, T.P., Hunt, J.J., Pritzel, A., Heess, N.M., Erez, T., Tassa, Y., Silver, D., & Wierstra, D. (2016). Continuous control with deep reinforcement learning. CoRR, abs/1509.02971. https://arxiv.org/abs/1509.02971
374
+
375
+ [^2]:Fujimoto, S., Hoof, H.V., & Meger, D. (2018). Addressing Function Approximation Error in Actor-Critic Methods. ArXiv, abs/1802.09477. https://arxiv.org/abs/1802.09477
cleanrl/docs/rl-algorithms/dqn.md ADDED
@@ -0,0 +1,396 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Deep Q-Learning (DQN)
2
+
3
+ ## Overview
4
+
5
+ As an extension of the Q-learning, DQN's main technical contribution is the use of replay buffer and target network, both of which would help improve the stability of the algorithm.
6
+
7
+
8
+ Original papers:
9
+
10
+ * [Human-level control through deep reinforcement learning
11
+ ](https://www.nature.com/articles/nature14236)
12
+
13
+ ## Implemented Variants
14
+
15
+
16
+ | Variants Implemented | Description |
17
+ | ----------- | ----------- |
18
+ | :material-github: [`dqn_atari.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/dqn_atari.py), :material-file-document: [docs](/rl-algorithms/dqn/#dqn_ataripy) | For playing Atari games. It uses convolutional layers and common atari-based pre-processing techniques. |
19
+ | :material-github: [`dqn.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/dqn.py), :material-file-document: [docs](/rl-algorithms/dqn/#dqnpy) | For classic control tasks like `CartPole-v1`. |
20
+ | :material-github: [`dqn_atari_jax.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/dqn_atari_jax.py), :material-file-document: [docs](/rl-algorithms/dqn/#dqn_atari_jaxpy) | For playing Atari games. It uses convolutional layers and common atari-based pre-processing techniques. |
21
+ | :material-github: [`dqn_jax.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/dqn_jax.py), :material-file-document: [docs](/rl-algorithms/dqn/#dqn_jaxpy) | For classic control tasks like `CartPole-v1`. |
22
+
23
+
24
+ Below are our single-file implementations of DQN:
25
+
26
+
27
+ ## `dqn_atari.py`
28
+
29
+ The [dqn_atari.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/dqn_atari.py) has the following features:
30
+
31
+ * For playing Atari games. It uses convolutional layers and common atari-based pre-processing techniques.
32
+ * Works with the Atari's pixel `Box` observation space of shape `(210, 160, 3)`
33
+ * Works with the `Discrete` action space
34
+
35
+ ### Usage
36
+
37
+ ```bash
38
+ uv pip install ".[atari]"
39
+ python cleanrl/dqn_atari.py --env-id BreakoutNoFrameskip-v4
40
+ python cleanrl/dqn_atari.py --env-id PongNoFrameskip-v4
41
+ ```
42
+
43
+ === "poetry"
44
+
45
+ ```bash
46
+ uv pip install ".[atari]"
47
+ uv run python cleanrl/dqn_atari.py --env-id BreakoutNoFrameskip-v4
48
+ uv run python cleanrl/dqn_atari.py --env-id PongNoFrameskip-v4
49
+ ```
50
+
51
+ === "pip"
52
+
53
+ ```bash
54
+ pip install -r requirements/requirements-atari.txt
55
+ python cleanrl/dqn_atari.py --env-id BreakoutNoFrameskip-v4
56
+ python cleanrl/dqn_atari.py --env-id PongNoFrameskip-v4
57
+ ```
58
+
59
+
60
+ ### Explanation of the logged metrics
61
+
62
+ Running `python cleanrl/dqn_atari.py` will automatically record various metrics such as actor or value losses in Tensorboard. Below is the documentation for these metrics:
63
+
64
+ * `charts/episodic_return`: episodic return of the game
65
+ * `charts/SPS`: number of steps per second
66
+ * `losses/td_loss`: the mean squared error (MSE) between the Q values at timestep $t$ and the Bellman update target estimated using the reward $r_t$ and the Q values at timestep $t+1$, thus minimizing the *one-step* temporal difference. Formally, it can be expressed by the equation below.
67
+ $$
68
+ J(\theta^{Q}) = \mathbb{E}_{(s,a,r,s') \sim \mathcal{D}} \big[ (Q(s, a) - y)^2 \big],
69
+ $$
70
+ with the Bellman update target is $y = r + \gamma \, Q^{'}(s', a')$ and the replay buffer is $\mathcal{D}$.
71
+ * `losses/q_values`: implemented as `qf1(data.observations, data.actions).view(-1)`, it is the average Q values of the sampled data in the replay buffer; useful when gauging if under or over estimation happens.
72
+
73
+
74
+ ### Implementation details
75
+
76
+ [dqn_atari.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/dqn_atari.py) is based on (Mnih et al., 2015)[^1] but presents a few implementation differences:
77
+
78
+ 1. `dqn_atari.py` use slightly different hyperparameters. Specifically,
79
+ - `dqn_atari.py` uses the more popular Adam Optimizer with the `--learning-rate=1e-4` as follows:
80
+ ```python
81
+ optim.Adam(q_network.parameters(), lr=1e-4)
82
+ ```
83
+ whereas (Mnih et al., 2015)[^1] (Extended Data Table 1) uses the RMSProp optimizer with `--learning-rate=2.5e-4`, gradient momentum `0.95`, squared gradient momentum `0.95`, and min squared gradient `0.01` as follows:
84
+ ```python
85
+ optim.RMSprop(
86
+ q_network.parameters(),
87
+ lr=2.5e-4,
88
+ momentum=0.95,
89
+ # ... PyTorch's RMSprop does not directly support
90
+ # squared gradient momentum and min squared gradient
91
+ # so we are not sure what to put here.
92
+ )
93
+ ```
94
+ - `dqn_atari.py` uses `--learning-starts=80000` whereas (Mnih et al., 2015)[^1] (Extended Data Table 1) uses `--learning-starts=50000`.
95
+ - `dqn_atari.py` uses `--target-network-frequency=1000` whereas (Mnih et al., 2015)[^1] (Extended Data Table 1) uses `--target-network-frequency=10000`.
96
+ - `dqn_atari.py` uses `--total-timesteps=10000000` (i.e., 10M timesteps = 40M frames because of frame-skipping) whereas (Mnih et al., 2015)[^1] uses `--total-timesteps=50000000` (i.e., 50M timesteps = 200M frames) (See "Training details" under "METHODS" on page 6 and the related source code [run_gpu#L32](https://github.com/deepmind/dqn/blob/9d9b1d13a2b491d6ebd4d046740c511c662bbe0f/run_gpu#L32), [dqn/train_agent.lua#L81-L82](https://github.com/deepmind/dqn/blob/9d9b1d13a2b491d6ebd4d046740c511c662bbe0f/dqn/train_agent.lua#L81-L82), and [dqn/train_agent.lua#L165-L169](https://github.com/deepmind/dqn/blob/9d9b1d13a2b491d6ebd4d046740c511c662bbe0f/dqn/train_agent.lua#L165-L169)).
97
+ - `dqn_atari.py` uses `--end-e=0.01` (the final exploration epsilon) whereas (Mnih et al., 2015)[^1] (Extended Data Table 1) uses `--end-e=0.1`.
98
+ - `dqn_atari.py` uses `--exploration-fraction=0.1` whereas (Mnih et al., 2015)[^1] (Extended Data Table 1) uses `--exploration-fraction=0.02` (all corresponds to 250000 steps or 1M frames being the frame that epsilon is annealed to `--end-e=0.1` ).
99
+ - `dqn_atari.py` handles truncation and termination properly like (Mnih et al., 2015)[^1] by using SB3's replay buffer's `handle_timeout_termination=True`.
100
+ 2. `dqn_atari.py` use a self-contained evaluation scheme: `dqn_atari.py` reports the episodic returns obtained throughout training, whereas (Mnih et al., 2015)[^1] is trained with `--end-e=0.1` but reported episodic returns using a separate evaluation process with `--end-e=0.01` (See "Evaluation procedure" under "METHODS" on page 6).
101
+ 3. `dqn_atari.py` implements target network updates as Polyak updates. Compared to the original implementation in (Mnih et al., 2015)[^1], this version allows soft updates of the target network weights with `--tau` (update coefficient) values of less than 1 (i.e. `--tau=0.9`). Note that by default `--tau=1.0` is used to be consistent with (Mnih et al., 2015)[^1].
102
+ 4. `dqn_atari.py` uses the standard MSE loss function, whereas (Mnih et al., 2015)[^1] "...found it helpful to clip the error term from the update $r + \gamma \max_{a'}Q(s', a'; \theta^{-}_{i}) - Q(s, a; \theta_{i})$ to be between -1 and 1" (See "Training algorithm for deep Q-networks" under "METHODS" on page 7).
103
+
104
+ ### Experiment results
105
+
106
+ To run benchmark experiments, see :material-github: [benchmark/dqn.sh](https://github.com/vwxyzjn/cleanrl/blob/master/benchmark/dqn.sh). Specifically, execute the following command:
107
+
108
+ <script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fvwxyzjn%2Fcleanrl%2Fblob%2Fmaster%2Fbenchmark%2Fdqn.sh%23L8-L13&style=github&showBorder=on&showLineNumbers=on&showFileMeta=on&showCopy=on"></script>
109
+
110
+ Below are the average episodic returns for `dqn_atari.py`.
111
+
112
+
113
+ | Environment | `dqn_atari.py` 10M steps | (Mnih et al., 2015)[^1] 50M steps | (Hessel et al., 2017, Figure 5)[^3]
114
+ | ----------- | ----------- | ----------- | ---- |
115
+ | BreakoutNoFrameskip-v4 | 366.928 ± 39.89 |401.2 ± 26.9 | ~230 at 10M steps, ~300 at 50M steps
116
+ | PongNoFrameskip-v4 | 20.25 ± 0.41 | 18.9 ± 1.3 | ~20 10M steps, ~20 at 50M steps
117
+ | BeamRiderNoFrameskip-v4 | 6673.24 ± 1434.37 | 6846 ± 1619 | ~6000 10M steps, ~7000 at 50M steps
118
+
119
+
120
+ Note that we save computational time by reducing timesteps from 50M to 10M, but our `dqn_atari.py` scores the same or higher than (Mnih et al., 2015)[^1] in 10M steps.
121
+
122
+
123
+ Learning curves:
124
+
125
+ <div class="grid-container">
126
+ <img src="../dqn/BeamRiderNoFrameskip-v4.png">
127
+
128
+ <img src="../dqn/BreakoutNoFrameskip-v4.png">
129
+
130
+ <img src="../dqn/PongNoFrameskip-v4.png">
131
+ </div>
132
+
133
+
134
+ Tracked experiments and game play videos:
135
+
136
+ <iframe src="https://wandb.ai/openrlbenchmark/openrlbenchmark/reports/Atari-CleanRL-s-DQN--VmlldzoxNjk3NjYx" style="width:100%; height:500px" title="CleanRL DQN + Atari Tracked Experiments"></iframe>
137
+
138
+
139
+ ## `dqn.py`
140
+
141
+ The [dqn.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/dqn.py) has the following features:
142
+
143
+ * Works with the `Box` observation space of low-level features
144
+ * Works with the `Discrete` action space
145
+ * Works with envs like `CartPole-v1`
146
+
147
+
148
+ ### Usage
149
+
150
+
151
+
152
+ === "poetry"
153
+
154
+ ```bash
155
+ uv run python cleanrl/dqn.py --env-id CartPole-v1
156
+ ```
157
+
158
+ === "pip"
159
+
160
+ ```bash
161
+ python cleanrl/dqn.py --env-id CartPole-v1
162
+ ```
163
+
164
+
165
+ ### Explanation of the logged metrics
166
+
167
+ See [related docs](/rl-algorithms/dqn/#explanation-of-the-logged-metrics) for `dqn_atari.py`.
168
+
169
+ ### Implementation details
170
+
171
+ The [dqn.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/dqn.py) shares the same implementation details as [`dqn_atari.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/dqn_atari.py) except the `dqn.py` runs with different hyperparameters and neural network architecture. Specifically,
172
+
173
+ 1. `dqn.py` uses a simpler neural network as follows:
174
+ ```python
175
+ self.network = nn.Sequential(
176
+ nn.Linear(np.array(env.single_observation_space.shape).prod(), 120),
177
+ nn.ReLU(),
178
+ nn.Linear(120, 84),
179
+ nn.ReLU(),
180
+ nn.Linear(84, env.single_action_space.n),
181
+ )
182
+ ```
183
+ 2. `dqn.py` runs with different hyperparameters:
184
+
185
+ ```bash
186
+ python dqn.py --total-timesteps 500000 \
187
+ --learning-rate 2.5e-4 \
188
+ --buffer-size 10000 \
189
+ --gamma 0.99 \
190
+ --target-network-frequency 500 \
191
+ --max-grad-norm 0.5 \
192
+ --batch-size 128 \
193
+ --start-e 1 \
194
+ --end-e 0.05 \
195
+ --exploration-fraction 0.5 \
196
+ --learning-starts 10000 \
197
+ --train-frequency 10
198
+ ```
199
+
200
+
201
+ ### Experiment results
202
+
203
+ To run benchmark experiments, see :material-github: [benchmark/dqn.sh](https://github.com/vwxyzjn/cleanrl/blob/master/benchmark/dqn.sh). Specifically, execute the following command:
204
+
205
+ <script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fvwxyzjn%2Fcleanrl%2Fblob%2Fmaster%2Fbenchmark%2Fdqn.sh%23L2-L6&style=github&showBorder=on&showLineNumbers=on&showFileMeta=on&showCopy=on"></script>
206
+
207
+ Below are the average episodic returns for `dqn.py`.
208
+
209
+
210
+ | Environment | `dqn.py` |
211
+ | ----------- | ----------- |
212
+ | CartPole-v1 | 488.69 ± 16.11 |
213
+ | Acrobot-v1 | -91.54 ± 7.20 |
214
+ | MountainCar-v0 | -194.95 ± 8.48 |
215
+
216
+
217
+ Note that the DQN has no official benchmark on classic control environments, so we did not include a comparison. That said, our `dqn.py` was able to achieve near perfect scores in `CartPole-v1` and `Acrobot-v1`; further, it can obtain successful runs in the sparse environment `MountainCar-v0`.
218
+
219
+
220
+ Learning curves:
221
+
222
+ <div class="grid-container">
223
+ <img src="../dqn/CartPole-v1.png">
224
+
225
+ <img src="../dqn/Acrobot-v1.png">
226
+
227
+ <img src="../dqn/MountainCar-v0.png">
228
+ </div>
229
+
230
+ Tracked experiments and game play videos:
231
+
232
+ <iframe src="https://wandb.ai/openrlbenchmark/openrlbenchmark/reports/Classic-Control-CleanRL-s-DQN--VmlldzoxODE4Mjg1" style="width:100%; height:500px" title="CleanRL DQN Tracked Experiments"></iframe>
233
+
234
+
235
+
236
+ ## `dqn_atari_jax.py`
237
+
238
+
239
+ The [dqn_atari_jax.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/dqn_atari_jax.py) has the following features:
240
+
241
+ * Uses [Jax](https://github.com/google/jax), [Flax](https://github.com/google/flax), and [Optax](https://github.com/deepmind/optax) instead of `torch`. [dqn_atari_jax.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/dqn_atari_jax.py) is roughly 25%-50% faster than [dqn_atari.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/dqn_atari.py)
242
+ * For playing Atari games. It uses convolutional layers and common atari-based pre-processing techniques.
243
+ * Works with the Atari's pixel `Box` observation space of shape `(210, 160, 3)`
244
+ * Works with the `Discrete` action space
245
+
246
+ ### Usage
247
+
248
+
249
+ === "poetry"
250
+
251
+ ```bash
252
+ uv pip install ".[atari, jax]"
253
+ uv pip install --upgrade "jax[cuda11_cudnn82]==0.4.8" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
254
+ uv run python cleanrl/dqn_atari_jax.py --env-id BreakoutNoFrameskip-v4
255
+ uv run python cleanrl/dqn_atari_jax.py --env-id PongNoFrameskip-v4
256
+ ```
257
+
258
+ === "pip"
259
+
260
+ ```bash
261
+ pip install -r requirements/requirements-atari.txt
262
+ pip install -r requirements/requirements-jax.txt
263
+ pip install --upgrade "jax[cuda]==0.3.17" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
264
+ python cleanrl/dqn_atari_jax.py --env-id BreakoutNoFrameskip-v4
265
+ python cleanrl/dqn_atari_jax.py --env-id PongNoFrameskip-v4
266
+ ```
267
+
268
+
269
+ ???+ warning
270
+
271
+ Note that JAX does not work in Windows :fontawesome-brands-windows:. The official [docs](https://github.com/google/jax#installation) recommends using Windows Subsystem for Linux (WSL) to install JAX.
272
+
273
+ ### Explanation of the logged metrics
274
+
275
+ See [related docs](/rl-algorithms/dqn/#explanation-of-the-logged-metrics) for `dqn_atari.py`.
276
+
277
+ ### Implementation details
278
+
279
+ See [related docs](/rl-algorithms/dqn/#implementation-details) for `dqn_atari.py`.
280
+
281
+ ### Experiment results
282
+
283
+ To run benchmark experiments, see :material-github: [benchmark/dqn.sh](https://github.com/vwxyzjn/cleanrl/blob/master/benchmark/dqn.sh). Specifically, execute the following command:
284
+
285
+ <script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fvwxyzjn%2Fcleanrl%2Fblob%2Fmaster%2Fbenchmark%2Fdqn.sh%23L23-L29&style=github&showBorder=on&showLineNumbers=on&showFileMeta=on&showCopy=on"></script>
286
+
287
+
288
+ Below are the average episodic returns for [`dqn_atari_jax.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/dqn_atari_jax.py) (3 random seeds).
289
+
290
+
291
+ | Environment | `dqn_atari_jax.py` 10M steps | `dqn_atari.py` 10M steps | (Mnih et al., 2015)[^1] 50M steps | (Hessel et al., 2017, Figure 5)[^3] |
292
+ | ----------------------- | ---------------------------- | ------------------------ | --------------------------------- | ------------------------------------ |
293
+ | BreakoutNoFrameskip-v4 | 377.82 ± 34.91 | 366.928 ± 39.89 | 401.2 ± 26.9 | ~230 at 10M steps, ~300 at 50M steps |
294
+ | PongNoFrameskip-v4 | 20.43 ± 0.34 | 20.25 ± 0.41 | 18.9 ± 1.3 | ~20 10M steps, ~20 at 50M steps |
295
+ | BeamRiderNoFrameskip-v4 | 5938.13 ± 955.84 | 6673.24 ± 1434.37 | 6846 ± 1619 | ~6000 10M steps, ~7000 at 50M steps |
296
+
297
+
298
+ ???+ info
299
+
300
+ We observe a speedup of `~25%` in ['dqn_atari_jax.py'](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/dqn_atari_jax.py) compared to ['dqn_atari.py'](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/dqn_atari.py). This could be because the training loop is tightly integrated with the experience collection loop. We run a training loop every `4` environment steps by default. So more time is utilised in collecting experience than training the network. We observe much more speed-ups in algorithms which run a training step for each environment step. E.g., [DDPG](/rl-algorithms/ddpg/#experiment-results_1)
301
+
302
+ Learning curves:
303
+
304
+ <div class="grid-container">
305
+ <img src="../dqn/jax/BeamRiderNoFrameskip-v4.png">
306
+ <img src="../dqn/jax/BeamRiderNoFrameskip-v4-time.png">
307
+
308
+ <img src="../dqn/jax/BreakoutNoFrameskip-v4.png">
309
+ <img src="../dqn/jax/BreakoutNoFrameskip-v4-time.png">
310
+
311
+ <img src="../dqn/jax/PongNoFrameskip-v4.png">
312
+ <img src="../dqn/jax/PongNoFrameskip-v4-time.png">
313
+ </div>
314
+
315
+ Tracked experiments and game play videos:
316
+
317
+ <iframe src="https://wandb.ai/openrlbenchmark/openrlbenchmark/reports/Atari-CleanRL-s-DQN-JAX--VmlldzoyMzM3MDg1" style="width:100%; height:500px" title="CleanRL DQN + JAX + Atari Tracked Experiments"></iframe>
318
+
319
+
320
+
321
+ ## `dqn_jax.py`
322
+ * Uses [Jax](https://github.com/google/jax), [Flax](https://github.com/google/flax), and [Optax](https://github.com/deepmind/optax) instead of `torch`. [dqn_jax.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/dqn_jax.py) is roughly 50% faster than [dqn.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/dqn.py)
323
+ * Works with the `Box` observation space of low-level features
324
+ * Works with the `Discrete` action space
325
+ * Works with envs like `CartPole-v1`
326
+
327
+ ### Usage
328
+
329
+ ```bash
330
+ python cleanrl/dqn_jax.py --env-id CartPole-v1
331
+ ```
332
+
333
+ === "poetry"
334
+
335
+ ```bash
336
+ uv pip install --upgrade "jax[cuda11_cudnn82]==0.4.8" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
337
+ uv run python cleanrl/dqn_jax.py --env-id CartPole-v1
338
+ ```
339
+
340
+ === "pip"
341
+
342
+ ```bash
343
+ pip install -r requirements/requirements-jax.txt
344
+ pip install --upgrade "jax[cuda]==0.3.17" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
345
+ python cleanrl/dqn_jax.py --env-id CartPole-v1
346
+ ```
347
+
348
+
349
+ ### Explanation of the logged metrics
350
+
351
+ See [related docs](/rl-algorithms/dqn/#explanation-of-the-logged-metrics) for `dqn_atari.py`.
352
+
353
+ ### Implementation details
354
+
355
+ See [related docs](/rl-algorithms/dqn/#implementation-details_1) for `dqn.py`.
356
+
357
+ ### Experiment results
358
+
359
+ To run benchmark experiments, see :material-github: [benchmark/dqn.sh](https://github.com/vwxyzjn/cleanrl/blob/master/benchmark/dqn.sh). Specifically, execute the following command:
360
+
361
+ <script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fvwxyzjn%2Fcleanrl%2Fblob%2Fmaster%2Fbenchmark%2Fdqn.sh%23L15-L21&style=github&showBorder=on&showLineNumbers=on&showFileMeta=on&showCopy=on"></script>
362
+
363
+ Below are the average episodic returns for [`dqn_jax.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/dqn_jax.py) (3 random seeds).
364
+
365
+
366
+
367
+ | Environment | `dqn_jax.py` | `dqn.py` |
368
+ | ----------- | ----------- | ----------- |
369
+ | CartPole-v1 | 498.38 ± 2.29 | 488.69 ± 16.11 |
370
+ | Acrobot-v1 | -88.89 ± 1.56 | -91.54 ± 7.20 |
371
+ | MountainCar-v0 | -188.90 ± 11.78 | -194.95 ± 8.48 |
372
+
373
+
374
+
375
+ <div class="grid-container">
376
+ <img src="../dqn/jax/CartPole-v1.png">
377
+ <img src="../dqn/jax/CartPole-v1-time.png">
378
+
379
+ <img src="../dqn/jax/Acrobot-v1.png">
380
+ <img src="../dqn/jax/Acrobot-v1-time.png">
381
+
382
+ <img src="../dqn/jax/MountainCar-v0.png">
383
+ <img src="../dqn/jax/MountainCar-v0-time.png">
384
+ </div>
385
+
386
+
387
+ Tracked experiments and game play videos:
388
+
389
+ <iframe src="https://wandb.ai/openrlbenchmark/openrlbenchmark/reports/Classic-Control-CleanRL-s-DQN-JAX--VmlldzozMjM5Mjgx" style="width:100%; height:500px" title="CleanRL DQN + JAX Tracked Experiments"></iframe>
390
+
391
+
392
+
393
+
394
+ [^1]:Mnih, V., Kavukcuoglu, K., Silver, D. et al. Human-level control through deep reinforcement learning. Nature 518, 529–533 (2015). https://doi.org/10.1038/nature14236
395
+ [^2]:\[Proposal\] Formal API handling of truncation vs termination. https://github.com/openai/gym/issues/2510
396
+ [^3]: Hessel, M., Modayil, J., Hasselt, H.V., Schaul, T., Ostrovski, G., Dabney, W., Horgan, D., Piot, B., Azar, M.G., & Silver, D. (2018). Rainbow: Combining Improvements in Deep Reinforcement Learning. AAAI.
cleanrl/docs/rl-algorithms/ppg.md ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Phasic Policy Gradient (PPG)
2
+
3
+ ## Overview
4
+
5
+ PPG is a DRL algorithm that separates policy and value function training by introducing an auxiliary phase. The training proceeds by running PPO during the policy phase, saving all the experience in a replay buffer. Then the replay buffer is used to train the value function. This makes the algorithm considerably slower than PPO, but improves sample efficiency on Procgen benchmark.
6
+
7
+ Original paper:
8
+
9
+ * [Phasic Policy Gradient](https://arxiv.org/abs/2009.04416)
10
+
11
+ Reference resources:
12
+
13
+ * [Code for the paper "Phasic Policy Gradient"](https://github.com/openai/phasic-policy-gradient) - by original authors from OpenAI
14
+
15
+ The original code has multiple code level details that are not mentioned in the paper. We found these changes to be important for reproducing the results claimed by the paper.
16
+
17
+ ## Implemented Variants
18
+
19
+
20
+ | Variants Implemented | Description |
21
+ | ----------- | ----------- |
22
+ | :material-github: [`ppg_procgen.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ppg_procgen.py), :material-file-document: [docs](/rl-algorithms/ppg/#ppg_procgenpy) | For classic control tasks like `CartPole-v1`. |
23
+
24
+ Below are our single-file implementations of PPG:
25
+
26
+ ## `ppg_procgen.py`
27
+
28
+ `ppg_procgen.py` works with the Procgen benchmark, which uses 64x64 RGB image observations, and discrete actions
29
+
30
+ ### Usage
31
+
32
+ === "uv"
33
+
34
+ ```bash
35
+ uv pip install ".[procgen]"
36
+ uv run python cleanrl/ppg_procgen.py --help
37
+ uv run python cleanrl/ppg_procgen.py --env-id starpilot
38
+ ```
39
+
40
+ === "pip"
41
+
42
+ ```bash
43
+ pip install -r requirements/requirements-procgen.txt
44
+ python cleanrl/ppg_procgen.py --help
45
+ python cleanrl/ppg_procgen.py --env-id starpilot
46
+ ```
47
+
48
+ ### Explanation of the logged metrics
49
+
50
+ Running `python cleanrl/ppg_procgen.py` will automatically record various metrics such as actor or value losses in Tensorboard. Below is the documentation for these metrics:
51
+
52
+ Same as PPO:
53
+
54
+ * `charts/episodic_return`: episodic return of the game
55
+ * `charts/episodic_length`: episodic length of the game
56
+ * `charts/SPS`: number of steps per second (this is initially high but drops off after the auxiliary phase)
57
+ * `charts/learning_rate`: the current learning rate (annealing is not done by default)
58
+ * `losses/value_loss`: the mean value loss across all data points
59
+ * `losses/policy_loss`: the mean policy loss across all data points
60
+ * `losses/entropy`: the mean entropy value across all data points
61
+ * `losses/old_approx_kl`: the approximate Kullback–Leibler divergence, measured by `(-logratio).mean()`, which corresponds to the k1 estimator in John Schulman’s blog post on [approximating KL](http://joschu.net/blog/kl-approx.html)
62
+ * `losses/approx_kl`: better alternative to `olad_approx_kl` measured by `(logratio.exp() - 1) - logratio`, which corresponds to the k3 estimator in [approximating KL](http://joschu.net/blog/kl-approx.html)
63
+ * `losses/clipfrac`: the fraction of the training data that triggered the clipped objective
64
+ * `losses/explained_variance`: the explained variance for the value function
65
+
66
+ PPG specific:
67
+
68
+ * `losses/aux/kl_loss`: the mean value of the KL divergence when distilling the latest policy during the auxiliary phase.
69
+ * `losses/aux/aux_value_loss`: the mean value loss on the auxiliary value head
70
+ * `losses/aux/real_value_loss`: the mean value loss on the detached value head used to calculate the GAE returns during policy phase
71
+
72
+ ### Implementation details
73
+
74
+ `ppg_procgen.py` includes the <TODO> level implementation details that are different from PPO:
75
+
76
+ 1. Full rollout sampling during auxiliary phase - (:material-github: [phasic_policy_gradient/ppg.py#L173](https://github.com/openai/phasic-policy-gradient/blob/c789b00be58aa704f7223b6fc8cd28a5aaa2e101/phasic_policy_gradient/ppg.py#L173)) - Instead of randomly sampling observations over the entire auxiliary buffer, PPG samples full rullouts from the buffer (Sets of 256 steps). This full rollout sampling is only done during the auxiliary phase. Note that the rollouts will still be at random starting points because PPO truncates the rollouts per env. This change gives a decent performance boost.
77
+
78
+ 1. Batch level advantage normalization - PPG normalizes the full batch of advantage values before PPO updates instead of advantage normalization on each minibatch. (:material-github: [phasic_policy_gradient/ppo.py#L70](https://github.com/openai/phasic-policy-gradient/blob/c789b00be58aa704f7223b6fc8cd28a5aaa2e101/phasic_policy_gradient/ppo.py#L70))
79
+
80
+ 1. Normalized network initialization - (:material-github: [phasic_policy_gradient/impala_cnn.py#L64](https://github.com/openai/phasic-policy-gradient/blob/c789b00be58aa704f7223b6fc8cd28a5aaa2e101/phasic_policy_gradient/impala_cnn.py#L64)) - PPG uses normalized initialization for all layers, with different scales.
81
+ * Original PPO used orthogonal initialization of only the Policy head and Value heads with scale of 0.01 and 1. respectively.
82
+ * For PPG
83
+ * All weights are initialized with the default torch initialization (Kaiming Uniform)
84
+ * Each layer’s weights are divided by the L2 norm of the weights such that the weights of `input_channels` axis are individually normalized (axis 1 for linear layers and 1,2,3 for convolutional layers). Then the weights are multiplied by a scale factor.
85
+ * Scale factors for different layers
86
+ * Value head, Policy head, Auxiliary value head - 0.1
87
+ * Fully connected layer after last conv later - 1.4
88
+ * Convolutional layers - Approximately 0.638
89
+ 1. The Adam Optimizer's Epsilon Parameter -(:material-github: [phasic_policy_gradient/ppg.py#L239](https://github.com/openai/phasic-policy-gradient/blob/c789b00be58aa704f7223b6fc8cd28a5aaa2e101/phasic_policy_gradient/ppg.py#L239)) - Set to torch default of 1e-8 instead of 1e-5 which is used in PPO.
90
+ 1. Use the same `gamma` parameter in the `NormalizeReward` wrapper. Note that the original implementation from [openai/train-procgen](https://github.com/openai/train-procgen) uses the default `gamma=0.99` in [the `VecNormalize` wrapper](https://github.com/openai/train-procgen/blob/1a2ae2194a61f76a733a39339530401c024c3ad8/train_procgen/train.py#L43) but `gamma=0.999` as PPO's parameter. The mismatch between the `gamma`s is technically incorrect. See [#209](https://github.com/vwxyzjn/cleanrl/pull/209)
91
+
92
+ Here are some additional notes:
93
+
94
+ - All the default hyperparameters from the original PPG implementation are used. Except setting 64 for the number of environments.
95
+ - The original PPG paper does not report results on easy environments, hence more hyperparameter tuning can give better results.
96
+ - Skipping every alternate auxiliary phase gives similar performance on easy environments while saving compute.
97
+ - Normalized network initialization scheme seems to matter a lot, but using layernorm with orthogonal initialization also works.
98
+ - Using mixed precision for auxiliary phase also works well to save compute, but using on policy phase makes training unstable.
99
+
100
+
101
+ Also, `ppg_procgen.py` differs from the original `openai/phasic-policy-gradient` implementation in the following ways.
102
+
103
+ - The original PPG code supports LSTM whereas the CleanRL code does not.
104
+ - The original PPG code uses separate optimizers for policy and auxiliary phase, but we do not implement this as we found it to not make too much difference.
105
+ - The original PPG code utilizes multiple GPUs but our implementation does not
106
+
107
+
108
+ ### Experiment results
109
+
110
+ To run benchmark experiments, see :material-github: [benchmark/ppg.sh](https://github.com/vwxyzjn/cleanrl/blob/master/benchmark/ppg.sh). Specifically, execute the following command:
111
+
112
+ <script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fvwxyzjn%2Fcleanrl%2Fblob%2Fmaster%2Fbenchmark%2Fppg.sh%23L3-L8&style=github&showBorder=on&showLineNumbers=on&showFileMeta=on&showCopy=on"></script>
113
+
114
+
115
+ Below are the average episodic returns for `ppg_procgen.py`, and comparison with `ppg_procgen.py` on 25M timesteps.
116
+
117
+ | Environment | `ppg_procgen.py` | `ppo_procgen.py` | `openai/phasic-policy-gradient` (easy) |
118
+ |------------------|------------------|------------------|----------------------------------------|
119
+ | Starpilot (easy) | 34.82 ± 13.77 | 32.47 ± 11.21 | 42.01 ± 9.59 |
120
+ | Bossfight (easy) | 10.78 ± 1.90 | 9.63 ± 2.35 | 10.71 ± 2.05 |
121
+ | Bigfish (easy) | 24.23 ± 10.73 | 16.80 ± 9.49 | 15.94 ± 10.80 |
122
+
123
+
124
+ ???+ warning
125
+
126
+ Note that we have run the procgen experiments using the `easy` distribution for reducing the computational cost. However, the original paper's results were condcuted with the `hard` distribution mode. For convenience, in the learning curves below, we compared the performance of the original code base (`openai/phasic-policy-gradient` the purple curve) in the `easy` distribution.
127
+
128
+ Learning curves:
129
+
130
+ <div class="grid-container">
131
+ <img src="../ppg/StarPilot.png">
132
+ <img src="../ppg/comparison/StarPilot.png">
133
+
134
+ <img src="../ppg/BossFight.png">
135
+ <img src="../ppg/comparison/BossFight.png">
136
+
137
+ <img src="../ppg/BigFish.png">
138
+ <img src="../ppg/comparison/BigFish.png">
139
+ </div>
140
+
141
+
142
+ ???+ info
143
+
144
+ Also note that our `ppo_procgen.py` which closely matches implementation details of `openai/baselines`' PPO which might not be the same as `openai/phasic-policy-gradient`'s PPO. We take the reported results from (Cobbe et al., 2020)[^1] and (Cobbe et al., 2021)[^2] and compared them in a [google sheet](https://docs.google.com/spreadsheets/d/1ZC_D2WPL6-PzhecM4ZFQWQ6nY6dkXeQDOIgRHVp1BNU/edit?usp=sharing) (screenshot shown below). As shown, the performance seems to diverge a bit. We also note that (Cobbe et al., 2020)[^1] used [`procgen==0.9.2`](https://github.com/openai/train-procgen/blob/1a2ae2194a61f76a733a39339530401c024c3ad8/environment.yml#L10) and (Cobbe et al., 2021)[^2] used [`procgen==0.10.4`](https://github.com/openai/phasic-policy-gradient/blob/7295473f0185c82f9eb9c1e17a373135edd8aacc/environment.yml#L10), which also could cause performance difference. It is for this reason, we ran our own `openai/phasic-policy-gradient` experiments on the `easy` distribution for comparison, but this does mean it's challenging to compare our results against those in the original PPG paper (Cobbe et al., 2021)[^2].
145
+
146
+ ![PPG's PPO compared to openai/baselines' PPO](../ppg/ppg-ppo.png)
147
+
148
+ Tracked experiments and game play videos:
149
+
150
+
151
+ <iframe src="https://wandb.ai/openrlbenchmark/openrlbenchmark/reports/Procgen-CleanRL-s-PPG--VmlldzoyMDc1MDMz" style="width:100%; height:500px" title="Procgen-CleanRL-s-PPG"></iframe>
152
+
153
+ <iframe src="https://wandb.ai/openrlbenchmark/openrlbenchmark/reports/Procgen-CleanRL-s-PPG-vs-PPO-vs-openai-phasic-policy-gradient--VmlldzoyMDc1MDc3" style="width:100%; height:500px" title="Procgen-CleanRL-s-PPG-PPO-openai-phasic-policy-gradient"></iframe>
154
+
155
+
156
+ [^1]: Cobbe, K., Hesse, C., Hilton, J., & Schulman, J. (2020, November). Leveraging procedural generation to benchmark reinforcement learning. In International conference on machine learning (pp. 2048-2056). PMLR.
157
+ [^2]: Cobbe, K. W., Hilton, J., Klimov, O., & Schulman, J. (2021, July). Phasic policy gradient. In International Conference on Machine Learning (pp. 2020-2027). PMLR.
158
+
cleanrl/docs/rl-algorithms/ppo-isaacgymenvs.md ADDED
@@ -0,0 +1,259 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3
+ SPDX-License-Identifier: MIT
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a
6
+ copy of this software and associated documentation files (the "Software"),
7
+ to deal in the Software without restriction, including without limitation
8
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
+ and/or sell copies of the Software, and to permit persons to whom the
10
+ Software is furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21
+ DEALINGS IN THE SOFTWARE.
22
+ -->
23
+
24
+ ## `ppo_continuous_action_isaacgym.py`
25
+
26
+
27
+ ???+ warning
28
+
29
+ `ppo_continuous_action_isaacgym.py` is temporarily deprecated. Please checkout the code in [https://github.com/vwxyzjn/cleanrl/releases/tag/v1.0.0](https://github.com/vwxyzjn/cleanrl/releases/tag/v1.0.0)
30
+
31
+
32
+ The [ppo_continuous_action_isaacgym.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ppo_continuous_action_isaacgym/ppo_continuous_action_isaacgym.py) has the following features:
33
+
34
+ - Works with IsaacGymEnvs.
35
+ - Works with the `Box` observation space of low-level features
36
+ - Works with the `Box` (continuous) action space
37
+
38
+ [IsaacGymEnvs](https://github.com/NVIDIA-Omniverse/IsaacGymEnvs) is a hardware-accelerated (or GPU-accelerated) robotics simulation environment based on `torch`, which allows us to run thousands of simulation environments at the same time, empowering RL agents to learn many MuJoCo-style robotics tasks in minutes instead of hours. When creating an environment with IsaacGymEnvs via `isaacgymenvs.make("Ant")`, it creates a vectorized environment which produces GPU tensors as observations and take GPU tensors as actions to execute.
39
+
40
+ ???+ info
41
+
42
+ Note that **Isaac Gym** is the underlying core physics engine, and **IssacGymEnvs** is a collection of environments built on Isaac Gym.
43
+
44
+ ???+ info
45
+
46
+ `ppo_continuous_action_isaacgym.py` works with most environments in IsaacGymEnvs but it does not work with the following environments yet:
47
+
48
+ * AnymalTerrain
49
+ * FrankaCabinet
50
+ * ShadowHandOpenAI_FF
51
+ * ShadowHandOpenAI_LSTM
52
+ * Trifinger
53
+ * Ingenuity Quadcopter
54
+
55
+ 🔥 we need contributors to work on supporting and tuning our PPO implementation in these envs. If you are interested, please read our [contribution guide](https://github.com/vwxyzjn/cleanrl/blob/master/CONTRIBUTING.md) and reach out!
56
+
57
+ ### Usage
58
+
59
+ The installation of `isaacgym` requires a bit of work since it's not a standard Python package.
60
+
61
+ Please go to [https://developer.nvidia.com/isaac-gym](https://developer.nvidia.com/isaac-gym) to download and install the latest version of Issac Gym which should look like `IsaacGym_Preview_4_Package.tar.gz`. Put this `IsaacGym_Preview_4_Package.tar.gz` into the `~/Downloads/` folder. Make sure your python version is either 3.7, or 3.8 (3.9 _not_ supported yet).
62
+
63
+ ```bash
64
+ # extract and move the content in `python` folder in the IsaacGym_Preview_4_Package.tar.gz
65
+ # into the `cleanrl/ppo_continuous_action_isaacgym/isaacgym/` folder
66
+ cp ~/Downloads/IsaacGym_Preview_4_Package.tar.gz IsaacGym_Preview_4_Package.tar.gz
67
+ stat IsaacGym_Preview_4_Package.tar.gz
68
+ mkdir temp_isaacgym
69
+ tar -xf IsaacGym_Preview_4_Package.tar.gz -C temp_isaacgym
70
+ mv temp_isaacgym/isaacgym/python/* cleanrl/ppo_continuous_action_isaacgym/isaacgym
71
+ rm -rf temp_isaacgym
72
+
73
+ # if your global python version is not either 3.7 nor 3.8, you need to tell poetry specifically to use a 3.7 or 3.8 python
74
+ # e.g., `poetry env use /home/costa/.pyenv/versions/3.7.8/bin/python`
75
+ poetry install --with isaacgym
76
+ # if you are using NVIDIA's 30xx GPU, you need to specifically install cuda 11.3 wheels
77
+ # `uv pip install torch --upgrade --extra-index-url https://download.pytorch.org/whl/cu113`
78
+ uv run python cleanrl/ppo_continuous_action_isaacgym/ppo_continuous_action_isaacgym.py --help
79
+ uv run python cleanrl/ppo_continuous_action_isaacgym/ppo_continuous_action_isaacgym.py --env-id Ant
80
+ ```
81
+
82
+ <script id="asciicast-510341" src="https://asciinema.org/a/510341.js" async></script>
83
+
84
+
85
+ ???+ warning
86
+
87
+ If you encounter the following installation error
88
+
89
+ ```bash
90
+ Python.h: No such file or directory
91
+ #include <Python.h>
92
+ ```
93
+
94
+ or
95
+
96
+ ```bash
97
+ libpython3.8.so.1.0: cannot open shared object file: No such file or directory
98
+ ```
99
+
100
+ It usually means your python distribution does not include the shared library files. If you are ubuntu, you can install the following packages:
101
+
102
+ ```bash
103
+ sudo apt-get install libpython3.8-dev # or sudo apt-get install libpython3.7-dev
104
+ ```
105
+
106
+ If you are using [pyenv](https://github.com/pyenv/pyenv), you may try the following:
107
+
108
+ ```bash
109
+ env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.7.8
110
+ ```
111
+
112
+ ### Explanation of the logged metrics
113
+
114
+ See [related docs](/rl-algorithms/ppo/#explanation-of-the-logged-metrics) for `ppo.py`.
115
+
116
+ Additionally, `charts/consecutive_successes` means the number of consecutive episodes that the agent has successfully manipulating the rubix cube to the desired state.
117
+
118
+ ### Implementation details
119
+
120
+ [ppo_continuous_action_isaacgym.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ppo_continuous_action_isaacgym/ppo_continuous_action_isaacgym.py) is based on `ppo_continuous_action.py` (see related [docs](/rl-algorithms/ppo/#ppo_continuous_actionpy)), with a few modifications:
121
+
122
+ 1. **Different set of hyperparameters**: `ppo_continuous_action_isaacgym.py` uses hyperparameters primarily derived from [rl-games](https://github.com/Denys88/rl_games)' configuration (see [example](https://github.com/NVIDIA-Omniverse/IsaacGymEnvs/blob/main/isaacgymenvs/cfg/train/AntPPO.yaml)). The basic spirit is to run more `total_timesteps`, with larger `num_envs` and smaller `num_steps`.
123
+
124
+ | arguments | `ppo_continuous_action.py` | `ppo_continuous_action_isaacgym.py` | `ppo_continuous_action_isaacgym.py` (for `ShadowHand` and `AllegroHand`) |
125
+ | ----------------- | -------------------------- | ----------------------------------- | ----------------------------------- |
126
+ | --total-timesteps | 1000000 | 30000000 | 600000000 |
127
+ | --learning-rate | 3e-4 | 0.0026 | 0.0026 |
128
+ | --num-envs | 1 | 4096 | 8192 |
129
+ | --num-steps | 2048 | 16 | 8 |
130
+ | --anneal-lr | True | False | False |
131
+ | --num-minibatches | 32 | 2 | 4 |
132
+ | --update-epochs | 10 | 4 | 5 |
133
+ | --clip-vloss | True | False | False |
134
+ | --vf-coef | 0.5 | 2 | 2 |
135
+ | --max-grad-norm | 0.5 | 1 | 1 |
136
+ | --reward-scaler | N/A | 1 | 0.01 |
137
+
138
+ 1. **Slightly larger NN**: `ppo_continuous_action.py` uses the following NN:
139
+ ```python
140
+ self.critic = nn.Sequential(
141
+ layer_init(nn.Linear(np.array(envs.single_observation_space.shape).prod(), 64)),
142
+ nn.Tanh(),
143
+ layer_init(nn.Linear(64, 64)),
144
+ nn.Tanh(),
145
+ layer_init(nn.Linear(64, 1), std=1.0),
146
+ )
147
+ self.actor_mean = nn.Sequential(
148
+ layer_init(nn.Linear(np.array(envs.single_observation_space.shape).prod(), 64)),
149
+ nn.Tanh(),
150
+ layer_init(nn.Linear(64, 64)),
151
+ nn.Tanh(),
152
+ layer_init(nn.Linear(64, np.prod(envs.single_action_space.shape)), std=0.01),
153
+ )
154
+ ```
155
+ while `ppo_continuous_action_isaacgym.py` uses the following NN:
156
+ ```python
157
+ self.critic = nn.Sequential(
158
+ layer_init(nn.Linear(np.array(envs.single_observation_space.shape).prod(), 256)),
159
+ nn.Tanh(),
160
+ layer_init(nn.Linear(256, 256)),
161
+ nn.Tanh(),
162
+ layer_init(nn.Linear(256, 1), std=1.0),
163
+ )
164
+ self.actor_mean = nn.Sequential(
165
+ layer_init(nn.Linear(np.array(envs.single_observation_space.shape).prod(), 256)),
166
+ nn.Tanh(),
167
+ layer_init(nn.Linear(256, 256)),
168
+ nn.Tanh(),
169
+ layer_init(nn.Linear(256, np.prod(envs.single_action_space.shape)), std=0.01),
170
+ )
171
+ ```
172
+ 1. **No normalization and clipping**: `ppo_continuous_action_isaacgym.py` does _not_ do observation and reward normalization and clipping for simplicity. It does however optionally offer an option to scale the rewards via `--reward-scaler x`, which multiplies all the rewards obtained by `x` as an example.
173
+ 1. **Remove all CPU-related code**: `ppo_continuous_action_isaacgym.py` needs to remove all CPU-related code (e.g. `action.cpu().numpy()`). This is because almost everything in IsaacGymEnvs happens in GPU. To do this, the major modifications include the following:
174
+ 1. Create a custom `RecordEpisodeStatisticsTorch` wrapper that records statstics using GPU tensors instead of `numpy` arrays.
175
+ 1. Avoid transferring the tensors to CPU. The related code in `ppo_continuous_action.py` looks like
176
+ ```python
177
+ next_obs, reward, done, info = envs.step(action.cpu().numpy())
178
+ rewards[step] = torch.tensor(reward).to(device).view(-1)
179
+ next_obs, next_done = torch.Tensor(next_obs).to(device), torch.Tensor(done).to(device)
180
+ ```
181
+ and the related code in `ppo_continuous_action_isaacgym.py` looks like
182
+ ```python
183
+ next_obs, rewards[step], next_done, info = envs.step(action)
184
+ ```
185
+
186
+ ### Experiment results
187
+
188
+ To run benchmark experiments, see :material-github: [benchmark/ppo.sh](https://github.com/vwxyzjn/cleanrl/blob/master/benchmark/ppo.sh). Specifically, execute the following command:
189
+
190
+ <script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fvwxyzjn%2Fcleanrl%2Fblob%2Fmaster%2Fbenchmark%2Fppo.sh%23L61-L73&style=github&showBorder=on&showLineNumbers=on&showFileMeta=on&showCopy=on"></script>
191
+
192
+ Below are the average episodic returns for `ppo_continuous_action_isaacgym.py`. To ensure the quality of the implementation, we compared the results against [Denys88/rl_games](https://github.com/Denys88/rl_games)' PPO and present the training time (units being `s (seconds), m (minutes)`). The hardware used is a NVIDIA RTX A6000 in a 24 core machine.
193
+
194
+ | Environment (training time) | `ppo_continuous_action_isaacgym.py` | [Denys88/rl_games](https://github.com/Denys88/rl_games) |
195
+ | --------------------------- | ----------------------------------- | ------------------------------------------------------- |
196
+ | Cartpole (40s) | 413.66 ± 120.93 | 417.49 (30s) |
197
+ | Ant (240s) | 3953.30 ± 667.086 | 5873.05 |
198
+ | Humanoid (350s) | 2987.95 ± 257.60 | 6254.73 |
199
+ | Anymal (317s) | 29.34 ± 17.80 | 62.76 |
200
+ | BallBalance (160s) | 161.92 ± 89.20 | 319.76 |
201
+ | AllegroHand (200m) | 762.93 ± 427.92 | 3479.85 |
202
+ | ShadowHand (130m) | 427.16 ± 161.79 | 5713.74 |
203
+
204
+ Learning curves:
205
+
206
+ <div class="grid-container">
207
+ <img src="../ppo/isaacgymenvs/Cartpole.png">
208
+ <img src="../ppo/isaacgymenvs/Cartpole-time.png">
209
+ <img src="../ppo/isaacgymenvs/Ant.png">
210
+ <img src="../ppo/isaacgymenvs/Ant-time.png">
211
+ <img src="../ppo/isaacgymenvs/Humanoid.png">
212
+ <img src="../ppo/isaacgymenvs/Humanoid-time.png">
213
+ <img src="../ppo/isaacgymenvs/BallBalance.png">
214
+ <img src="../ppo/isaacgymenvs/BallBalance-time.png">
215
+ <img src="../ppo/isaacgymenvs/Anymal.png">
216
+ <img src="../ppo/isaacgymenvs/Anymal-time.png">
217
+ <img src="../ppo/isaacgymenvs/AllegroHand.png">
218
+ <img src="../ppo/isaacgymenvs/AllegroHand-time.png">
219
+ <img src="../ppo/isaacgymenvs/AllegroHand-c.png">
220
+ <img src="../ppo/isaacgymenvs/AllegroHand-c-time.png">
221
+ <img src="../ppo/isaacgymenvs/ShadowHand.png">
222
+ <img src="../ppo/isaacgymenvs/ShadowHand-time.png">
223
+ <img src="../ppo/isaacgymenvs/ShadowHand-c.png">
224
+ <img src="../ppo/isaacgymenvs/ShadowHand-c-time.png">
225
+ </div>
226
+
227
+ ???+ info
228
+
229
+ Note `ppo_continuous_action_isaacgym.py`'s performance seems poor compared to [Denys88/rl_games](https://github.com/Denys88/rl_games)' PPO. This is likely due to a few reasons.
230
+
231
+ 1. [Denys88/rl_games](https://github.com/Denys88/rl_games)' PPO uses different sets of tuned hyperparameters and neural network architecture configuration for different tasks, whereas `ppo_continuous_action_isaacgym.py` only uses one neural network architecture and 2 set of hyperparameters (ignoring `--total-timesteps`).
232
+ 1. `ppo_continuous_action_isaacgym.py` does not use observation normalization (because in my preliminary testing for some reasons it did not help).
233
+
234
+ While it should be possible to obtain higher scores with more tuning, the purpose of `ppo_continuous_action_isaacgym.py` is to hit a balance between simplicity and performance. I think `ppo_continuous_action_isaacgym.py` has relatively good performance with a concise codebase, which should be easy to modify and extend for practitioners.
235
+
236
+
237
+ Tracked experiments and game play videos:
238
+
239
+
240
+ <iframe src="https://wandb.ai/openrlbenchmark/openrlbenchmark/reports/Isaac-Gym-CleanRL-s-PPO--VmlldzoyMzQzNzMz" style="width:100%; height:500px" title="Isaac-Gym-CleanRL-s-PPO"></iframe>
241
+
242
+
243
+ Old Learning curves w/ Isaac Gym Preview 3 (no longer available in Nvidia's website for download):
244
+
245
+ <div class="grid-container">
246
+ <img src="../ppo/isaacgymenvs/old/Cartpole.png">
247
+ <img src="../ppo/isaacgymenvs/old/Ant.png">
248
+ <img src="../ppo/isaacgymenvs/old/Humanoid.png">
249
+ <img src="../ppo/isaacgymenvs/old/BallBalance.png">
250
+ <img src="../ppo/isaacgymenvs/old/Anymal.png">
251
+ <img src="../ppo/isaacgymenvs/old/AllegroHand.png">
252
+ <img src="../ppo/isaacgymenvs/old/ShadowHand.png">
253
+ </div>
254
+
255
+ ???+ info
256
+
257
+ Note the `AllegroHand` and `ShadowHand` experiments used the following command `ppo_continuous_action_isaacgym.py --track --capture_video --num-envs 16384 --num-steps 8 --update-epochs 5 --reward-scaler 0.01 --total-timesteps 600000000 --record-video-step-frequency 3660`. Costa: I was able to run this during my internship at NVIDIA, but in my home setup, the computer has less GPU memory which makes it hard to replicate the results w/ `--num-envs 16384`.
258
+
259
+
cleanrl/docs/rl-algorithms/ppo-rnd.md ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Random Network Distillation (RND)
2
+
3
+
4
+ ## Overview
5
+
6
+ RND is an exploration bonus for RL methods that's easy to implement and enables significant progress in some hard exploration Atari games such as Montezuma's Revenge. We use [Proximal Policy Gradient](/rl-algorithms/ppo/#ppopy) as our RL method as used by original paper's [implementation](https://github.com/openai/random-network-distillation)
7
+
8
+
9
+ Original paper:
10
+
11
+ * [Exploration by Random Network Distillation](https://arxiv.org/abs/1810.12894)
12
+
13
+ ## Implemented Variants
14
+
15
+
16
+ | Variants Implemented | Description |
17
+ | ----------- | ----------- |
18
+ | :material-github: [`ppo_rnd_envpool.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ppo_rnd_envpool.py), :material-file-document: [docs](/rl-algorithms/ppo-rnd/#ppo_rnd_envpoolpy) | For Atari games, uses EnvPool. |
19
+
20
+
21
+ Below are our single-file implementations of RND:
22
+
23
+ ## `ppo_rnd_envpool.py`
24
+
25
+ The [ppo_rnd_envpool.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ppo_rnd_envpool.py) has the following features:
26
+
27
+ * Uses the blazing fast [Envpool](https://github.com/sail-sg/envpool) vectorized environment.
28
+ * For playing Atari games. It uses convolutional layers and common atari-based pre-processing techniques.
29
+ * Works with the Atari's pixel `Box` observation space of shape `(210, 160, 3)`
30
+ * Works with the `Discerete` action space
31
+
32
+ ???+ warning
33
+
34
+ Note that `ppo_rnd_envpool.py` does not work in Windows :fontawesome-brands-windows: and MacOs :fontawesome-brands-apple:. See envpool's built wheels here: [https://pypi.org/project/envpool/#files](https://pypi.org/project/envpool/#files)
35
+
36
+ ???+ bug
37
+
38
+ EnvPool's vectorized environment **does not behave the same** as gym's vectorized environment, which causes a compatibility bug in our PPO implementation. When an action $a$ results in an episode termination or truncation, the environment generates $s_{last}$ as the terminated or truncated state; we then use $s_{new}$ to denote the initial state of the new episodes. Here is how the bahviors differ:
39
+
40
+ * Under the vectorized environment of `envpool<=0.6.4`, the `obs` in `obs, reward, done, info = env.step(action)` is the truncated state $s_{last}$
41
+ * Under the vectorized environment of `gym==0.23.1`, the `obs` in `obs, reward, done, info = env.step(action)` is the initial state $s_{new}$.
42
+
43
+ This causes the $s_{last}$ to be off by one.
44
+ See [:material-github: sail-sg/envpool#194](https://github.com/sail-sg/envpool/issues/194) for more detail. However, it does not seem to impact performance, so we take a note here and await for the upstream fix.
45
+
46
+
47
+ ### Usage
48
+
49
+ === "poetry"
50
+
51
+ ```bash
52
+ uv pip install ".[envpool]"
53
+ uv run python cleanrl/ppo_rnd_envpool.py --help
54
+ uv run python cleanrl/ppo_rnd_envpool.py --env-id MontezumaRevenge-v5
55
+ ```
56
+
57
+ === "pip"
58
+
59
+ ```bash
60
+ pip install -r requirements/requirements-envpool.txt
61
+ python cleanrl/ppo_rnd_envpool.py --help
62
+ python cleanrl/ppo_rnd_envpool.py --env-id MontezumaRevenge-v5
63
+ ```
64
+
65
+ ### Explanation of the logged metrics
66
+
67
+ See [related docs](/rl-algorithms/ppo/#explanation-of-the-logged-metrics) for `ppo.py`.
68
+ Below is the additional metric for RND:
69
+
70
+ * `charts/episode_curiosity_reward`: episodic intrinsic rewards.
71
+ * `losses/fwd_loss`: the prediction error between predict network and target network, can also be viewed as a proxy of the curiosity reward in that batch.
72
+
73
+ ### Implementation details
74
+
75
+ [ppo_rnd_envpool.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ppo_rnd_envpool.py) uses a customized `RecordEpisodeStatistics` to work with envpool but has the same other implementation details as `ppo_atari.py` (see [related docs](/rl-algorithms/ppo/#implementation-details_1)). Additionally, it has the following additional details:
76
+
77
+ 1. We initialize the normalization parameters by stepping a random agent in the environment by `args.num_steps * args.num_iterations_obs_norm_init`. `args.num_iterations_obs_norm_init=50` comes from the [original implementation](https://github.com/openai/random-network-distillation/blob/f75c0f1efa473d5109d487062fd8ed49ddce6634/run_atari.py#L69).
78
+ 1. We uses sticky action from [envpool](https://envpool.readthedocs.io/en/latest/env/atari.html?highlight=repeat_action_probability%20#options) to facilitate the exploration like done in the [original implementation](https://github.com/openai/random-network-distillation/blob/f75c0f1efa473d5109d487062fd8ed49ddce6634/atari_wrappers.py#L204).
79
+
80
+ ### Experiment results
81
+
82
+ To run benchmark experiments, see :material-github: [benchmark/rnd.sh](https://github.com/vwxyzjn/cleanrl/blob/master/benchmark/rnd.sh). Specifically, execute the following command:
83
+
84
+ <script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fvwxyzjn%2Fcleanrl%2Fblob%2Fmaster%2Fbenchmark%2Frnd.sh%23L3-L8&style=github&type=code&showBorder=on&showLineNumbers=on&showFileMeta=on&showFullPath=on&showCopy=on"></script>
85
+
86
+ Below are the average episodic returns for `ppo_rnd_envpool.py`. To ensure the quality of the implementation, we compared the results against `openai/random-network-distillation`' PPO.
87
+
88
+ | Environment | `ppo_rnd_envpool.py` | (Burda et al., 2019, Figure 7)[^1] 2000M steps
89
+ | ----------- | ----------- | ----------- |
90
+ | MontezumaRevengeNoFrameSkip-v4 | 7100 (1 seed) | 8152 (3 seeds) |
91
+
92
+ Note the MontezumaRevengeNoFrameSkip-v4 has same setting to MontezumaRevenge-v5.
93
+ Our benchmark has one seed due to limited compute resource and extreme long run time (~250 hours).
94
+
95
+
96
+ Learning curves:
97
+
98
+ <div class="grid-container">
99
+ <img src="../ppo-rnd/MontezumaRevenge-v5.png">
100
+ <img src="../ppo-rnd/MontezumaRevenge-v5-time.png">
101
+ </div>
102
+
103
+ <div></div>
104
+
105
+
106
+ Tracked experiments and game play videos:
107
+
108
+ <iframe src="https://wandb.ai/openrlbenchmark/openrlbenchmark/reports/-MontezumaRevenge-CleanRL-s-PPO-RND--VmlldzoyNTIyNjc5" style="width:100%; height:1200px" title="MontezumaRevenge: CleanRL's PPO + RND"></iframe>
109
+
110
+
111
+ [^1]:Burda, Yuri, et al. "Exploration by random network distillation." Seventh International Conference on Learning Representations. 2019.
cleanrl/docs/rl-algorithms/ppo-trxl.md ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Tranformer-XL (PPO-TrXL)
2
+
3
+ ## Overview
4
+
5
+ Real-world tasks may expose imperfect information (e.g. partial observability). Such tasks require an agent to leverage memory capabilities. One way to do this is to use recurrent neural networks (e.g. LSTM) as seen in :material-github: [`ppo_atari_lstm.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ppo_atari_lstm.py), :material-file-document: [docs](/rl-algorithms/ppo/#ppo_atari_lstmpy). Here, Transformer-XL is used as episodic memory in Proximal Policy Optimization (PPO).
6
+
7
+ Original Paper and Implementation
8
+
9
+ * :material-file-document: [Memory Gym: Towards Endless Tasks to Benchmark Memory Capabilities of Agents](https://arxiv.org/abs/2309.17207)
10
+ * :material-github: [neroRL](https://github.com/MarcoMeter/neroRL)
11
+ * :material-github: [Episodic Transformer Memory PPO](https://github.com/MarcoMeter/episodic-transformer-memory-ppo)
12
+ * :material-github: [Endless Memory Gym](https://github.com/MarcoMeter/endless-memory-gym)
13
+ * :material-play-circle: [Interactive Visualizations of Trained Agents](https://marcometer.github.io/)
14
+
15
+ Related Publications and Repositories
16
+
17
+ * :material-file-document: [Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context](https://arxiv.org/abs/1901.02860)
18
+ * :material-file-document: [Stabilizing Transformers for Reinforcement Learning](https://arxiv.org/abs/1910.06764)
19
+ * :material-file-document: [Towards mental time travel: a hierarchical memory for reinforcement learning agents](https://arxiv.org/abs/2105.14039)
20
+ * :material-file-document: [Grounded Language Learning Fast and Slow](https://arxiv.org/abs/2009.01719)
21
+ * :material-github: [transformerXL_PPO_JAX](https://github.com/Reytuag/transformerXL_PPO_JAX)
22
+
23
+ ## Implemented Variants
24
+
25
+
26
+ | Variants Implemented | Description |
27
+ | ----------- | ----------- |
28
+ | :material-github: [`ppo_trxl.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ppo_trxl/ppo_trxl.py), :material-file-document: [docs](/rl-algorithms/ppo-trxl#ppo_trxlpy) | For training on tasks like `Endless-MortarMayhem-v0`. |
29
+
30
+ Below is our single-file implementation of PPO-TrXL:
31
+
32
+ ## `ppo_trxl.py`
33
+
34
+ `ppo_trxl.py` has the following features:
35
+
36
+ * Works with Memory Gym's environments (84x84 RGB image observation).
37
+ * Works with Minigrid Memory (84x84 RGB image observation).
38
+ * Works also with environments exposing only game state vector observations (e.g. Proof of Memory Environment).
39
+ * Works with just single or multi-discrete action spaces.
40
+
41
+ ### Usage
42
+
43
+ As the recommended way, the requirements default to PyTorch's CUDA packages.
44
+
45
+ === "poetry"
46
+
47
+ ```bash
48
+ cd cleanrl/ppo_trxl
49
+ poetry install
50
+ uv run python ppo_trxl.py --help
51
+ uv run python ppo_trxl.py --env-id Endless-MortarMayhem-v0
52
+ ```
53
+
54
+ === "pip"
55
+
56
+ ```bash
57
+ pip install -r requirements/requirements-memory_gym.txt
58
+ python cleanrl/ppo_trxl/ppo_trxl.py --help
59
+ python cleanrl/ppo_trxl/ppo_trxl.py --env-id Endless-MortarMayhem-v0
60
+ ```
61
+
62
+ ### Explanation of the logged metrics
63
+
64
+ * `episode/r_mean`: mean of the episodic return of the game
65
+ * `episode/l_mean`: mean of the episode length of the game in steps
66
+ * `episode/t_mean`: mean of the episode duration of the game in seconds
67
+ * `episode/advantage_mean`: mean of all computed advantages
68
+ * `episode/value_mean`: mean of all approximated values
69
+ * `charts/SPS`: number of steps per second
70
+ * `charts/learning_rate`: the current learning rate
71
+ * `charts/entropy_coefficient`: the current entropy coefficient
72
+ * `losses/value_loss`: the mean value loss across all data points
73
+ * `losses/policy_loss`: the mean policy loss across all data points
74
+ * `losses/entropy`: the mean entropy value across all data points
75
+ * `losses/reconstruction_loss`: the mean observation reconstruction loss value across all data points
76
+ * `losses/loss`: the mean of all summed losses across all data points
77
+ * `losses/old_approx_kl`: the approximate Kullback–Leibler divergence, measured by `(-logratio).mean()`, which corresponds to the k1 estimator in John Schulman’s blog post on [approximating KL](http://joschu.net/blog/kl-approx.html)
78
+ * `losses/approx_kl`: better alternative to `olad_approx_kl` measured by `(logratio.exp() - 1) - logratio`, which corresponds to the k3 estimator in [approximating KL](http://joschu.net/blog/kl-approx.html)
79
+ * `losses/clipfrac`: the fraction of the training data that triggered the clipped objective
80
+ * `losses/explained_variance`: the explained variance for the value function
81
+
82
+ ### Implementation details
83
+
84
+ Most details are derived from [`ppo.py`](/rl-algorithms/ppo#ppopy). These are additional or differing details:
85
+
86
+ 1. The policy and value function share parameters.
87
+ 2. Multi-head attention is implemented so that all heads share parameters.
88
+ 3. Absolute positional encoding is used as default. Learned positional encodings are supported.
89
+ 4. Previously computed hidden states of the TrXL layers are cached and reused for up to `trxl_memory_length`. Only 1 hidden state is computed anew.
90
+ 5. TrXL layers adhere to pre-layer normalization.
91
+ 6. Support for multi-discrete action spaces.
92
+ 7. Support for an auxiliary observation reconstruction loss, which reconstructs TrXL's output to the fed visual observation.
93
+ 8. The learning rate and the entropy bonus coefficient linearly decay until reaching a lower threshold.
94
+
95
+ ### Experiment results
96
+
97
+ Note: When training on potentially endless episodes, the cached hidden states demand a large GPU memory. To reproduce the following experiments a minimum of 40GB is required. One workaround is to cache the hidden states in the buffer with lower precision as bfloat16. This is under examination for future updates.
98
+
99
+ | | PPO-TrXL |
100
+ |:-----------------------------|:------------|
101
+ | MortarMayhem-Grid-v0 | 0.99 ± 0.00 |
102
+ | MortarMayhem-v0 | 0.99 ± 0.00 |
103
+ | Endless-MortarMayhem-v0 | 1.50 ± 0.02 |
104
+ | MysteryPath-Grid-v0 | 0.97 ± 0.01 |
105
+ | MysteryPath-v0 | 1.67 ± 0.02 |
106
+ | Endless-MysteryPath-v0 | 1.84 ± 0.06 |
107
+ | SearingSpotlights-v0 | 1.11 ± 0.08 |
108
+ | Endless-SearingSpotlights-v0 | 1.60 ± 0.03 |
109
+
110
+ Learning curves:
111
+
112
+
113
+ <img src="../ppo-trxl/compare.png">
114
+
115
+
116
+ Tracked experiments:
117
+
118
+ <iframe src="https://api.wandb.ai/links/m-pleines/wo9m43hv" style="width:100%; height:500px" title="CleanRL-s-PPO-TrXL"></iframe>
119
+
120
+
121
+ ### Hyperparameters
122
+
123
+ Memory Gym Environments
124
+
125
+ Please refer to the defaults in [`ppo_trxl.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ppo_trxl/ppo_trxl.py) and the single modifications as found in [`benchmark/ppo_trxl.sh`](https://github.com/vwxyzjn/cleanrl/blob/master/benchmark/ppo_trxl.sh)
126
+
127
+ ProofofMemory-v0
128
+ ```bash
129
+ uv run python ppo_trxl.py \
130
+ --env_id ProofofMemory-v0 \
131
+ --total_timesteps 25000 \
132
+ --num_envs 16 \
133
+ --num_steps 128 \
134
+ --num_minibatches 8 \
135
+ --update_epochs 4 \
136
+ --trxl_num_layers 4 \
137
+ --trxl_num_heads 1 \
138
+ --trxl_dim 64 \
139
+ --trxl_memory_length 16 \
140
+ --trxl_positional_encoding none \
141
+ --vf_coef 0.1 \
142
+ --max_grad_norm 0.5 \
143
+ --init_lr 3.0e-4 \
144
+ --init_ent_coef 0.001 \
145
+ --clip_coef 0.2
146
+ ```
147
+
148
+ MiniGrid-MemoryS9-v0
149
+ ```bash
150
+ uv run python ppo_trxl.py \
151
+ --env_id MiniGrid-MemoryS9-v0 \
152
+ --total_timesteps 2048000 \
153
+ --num_envs 16 \
154
+ --num_steps 256 \
155
+ --trxl_num_layers 2 \
156
+ --trxl_num_heads 4 \
157
+ --trxl_dim 256 \
158
+ --trxl_memory_length 64 \
159
+ --max_grad_norm 0.25 \
160
+ --anneal_steps 4096000
161
+ --clip_coef 0.2
162
+ ```
163
+
164
+ ### Enjoy pre-trained models
165
+
166
+ Use [`cleanrl/ppo_trxl/enjoy.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ppo_trxl/enjoy.py) to watch pre-trained agents.
167
+ You can retrieve pre-trained models from [huggingface](https://huggingface.co/LilHairdy/cleanrl_memory_gym).
168
+ Note that Memory Gym environments are usually rendered using the `debug_rgb_array` render mode, which shows ground truth information about the current task that the agent cannot observe.
169
+
170
+
171
+ Run models from the hub:
172
+ ```bash
173
+ python cleanrl/ppo_trxl/enjoy.py --hub --name Endless-MortarMayhem-v0_12.nn
174
+ python cleanrl/ppo_trxl/enjoy.py --hub --name Endless-MysterPath-v0_11.nn
175
+ python cleanrl/ppo_trxl/enjoy.py --hub --name Endless-SearingSpotlights-v0_30.nn
176
+ python cleanrl/ppo_trxl/enjoy.py --hub --name MiniGrid-MemoryS9-v0_10.nn
177
+ python cleanrl/ppo_trxl/enjoy.py --hub --name ProofofMemory-v0_1.nn
178
+ ```
179
+
180
+
181
+ Run local models (or download them from the hub manually):
182
+ ```bash
183
+ python cleanrl/ppo_trxl/enjoy.py --name Your.cleanrl_model
184
+ ```
cleanrl/docs/rl-algorithms/ppo/ppo_atari_envpool_xla_jax/atari_hns.md ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ | Environment | CleanRL ppo_atari_envpool_xla_jax.py | openai/baselines' PPO |
2
+ |:--------------------|---------------------------------------:|------------------------:|
3
+ | Alien-v5 | 0.219853 | 0.191542 |
4
+ | Amidar-v5 | 0.356735 | 0.315461 |
5
+ | Assault-v5 | 10.6075 | 7.36794 |
6
+ | Asterix-v5 | 0.377642 | 0.39187 |
7
+ | Asteroids-v5 | 0.0203601 | 0.0160295 |
8
+ | Atlantis-v5 | 242.083 | 190.667 |
9
+ | BankHeist-v5 | 1.59491 | 1.59851 |
10
+ | BattleZone-v5 | 0.648278 | 0.51552 |
11
+ | BeamRider-v5 | 0.125822 | 0.143463 |
12
+ | Berzerk-v5 | 0.382584 | 0.304512 |
13
+ | Bowling-v5 | 0.152385 | 0.284618 |
14
+ | Boxing-v5 | 7.66295 | 7.77164 |
15
+ | Breakout-v5 | 14.9339 | 13.4441 |
16
+ | Centipede-v5 | 0.0825898 | 0.160915 |
17
+ | ChopperCommand-v5 | 0.721451 | 0.0186007 |
18
+ | CrazyClimber-v5 | 4.2051 | 4.0279 |
19
+ | Defender-v5 | 3.07092 | 2.98276 |
20
+ | DemonAttack-v5 | 12.465 | 6.60937 |
21
+ | DoubleDunk-v5 | 4.56009 | 4.36364 |
22
+ | Enduro-v5 | 1.4675 | 1.23315 |
23
+ | FishingDerby-v5 | 2.13815 | 2.1809 |
24
+ | Freeway-v5 | 1.1185 | 1.11205 |
25
+ | Frostbite-v5 | 0.196544 | 0.201265 |
26
+ | Gopher-v5 | 5.1566 | 1.22603 |
27
+ | Gravitar-v5 | 0.304855 | 0.21953 |
28
+ | Hero-v5 | 0.792007 | 0.837516 |
29
+ | IceHockey-v5 | 0.519077 | 0.535946 |
30
+ | Jamesbond-v5 | 1.73523 | 1.78046 |
31
+ | Kangaroo-v5 | 2.4236 | 1.2536 |
32
+ | Krull-v5 | 7.29433 | 6.62758 |
33
+ | KungFuMaster-v5 | 1.17164 | 1.28383 |
34
+ | MontezumaRevenge-v5 | 5.05722e-05 | 0 |
35
+ | MsPacman-v5 | 0.324235 | 0.271832 |
36
+ | NameThisGame-v5 | 0.547252 | 0.594366 |
37
+ | Phoenix-v5 | 2.04392 | 1.22382 |
38
+ | Pitfall-v5 | 0.0342621 | 0.0340544 |
39
+ | Pong-v5 | 1.16173 | 1.16443 |
40
+ | PrivateEye-v5 | 0.00107307 | -5.30276e-05 |
41
+ | Qbert-v5 | 1.22388 | 1.06233 |
42
+ | Riverraid-v5 | 0.440997 | 0.502486 |
43
+ | RoadRunner-v5 | 2.46769 | 5.14629 |
44
+ | Robotank-v5 | 1.36598 | 1.42268 |
45
+ | Seaquest-v5 | 0.0276666 | 0.040157 |
46
+ | Skiing-v5 | 0.189151 | 0.250475 |
47
+ | Solaris-v5 | 0.100747 | 0.0768074 |
48
+ | SpaceInvaders-v5 | 0.666901 | 0.571875 |
49
+ | StarGunner-v5 | 5.51553 | 4.198 |
50
+ | Surround-v5 | 0.427541 | 0.237518 |
51
+ | Tennis-v5 | 0.564862 | 0.908756 |
52
+ | TimePilot-v5 | 1.59937 | 1.32888 |
53
+ | Tutankham-v5 | 1.45338 | 1.19416 |
54
+ | UpNDown-v5 | 38.4992 | 11.5527 |
55
+ | Venture-v5 | 0 | 0.097076 |
56
+ | VideoPinball-v5 | 18.9358 | 11.7083 |
57
+ | WizardOfWor-v5 | 1.35567 | 1.0638 |
58
+ | YarsRevenge-v5 | 1.04117 | 0.0999445 |
59
+ | Zaxxon-v5 | 0.654571 | 0.694391 |
cleanrl/docs/rl-algorithms/ppo/ppo_atari_envpool_xla_jax/atari_returns.md ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ | Environment | CleanRL ppo_atari_envpool_xla_jax.py | openai/baselines' PPO |
2
+ |:--------------------|---------------------------------------:|------------------------:|
3
+ | Alien-v5 | 1744.76 | 1549.42 |
4
+ | Amidar-v5 | 617.137 | 546.406 |
5
+ | Assault-v5 | 5734.04 | 4050.78 |
6
+ | Asterix-v5 | 3341.9 | 3459.9 |
7
+ | Asteroids-v5 | 1669.3 | 1467.19 |
8
+ | Atlantis-v5 | 3.92929e+06 | 3.09748e+06 |
9
+ | BankHeist-v5 | 1192.68 | 1195.34 |
10
+ | BattleZone-v5 | 24937.9 | 20314.3 |
11
+ | BeamRider-v5 | 2447.84 | 2740.02 |
12
+ | Berzerk-v5 | 1082.72 | 887.019 |
13
+ | Bowling-v5 | 44.0681 | 62.2634 |
14
+ | Boxing-v5 | 92.0554 | 93.3596 |
15
+ | Breakout-v5 | 431.795 | 388.891 |
16
+ | Centipede-v5 | 2910.69 | 3688.16 |
17
+ | ChopperCommand-v5 | 5555.84 | 933.333 |
18
+ | CrazyClimber-v5 | 116114 | 111675 |
19
+ | Defender-v5 | 51439.2 | 50045.1 |
20
+ | DemonAttack-v5 | 22824.8 | 12173.9 |
21
+ | DoubleDunk-v5 | -8.56781 | -9 |
22
+ | Enduro-v5 | 1262.79 | 1061.12 |
23
+ | FishingDerby-v5 | 21.6222 | 23.8876 |
24
+ | Freeway-v5 | 33.1075 | 32.9167 |
25
+ | Frostbite-v5 | 904.346 | 924.5 |
26
+ | Gopher-v5 | 11369.6 | 2899.57 |
27
+ | Gravitar-v5 | 1141.95 | 870.755 |
28
+ | Hero-v5 | 24628.3 | 25984.5 |
29
+ | IceHockey-v5 | -4.91917 | -4.71505 |
30
+ | Jamesbond-v5 | 504.105 | 516.489 |
31
+ | Kangaroo-v5 | 7281.59 | 3791.5 |
32
+ | Krull-v5 | 9384.7 | 8672.95 |
33
+ | KungFuMaster-v5 | 26594.5 | 29116.1 |
34
+ | MontezumaRevenge-v5 | 0.240385 | 0 |
35
+ | MsPacman-v5 | 2461.62 | 2113.44 |
36
+ | NameThisGame-v5 | 5442.67 | 5713.89 |
37
+ | Phoenix-v5 | 14008.5 | 8693.21 |
38
+ | Pitfall-v5 | -0.0801282 | -1.47059 |
39
+ | Pong-v5 | 20.309 | 20.4043 |
40
+ | PrivateEye-v5 | 99.5283 | 21.2121 |
41
+ | Qbert-v5 | 16430.7 | 14283.4 |
42
+ | Riverraid-v5 | 8297.21 | 9267.48 |
43
+ | RoadRunner-v5 | 19342.2 | 40325 |
44
+ | Robotank-v5 | 15.45 | 16 |
45
+ | Seaquest-v5 | 1230.02 | 1754.44 |
46
+ | Skiing-v5 | -14684.3 | -13901.7 |
47
+ | Solaris-v5 | 2353.62 | 2088.12 |
48
+ | SpaceInvaders-v5 | 1162.16 | 1017.65 |
49
+ | StarGunner-v5 | 53535.9 | 40906 |
50
+ | Surround-v5 | -2.94558 | -6.08095 |
51
+ | Tennis-v5 | -15.0446 | -9.71429 |
52
+ | TimePilot-v5 | 6224.87 | 5775.53 |
53
+ | Tutankham-v5 | 238.419 | 197.929 |
54
+ | UpNDown-v5 | 430177 | 129459 |
55
+ | Venture-v5 | 0 | 115.278 |
56
+ | VideoPinball-v5 | 42975.3 | 32777.4 |
57
+ | WizardOfWor-v5 | 6247.83 | 5024.03 |
58
+ | YarsRevenge-v5 | 56696.7 | 8238.44 |
59
+ | Zaxxon-v5 | 6015.8 | 6379.79 |
cleanrl/docs/rl-algorithms/ppo/ppo_atari_envpool_xla_jax/hms_each_game.svg ADDED
cleanrl/docs/rl-algorithms/ppo/ppo_atari_envpool_xla_jax/hns_ppo_vs_baselines.svg ADDED
cleanrl/docs/rl-algorithms/ppo/ppo_atari_envpool_xla_jax/hns_ppo_vs_baselines2.svg ADDED
cleanrl/docs/rl-algorithms/ppo/ppo_atari_envpool_xla_jax/hns_ppo_vs_r2d2.svg ADDED
cleanrl/docs/rl-algorithms/ppo/ppo_atari_envpool_xla_jax/runset_0_hms_bar.svg ADDED
cleanrl/docs/rl-algorithms/ppo/ppo_atari_envpool_xla_jax/runset_1_hms_bar.svg ADDED
cleanrl/docs/rl-algorithms/rpo.md ADDED
@@ -0,0 +1,389 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Robust Policy Optimization (RPO)
2
+
3
+ ## Overview
4
+
5
+ RPO leverages a method of perturbing the distribution representing actions. The goal is to encourage high-entropy actions and provide a better representation of the action space. The method consists of a simple modification on top of the objective of the PPO algorithm. In the RPO algorithm, the mean of the action distribution is perturbed using a random number drawn from a Uniform distribution.
6
+
7
+ Original paper:
8
+
9
+ * [Robust Policy Optimization in Deep Reinforcement Learning](https://arxiv.org/abs/2212.07536)
10
+
11
+ ## Implemented Variants
12
+
13
+
14
+ | Variants Implemented | Description |
15
+ | ----------- | ----------- |
16
+ | :material-github: [`rpo_continuous_action.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/rpo_continuous_action.py), :material-file-document: [docs](/rl-algorithms/rpo/#rpo_continuous_actionpy) | For classic control tasks like Gym `Pendulum-v1`, and dm_control. |
17
+
18
+ Below are our single-file implementations of RPO:
19
+
20
+ ## `rpo_continuous_action.py`
21
+
22
+ `rpo_continuous_action.py` works with Gym (Gymnasium), dm_control, Mujoco environments with continuous action and vector observations.
23
+
24
+ The [rpo_continuous_action.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/rpo_continuous_action.py) has the following features (similar to [ppo_continuous_action.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/ppo_continuous_action.py)):
25
+
26
+ * For continuous action space. Also implemented Mujoco-specific code-level optimizations
27
+ * Works with the `Box` observation space of low-level features
28
+ * Works with the `Box` (continuous) action space
29
+ * adding experimental support for [Gymnasium](https://gymnasium.farama.org/)
30
+ * 🧪 support `dm_control` environments via [Shimmy](https://github.com/Farama-Foundation/Shimmy)
31
+
32
+ ### Usage
33
+
34
+ ```bash
35
+ # mujoco v4 environments
36
+ uv pip install ".[mujoco]"
37
+ python cleanrl/rpo_continuous_action.py --help
38
+ python cleanrl/rpo_continuous_action.py --env-id Walker2d-v4
39
+ # NOTE: we recommend using --rpo-alpha 0.01 for Ant Hopper InvertedDoublePendulum Reacher Pusher
40
+ python cleanrl/rpo_continuous_action.py --env-id Ant-v4 --rpo-alpha 0.01
41
+ # dm_control v4 environments
42
+ uv pip install ".[mujoco, dm_control]"
43
+ python cleanrl/rpo_continuous_action.py --env-id dm_control/cartpole-balance-v0
44
+ # BipedalWalker-v3 experiment (hack)
45
+ uv pip install .
46
+ uv pip install box2d-py==2.3.5
47
+ python cleanrl/rpo_continuous_action.py --env-id BipedalWalker-v3
48
+ ```
49
+
50
+
51
+ === "poetry"
52
+
53
+ ```bash
54
+ # mujoco v4 environments
55
+ uv pip install ".[mujoco]"
56
+ python cleanrl/rpo_continuous_action.py --help
57
+ python cleanrl/rpo_continuous_action.py --env-id Hopper-v4
58
+ # NOTE: we recommend using --rpo-alpha 0.01 for Ant Hopper InvertedDoublePendulum Reacher Pusher
59
+ python cleanrl/rpo_continuous_action.py --env-id Ant-v4 --rpo-alpha 0.01
60
+ # dm_control environments
61
+ uv pip install ".[mujoco, dm_control]"
62
+ python cleanrl/rpo_continuous_action.py --env-id dm_control/cartpole-balance-v0
63
+ # BipedalWalker-v3 experiment (hack)
64
+ uv pip install box2d-py==2.3.5
65
+ uv run python cleanrl/rpo_continuous_action.py --env-id BipedalWalker-v3
66
+ ```
67
+
68
+ === "pip"
69
+
70
+ ```bash
71
+ pip install -r requirements/requirements-mujoco.txt
72
+ python cleanrl/rpo_continuous_action.py --help
73
+ python cleanrl/rpo_continuous_action.py --env-id Hopper-v4
74
+ # NOTE: we recommend using --rpo-alpha 0.01 for Ant Hopper InvertedDoublePendulum Reacher Pusher
75
+ python cleanrl/rpo_continuous_action.py --env-id Ant-v4 --rpo-alpha 0.01
76
+ pip install -r requirements/requirements-dm_control.txt
77
+ python cleanrl/rpo_continuous_action.py --env-id dm_control/cartpole-balance-v0
78
+ pip install box2d-py==2.3.5
79
+ python cleanrl/rpo_continuous_action.py --env-id BipedalWalker-v3
80
+ ```
81
+
82
+
83
+ ### Explanation of the logged metrics
84
+
85
+ See [related docs](/rl-algorithms/ppo/#explanation-of-the-logged-metrics) for `ppo.py`.
86
+
87
+ ### Implementation details
88
+ [rpo_continuous_action.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/rpo_continuous_action.py) has the same implementation details as `ppo_continuous_action.py` (see related [docs](/rl-algorithms/ppo/#ppo_continuous_actionpy)) but with a few lines of code differences.
89
+
90
+ ```python hl_lines="30-34"
91
+ class Agent(nn.Module):
92
+ def __init__(self, envs):
93
+ super().__init__()
94
+ self.critic = nn.Sequential(
95
+ layer_init(nn.Linear(np.array(envs.single_observation_space.shape).prod(), 64)),
96
+ nn.Tanh(),
97
+ layer_init(nn.Linear(64, 64)),
98
+ nn.Tanh(),
99
+ layer_init(nn.Linear(64, 1), std=1.0),
100
+ )
101
+ self.actor_mean = nn.Sequential(
102
+ layer_init(nn.Linear(np.array(envs.single_observation_space.shape).prod(), 64)),
103
+ nn.Tanh(),
104
+ layer_init(nn.Linear(64, 64)),
105
+ nn.Tanh(),
106
+ layer_init(nn.Linear(64, np.prod(envs.single_action_space.shape)), std=0.01),
107
+ )
108
+ self.actor_logstd = nn.Parameter(torch.zeros(1, np.prod(envs.single_action_space.shape)))
109
+
110
+ def get_value(self, x):
111
+ return self.critic(x)
112
+
113
+ def get_action_and_value(self, x, action=None):
114
+ action_mean = self.actor_mean(x)
115
+ action_logstd = self.actor_logstd.expand_as(action_mean)
116
+ action_std = torch.exp(action_logstd)
117
+ probs = Normal(action_mean, action_std)
118
+ if action is None:
119
+ action = probs.sample()
120
+ else: # new to RPO
121
+ # sample again to add stochasticity, for the policy update
122
+ z = torch.FloatTensor(action_mean.shape).uniform_(-self.rpo_alpha, self.rpo_alpha)
123
+ action_mean = action_mean + z
124
+ probs = Normal(action_mean, action_std)
125
+
126
+ ```
127
+
128
+ ???+ note
129
+
130
+ RPO usages the same PPO-specific hyperparameters. In benchmarking results, we run both algorithms for 8M timesteps.
131
+ RPO has one additional hyperparameter, `rpo_alpha`, which determines the amount of random perturbation on the action mean.
132
+ We set a default value of `rpo_alpha=0.5` at which RPO is strictly equal to or better than the default PPO in 93% of environments tested (all 48/48 dm_control, 2/2 Gym, 7/11 mujoco_v4. Total 57 out of 61 environments tested.).
133
+ With finetuning `rpo_alpha=0.01` on four mujoco environments, namely, Ant, InvertedDoublePendulum, Reacher, and Pusher, RPO is strictly equal to or better than the default PPO in all tested environments.
134
+
135
+ ### Experiment results
136
+
137
+ To run benchmark experiments, see [benchmark/rpo.sh](https://github.com/vwxyzjn/cleanrl/blob/master/benchmark/rpo.sh). Specifically, execute the following command:
138
+ <script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fvwxyzjn%2Fcleanrl%2Fblob%2Fmaster%2Fbenchmark%2Frpo.sh%23L1-L6&style=github&showBorder=on&showLineNumbers=on&showFileMeta=on&showCopy=on"></script>
139
+
140
+ ???+ note "Result tables, learning curves"
141
+
142
+ === "dm_control"
143
+
144
+ Results on all dm_control environments. The PPO and RPO run for 8M timesteps, and results are computed over 10 random seeds.
145
+
146
+ | | ppo_continuous_action_8M ({'tag': ['v1.0.0-13-gcbd83f6']}) | rpo_continuous_action ({'tag': ['pr-331']}) |
147
+ |:--------------------------------------|:-------------------------------------------------------------|:----------------------------------------------|
148
+ | dm_control/acrobot-swingup-v0 | 26.87 ± 7.93 | 42.97 ± 2.71 |
149
+ | dm_control/acrobot-swingup_sparse-v0 | 1.70 ± 0.88 | 3.31 ± 0.84 |
150
+ | dm_control/ball_in_cup-catch-v0 | 935.26 ± 12.57 | 939.75 ± 10.18 |
151
+ | dm_control/cartpole-balance-v0 | 790.36 ± 17.64 | 795.12 ± 10.49 |
152
+ | dm_control/cartpole-balance_sparse-v0 | 986.04 ± 9.93 | 988.56 ± 4.28 |
153
+ | dm_control/cartpole-swingup-v0 | 590.21 ± 16.72 | 613.46 ± 10.91 |
154
+ | dm_control/cartpole-swingup_sparse-v0 | 240.14 ± 299.93 | 525.49 ± 185.96 |
155
+ | dm_control/cartpole-two_poles-v0 | 216.31 ± 4.03 | 218.31 ± 7.30 |
156
+ | dm_control/cartpole-three_poles-v0 | 160.03 ± 2.52 | 159.97 ± 2.28 |
157
+ | dm_control/cheetah-run-v0 | 472.14 ± 99.62 | 565.51 ± 58.03 |
158
+ | dm_control/dog-stand-v0 | 332.06 ± 23.66 | 501.22 ± 131.98 |
159
+ | dm_control/dog-walk-v0 | 124.92 ± 23.13 | 166.39 ± 44.65 |
160
+ | dm_control/dog-trot-v0 | 79.89 ± 12.30 | 115.39 ± 29.68 |
161
+ | dm_control/dog-run-v0 | 69.07 ± 8.17 | 104.27 ± 24.44 |
162
+ | dm_control/dog-fetch-v0 | 28.34 ± 4.87 | 43.58 ± 6.88 |
163
+ | dm_control/finger-spin-v0 | 630.06 ± 252.99 | 848.67 ± 25.21 |
164
+ | dm_control/finger-turn_easy-v0 | 237.76 ± 78.10 | 450.88 ± 133.54 |
165
+ | dm_control/finger-turn_hard-v0 | 83.76 ± 28.96 | 259.99 ± 144.83 |
166
+ | dm_control/fish-upright-v0 | 559.72 ± 65.79 | 803.21 ± 28.36 |
167
+ | dm_control/fish-swim-v0 | 80.42 ± 9.18 | 140.33 ± 49.10 |
168
+ | dm_control/hopper-stand-v0 | 3.26 ± 1.65 | 404.39 ± 198.17 |
169
+ | dm_control/hopper-hop-v0 | 6.48 ± 18.92 | 62.60 ± 87.29 |
170
+ | dm_control/humanoid-stand-v0 | 20.76 ± 29.35 | 140.43 ± 57.27 |
171
+ | dm_control/humanoid-walk-v0 | 8.92 ± 18.01 | 77.00 ± 53.00 |
172
+ | dm_control/humanoid-run-v0 | 5.44 ± 9.16 | 24.00 ± 19.54 |
173
+ | dm_control/humanoid-run_pure_state-v0 | 1.13 ± 0.11 | 3.24 ± 2.41 |
174
+ | dm_control/humanoid_CMU-stand-v0 | 4.64 ± 0.37 | 4.32 ± 0.33 |
175
+ | dm_control/humanoid_CMU-run-v0 | 0.88 ± 0.09 | 0.80 ± 0.09 |
176
+ | dm_control/manipulator-bring_ball-v0 | 0.42 ± 0.14 | 0.44 ± 0.23 |
177
+ | dm_control/manipulator-bring_peg-v0 | 0.95 ± 0.43 | 1.07 ± 1.01 |
178
+ | dm_control/manipulator-insert_ball-v0 | 41.24 ± 27.27 | 43.63 ± 12.77 |
179
+ | dm_control/manipulator-insert_peg-v0 | 40.72 ± 15.95 | 44.87 ± 26.55 |
180
+ | dm_control/pendulum-swingup-v0 | 472.19 ± 385.47 | 774.30 ± 21.03 |
181
+ | dm_control/point_mass-easy-v0 | 534.23 ± 264.35 | 653.73 ± 23.14 |
182
+ | dm_control/point_mass-hard-v0 | 129.75 ± 61.18 | 185.81 ± 36.25 |
183
+ | dm_control/quadruped-walk-v0 | 247.29 ± 90.48 | 602.64 ± 223.23 |
184
+ | dm_control/quadruped-run-v0 | 171.50 ± 37.90 | 367.98 ± 117.18 |
185
+ | dm_control/quadruped-escape-v0 | 23.11 ± 10.48 | 68.50 ± 27.81 |
186
+ | dm_control/quadruped-fetch-v0 | 183.71 ± 25.14 | 216.32 ± 17.44 |
187
+ | dm_control/reacher-easy-v0 | 773.01 ± 56.70 | 716.89 ± 50.07 |
188
+ | dm_control/reacher-hard-v0 | 637.84 ± 81.15 | 576.81 ± 48.25 |
189
+ | dm_control/stacker-stack_2-v0 | 58.02 ± 11.04 | 70.95 ± 16.84 |
190
+ | dm_control/stacker-stack_4-v0 | 73.84 ± 14.48 | 65.54 ± 18.06 |
191
+ | dm_control/swimmer-swimmer6-v0 | 164.22 ± 18.44 | 159.60 ± 39.52 |
192
+ | dm_control/swimmer-swimmer15-v0 | 161.02 ± 24.56 | 153.91 ± 28.08 |
193
+ | dm_control/walker-stand-v0 | 439.24 ± 210.22 | 734.74 ± 142.52 |
194
+ | dm_control/walker-walk-v0 | 305.74 ± 92.15 | 787.11 ± 125.97 |
195
+ | dm_control/walker-run-v0 | 128.18 ± 91.52 | 391.56 ± 119.75 |
196
+
197
+ Learning curves:
198
+ ![](../rpo/dm_control_all_ppo_rpo_8M.png)
199
+
200
+ Tracked experiments:
201
+
202
+ <iframe loading="lazy" src="https://wandb.ai/openrlbenchmark/cleanrl/reports/RPO-on-dm_control-Part-1--VmlldzozMjU4NTE4" style="width:100%; height:500px" title="dm_control-CleanRL-s-RPO-part-1"></iframe>
203
+ <iframe loading="lazy" src="https://wandb.ai/openrlbenchmark/cleanrl/reports/RPO-on-dm_control-Part-2--VmlldzozMjU4NjYy" style="width:100%; height:500px" title="dm_control-CleanRL-s-RPO-part-2"></iframe>
204
+
205
+
206
+
207
+
208
+ === "MuJoCo v4"
209
+
210
+ | | ppo_continuous_action_8M ({'tag': ['v1.0.0-13-gcbd83f6']}) | rpo_continuous_action ({'tag': ['pr-331']}) |
211
+ |:--------------------|:-------------------------------------------------------------|:----------------------------------------------|
212
+ | HumanoidStandup-v4 | 109325.87 ± 16161.71 | 150972.11 ± 6926.19 |
213
+ | Humanoid-v4 | 583.17 ± 27.88 | 799.44 ± 170.85 |
214
+ | InvertedPendulum-v4 | 888.83 ± 34.66 | 879.81 ± 35.52 |
215
+ | Walker2d-v4 | 2872.92 ± 690.53 | 3665.48 ± 278.61 |
216
+
217
+ Learning curves:
218
+ ![](../rpo/mujoco_v4_part1.png)
219
+
220
+
221
+ Tracked experiments:
222
+
223
+ <iframe loading="lazy" src="https://wandb.ai/openrlbenchmark/cleanrl/reports/RPO-on-Mujoco_v4-Part-1--VmlldzozMjU3ODIz" style="width:100%; height:500px" title="RPO-mujoco-v4-part1"></iframe>
224
+
225
+
226
+ The following environments require tuning of `alpha` (Algorithm 1, line 13, paper: https://arxiv.org/pdf/2212.07536.pdf). As described in the paper, this variable should be tuned for environments tested. A larger value means more randomness, whereas a smaller value indicates less randomness. Some mujoco environments require a smaller `alpha=0.01` value to achieve a reasonable performance compared to `alpha=0.5` for the rest of the environments. This version (`alpha=0.01`) of runs is indicated as `rpo_continuous_action_alpha_0_01` in the table and learning curves.
227
+
228
+ | | ppo_continuous_action_8M ({'tag': ['v1.0.0-13-gcbd83f6']}) | rpo_continuous_action_alpha_0_01 ({'tag': ['pr-331']}) |
229
+ |:--------------------------|:-------------------------------------------------------------|:---------------------------------------------------------|
230
+ | Ant-v4 | 1824.17 ± 905.78 | 2702.91 ± 683.53 |
231
+ | HalfCheetah-v4 | 2637.19 ± 1068.49 | 2716.51 ± 1314.93 |
232
+ | Hopper-v4 | 2741.42 ± 269.11 | 2334.22 ± 441.89 |
233
+ | InvertedDoublePendulum-v4 | 5626.22 ± 289.23 | 5409.03 ± 318.68 |
234
+ | Reacher-v4 | -4.65 ± 0.96 | -3.93 ± 0.19 |
235
+ | Swimmer-v4 | 124.88 ± 22.24 | 129.97 ± 12.02 |
236
+ | Pusher-v4 | -30.35 ± 6.43 | -31.48 ± 9.83 |
237
+
238
+ Learning curves:
239
+ ![](../rpo/mujoco_v4_part2.png)
240
+
241
+ Tracked experiments:
242
+
243
+ <iframe loading="lazy" src="https://wandb.ai/openrlbenchmark/cleanrl/reports/RPO-on-Mujoco_v4-Part-2--VmlldzozMjU3OTM4" style="width:100%; height:500px" title="RPO-mujoco-v4-part2"></iframe>
244
+
245
+
246
+ Results with `rpo_alpha=0.5` (not tuned) on the tuned environments:
247
+
248
+ | | ppo_continuous_action_8M ({'tag': ['v1.0.0-13-gcbd83f6']}) | rpo_continuous_action ({'tag': ['pr-331']}) |
249
+ |:--------------------------|:-------------------------------------------------------------|:----------------------------------------------|
250
+ | Ant-v4 | 1774.42 ± 819.08 | -7.99 ± 2.47 |
251
+ | HalfCheetah-v4 | 2667.34 ± 1109.99 | 2163.57 ± 790.16 |
252
+ | Hopper-v4 | 2761.77 ± 286.88 | 1557.18 ± 206.74 |
253
+ | InvertedDoublePendulum-v4 | 5644.00 ± 353.46 | 296.97 ± 15.95 |
254
+ | Reacher-v4 | -4.67 ± 0.88 | -66.35 ± 0.66 |
255
+ | Swimmer-v4 | 124.52 ± 22.10 | 117.82 ± 10.07 |
256
+ | Pusher-v4 | -30.62 ± 6.80 | -276.32 ± 26.99 |
257
+
258
+ Learning curves:
259
+ ![](../rpo/mujoco_v4_part2_0_5.png)
260
+
261
+
262
+ Tracked experiments:
263
+
264
+ <iframe loading="lazy" src="https://wandb.ai/openrlbenchmark/cleanrl/reports/RPO-alpha-0-5-on-Mujoco_v4-Part-2--VmlldzozMjU4MTM1" style="width:100%; height:500px" title="RPO-mujoco-v4-0-5-part-2"></iframe>
265
+
266
+
267
+
268
+ === "MuJoCo v2"
269
+
270
+ | | ppo_continuous_action_8M ({'tag': ['v1.0.0-13-gcbd83f6']}) | rpo_continuous_action ({'tag': ['pr-331']}) |
271
+ |:--------------------|:-------------------------------------------------------------|:----------------------------------------------|
272
+ | HumanoidStandup-v2 | 109118.07 ± 19422.20 | 156848.90 ± 11414.50 |
273
+ | Humanoid-v2 | 588.22 ± 43.80 | 717.37 ± 97.18 |
274
+ | InvertedPendulum-v2 | 867.64 ± 19.97 | 866.60 ± 27.06 |
275
+ | Walker2d-v2 | 3220.99 ± 923.84 | 4150.51 ± 348.03 |
276
+
277
+ Learning curves:
278
+ ![](../rpo/mujoco_v2_part1.png)
279
+
280
+ Tracked experiments:
281
+
282
+ <iframe loading="lazy" src="https://wandb.ai/openrlbenchmark/cleanrl/reports/RPO-on-Mujoco_v2-Part-1--VmlldzozMjU4Mjc5" style="width:100%; height:500px" title="RPO-mujoco-v2-part1"></iframe>
283
+
284
+ The following environments require tuning of `alpha` (Algorithm 1, line 13, paper: https://arxiv.org/pdf/2212.07536.pdf). As described in the paper, this variable should be tuned for environments tested. A larger value means more randomness, whereas a smaller value indicates less randomness. Some mujoco environments require a smaller `alpha=0.01` value to achieve a reasonable performance compared to `alpha=0.5` for the rest of the environments. This version (`alpha=0.01`) of runs is indicated as `rpo_continuous_action_alpha_0_01` in the table and learning curves.
285
+
286
+ | | ppo_continuous_action_8M ({'tag': ['v1.0.0-13-gcbd83f6']}) | rpo_continuous_action_alpha_0_01 ({'tag': ['pr-331']}) |
287
+ |:--------------------------|:-------------------------------------------------------------|:---------------------------------------------------------|
288
+ | Ant-v2 | 2412.35 ± 949.44 | 3084.95 ± 759.51 |
289
+ | HalfCheetah-v2 | 2717.27 ± 1269.85 | 2707.91 ± 1215.21 |
290
+ | Hopper-v2 | 2387.39 ± 645.41 | 2272.78 ± 588.66 |
291
+ | InvertedDoublePendulum-v2 | 5630.91 ± 377.93 | 5661.29 ± 316.04 |
292
+ | Reacher-v2 | -4.61 ± 0.53 | -4.24 ± 0.25 |
293
+ | Swimmer-v2 | 132.07 ± 9.92 | 141.37 ± 8.70 |
294
+ | Pusher-v2 | -33.93 ± 8.55 | -26.22 ± 2.52 |
295
+
296
+
297
+ Learning curves:
298
+ ![](../rpo/mujoco_v2_part2.png)
299
+
300
+ Tracked experiments:
301
+
302
+ <iframe loading="lazy" src="https://wandb.ai/openrlbenchmark/cleanrl/reports/RPO-on-Mujoco_v2-Part-2--VmlldzozMjU4MzI1" style="width:100%; height:500px" title="RPO-mujoco-v2-part1"></iframe>
303
+
304
+ Results with `rpo_alpha=0.5` (not tuned) on the tuned environments:
305
+
306
+ | | ppo_continuous_action_8M ({'tag': ['v1.0.0-13-gcbd83f6']}) | rpo_continuous_action ({'tag': ['pr-331']}) |
307
+ |:--------------------------|:-------------------------------------------------------------|:----------------------------------------------|
308
+ | Ant-v2 | 2495.65 ± 991.65 | -7.81 ± 3.57 |
309
+ | HalfCheetah-v2 | 2722.03 ± 1231.28 | 2605.06 ± 1183.30 |
310
+ | Hopper-v2 | 2356.83 ± 650.91 | 1609.79 ± 164.16 |
311
+ | InvertedDoublePendulum-v2 | 5675.31 ± 244.34 | 274.78 ± 16.40 |
312
+ | Reacher-v2 | -4.67 ± 0.48 | -66.55 ± 0.20 |
313
+ | Swimmer-v2 | 131.53 ± 9.94 | 114.34 ± 3.95 |
314
+ | Pusher-v2 | -33.46 ± 8.41 | -275.09 ± 15.65 |
315
+
316
+ Learning curves:
317
+ ![](../rpo/mujoco_v2_part2_0_5.png)
318
+
319
+
320
+ Tracked experiments:
321
+
322
+ <iframe loading="lazy" src="https://wandb.ai/openrlbenchmark/cleanrl/reports/RPO-alpha-0-5-on-Mujoco_v2-Part-2--VmlldzozMjU4MzQ0" style="width:100%; height:500px" title="RPO-mujoco-v2-0-5-part-2s"></iframe>
323
+
324
+
325
+
326
+
327
+ === "Gym(Gymnasium)"
328
+
329
+ Results on two continuous gym environments. The PPO and RPO run for 8M timesteps, and results are computed over 10 random seeds.
330
+
331
+
332
+ | | ppo_continuous_action_8M ({'tag': ['v1.0.0-13-gcbd83f6']}) | rpo_continuous_action ({'tag': ['pr-331']}) |
333
+ |:-----------------|:-------------------------------------------------------------|:----------------------------------------------|
334
+ | Pendulum-v1 | -1141.98 ± 135.55 | -151.08 ± 3.73 |
335
+ | BipedalWalker-v3 | 172.12 ± 96.05 | 227.11 ± 18.23 |
336
+
337
+ Learning curves:
338
+ ![](../rpo/gym.png)
339
+
340
+ Tracked experiments:
341
+
342
+ <iframe loading="lazy" src="https://wandb.ai/openrlbenchmark/cleanrl/reports/RPO-on-Gym-Gymnasium---VmlldzozMjU3NzUy" style="width:100%; height:500px" title="RPO-gymnasium"></iframe>
343
+
344
+
345
+
346
+ ???+ failure
347
+
348
+ Failure case of `rpo_alpha=0.5`:
349
+
350
+ Overall, we observed that `rpo_alpha=0.5` is strictly equal to or better than the default PPO in 93% of environments tested (all 48/48 dm_control, 2/2 Gym, 7/11 mujoco_v4. Total 57 out of 61 environments tested).
351
+
352
+ Here are the failure cases:
353
+ `Mujoco v4 and v2: Ant InvertedDoublePendulum Reacher Pusher`
354
+
355
+ | | ppo_continuous_action_8M ({'tag': ['v1.0.0-13-gcbd83f6']}) | rpo_continuous_action ({'tag': ['pr-331']}) |
356
+ |:--------------------------|:-------------------------------------------------------------|:----------------------------------------------|
357
+ | Ant-v4 | 1831.63 ± 867.71 | -10.43 ± 8.16 |
358
+ | InvertedDoublePendulum-v4 | 5490.71 ± 261.50 | 303.36 ± 13.39 |
359
+ | Reacher-v4 | -4.58 ± 0.73 | -66.62 ± 0.56 |
360
+ | Pusher-v4 | -30.63 ± 6.42 | -276.11 ± 26.52 |
361
+
362
+ Learning curves:
363
+ ![](../rpo/mujoco_v4_failure_0_5.png)
364
+
365
+ Tracked experiments:
366
+
367
+ <iframe loading="lazy" src="https://wandb.ai/openrlbenchmark/cleanrl/reports/RPO-alpha-0-5-s-failure-cases-on-Mujoco_v4--VmlldzozMjU4MTYy" style="width:100%; height:500px" title="RPO-mujoco-v4-failure-cases"></iframe>
368
+
369
+
370
+
371
+ | | ppo_continuous_action_8M ({'tag': ['v1.0.0-13-gcbd83f6']}) | rpo_continuous_action ({'tag': ['pr-331']}) |
372
+ |:--------------------------|:-------------------------------------------------------------|:----------------------------------------------|
373
+ | Ant-v2 | 2493.50 ± 993.24 | -7.26 ± 2.28 |
374
+ | InvertedDoublePendulum-v2 | 5568.37 ± 401.65 | 278.94 ± 15.34 |
375
+ | Reacher-v2 | -4.62 ± 0.47 | -66.61 ± 0.23 |
376
+ | Pusher-v2 | -33.51 ± 8.47 | -276.01 ± 15.93 |
377
+
378
+
379
+ Learning curves:
380
+ ![](../rpo/mujoco_v2_failure_0_5.png)
381
+
382
+
383
+ Tracked experiments:
384
+
385
+ <iframe loading="lazy" src="https://wandb.ai/openrlbenchmark/cleanrl/reports/RPO-alpha-0-5-s-failure-cases-on-Mujoco_v2--VmlldzozMjU4MjQ1" style="width:100%; height:500px" title="RPO-mujoco-v4-failure-cases"></iframe>
386
+
387
+
388
+ However, tuning of `rpo_alpha` (`rpo_alpha=0.01` on failed cases) helps RPO to overcome the failure, and it performs strictly equal to or better than the default PPO in all (100%) of tested environments.
389
+
cleanrl/docs/rl-algorithms/sac.md ADDED
@@ -0,0 +1,413 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Soft Actor-Critic (SAC)
2
+
3
+ ## Overview
4
+
5
+ The Soft Actor-Critic (SAC) algorithm extends the DDPG algorithm by 1) using a stochastic policy, which in theory can express multi-modal optimal policies.
6
+ This also enables the use of 2) *entropy regularization* based on the stochastic policy's entropy. It serves as a built-in, state-dependent exploration heuristic for the agent, instead of relying on non-correlated noise processes as in [DDPG](/rl-algorithms/ddpg/), or [TD3](/rl-algorithms/td3/)
7
+ Additionally, it incorporates the 3) usage of two *Soft Q-network* to reduce the overestimation bias issue in Q-network-based methods.
8
+
9
+ Original papers:
10
+ The SAC algorithm's initial proposal, and later updates and improvements can be chronologically traced through the following publications:
11
+
12
+ * [Reinforcement Learning with Deep Energy-Based Policies](https://arxiv.org/abs/1702.08165)
13
+ * [Soft Actor-Critic: Off-Policy Maximum Entropy Deep Reinforcement Learning with a Stochastic Actor](https://arxiv.org/abs/1801.01290)
14
+ * [Composable Deep Reinforcement Learning for Robotic Manipulation](https://arxiv.org/abs/1803.06773)
15
+ * [Soft Actor-Critic Algorithms and Applications](https://arxiv.org/abs/1812.05905)
16
+ * [Soft Actor-Critic for Discrete Action Settings](https://arxiv.org/abs/1910.07207) (No peer review, preprint only)
17
+
18
+ Reference resources:
19
+
20
+ * :material-github: [haarnoja/sac](https://github.com/haarnoja/sac)
21
+ * :material-github: [openai/spinningup](https://github.com/openai/spinningup/tree/master/spinup/algos/tf1/sac)
22
+ * :material-github: [pranz24/pytorch-soft-actor-critic](https://github.com/pranz24/pytorch-soft-actor-critic)
23
+ * :material-github: [DLR-RM/stable-baselines3](https://github.com/DLR-RM/stable-baselines3/tree/master/stable_baselines3/sac)
24
+ * :material-github: [denisyarats/pytorch_sac](https://github.com/denisyarats/pytorch_sac)
25
+ * :material-github: [haarnoja/softqlearning](https://github.com/haarnoja/softqlearning)
26
+ * :material-github: [rail-berkeley/softlearning](https://github.com/rail-berkeley/softlearning)
27
+ * :material-github: [p-christ/Deep-Reinforcement-Learning-Algorithms-with-PyTorch](https://github.com/p-christ/Deep-Reinforcement-Learning-Algorithms-with-PyTorch)
28
+ * :material-github: [toshikwa/sac-discrete.pytorch](https://github.com/toshikwa/sac-discrete.pytorch)
29
+
30
+ | Variants Implemented | Description |
31
+ | ----------- | ----------- |
32
+ | :material-github: [`sac_continuous_actions.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/sac_continuous_action.py), :material-file-document: [docs](/rl-algorithms/sac/#sac_continuous_actionpy) | For continuous action spaces |
33
+ | :material-github: [`sac_atari.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/sac_atari.py), :material-file-document: [docs](/rl-algorithms/sac/#sac_ataripy) | For discrete action spaces |
34
+
35
+ Below are our single-file implementations of SAC:
36
+
37
+ ## `sac_continuous_action.py`
38
+
39
+ The [sac_continuous_action.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/sac_continuous_action.py) has the following features:
40
+
41
+ * For continuous action spaces.
42
+ * Works with the `Box` observation space of low-level features.
43
+ * Works with the `Box` (continuous) action space.
44
+ * Numerically stable stochastic policy based on :material-github: [openai/spinningup](https://github.com/openai/spinningup/tree/master/spinup/algos/tf1/sac) and [pranz24/pytorch-soft-actor-critic](https://github.com/pranz24/pytorch-soft-actor-critic) implementations.
45
+ * Supports automatic entropy coefficient $\alpha$ tuning, enabled by default.
46
+
47
+ ### Usage for continuous action spaces
48
+
49
+ === "poetry"
50
+
51
+ ```bash
52
+ poetry install
53
+ uv pip install ".[mujoco]"
54
+ uv run python cleanrl/sac_continuous_action.py --help
55
+ uv run python cleanrl/sac_continuous_action.py --env-id Hopper-v4
56
+ uv run python cleanrl/sac_continuous_action.py --env-id Hopper-v4 --autotune False --alpha 0.2 ## Without Automatic entropy coef. tuning
57
+ ```
58
+
59
+ === "pip"
60
+
61
+ ```bash
62
+ pip install -r requirements/requirements-mujoco.txt
63
+ python cleanrl/sac_continuous_action.py --help
64
+ python cleanrl/sac_continuous_action.py --env-id Mujoco-v4
65
+ python cleanrl/sac_continuous_action.py --env-id Hopper-v4 --autotune False --alpha 0.2 ## Without Automatic entropy coef. tuning
66
+ ```
67
+
68
+ ### Explanation of the logged metrics
69
+
70
+ Running python cleanrl/sac_continuous_action.py will automatically record various metrics such as actor or value losses in Tensorboard. Below is the documentation for these metrics:
71
+
72
+ * `charts/episodic_return`: the episodic return of the game during training
73
+
74
+ * `charts/SPS`: number of steps per second
75
+
76
+ * `losses/qf1_loss`, `losses/qf2_loss`: for each Soft Q-value network $Q_{\theta_i}$, $i \in \{1,2\}$, this metric holds the mean squared error (MSE) between the soft Q-value estimate $Q_{\theta_i}(s, a)$ and the *entropy regularized* Bellman update target estimated as $r_t + \gamma \, Q_{\theta_{i}^{'}}(s', a') + \alpha \, \mathcal{H} \big[ \pi(a' \vert s') \big]$.
77
+
78
+ More formally, the Soft Q-value loss for the $i$-th network is obtained by:
79
+
80
+ $$
81
+ J(\theta^{Q}_{i}) = \mathbb{E}_{(s,a,r,s') \sim \mathcal{D}} \big[ (Q_{\theta_i}(s, a) - y)^2 \big]
82
+ $$
83
+
84
+ with the *entropy regularized*, *Soft Bellman update target*:
85
+ $$
86
+ y = r(s, a) + \gamma ({\color{orange} \min_{\theta_{1,2}}Q_{\theta_i^{'}}(s',a')} - \alpha \, \text{log} \pi( \cdot \vert s'))
87
+ $$ where $a' \sim \pi( \cdot \vert s')$, $\text{log} \pi( \cdot \vert s')$ approximates the entropy of the policy, and $\mathcal{D}$ is the replay buffer storing samples of the agent during training.
88
+
89
+ Here, $\min_{\theta_{1,2}}Q_{\theta_i^{'}}(s',a')$ takes the minimum *Soft Q-value network* estimate between the two target Q-value networks $Q_{\theta_1^{'}}$ and $Q_{\theta_2^{'}}$ for the next state and action pair, so as to reduce over-estimation bias.
90
+
91
+ * `losses/qf_loss`: averages `losses/qf1_loss` and `losses/qf2_loss` for comparison with algorithms using a single Q-value network.
92
+
93
+ * `losses/actor_loss`: Given the stochastic nature of the policy in SAC, the actor (or policy) objective is formulated so as to maximize the likelihood of actions $a \sim \pi( \cdot \vert s)$ that would result in high Q-value estimate $Q(s, a)$. Additionally, the policy objective encourages the policy to maintain its entropy high enough to help explore, discover, and capture multi-modal optimal policies.
94
+
95
+ The policy's objective function can thus be defined as:
96
+
97
+ $$
98
+ \text{max}_{\phi} \, J_{\pi}(\phi) = \mathbb{E}_{s \sim \mathcal{D}} \Big[ \text{min}_{i=1,2} Q_{\theta_i}(s, a) - \alpha \, \text{log}\pi_{\phi}(a \vert s) \Big]
99
+ $$
100
+
101
+ where the action is sampled using the reparameterization trick[^1]: $a = \mu_{\phi}(s) + \epsilon \, \sigma_{\phi}(s)$ with $\epsilon \sim \mathcal{N}(0, 1)$, $\text{log} \pi_{\phi}( \cdot \vert s')$ approximates the entropy of the policy, and $\mathcal{D}$ is the replay buffer storing samples of the agent during training.
102
+
103
+ * `losses/alpha`: $\alpha$ coefficient for *entropy regularization* of the policy.
104
+
105
+ * `losses/alpha_loss`: In the policy's objective defined above, the coefficient of the *entropy bonus* $\alpha$ is kept fixed all across the training.
106
+ As suggested by the authors in Section 5 of the [*Soft Actor-Critic And Applications*](https://arxiv.org/abs/1812.05905) paper, the original purpose of augmenting the standard reward with the entropy of the policy is to *encourage exploration* of not well enough explored states (thus high entropy).
107
+ Conversely, for states where the policy has already learned a near-optimal policy, it would be preferable to reduce the entropy bonus of the policy, so that it does not *become sub-optimal due to the entropy maximization incentive*.
108
+
109
+ Therefore, having a fixed value for $\alpha$ does not fit this desideratum of matching the entropy bonus with the knowledge of the policy at an arbitrary state during its training.
110
+
111
+ To mitigate this, the authors proposed a method to dynamically adjust $\alpha$ as the policy is trained, which is as follows:
112
+
113
+ $$
114
+ \alpha^{*}_t = \text{argmin}_{\alpha_t} \mathbb{E}_{a_t \sim \pi^{*}_t} \big[ -\alpha_t \, \text{log}\pi^{*}_t(a_t \vert s_t; \alpha_t) - \alpha_t \mathcal{H} \big],
115
+ $$
116
+
117
+ where $\mathcal{H}$ represents the *target entropy*, the desired lower bound for the expected entropy of the policy over the trajectory distribution induced by the latter.
118
+ As a heuristic for the *target entropy*, the authors use the dimension of the action space of the task.
119
+
120
+ ### Implementation details
121
+
122
+ CleanRL's [`sac_continuous_action.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/sac_continuous_action.py) implementation is based on :material-github: [openai/spinningup](https://github.com/openai/spinningup/tree/master/spinup/algos/pytorch/sac).
123
+
124
+ 1. [`sac_continuous_action.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/sac_continuous_action.py) uses a *numerically stable* estimation method for the standard deviation $\sigma$ of the policy, which squashes it into a range of reasonable values for a standard deviation:
125
+
126
+ ```python hl_lines="1-2 19-21"
127
+ LOG_STD_MAX = 2
128
+ LOG_STD_MIN = -5
129
+
130
+ class Actor(nn.Module):
131
+ def __init__(self, env):
132
+ super(Actor, self).__init__()
133
+ self.fc1 = nn.Linear(np.array(env.single_observation_space.shape).prod(), 256)
134
+ self.fc2 = nn.Linear(256, 256)
135
+ self.fc_mean = nn.Linear(256, np.prod(env.single_action_space.shape))
136
+ self.fc_logstd = nn.Linear(256, np.prod(env.single_action_space.shape))
137
+ # action rescaling
138
+ self.action_scale = torch.FloatTensor((env.action_space.high - env.action_space.low) / 2.0)
139
+ self.action_bias = torch.FloatTensor((env.action_space.high + env.action_space.low) / 2.0)
140
+
141
+ def forward(self, x):
142
+ x = F.relu(self.fc1(x))
143
+ x = F.relu(self.fc2(x))
144
+ mean = self.fc_mean(x)
145
+ log_std = self.fc_logstd(x)
146
+ log_std = torch.tanh(log_std)
147
+ log_std = LOG_STD_MIN + 0.5 * (LOG_STD_MAX - LOG_STD_MIN) * (log_std + 1) # From SpinUp / Denis Yarats
148
+
149
+ return mean, log_std
150
+
151
+ def get_action(self, x):
152
+ mean, log_std = self(x)
153
+ std = log_std.exp()
154
+ normal = torch.distributions.Normal(mean, std)
155
+ x_t = normal.rsample() # for reparameterization trick (mean + std * N(0,1))
156
+ y_t = torch.tanh(x_t)
157
+ action = y_t * self.action_scale + self.action_bias
158
+ log_prob = normal.log_prob(x_t)
159
+ # Enforcing Action Bound
160
+ log_prob -= torch.log(self.action_scale * (1 - y_t.pow(2)) + 1e-6)
161
+ log_prob = log_prob.sum(1, keepdim=True)
162
+ mean = torch.tanh(mean) * self.action_scale + self.action_bias
163
+ return action, log_prob, mean
164
+
165
+ def to(self, device):
166
+ self.action_scale = self.action_scale.to(device)
167
+ self.action_bias = self.action_bias.to(device)
168
+ return super(Actor, self).to(device)
169
+ ```
170
+
171
+ Note that unlike :material-github: [openai/spinningup](https://github.com/openai/spinningup/tree/master/spinup/algos/tf1/sac)'s implementation which uses `LOG_STD_MIN = -20`, CleanRL's uses `LOG_STD_MIN = -5` instead.
172
+
173
+ 2. [`sac_continuous_action.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/sac_continuous_action.py) uses different learning rates for the policy and the Soft Q-value networks optimization.
174
+
175
+ ```python
176
+ parser.add_argument("--policy-lr", type=float, default=3e-4,
177
+ help="the learning rate of the policy network optimizer")
178
+ parser.add_argument("--q-lr", type=float, default=1e-3,
179
+ help="the learning rate of the Q network network optimizer")
180
+ ```
181
+
182
+ while [openai/spinningup](https://github.com/openai/spinningup/blob/038665d62d569055401d91856abb287263096178/spinup/algos/tf1/sac/sac.py#L44)'s uses a single learning rate of `lr=1e-3` for both components.
183
+
184
+ Note that in case it is used, the *automatic entropy coefficient* $\alpha$'s tuning shares the `q-lr` learning rate:
185
+
186
+ ```python hl_lines="6"
187
+ # Automatic entropy tuning
188
+ if args.autotune:
189
+ target_entropy = -torch.prod(torch.Tensor(envs.single_action_space.shape).to(device)).item()
190
+ log_alpha = torch.zeros(1, requires_grad=True, device=device)
191
+ alpha = log_alpha.exp().item()
192
+ a_optimizer = optim.Adam([log_alpha], lr=args.q_lr)
193
+ else:
194
+ alpha = args.alpha
195
+ ```
196
+
197
+ 3. [`sac_continuous_action.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/sac_continuous_action.py) uses `--batch-size=256` while :material-github: [openai/spinningup](https://github.com/openai/spinningup/blob/038665d62d569055401d91856abb287263096178/spinup/algos/tf1/sac/sac.py#L44)'s uses `--batch-size=100` by default.
198
+
199
+ ### Experiment results
200
+
201
+ To run benchmark experiments, see :material-github: [benchmark/sac.sh](https://github.com/vwxyzjn/cleanrl/blob/master/benchmark/sac.sh). Specifically, execute the following command:
202
+
203
+ ``` title="benchmark/sac.sh" linenums="1"
204
+ --8<-- "benchmark/sac.sh::7"
205
+ ```
206
+
207
+ The table below compares the results of CleanRL's [`sac_continuous_action.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/sac_continuous_action.py) with the [latest published results](https://arxiv.org/abs/1812.05905) by the original authors of the SAC algorithm.
208
+
209
+ ???+ info
210
+ Note that the results table above references the *training episodic return* for [`sac_continuous_action.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/sac_continuous_action.py), the results of [Soft Actor-Critic Algorithms and Applications](https://arxiv.org/abs/1812.05905) reference *evaluation episodic return* obtained by running the policy in the deterministic mode.
211
+
212
+ | Environment | [`sac_continuous_action.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/sac_continuous_action.py) |[SAC: Algorithms and Applications](https://arxiv.org/abs/1812.05905) @ 1M steps|
213
+ | --------------- | ------------------ | ---------------- |
214
+ | HalfCheetah-v2 | 9634.89 ± 1423.73 | ~11,250 |
215
+ | Walker2d-v2 | 3591.45 ± 911.33 | ~4,800 |
216
+ | Hopper-v2 | 2310.46 ± 342.82 | ~3,250 |
217
+ | InvertedPendulum-v4 | 909.37 ± 55.66 | N/A |
218
+ | Humanoid-v4 | 4996.29 ± 686.40 | ~4500
219
+ | Pusher-v4 | -22.45 ± 0.51 | N/A |
220
+
221
+ Learning curves:
222
+
223
+ ``` title="benchmark/sac_plot.sh" linenums="1"
224
+ --8<-- "benchmark/sac_plot.sh::9"
225
+ ```
226
+
227
+
228
+ <img loading="lazy" src="https://huggingface.co/datasets/cleanrl/benchmark/resolve/main/benchmark/pr-424/sac.png">
229
+ <img loading="lazy" src="https://huggingface.co/datasets/cleanrl/benchmark/resolve/main/benchmark/pr-424/sac-time.png">
230
+
231
+ Tracked experiments and game play videos:
232
+
233
+ <iframe src="https://wandb.ai/openrlbenchmark/openrlbenchmark/reports/MuJoCo-CleanRL-s-SAC--VmlldzoxNzI1NDM0" style="width:100%; height:1200px" title="MuJoCo: CleanRL's SAC"></iframe>
234
+
235
+ ## `sac_atari.py`
236
+
237
+ The [sac_atari.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/sac_atari.py) has the following features:
238
+
239
+ * For discrete action spaces.
240
+ * Works with the `Box` observation space of low-level features.
241
+ * Works with the `Discrete` action space.
242
+ * Improved stability and wall-clock efficiency through updates only every n-th step.
243
+ * Supports automatic entropy coefficient $\alpha$ tuning, enabled by default.
244
+
245
+ ### Usage for discrete action spaces
246
+
247
+ === "poetry"
248
+
249
+ ```bash
250
+ uv pip install ".[atari]"
251
+ uv run python cleanrl/sac_atari.py.py --env-id PongNoFrameskip-v4
252
+ uv run python cleanrl/sac_atari.py.py --env-id PongNoFrameskip-v4 --autotune False --alpha 0.2
253
+ ```
254
+
255
+ === "pip"
256
+
257
+ ```bash
258
+ pip install -r requirements/requirements-atari.txt
259
+ python cleanrl/sac_atari.py.py --env-id PongNoFrameskip-v4
260
+ python cleanrl/sac_atari.py.py --env-id PongNoFrameskip-v4 --autotune False --alpha 0.2
261
+ ```
262
+
263
+ ### Explanation of the logged metrics
264
+
265
+ The metrics logged by `python cleanrl/sac_atari.py` are the same as the ones logged by `python cleanrl/sac_continuous_action.py` (see the [related docs](/rl-algorithms/sac/#explanation-of-the-logged-metrics)). However, the computations for the objectives differ in some details highlighted below:
266
+
267
+ * `losses/qf1_loss`, `losses/qf2_loss`: for each Soft Q-value network $Q_{\theta_i}$, $i \in \{1,2\}$, this metric holds the mean squared error (MSE) between the soft Q-value estimate $Q_{\theta_i}(s, a)$ and the *entropy regularized* Bellman update target estimated as $r_t + \gamma \, Q_{\theta_{i}^{'}}(s', a') + \alpha \, \mathcal{H} \big[ \pi(a' \vert s') \big]$.
268
+
269
+ SAC-discrete is able to exploit the discrete action space by using the full action distribution to calculate the Soft Q-targets instead of relying on a Monte Carlo approximation from a single Q-value. The new Soft Q-target is stated below with differences to the [continuous SAC target](/rl-algorithms/sac/#explanation-of-the-logged-metrics) highlighted in orange:
270
+ $$
271
+ y = r(s, a) + \gamma \, {\color{orange}\pi (a | s^\prime)^{\mathsf T}} \Big(\min_{\theta_{1,2}} {\color{orange}Q_{\theta_i^{'}}(s')} - \alpha \, \log \pi( \cdot \vert s')\Big)~,
272
+ $$
273
+
274
+ Note how in the discrete setting the Q-function $Q_{\theta_i^{'}}(s')$ is a mapping $Q:S \rightarrow \mathbb R^{|\mathcal A|}$ that only takes states as inputs and outputs Q-values for all actions. Using all this available information and additionally weighing the target by the corresponding action selection probability reduces variance of the gradient.
275
+
276
+ * `losses/actor_loss`: Given the stochastic nature of the policy in SAC, the actor (or policy) objective is formulated so as to maximize the likelihood of actions $a \sim \pi( \cdot \vert s)$ that would result in high Q-value estimate $Q(s, a)$. Additionally, the policy objective encourages the policy to maintain its entropy high enough to help explore, discover, and capture multi-modal optimal policies.
277
+
278
+ SAC-discrete uses an action probability-weighted (highlighted in orange) objective given as:
279
+
280
+ $$
281
+ \text{max}_{\phi} \, J_{\pi}(\phi) = \mathbb{E}_{s \sim \mathcal{D}} \bigg[ {\color{orange}\pi (a | s)^{\mathsf T}} \Big( \text{min}_{i=1,2} {\color{orange} Q_{\theta_i}(s)} - \alpha \, \log\pi_{\phi}(a \vert s) \Big) \bigg]
282
+ $$
283
+
284
+ Unlike for continuous action spaces, there is *no need for the reparameterization trick* due to using a Categorical policy. Similar to the critic objective, the Q-function $Q_{\theta_i}(s)$ is a function from states to real numbers and does not require actions as inputs.
285
+
286
+ * `losses/alpha_loss`: In the policy's objective defined above, the coefficient of the *entropy bonus* $\alpha$ is kept fixed all across the training.
287
+ As suggested by the authors in Section 5 of the [*Soft Actor-Critic And Applications*](https://arxiv.org/abs/1812.05905) paper, the original purpose of augmenting the standard reward with the entropy of the policy is to *encourage exploration* of not well enough explored states (thus high entropy).
288
+ Conversely, for states where the policy has already learned a near-optimal policy, it would be preferable to reduce the entropy bonus of the policy, so that it does not *become sub-optimal due to the entropy maximization incentive*.
289
+
290
+ In SAC-discrete, it is possible to weigh the target for the entropy coefficient by the policy's action selection probabilities to reduce gradient variance. This is the same trick that was already used in the critic and actor objectives, with differences to the regular SAC objective marked in orange:
291
+
292
+ $$
293
+ \alpha^{*}_t = \text{argmin}_{\alpha_t} \mathbb{E}_{a_t \sim \pi^{*}_t} \, {\color{orange}\pi (a | s)^{\mathsf T}}\big[ -\alpha_t \, \log\pi^{*}_t(a_t \vert s_t; \alpha_t) - \alpha_t \tau \mathcal{H} \big],
294
+ $$
295
+
296
+ Since SAC-discrete uses a Categorical policy in a discrete action space, a different entropy target is required. The author uses the *maximum entropy Categorical distribution* (assigning uniform probability to all available actions) scaled by a factor of $\tau~.$
297
+
298
+ ### Implementation details
299
+
300
+ [`sac_atari.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/sac_atari.py) uses the wrappers highlighted in the "9 Atari implementation details" in [The 37 Implementation Details of Proximal Policy Optimization](https://iclr-blog-track.github.io/2022/03/25/ppo-implementation-details/), which are as follows:
301
+
302
+ 1. The Use of `NoopResetEnv` (:material-github: [common/atari_wrappers.py#L12](https://github.com/openai/baselines/blob/ea25b9e8b234e6ee1bca43083f8f3cf974143998/baselines/common/atari_wrappers.py#L12))
303
+ 2. The Use of `MaxAndSkipEnv` (:material-github: [common/atari_wrappers.py#L97](https://github.com/openai/baselines/blob/ea25b9e8b234e6ee1bca43083f8f3cf974143998/baselines/common/atari_wrappers.py#L97))
304
+ 3. The Use of `EpisodicLifeEnv` (:material-github: [common/atari_wrappers.py#L61](https://github.com/openai/baselines/blob/ea25b9e8b234e6ee1bca43083f8f3cf974143998/baselines/common/atari_wrappers.py#L61))
305
+ 4. The Use of `FireResetEnv` (:material-github: [common/atari_wrappers.py#L41](https://github.com/openai/baselines/blob/ea25b9e8b234e6ee1bca43083f8f3cf974143998/baselines/common/atari_wrappers.py#L41))
306
+ 5. The Use of `WarpFrame` (Image transformation) [common/atari_wrappers.py#L134](https://github.com/openai/baselines/blob/ea25b9e8b234e6ee1bca43083f8f3cf974143998/baselines/common/atari_wrappers.py#L134)
307
+ 6. The Use of `ClipRewardEnv` (:material-github: [common/atari_wrappers.py#L125](https://github.com/openai/baselines/blob/ea25b9e8b234e6ee1bca43083f8f3cf974143998/baselines/common/atari_wrappers.py#L125))
308
+ 7. The Use of `FrameStack` (:material-github: [common/atari_wrappers.py#L188](https://github.com/openai/baselines/blob/ea25b9e8b234e6ee1bca43083f8f3cf974143998/baselines/common/atari_wrappers.py#L188))
309
+ 8. Shared Nature-CNN network for the policy and value functions (:material-github: [common/policies.py#L157](https://github.com/openai/baselines/blob/ea25b9e8b234e6ee1bca43083f8f3cf974143998/baselines/common/policies.py#L157), [common/models.py#L15-L26](https://github.com/openai/baselines/blob/ea25b9e8b234e6ee1bca43083f8f3cf974143998/baselines/common/models.py#L15-L26))
310
+ 9. Scaling the Images to Range [0, 1] (:material-github: [common/models.py#L19](https://github.com/openai/baselines/blob/9b68103b737ac46bc201dfb3121cfa5df2127e53/baselines/common/models.py#L19))
311
+
312
+ Other noteworthy implementation details apart from the Atari wrapping are as follows:
313
+
314
+ 1. [`sac_atari.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/sac_atari.py) initializes the weights of its networks using He initialization (named after its author Kaiming He) from the paper ["Delving Deep into Rectifiers:
315
+ Surpassing Human-Level Performance on ImageNet Classification"](https://arxiv.org/pdf/1502.01852.pdf). The corresponding function in PyTorch is `kaiming_normal_`, its documentation can be found [here](https://pytorch.org/docs/stable/nn.init.html). In essence, it means the weights of each layer are initialized according to a Normal distribution with mean $\mu=0$ and
316
+
317
+ $$
318
+ \sigma = \frac{\text{gain}}{\sqrt{\text{fan}}}~,
319
+ $$
320
+
321
+ where $\text{fan}$ is the number of input neurons to the layer and $\text{gain}$ is a constant set to $\sqrt{2}$ for `ReLU` layers.
322
+
323
+ 2. [`sac_atari.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/sac_atari.py) uses the Adam[^2] optimizer with an increased $\epsilon$-parameter to improve its stability. This results in an increase in the denominator of the update rule:
324
+
325
+ $$
326
+ \frac{\hat{m}_t}{\sqrt{\hat{v}_t} + \epsilon}
327
+ $$
328
+
329
+ Here $\hat{m}_t$ is the bias-corrected first moment and $\hat{v}_t$ the bias-corrected second raw moment.
330
+
331
+ 3. [`sac_atari.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/sac_atari.py) uses the action selection probabilities of the policy in multiple places to *reduce the variance of gradient estimates*. The target for the Soft Q-value estimate is weighted accordingly:
332
+
333
+ ```python hl_lines="7"
334
+ # CRITIC training
335
+ with torch.no_grad():
336
+ _, next_state_log_pi, next_state_action_probs = actor.get_action(data.next_observations)
337
+ qf1_next_target = qf1_target(data.next_observations)
338
+ qf2_next_target = qf2_target(data.next_observations)
339
+ # we can use the action probabilities instead of MC sampling to estimate the expectation
340
+ min_qf_next_target = next_state_action_probs * (
341
+ torch.min(qf1_next_target, qf2_next_target) - alpha * next_state_log_pi
342
+ )
343
+ ```
344
+
345
+ A similar action-probability weighting can be used for the actor gradient:
346
+
347
+ ```python hl_lines="7"
348
+ _, log_pi, action_probs = actor.get_action(data.observations)
349
+ with torch.no_grad():
350
+ qf1_values = qf1(data.observations)
351
+ qf2_values = qf2(data.observations)
352
+ min_qf_values = torch.min(qf1_values, qf2_values)
353
+ # no need for reparameterization, the expectation can be calculated for discrete actions
354
+ actor_loss = (action_probs * ((alpha * log_pi) - min_qf_values)).mean()
355
+ ```
356
+
357
+ Lastly, this variance reduction scheme is also used when automatic entropy tuning is enabled:
358
+
359
+ ```python hl_lines="3"
360
+ if args.autotune:
361
+ # reuse action probabilities for temperature loss
362
+ alpha_loss = (action_probs.detach() * (-log_alpha.exp() * (log_pi + target_entropy).detach())).mean()
363
+
364
+ a_optimizer.zero_grad()
365
+ alpha_loss.backward()
366
+ a_optimizer.step()
367
+ alpha = log_alpha.exp().item()
368
+ ```
369
+
370
+ 4. [`sac_atari.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/sac_atari.py) uses `--target-entropy-scale=0.89` while the [SAC-discrete paper](https://arxiv.org/abs/1910.07207) uses `--target-entropy-scale=0.98` due to improved stability when training for more than 100k steps. Tuning this parameter to the environment at hand is advised and can lead to significant performance gains.
371
+
372
+ 5. [`sac_atari.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/sac_atari.py) performs learning updates only on every $n^{\text{th}}$ step. This leads to improved stability and prevents the agent's performance from degenerating during longer training runs.
373
+ Note the difference to [`sac_continuous_action.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/sac_continuous_action.py): [`sac_atari.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/sac_atari.py) updates every $n^{\text{th}}$ environment step and does a single update of actor and critic on every update step. [`sac_continuous_action.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/sac_continuous_action.py) updates the critic every step and the actor every $n^{\text{th}}$ step. It then compensates for the delayed actor updates by performing $n$ actor update steps.
374
+
375
+ 6. [`sac_atari.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/sac_atari.py) handles truncation and termination properly like (Mnih et al., 2015)[^3] by using SB3's replay buffer's `handle_timeout_termination=True`.
376
+
377
+ ### Atari experiment results for SAC-discrete
378
+
379
+ Run benchmarks for :material-github: [benchmark/sac_atari.sh](https://github.com/vwxyzjn/cleanrl/blob/master/benchmark/sac_atari.sh) by executing:
380
+
381
+ <script src="https://emgithub.com/embed-v2.js?target=https%3A%2F%2Fgithub.com%2Ftimoklein%2Fcleanrl%2Fblob%2Fsac-discrete%2Fbenchmark%2Fsac_atari.sh&style=github&type=code&showBorder=on&showLineNumbers=on&showFileMeta=on&showFullPath=on&showCopy=on"></script>
382
+
383
+ The table below compares the results of CleanRL's [`sac_atari.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/sac_atari.py) with the [original paper results](https://arxiv.org/abs/1910.07207).
384
+
385
+ ???+ info
386
+ Note that the results table above references the *training episodic return* for [`sac_atari.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/sac_atari.py) without evaluation mode.
387
+
388
+ | Environment | [`sac_atari.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/sac_atari.py) 100k steps |[SAC for Discrete Action Settings](https://arxiv.org/abs/1910.07207) 100k steps| [`sac_atari.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/sac_atari.py) 5M steps | [`dqn_atari.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/dqn_atari.py) 10M steps
389
+ | --------------- | ------------------ | ---------------- | ---------------- | ---------------- |
390
+ | PongNoFrameskip-v4 | ~ -20.21 ± 0.62 | -20.98 ± 0.0 | ~19.24 ± 1.81 | 20.25 ± 0.41 |
391
+ | BreakoutNoFrameskip-v4 | ~2.33 ± 1.28 | - | ~343.66 ± 93.34 | 366.928 ± 39.89 |
392
+ | BeamRiderNoFrameskip-v4 | ~396.15 ± 155.81 | 432.1 ± 44.0 | ~8658.97 ± 1554.66 | 6673.24 ± 1434.37 |
393
+
394
+ Learning curves:
395
+
396
+ <div class="grid-container">
397
+ <img src="../sac/PongNoFrameskip-v4.png">
398
+ <img src="../sac/BreakoutNoFrameskip-v4.png">
399
+ <img src="../sac/BeamRiderNoFrameskip-v4.png">
400
+ </div>
401
+
402
+ <div></div>
403
+
404
+
405
+ Tracked experiments:
406
+
407
+ <iframe src="https://wandb.ai/openrlbenchmark/cleanrl/reports/Atari-CleanRL-s-SAC-discrete--VmlldzoyNzgxMTI2" style="border:none;height:1024px;width:100%"></iframe>
408
+
409
+ [^1]:Diederik P Kingma, Max Welling (2016). Auto-Encoding Variational Bayes. ArXiv, abs/1312.6114. https://arxiv.org/abs/1312.6114
410
+
411
+ [^2]:Diederik P Kingma, Jimmy Lei Ba (2015). Adam: A Method for Stochastic Optimization. ArXiv, abs/1412.6980. https://arxiv.org/abs/1412.6980
412
+
413
+ [^3]:Mnih, V., Kavukcuoglu, K., Silver, D. et al. Human-level control through deep reinforcement learning. Nature 518, 529–533 (2015). https://doi.org/10.1038/nature14236
cleanrl/docs/rl-algorithms/td3.md ADDED
@@ -0,0 +1,260 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Twin Delayed Deep Deterministic Policy Gradient (TD3)
2
+
3
+
4
+ ## Overview
5
+
6
+ TD3 is a popular DRL algorithm for continuous control. It extends DDPG with three techniques: 1) Clipped Double Q-Learning, 2) Delayed Policy Updates, and 3) Target Policy Smoothing Regularization. With these three techniques TD3 shows significantly better performance compared to DDPG.
7
+
8
+
9
+ Original paper:
10
+
11
+ * [Addressing Function Approximation Error in Actor-Critic Methods](https://arxiv.org/abs/1802.09477)
12
+
13
+ Reference resources:
14
+
15
+ * :material-github: [sfujim/TD3](https://github.com/sfujim/TD3)
16
+ * [Twin Delayed DDPG | Spinning Up in Deep RL](https://spinningup.openai.com/en/latest/algorithms/td3.html)
17
+
18
+ ## Implemented Variants
19
+
20
+
21
+ | Variants Implemented | Description |
22
+ | ----------- | ----------- |
23
+ | :material-github: [`td3_continuous_action.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/td3_continuous_action.py), :material-file-document: [docs](/rl-algorithms/td3/#td3_continuous_actionpy) | For continuous action space |
24
+ | :material-github: [`td3_continuous_action_jax.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/td3_continuous_action_jax.py), :material-file-document: [docs](/rl-algorithms/td3/#td3_continuous_action_jaxpy) | For continuous action space |
25
+
26
+ Below are our single-file implementations of TD3:
27
+
28
+ ## `td3_continuous_action.py`
29
+
30
+ The [td3_continuous_action.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/td3_continuous_action.py) has the following features:
31
+
32
+ * For continuous action space
33
+ * Works with the `Box` observation space of low-level features
34
+ * Works with the `Box` (continuous) action space
35
+
36
+ ### Usage
37
+
38
+ === "poetry"
39
+
40
+ ```bash
41
+ uv pip install ".[mujoco]"
42
+ uv run python cleanrl/td3_continuous_action.py --help
43
+ uv run python cleanrl/td3_continuous_action.py --env-id Hopper-v4
44
+ ```
45
+
46
+ === "pip"
47
+
48
+ ```bash
49
+ pip install -r requirements/requirements-mujoco.txt
50
+ python cleanrl/td3_continuous_action.py --help
51
+ python cleanrl/td3_continuous_action.py --env-id Hopper-v4
52
+ ```
53
+
54
+ ### Explanation of the logged metrics
55
+
56
+ Running `python cleanrl/td3_continuous_action.py` will automatically record various metrics such as various losses in Tensorboard. Below are the documentation for these metrics:
57
+
58
+ * `charts/episodic_return`: episodic return of the game
59
+ * `charts/SPS`: number of steps per second
60
+ * `losses/qf1_loss`: the MSE between the Q values at timestep $t$ and the target Q values at timestep $t+1$, which minimizes temporal difference.
61
+ * `losses/actor_loss`: implemented as `-qf1(data.observations, actor(data.observations)).mean()`; it is the *negative* average Q values calculated based on the 1) observations and the 2) actions computed by the actor based on these observations. By minimizing `actor_loss`, the optimizer updates the actors parameter using the following gradient (Fujimoto et al., 2018, Algorithm 1)[^2]:
62
+
63
+ $$ \nabla_{\phi} J(\phi)=\left.N^{-1} \sum \nabla_{a} Q_{\theta_{1}}(s, a)\right|_{a=\pi_{\phi}(s)} \nabla_{\phi} \pi_{\phi}(s) $$
64
+
65
+ * `losses/qf1_values`: implemented as `qf1(data.observations, data.actions).view(-1); it is the average Q values of the sampled data in the replay buffer; useful when gauging if under or over estimations happen
66
+
67
+
68
+ ### Implementation details
69
+
70
+ Our [`td3_continuous_action.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/td3_continuous_action.py) is based on the [`TD3.py`](https://github.com/sfujim/TD3/blob/master/TD3.py) from :material-github: [sfujim/TD3](https://github.com/sfujim/TD3). Our [`td3_continuous_action.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/td3_continuous_action.py) presents the following implementation differences.
71
+
72
+ 1. [`td3_continuous_action.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/td3_continuous_action.py) uses a two separate objects `qf1` and `qf2` to represents the two Q functions in the Clipped Double Q-learning architecture, whereas [`TD3.py`](https://github.com/sfujim/TD3/blob/master/TD3.py) (Fujimoto et al., 2018)[^2] uses a single `Critic` class that contains both Q networks. That said, these two implementations are virtually the same.
73
+
74
+ 2. [`td3_continuous_action.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/td3_continuous_action.py) also adds support for handling continuous environments where the lower and higher bounds of the action space are not $[-1,1]$, or are asymmetric.
75
+ The case where the bounds are not $[-1,1]$ is handled in [`TD3.py`](https://github.com/sfujim/TD3/blob/385b33ac7de4767bab17eb02ade4a268d3e4e24f/TD3.py#L28) (Fujimoto et al., 2018)[^2] as follows:
76
+ ```python
77
+ class Actor(nn.Module):
78
+
79
+ ...
80
+
81
+ def forward(self, state):
82
+ a = F.relu(self.l1(state))
83
+ a = F.relu(self.l2(a))
84
+ return self.max_action * torch.tanh(self.l3(a)) # Scale from [-1,1] to [-action_high, action_high]
85
+ ```
86
+ On the other hand, in [`CleanRL's td3_continuous_action.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/td3_continuous_action.py), the mean and the scale of the action space are computed as `action_bias` and `action_scale` respectively.
87
+ Those scalars are in turn used to scale the output of a `tanh` activation function in the actor to the original action space range:
88
+ ```python
89
+ class Actor(nn.Module):
90
+ def __init__(self, env):
91
+ ...
92
+ # action rescaling
93
+ self.register_buffer("action_scale", torch.FloatTensor((env.action_space.high - env.action_space.low) / 2.0))
94
+ self.register_buffer("action_bias", torch.FloatTensor((env.action_space.high + env.action_space.low) / 2.0))
95
+
96
+ def forward(self, x):
97
+ x = F.relu(self.fc1(x))
98
+ x = F.relu(self.fc2(x))
99
+ x = torch.tanh(self.fc_mu(x))
100
+ return x * self.action_scale + self.action_bias # Scale from [-1,1] to [-action_low, action_high]
101
+ ```
102
+
103
+ Additionally, when drawing exploration noise that is added to the actions produced by the actor, [`CleanRL's td3_continuous_action.py`](https://github.com/dosssman/cleanrl/blob/10b606e7bd9bd1b06e455e8ef542df2b7699a20c/cleanrl/td3_continuous_action.py#L180) centers the distribution the sampled from at `action_bias`, and the scale of the distribution is set to `action_scale * exploration_noise`.
104
+
105
+ ???+ info
106
+
107
+ Note that `Humanoid-v2`, `InvertedPendulum-v2`, `Pusher-v2` have action space bounds that are not the standard `[-1, 1]`. See below and :material-github: [PR #196](https://github.com/vwxyzjn/cleanrl/issues/196)
108
+
109
+ ```
110
+ Ant-v2 Observation space: Box(-inf, inf, (111,), float64) Action space: Box(-1.0, 1.0, (8,), float32)
111
+ HalfCheetah-v2 Observation space: Box(-inf, inf, (17,), float64) Action space: Box(-1.0, 1.0, (6,), float32)
112
+ Hopper-v2 Observation space: Box(-inf, inf, (11,), float64) Action space: Box(-1.0, 1.0, (3,), float32)
113
+ Humanoid-v2 Observation space: Box(-inf, inf, (376,), float64) Action space: Box(-0.4, 0.4, (17,), float32)
114
+ InvertedDoublePendulum-v2 Observation space: Box(-inf, inf, (11,), float64) Action space: Box(-1.0, 1.0, (1,), float32)
115
+ InvertedPendulum-v2 Observation space: Box(-inf, inf, (4,), float64) Action space: Box(-3.0, 3.0, (1,), float32)
116
+ Pusher-v2 Observation space: Box(-inf, inf, (23,), float64) Action space: Box(-2.0, 2.0, (7,), float32)
117
+ Reacher-v2 Observation space: Box(-inf, inf, (11,), float64) Action space: Box(-1.0, 1.0, (2,), float32)
118
+ Swimmer-v2 Observation space: Box(-inf, inf, (8,), float64) Action space: Box(-1.0, 1.0, (2,), float32)
119
+ Walker2d-v2 Observation space: Box(-inf, inf, (17,), float64) Action space: Box(-1.0, 1.0, (6,), float32)
120
+ ```
121
+
122
+ ### Experiment results
123
+
124
+ To run benchmark experiments, see :material-github: [benchmark/td3.sh](https://github.com/vwxyzjn/cleanrl/blob/master/benchmark/td3.sh). Specifically, execute the following command:
125
+
126
+ ``` title="benchmark/td3.sh" linenums="1"
127
+ --8<-- "benchmark/td3.sh::7"
128
+ ```
129
+
130
+
131
+ Below are the average episodic returns for [`td3_continuous_action.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/td3_continuous_action.py) (3 random seeds). To ensure the quality of the implementation, we compared the results against (Fujimoto et al., 2018)[^2].
132
+
133
+ | Environment | [`td3_continuous_action.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/td3_continuous_action.py) | [`TD3.py`](https://github.com/sfujim/TD3/blob/master/TD3.py) (Fujimoto et al., 2018, Table 1)[^2] |
134
+ | ----------- | ----------- | ----------- |
135
+ | HalfCheetah-v4 | 9583.22 ± 126.09 |9636.95 ± 859.065 |
136
+ | Walker2d-v4 | 4057.59 ± 658.78 | 4682.82 ± 539.64 |
137
+ | Hopper-v4 | 3134.61 ± 360.18 | 3564.07 ± 114.74 |
138
+ | InvertedPendulum-v4 | 968.99 ± 25.80 | 1000.00 ± 0.00 |
139
+ | Humanoid-v4 | 5035.36 ± 21.67 | not available |
140
+ | Pusher-v4 | -30.92 ± 1.05 | not available |
141
+
142
+
143
+
144
+ ???+ info
145
+
146
+ Note that [`td3_continuous_action.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/td3_continuous_action.py) uses gym MuJoCo v4 environments while [`TD3.py`](https://github.com/sfujim/TD3/blob/master/TD3.py) (Fujimoto et al., 2018)[^2] uses the gym MuJoCo v1 environments.
147
+
148
+ Also note the performance of our `td3_continuous_action.py` seems to be worse than the reference implementation on Walker2d. This is likely due to :material-github: [openai/gym#938](https://github.com/openai/baselines/issues/938). We would have a hard time reproducing gym MuJoCo v1 environments because they have been long deprecated.
149
+
150
+ One other thing could cause the performance difference: the original code reported the average episodic return using determinisitc evaluation (i.e., without exploration noise), see [`sfujim/TD3/main.py#L15-L32`](https://github.com/sfujim/TD3/blob/385b33ac7de4767bab17eb02ade4a268d3e4e24f/main.py#L15-L32), whereas we reported the episodic return during training and the policy gets updated between environments steps.
151
+
152
+ Learning curves:
153
+
154
+ ``` title="benchmark/td3_plot.sh" linenums="1"
155
+ --8<-- "benchmark/td3_plot.sh::9"
156
+ ```
157
+
158
+ <img loading="lazy" src="https://huggingface.co/datasets/cleanrl/benchmark/resolve/main/benchmark/pr-424/td3.png">
159
+ <img loading="lazy" src="https://huggingface.co/datasets/cleanrl/benchmark/resolve/main/benchmark/pr-424/td3-time.png">
160
+
161
+ Tracked experiments and game play videos:
162
+
163
+ <iframe src="https://wandb.ai/openrlbenchmark/openrlbenchmark/reports/MuJoCo-CleanRL-s-TD3--VmlldzoxNjk4Mzk5" style="width:100%; height:500px" title="MuJoCo: CleanRL's TD3"></iframe>
164
+
165
+
166
+
167
+
168
+ ## `td3_continuous_action_jax.py`
169
+
170
+ The [td3_continuous_action_jax.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/td3_continuous_action_jax.py) has the following features:
171
+
172
+ * Uses [Jax](https://github.com/google/jax), [Flax](https://github.com/google/flax), and [Optax](https://github.com/deepmind/optax) instead of `torch`. [td3_continuous_action_jax.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/td3_continuous_action_jax.py) is roughly 2.5-4x faster than [td3_continuous_action.py](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/td3_continuous_action.py)
173
+ * For continuous action space
174
+ * Works with the `Box` observation space of low-level features
175
+ * Works with the `Box` (continuous) action space
176
+
177
+ ### Usage
178
+
179
+ === "poetry"
180
+
181
+ ```bash
182
+ uv pip install ".[mujoco, jax]"
183
+ uv run python cleanrl/td3_continuous_action_jax.py --help
184
+ uv run python cleanrl/td3_continuous_action_jax.py --env-id Hopper-v4
185
+ ```
186
+
187
+ === "pip"
188
+
189
+ ```bash
190
+ pip install -r requirements/requirements-mujoco.txt
191
+ pip install -r requirements/requirements-jax.txt
192
+ python cleanrl/td3_continuous_action_jax.py --help
193
+ python cleanrl/td3_continuous_action_jax.py --env-id Hopper-v4
194
+ ```
195
+
196
+ ### Explanation of the logged metrics
197
+
198
+ See [related docs](/rl-algorithms/td3/#explanation-of-the-logged-metrics) for `td3_continuous_action.py`.
199
+
200
+
201
+ ### Implementation details
202
+
203
+ See [related docs](/rl-algorithms/td3/#implementation-details) for `td3_continuous_action.py`.
204
+
205
+
206
+ ### Experiment results
207
+
208
+ To run benchmark experiments, see :material-github: [benchmark/td3.sh](https://github.com/vwxyzjn/cleanrl/blob/master/benchmark/td3.sh). Specifically, execute the following command:
209
+
210
+ ``` title="benchmark/td3.sh" linenums="1"
211
+ --8<-- "benchmark/td3.sh:12:19"
212
+ ```
213
+
214
+ Below are the average episodic returns for [`td3_continuous_action_jax.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/td3_continuous_action_jax.py) (3 random seeds).
215
+
216
+ {!benchmark/td3.md!}
217
+
218
+ Learning curves:
219
+
220
+
221
+ ``` title="benchmark/td3_plot.sh" linenums="1"
222
+ --8<-- "benchmark/td3_plot.sh:11:20"
223
+ ```
224
+
225
+ <img loading="lazy" src="https://huggingface.co/datasets/cleanrl/benchmark/resolve/main/benchmark/pr-424/td3.png">
226
+ <img loading="lazy" src="https://huggingface.co/datasets/cleanrl/benchmark/resolve/main/benchmark/pr-424/td3-time.png">
227
+
228
+ ???+ info
229
+
230
+ These are some previous experiments with TPUs. Note the results are very similar to the ones above, but the runtime can be different due to different hardware used.
231
+
232
+ Note that the experiments were conducted on different hardwares, so your mileage might vary. This inconsistency is because 1) re-running expeirments on the same hardware is computationally expensive and 2) requiring the same hardware is not inclusive nor feasible to other contributors who might have different hardwares.
233
+
234
+ That said, we roughly expect to see a 2-4x speed improvement from using [`td3_continuous_action_jax.py`](https://github.com/vwxyzjn/cleanrl/blob/master/cleanrl/td3_continuous_action_jax.py) under the same hardware. And if you disable the `--capture_video` overhead, the speed improvement will be even higher.
235
+
236
+ Learning curves:
237
+
238
+
239
+ <div class="grid-container">
240
+ <img loading="lazy" src="../td3-jax/HalfCheetah-v2.png">
241
+ <img loading="lazy" src="../td3-jax/HalfCheetah-v2-time.png">
242
+
243
+ <img loading="lazy" src="../td3-jax/Walker2d-v2.png">
244
+ <img loading="lazy" src="../td3-jax/Walker2d-v2-time.png">
245
+
246
+ <img loading="lazy" src="../td3-jax/Hopper-v2.png">
247
+ <img loading="lazy" src="../td3-jax/Hopper-v2-time.png">
248
+ </div>
249
+
250
+
251
+
252
+ Tracked experiments and game play videos:
253
+
254
+ <iframe src="https://wandb.ai/openrlbenchmark/openrlbenchmark/reports/MuJoCo-CleanRL-s-TD3-JAX--VmlldzoyMzU1OTA4" style="width:100%; height:500px" title="MuJoCo: CleanRL's TD3 + JAX"></iframe>
255
+
256
+
257
+
258
+ [^1]:Lillicrap, T.P., Hunt, J.J., Pritzel, A., Heess, N.M., Erez, T., Tassa, Y., Silver, D., & Wierstra, D. (2016). Continuous control with deep reinforcement learning. CoRR, abs/1509.02971. https://arxiv.org/abs/1509.02971
259
+
260
+ [^2]:Fujimoto, S., Hoof, H.V., & Meger, D. (2018). Addressing Function Approximation Error in Actor-Critic Methods. ArXiv, abs/1802.09477. https://arxiv.org/abs/1802.09477
cleanrl/docs/stylesheets/extra.css ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ .grid-container {
2
+ display: grid;
3
+ grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
4
+ image-rendering: -webkit-optimize-contrast;
5
+ grid-gap: 50px;
6
+ }
cleanrl/envs/__init__.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ """Environment utilities package"""
2
+ from .common import Difficulty
3
+
4
+ __all__ = ["Difficulty"]
cleanrl/envs/common.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Common utilities and enums for environments
3
+ """
4
+ from enum import Enum
5
+
6
+
7
+ class Difficulty(Enum):
8
+ """Difficulty levels for environments"""
9
+ EASY = "easy"
10
+ MEDIUM = "medium"
11
+ HARD = "hard"
cleanrl/requirements/requirements-atari.txt ADDED
@@ -0,0 +1,295 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file was autogenerated by uv via the following command:
2
+ # uv export --no-hashes --output-file requirements/requirements-atari.txt --extra atari
3
+ -e .
4
+ absl-py==1.4.0
5
+ # via tensorboard
6
+ ale-py==0.8.1
7
+ # via cleanrl
8
+ appdirs==1.4.4
9
+ # via wandb
10
+ autorom==0.4.2
11
+ # via cleanrl
12
+ autorom-accept-rom-license==0.6.1
13
+ # via autorom
14
+ cachetools==5.3.0
15
+ # via google-auth
16
+ certifi==2023.5.7
17
+ # via
18
+ # requests
19
+ # sentry-sdk
20
+ cfgv==3.3.1
21
+ # via pre-commit
22
+ charset-normalizer==3.1.0
23
+ # via requests
24
+ click==8.1.3
25
+ # via
26
+ # autorom
27
+ # autorom-accept-rom-license
28
+ # wandb
29
+ cloudpickle==2.2.1
30
+ # via
31
+ # gym
32
+ # gymnasium
33
+ colorama==0.4.4
34
+ # via
35
+ # click
36
+ # rich
37
+ # tqdm
38
+ # tyro
39
+ commonmark==0.9.1
40
+ # via rich
41
+ decorator==4.4.2
42
+ # via moviepy
43
+ distlib==0.3.6
44
+ # via virtualenv
45
+ docker-pycreds==0.4.0
46
+ # via wandb
47
+ docstring-parser==0.15
48
+ # via tyro
49
+ farama-notifications==0.0.4
50
+ # via gymnasium
51
+ filelock==3.12.0
52
+ # via
53
+ # huggingface-hub
54
+ # torch
55
+ # triton
56
+ # virtualenv
57
+ fsspec==2025.3.0 ; python_full_version < '3.9'
58
+ # via torch
59
+ fsspec==2025.5.1 ; python_full_version >= '3.9'
60
+ # via torch
61
+ gitdb==4.0.10
62
+ # via gitpython
63
+ gitpython==3.1.31
64
+ # via wandb
65
+ google-auth==2.18.0
66
+ # via
67
+ # google-auth-oauthlib
68
+ # tensorboard
69
+ google-auth-oauthlib==0.4.6
70
+ # via tensorboard
71
+ grpcio==1.54.0
72
+ # via tensorboard
73
+ gym==0.23.1
74
+ # via cleanrl
75
+ gym-notices==0.0.8
76
+ # via gym
77
+ gymnasium==0.29.1
78
+ # via
79
+ # cleanrl
80
+ # shimmy
81
+ huggingface-hub==0.11.1
82
+ # via cleanrl
83
+ identify==2.5.24
84
+ # via pre-commit
85
+ idna==3.4
86
+ # via requests
87
+ imageio==2.28.1
88
+ # via moviepy
89
+ imageio-ffmpeg==0.3.0
90
+ # via moviepy
91
+ importlib-metadata==5.2.0 ; python_full_version < '3.10'
92
+ # via
93
+ # ale-py
94
+ # gym
95
+ # gymnasium
96
+ # markdown
97
+ importlib-resources==5.12.0
98
+ # via
99
+ # ale-py
100
+ # autorom
101
+ # autorom-accept-rom-license
102
+ jinja2==3.1.2
103
+ # via torch
104
+ markdown==3.3.7
105
+ # via tensorboard
106
+ markupsafe==2.1.2
107
+ # via
108
+ # jinja2
109
+ # werkzeug
110
+ moviepy==1.0.3
111
+ # via cleanrl
112
+ mpmath==1.3.0
113
+ # via sympy
114
+ networkx==3.1 ; python_full_version < '3.9'
115
+ # via torch
116
+ networkx==3.2.1 ; python_full_version == '3.9.*'
117
+ # via torch
118
+ networkx==3.4.2 ; python_full_version >= '3.10'
119
+ # via torch
120
+ nodeenv==1.7.0
121
+ # via pre-commit
122
+ numpy==1.24.4
123
+ # via
124
+ # ale-py
125
+ # gym
126
+ # gymnasium
127
+ # imageio
128
+ # moviepy
129
+ # opencv-python
130
+ # shimmy
131
+ # tensorboard
132
+ nvidia-cublas-cu12==12.1.3.1 ; platform_machine == 'x86_64' and sys_platform == 'linux'
133
+ # via
134
+ # nvidia-cudnn-cu12
135
+ # nvidia-cusolver-cu12
136
+ # torch
137
+ nvidia-cuda-cupti-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
138
+ # via torch
139
+ nvidia-cuda-nvrtc-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
140
+ # via torch
141
+ nvidia-cuda-runtime-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
142
+ # via torch
143
+ nvidia-cudnn-cu12==9.1.0.70 ; platform_machine == 'x86_64' and sys_platform == 'linux'
144
+ # via torch
145
+ nvidia-cufft-cu12==11.0.2.54 ; platform_machine == 'x86_64' and sys_platform == 'linux'
146
+ # via torch
147
+ nvidia-curand-cu12==10.3.2.106 ; platform_machine == 'x86_64' and sys_platform == 'linux'
148
+ # via torch
149
+ nvidia-cusolver-cu12==11.4.5.107 ; platform_machine == 'x86_64' and sys_platform == 'linux'
150
+ # via torch
151
+ nvidia-cusparse-cu12==12.1.0.106 ; platform_machine == 'x86_64' and sys_platform == 'linux'
152
+ # via
153
+ # nvidia-cusolver-cu12
154
+ # torch
155
+ nvidia-nccl-cu12==2.20.5 ; platform_machine == 'x86_64' and sys_platform == 'linux'
156
+ # via torch
157
+ nvidia-nvjitlink-cu12==12.4.127 ; python_full_version < '3.9' and platform_machine == 'x86_64' and sys_platform == 'linux'
158
+ # via
159
+ # nvidia-cusolver-cu12
160
+ # nvidia-cusparse-cu12
161
+ nvidia-nvjitlink-cu12==12.6.85 ; python_full_version >= '3.9' and platform_machine == 'x86_64' and sys_platform == 'linux'
162
+ # via
163
+ # nvidia-cusolver-cu12
164
+ # nvidia-cusparse-cu12
165
+ nvidia-nvtx-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
166
+ # via torch
167
+ oauthlib==3.2.2
168
+ # via requests-oauthlib
169
+ opencv-python==4.7.0.72
170
+ # via cleanrl
171
+ packaging==23.1
172
+ # via huggingface-hub
173
+ pathtools==0.1.2
174
+ # via wandb
175
+ pillow==9.5.0
176
+ # via imageio
177
+ platformdirs==3.5.0
178
+ # via virtualenv
179
+ pre-commit==2.21.0
180
+ proglog==0.1.10
181
+ # via moviepy
182
+ protobuf==3.20.3
183
+ # via
184
+ # tensorboard
185
+ # wandb
186
+ psutil==5.9.5
187
+ # via wandb
188
+ pyasn1==0.5.0
189
+ # via
190
+ # pyasn1-modules
191
+ # rsa
192
+ pyasn1-modules==0.3.0
193
+ # via google-auth
194
+ pygame==2.1.0
195
+ # via cleanrl
196
+ pygments==2.15.1
197
+ # via rich
198
+ pyyaml==6.0.1
199
+ # via
200
+ # huggingface-hub
201
+ # pre-commit
202
+ # wandb
203
+ requests==2.30.0
204
+ # via
205
+ # autorom
206
+ # autorom-accept-rom-license
207
+ # huggingface-hub
208
+ # moviepy
209
+ # requests-oauthlib
210
+ # tensorboard
211
+ # wandb
212
+ requests-oauthlib==1.3.1
213
+ # via google-auth-oauthlib
214
+ rich==11.2.0
215
+ # via
216
+ # cleanrl
217
+ # tyro
218
+ rsa==4.7.2
219
+ # via google-auth
220
+ sentry-sdk==1.22.2
221
+ # via wandb
222
+ setproctitle==1.3.2
223
+ # via wandb
224
+ setuptools==67.7.2
225
+ # via
226
+ # nodeenv
227
+ # tensorboard
228
+ # wandb
229
+ shimmy==1.1.0
230
+ # via cleanrl
231
+ shtab==1.6.4
232
+ # via tyro
233
+ six==1.16.0
234
+ # via
235
+ # docker-pycreds
236
+ # google-auth
237
+ smmap==5.0.0
238
+ # via gitdb
239
+ sympy==1.12.1 ; python_full_version < '3.9'
240
+ # via torch
241
+ sympy==1.14.0 ; python_full_version >= '3.9'
242
+ # via torch
243
+ tenacity==8.2.3
244
+ # via cleanrl
245
+ tensorboard==2.11.2
246
+ # via cleanrl
247
+ tensorboard-data-server==0.6.1
248
+ # via tensorboard
249
+ tensorboard-plugin-wit==1.8.1
250
+ # via tensorboard
251
+ torch==2.4.1
252
+ # via cleanrl
253
+ tqdm==4.65.0
254
+ # via
255
+ # autorom
256
+ # huggingface-hub
257
+ # moviepy
258
+ # proglog
259
+ triton==3.0.0 ; platform_machine == 'x86_64' and sys_platform == 'linux'
260
+ # via torch
261
+ typing-extensions==4.13.2 ; python_full_version < '3.9'
262
+ # via
263
+ # ale-py
264
+ # gymnasium
265
+ # huggingface-hub
266
+ # torch
267
+ # tyro
268
+ # wandb
269
+ typing-extensions==4.14.1 ; python_full_version >= '3.9'
270
+ # via
271
+ # ale-py
272
+ # gymnasium
273
+ # huggingface-hub
274
+ # torch
275
+ # tyro
276
+ # wandb
277
+ tyro==0.5.10
278
+ # via cleanrl
279
+ urllib3==1.26.15
280
+ # via
281
+ # google-auth
282
+ # requests
283
+ # sentry-sdk
284
+ virtualenv==20.21.0
285
+ # via pre-commit
286
+ wandb==0.13.11
287
+ # via cleanrl
288
+ werkzeug==2.2.3
289
+ # via tensorboard
290
+ wheel==0.40.0
291
+ # via tensorboard
292
+ zipp==3.15.0 ; python_full_version < '3.10'
293
+ # via
294
+ # importlib-metadata
295
+ # importlib-resources
cleanrl/requirements/requirements-cloud.txt ADDED
@@ -0,0 +1,291 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file was autogenerated by uv via the following command:
2
+ # uv export --no-hashes --output-file requirements/requirements-cloud.txt --extra cloud
3
+ -e .
4
+ absl-py==1.4.0
5
+ # via tensorboard
6
+ appdirs==1.4.4
7
+ # via wandb
8
+ awscli==1.31.0
9
+ # via cleanrl
10
+ boto3==1.33.0
11
+ # via cleanrl
12
+ botocore==1.33.0
13
+ # via
14
+ # awscli
15
+ # boto3
16
+ # s3transfer
17
+ cachetools==5.3.0
18
+ # via google-auth
19
+ certifi==2023.5.7
20
+ # via
21
+ # requests
22
+ # sentry-sdk
23
+ cfgv==3.3.1
24
+ # via pre-commit
25
+ charset-normalizer==3.1.0
26
+ # via requests
27
+ click==8.1.3
28
+ # via wandb
29
+ cloudpickle==2.2.1
30
+ # via
31
+ # gym
32
+ # gymnasium
33
+ colorama==0.4.4
34
+ # via
35
+ # awscli
36
+ # click
37
+ # rich
38
+ # tqdm
39
+ # tyro
40
+ commonmark==0.9.1
41
+ # via rich
42
+ decorator==4.4.2
43
+ # via moviepy
44
+ distlib==0.3.6
45
+ # via virtualenv
46
+ docker-pycreds==0.4.0
47
+ # via wandb
48
+ docstring-parser==0.15
49
+ # via tyro
50
+ docutils==0.16
51
+ # via awscli
52
+ farama-notifications==0.0.4
53
+ # via gymnasium
54
+ filelock==3.12.0
55
+ # via
56
+ # huggingface-hub
57
+ # torch
58
+ # triton
59
+ # virtualenv
60
+ fsspec==2025.3.0 ; python_full_version < '3.9'
61
+ # via torch
62
+ fsspec==2025.5.1 ; python_full_version >= '3.9'
63
+ # via torch
64
+ gitdb==4.0.10
65
+ # via gitpython
66
+ gitpython==3.1.31
67
+ # via wandb
68
+ google-auth==2.18.0
69
+ # via
70
+ # google-auth-oauthlib
71
+ # tensorboard
72
+ google-auth-oauthlib==0.4.6
73
+ # via tensorboard
74
+ grpcio==1.54.0
75
+ # via tensorboard
76
+ gym==0.23.1
77
+ # via cleanrl
78
+ gym-notices==0.0.8
79
+ # via gym
80
+ gymnasium==0.29.1
81
+ # via cleanrl
82
+ huggingface-hub==0.11.1
83
+ # via cleanrl
84
+ identify==2.5.24
85
+ # via pre-commit
86
+ idna==3.4
87
+ # via requests
88
+ imageio==2.28.1
89
+ # via moviepy
90
+ imageio-ffmpeg==0.3.0
91
+ # via moviepy
92
+ importlib-metadata==5.2.0 ; python_full_version < '3.10'
93
+ # via
94
+ # gym
95
+ # gymnasium
96
+ # markdown
97
+ jinja2==3.1.2
98
+ # via torch
99
+ jmespath==1.0.1
100
+ # via
101
+ # boto3
102
+ # botocore
103
+ markdown==3.3.7
104
+ # via tensorboard
105
+ markupsafe==2.1.2
106
+ # via
107
+ # jinja2
108
+ # werkzeug
109
+ moviepy==1.0.3
110
+ # via cleanrl
111
+ mpmath==1.3.0
112
+ # via sympy
113
+ networkx==3.1 ; python_full_version < '3.9'
114
+ # via torch
115
+ networkx==3.2.1 ; python_full_version == '3.9.*'
116
+ # via torch
117
+ networkx==3.4.2 ; python_full_version >= '3.10'
118
+ # via torch
119
+ nodeenv==1.7.0
120
+ # via pre-commit
121
+ numpy==1.24.4
122
+ # via
123
+ # gym
124
+ # gymnasium
125
+ # imageio
126
+ # moviepy
127
+ # tensorboard
128
+ nvidia-cublas-cu12==12.1.3.1 ; platform_machine == 'x86_64' and sys_platform == 'linux'
129
+ # via
130
+ # nvidia-cudnn-cu12
131
+ # nvidia-cusolver-cu12
132
+ # torch
133
+ nvidia-cuda-cupti-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
134
+ # via torch
135
+ nvidia-cuda-nvrtc-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
136
+ # via torch
137
+ nvidia-cuda-runtime-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
138
+ # via torch
139
+ nvidia-cudnn-cu12==9.1.0.70 ; platform_machine == 'x86_64' and sys_platform == 'linux'
140
+ # via torch
141
+ nvidia-cufft-cu12==11.0.2.54 ; platform_machine == 'x86_64' and sys_platform == 'linux'
142
+ # via torch
143
+ nvidia-curand-cu12==10.3.2.106 ; platform_machine == 'x86_64' and sys_platform == 'linux'
144
+ # via torch
145
+ nvidia-cusolver-cu12==11.4.5.107 ; platform_machine == 'x86_64' and sys_platform == 'linux'
146
+ # via torch
147
+ nvidia-cusparse-cu12==12.1.0.106 ; platform_machine == 'x86_64' and sys_platform == 'linux'
148
+ # via
149
+ # nvidia-cusolver-cu12
150
+ # torch
151
+ nvidia-nccl-cu12==2.20.5 ; platform_machine == 'x86_64' and sys_platform == 'linux'
152
+ # via torch
153
+ nvidia-nvjitlink-cu12==12.4.127 ; python_full_version < '3.9' and platform_machine == 'x86_64' and sys_platform == 'linux'
154
+ # via
155
+ # nvidia-cusolver-cu12
156
+ # nvidia-cusparse-cu12
157
+ nvidia-nvjitlink-cu12==12.6.85 ; python_full_version >= '3.9' and platform_machine == 'x86_64' and sys_platform == 'linux'
158
+ # via
159
+ # nvidia-cusolver-cu12
160
+ # nvidia-cusparse-cu12
161
+ nvidia-nvtx-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
162
+ # via torch
163
+ oauthlib==3.2.2
164
+ # via requests-oauthlib
165
+ packaging==23.1
166
+ # via huggingface-hub
167
+ pathtools==0.1.2
168
+ # via wandb
169
+ pillow==9.5.0
170
+ # via imageio
171
+ platformdirs==3.5.0
172
+ # via virtualenv
173
+ pre-commit==2.21.0
174
+ proglog==0.1.10
175
+ # via moviepy
176
+ protobuf==3.20.3
177
+ # via
178
+ # tensorboard
179
+ # wandb
180
+ psutil==5.9.5
181
+ # via wandb
182
+ pyasn1==0.5.0
183
+ # via
184
+ # pyasn1-modules
185
+ # rsa
186
+ pyasn1-modules==0.3.0
187
+ # via google-auth
188
+ pygame==2.1.0
189
+ # via cleanrl
190
+ pygments==2.15.1
191
+ # via rich
192
+ python-dateutil==2.8.2
193
+ # via botocore
194
+ pyyaml==6.0.1
195
+ # via
196
+ # awscli
197
+ # huggingface-hub
198
+ # pre-commit
199
+ # wandb
200
+ requests==2.30.0
201
+ # via
202
+ # huggingface-hub
203
+ # moviepy
204
+ # requests-oauthlib
205
+ # tensorboard
206
+ # wandb
207
+ requests-oauthlib==1.3.1
208
+ # via google-auth-oauthlib
209
+ rich==11.2.0
210
+ # via
211
+ # cleanrl
212
+ # tyro
213
+ rsa==4.7.2
214
+ # via
215
+ # awscli
216
+ # google-auth
217
+ s3transfer==0.8.0
218
+ # via
219
+ # awscli
220
+ # boto3
221
+ sentry-sdk==1.22.2
222
+ # via wandb
223
+ setproctitle==1.3.2
224
+ # via wandb
225
+ setuptools==67.7.2
226
+ # via
227
+ # nodeenv
228
+ # tensorboard
229
+ # wandb
230
+ shtab==1.6.4
231
+ # via tyro
232
+ six==1.16.0
233
+ # via
234
+ # docker-pycreds
235
+ # google-auth
236
+ # python-dateutil
237
+ smmap==5.0.0
238
+ # via gitdb
239
+ sympy==1.12.1 ; python_full_version < '3.9'
240
+ # via torch
241
+ sympy==1.14.0 ; python_full_version >= '3.9'
242
+ # via torch
243
+ tenacity==8.2.3
244
+ # via cleanrl
245
+ tensorboard==2.11.2
246
+ # via cleanrl
247
+ tensorboard-data-server==0.6.1
248
+ # via tensorboard
249
+ tensorboard-plugin-wit==1.8.1
250
+ # via tensorboard
251
+ torch==2.4.1
252
+ # via cleanrl
253
+ tqdm==4.65.0
254
+ # via
255
+ # huggingface-hub
256
+ # moviepy
257
+ # proglog
258
+ triton==3.0.0 ; platform_machine == 'x86_64' and sys_platform == 'linux'
259
+ # via torch
260
+ typing-extensions==4.13.2 ; python_full_version < '3.9'
261
+ # via
262
+ # gymnasium
263
+ # huggingface-hub
264
+ # torch
265
+ # tyro
266
+ # wandb
267
+ typing-extensions==4.14.1 ; python_full_version >= '3.9'
268
+ # via
269
+ # gymnasium
270
+ # huggingface-hub
271
+ # torch
272
+ # tyro
273
+ # wandb
274
+ tyro==0.5.10
275
+ # via cleanrl
276
+ urllib3==1.26.15
277
+ # via
278
+ # botocore
279
+ # google-auth
280
+ # requests
281
+ # sentry-sdk
282
+ virtualenv==20.21.0
283
+ # via pre-commit
284
+ wandb==0.13.11
285
+ # via cleanrl
286
+ werkzeug==2.2.3
287
+ # via tensorboard
288
+ wheel==0.40.0
289
+ # via tensorboard
290
+ zipp==3.15.0 ; python_full_version < '3.10'
291
+ # via importlib-metadata
cleanrl/requirements/requirements-dm_control.txt ADDED
@@ -0,0 +1,315 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file was autogenerated by uv via the following command:
2
+ # uv export --no-hashes --output-file requirements/requirements-dm_control.txt --extra dm_control
3
+ -e .
4
+ absl-py==1.4.0
5
+ # via
6
+ # dm-control
7
+ # dm-env
8
+ # labmaze
9
+ # mujoco
10
+ # tensorboard
11
+ appdirs==1.4.4
12
+ # via wandb
13
+ cachetools==5.3.0
14
+ # via google-auth
15
+ certifi==2023.5.7
16
+ # via
17
+ # requests
18
+ # sentry-sdk
19
+ cfgv==3.3.1
20
+ # via pre-commit
21
+ charset-normalizer==3.1.0
22
+ # via requests
23
+ click==8.1.3
24
+ # via wandb
25
+ cloudpickle==2.2.1
26
+ # via
27
+ # gym
28
+ # gymnasium
29
+ colorama==0.4.4
30
+ # via
31
+ # click
32
+ # rich
33
+ # tqdm
34
+ # tyro
35
+ commonmark==0.9.1
36
+ # via rich
37
+ decorator==4.4.2
38
+ # via moviepy
39
+ distlib==0.3.6
40
+ # via virtualenv
41
+ dm-control==1.0.11
42
+ # via cleanrl
43
+ dm-env==1.6
44
+ # via dm-control
45
+ dm-tree==0.1.8
46
+ # via
47
+ # dm-control
48
+ # dm-env
49
+ docker-pycreds==0.4.0
50
+ # via wandb
51
+ docstring-parser==0.15
52
+ # via tyro
53
+ farama-notifications==0.0.4
54
+ # via gymnasium
55
+ filelock==3.12.0
56
+ # via
57
+ # huggingface-hub
58
+ # torch
59
+ # triton
60
+ # virtualenv
61
+ fsspec==2025.3.0 ; python_full_version < '3.9'
62
+ # via torch
63
+ fsspec==2025.5.1 ; python_full_version >= '3.9'
64
+ # via torch
65
+ gitdb==4.0.10
66
+ # via gitpython
67
+ gitpython==3.1.31
68
+ # via wandb
69
+ glfw==1.12.0
70
+ # via
71
+ # dm-control
72
+ # mujoco
73
+ google-auth==2.18.0
74
+ # via
75
+ # google-auth-oauthlib
76
+ # tensorboard
77
+ google-auth-oauthlib==0.4.6
78
+ # via tensorboard
79
+ grpcio==1.54.0
80
+ # via tensorboard
81
+ gym==0.23.1
82
+ # via cleanrl
83
+ gym-notices==0.0.8
84
+ # via gym
85
+ gymnasium==0.29.1
86
+ # via
87
+ # cleanrl
88
+ # shimmy
89
+ h5py==3.8.0
90
+ # via cleanrl
91
+ huggingface-hub==0.11.1
92
+ # via cleanrl
93
+ identify==2.5.24
94
+ # via pre-commit
95
+ idna==3.4
96
+ # via requests
97
+ imageio==2.28.1
98
+ # via moviepy
99
+ imageio-ffmpeg==0.3.0
100
+ # via moviepy
101
+ importlib-metadata==5.2.0 ; python_full_version < '3.10'
102
+ # via
103
+ # gym
104
+ # gymnasium
105
+ # markdown
106
+ jinja2==3.1.2
107
+ # via torch
108
+ labmaze==1.0.6
109
+ # via dm-control
110
+ lxml==4.9.3
111
+ # via dm-control
112
+ markdown==3.3.7
113
+ # via tensorboard
114
+ markupsafe==2.1.2
115
+ # via
116
+ # jinja2
117
+ # werkzeug
118
+ moviepy==1.0.3
119
+ # via cleanrl
120
+ mpmath==1.3.0
121
+ # via sympy
122
+ mujoco==2.3.3
123
+ # via
124
+ # cleanrl
125
+ # dm-control
126
+ networkx==3.1 ; python_full_version < '3.9'
127
+ # via torch
128
+ networkx==3.2.1 ; python_full_version == '3.9.*'
129
+ # via torch
130
+ networkx==3.4.2 ; python_full_version >= '3.10'
131
+ # via torch
132
+ nodeenv==1.7.0
133
+ # via pre-commit
134
+ numpy==1.24.4
135
+ # via
136
+ # dm-control
137
+ # dm-env
138
+ # gym
139
+ # gymnasium
140
+ # h5py
141
+ # imageio
142
+ # labmaze
143
+ # moviepy
144
+ # mujoco
145
+ # scipy
146
+ # shimmy
147
+ # tensorboard
148
+ nvidia-cublas-cu12==12.1.3.1 ; platform_machine == 'x86_64' and sys_platform == 'linux'
149
+ # via
150
+ # nvidia-cudnn-cu12
151
+ # nvidia-cusolver-cu12
152
+ # torch
153
+ nvidia-cuda-cupti-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
154
+ # via torch
155
+ nvidia-cuda-nvrtc-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
156
+ # via torch
157
+ nvidia-cuda-runtime-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
158
+ # via torch
159
+ nvidia-cudnn-cu12==9.1.0.70 ; platform_machine == 'x86_64' and sys_platform == 'linux'
160
+ # via torch
161
+ nvidia-cufft-cu12==11.0.2.54 ; platform_machine == 'x86_64' and sys_platform == 'linux'
162
+ # via torch
163
+ nvidia-curand-cu12==10.3.2.106 ; platform_machine == 'x86_64' and sys_platform == 'linux'
164
+ # via torch
165
+ nvidia-cusolver-cu12==11.4.5.107 ; platform_machine == 'x86_64' and sys_platform == 'linux'
166
+ # via torch
167
+ nvidia-cusparse-cu12==12.1.0.106 ; platform_machine == 'x86_64' and sys_platform == 'linux'
168
+ # via
169
+ # nvidia-cusolver-cu12
170
+ # torch
171
+ nvidia-nccl-cu12==2.20.5 ; platform_machine == 'x86_64' and sys_platform == 'linux'
172
+ # via torch
173
+ nvidia-nvjitlink-cu12==12.4.127 ; python_full_version < '3.9' and platform_machine == 'x86_64' and sys_platform == 'linux'
174
+ # via
175
+ # nvidia-cusolver-cu12
176
+ # nvidia-cusparse-cu12
177
+ nvidia-nvjitlink-cu12==12.6.85 ; python_full_version >= '3.9' and platform_machine == 'x86_64' and sys_platform == 'linux'
178
+ # via
179
+ # nvidia-cusolver-cu12
180
+ # nvidia-cusparse-cu12
181
+ nvidia-nvtx-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
182
+ # via torch
183
+ oauthlib==3.2.2
184
+ # via requests-oauthlib
185
+ packaging==23.1
186
+ # via huggingface-hub
187
+ pathtools==0.1.2
188
+ # via wandb
189
+ pillow==9.5.0
190
+ # via imageio
191
+ platformdirs==3.5.0
192
+ # via virtualenv
193
+ pre-commit==2.21.0
194
+ proglog==0.1.10
195
+ # via moviepy
196
+ protobuf==3.20.3
197
+ # via
198
+ # dm-control
199
+ # tensorboard
200
+ # wandb
201
+ psutil==5.9.5
202
+ # via wandb
203
+ pyasn1==0.5.0
204
+ # via
205
+ # pyasn1-modules
206
+ # rsa
207
+ pyasn1-modules==0.3.0
208
+ # via google-auth
209
+ pygame==2.1.0
210
+ # via cleanrl
211
+ pygments==2.15.1
212
+ # via rich
213
+ pyopengl==3.1.6
214
+ # via
215
+ # dm-control
216
+ # mujoco
217
+ pyparsing==3.0.9
218
+ # via dm-control
219
+ pyyaml==6.0.1
220
+ # via
221
+ # huggingface-hub
222
+ # pre-commit
223
+ # wandb
224
+ requests==2.30.0
225
+ # via
226
+ # dm-control
227
+ # huggingface-hub
228
+ # moviepy
229
+ # requests-oauthlib
230
+ # tensorboard
231
+ # wandb
232
+ requests-oauthlib==1.3.1
233
+ # via google-auth-oauthlib
234
+ rich==11.2.0
235
+ # via
236
+ # cleanrl
237
+ # tyro
238
+ rsa==4.7.2
239
+ # via google-auth
240
+ scipy==1.10.1
241
+ # via dm-control
242
+ sentry-sdk==1.22.2
243
+ # via wandb
244
+ setproctitle==1.3.2
245
+ # via wandb
246
+ setuptools==67.7.2
247
+ # via
248
+ # dm-control
249
+ # labmaze
250
+ # nodeenv
251
+ # tensorboard
252
+ # wandb
253
+ shimmy==1.1.0
254
+ # via cleanrl
255
+ shtab==1.6.4
256
+ # via tyro
257
+ six==1.16.0
258
+ # via
259
+ # docker-pycreds
260
+ # google-auth
261
+ smmap==5.0.0
262
+ # via gitdb
263
+ sympy==1.12.1 ; python_full_version < '3.9'
264
+ # via torch
265
+ sympy==1.14.0 ; python_full_version >= '3.9'
266
+ # via torch
267
+ tenacity==8.2.3
268
+ # via cleanrl
269
+ tensorboard==2.11.2
270
+ # via cleanrl
271
+ tensorboard-data-server==0.6.1
272
+ # via tensorboard
273
+ tensorboard-plugin-wit==1.8.1
274
+ # via tensorboard
275
+ torch==2.4.1
276
+ # via cleanrl
277
+ tqdm==4.65.0
278
+ # via
279
+ # dm-control
280
+ # huggingface-hub
281
+ # moviepy
282
+ # proglog
283
+ triton==3.0.0 ; platform_machine == 'x86_64' and sys_platform == 'linux'
284
+ # via torch
285
+ typing-extensions==4.13.2 ; python_full_version < '3.9'
286
+ # via
287
+ # gymnasium
288
+ # huggingface-hub
289
+ # torch
290
+ # tyro
291
+ # wandb
292
+ typing-extensions==4.14.1 ; python_full_version >= '3.9'
293
+ # via
294
+ # gymnasium
295
+ # huggingface-hub
296
+ # torch
297
+ # tyro
298
+ # wandb
299
+ tyro==0.5.10
300
+ # via cleanrl
301
+ urllib3==1.26.15
302
+ # via
303
+ # google-auth
304
+ # requests
305
+ # sentry-sdk
306
+ virtualenv==20.21.0
307
+ # via pre-commit
308
+ wandb==0.13.11
309
+ # via cleanrl
310
+ werkzeug==2.2.3
311
+ # via tensorboard
312
+ wheel==0.40.0
313
+ # via tensorboard
314
+ zipp==3.15.0 ; python_full_version < '3.10'
315
+ # via importlib-metadata
cleanrl/requirements/requirements-docs.txt ADDED
@@ -0,0 +1,365 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file was autogenerated by uv via the following command:
2
+ # uv export --no-hashes --output-file requirements/requirements-docs.txt --extra docs
3
+ -e .
4
+ absl-py==1.4.0
5
+ # via tensorboard
6
+ appdirs==1.4.4
7
+ # via wandb
8
+ cachetools==5.3.0
9
+ # via google-auth
10
+ certifi==2023.5.7
11
+ # via
12
+ # requests
13
+ # sentry-sdk
14
+ cfgv==3.3.1
15
+ # via pre-commit
16
+ charset-normalizer==3.1.0
17
+ # via requests
18
+ click==8.1.3
19
+ # via
20
+ # mkdocs
21
+ # wandb
22
+ cloudpickle==2.2.1
23
+ # via
24
+ # gym
25
+ # gymnasium
26
+ colorama==0.4.4
27
+ # via
28
+ # click
29
+ # mkdocs
30
+ # rich
31
+ # tqdm
32
+ # tyro
33
+ commonmark==0.9.1
34
+ # via rich
35
+ cycler==0.11.0
36
+ # via matplotlib
37
+ dataclasses==0.6
38
+ # via expt
39
+ decorator==4.4.2
40
+ # via moviepy
41
+ dill==0.3.6
42
+ # via multiprocess
43
+ distlib==0.3.6
44
+ # via virtualenv
45
+ docker-pycreds==0.4.0
46
+ # via wandb
47
+ docstring-parser==0.15
48
+ # via tyro
49
+ expt==0.4.1
50
+ # via openrlbenchmark
51
+ farama-notifications==0.0.4
52
+ # via gymnasium
53
+ filelock==3.12.0
54
+ # via
55
+ # huggingface-hub
56
+ # torch
57
+ # triton
58
+ # virtualenv
59
+ fonttools==4.38.0
60
+ # via matplotlib
61
+ fsspec==2025.3.0 ; python_full_version < '3.9'
62
+ # via torch
63
+ fsspec==2025.5.1 ; python_full_version >= '3.9'
64
+ # via torch
65
+ ghp-import==2.1.0
66
+ # via mkdocs
67
+ gitdb==4.0.10
68
+ # via gitpython
69
+ gitpython==3.1.31
70
+ # via wandb
71
+ google-auth==2.18.0
72
+ # via
73
+ # google-auth-oauthlib
74
+ # tensorboard
75
+ google-auth-oauthlib==0.4.6
76
+ # via tensorboard
77
+ grpcio==1.54.0
78
+ # via tensorboard
79
+ gym==0.23.1
80
+ # via cleanrl
81
+ gym-notices==0.0.8
82
+ # via gym
83
+ gymnasium==0.29.1
84
+ # via cleanrl
85
+ huggingface-hub==0.11.1
86
+ # via cleanrl
87
+ identify==2.5.24
88
+ # via pre-commit
89
+ idna==3.4
90
+ # via requests
91
+ imageio==2.28.1
92
+ # via moviepy
93
+ imageio-ffmpeg==0.3.0
94
+ # via moviepy
95
+ importlib-metadata==5.2.0
96
+ # via
97
+ # gym
98
+ # gymnasium
99
+ # markdown
100
+ # mkdocs
101
+ # openrlbenchmark
102
+ jinja2==3.1.2
103
+ # via
104
+ # mkdocs
105
+ # mkdocs-material
106
+ # torch
107
+ kiwisolver==1.4.4
108
+ # via matplotlib
109
+ markdown==3.3.7
110
+ # via
111
+ # markdown-include
112
+ # mkdocs
113
+ # mkdocs-material
114
+ # pymdown-extensions
115
+ # tensorboard
116
+ markdown-include==0.7.2
117
+ # via cleanrl
118
+ markupsafe==2.1.2
119
+ # via
120
+ # jinja2
121
+ # werkzeug
122
+ matplotlib==3.5.3
123
+ # via
124
+ # expt
125
+ # seaborn
126
+ # tueplots
127
+ mergedeep==1.3.4
128
+ # via mkdocs
129
+ mkdocs==1.4.3
130
+ # via mkdocs-material
131
+ mkdocs-material==8.5.11
132
+ # via cleanrl
133
+ mkdocs-material-extensions==1.1.1
134
+ # via mkdocs-material
135
+ moviepy==1.0.3
136
+ # via cleanrl
137
+ mpmath==1.3.0
138
+ # via sympy
139
+ multiprocess==0.70.14
140
+ # via
141
+ # expt
142
+ # openrlbenchmark
143
+ networkx==3.1 ; python_full_version < '3.9'
144
+ # via torch
145
+ networkx==3.2.1 ; python_full_version == '3.9.*'
146
+ # via torch
147
+ networkx==3.4.2 ; python_full_version >= '3.10'
148
+ # via torch
149
+ nodeenv==1.7.0
150
+ # via pre-commit
151
+ numpy==1.24.4
152
+ # via
153
+ # expt
154
+ # gym
155
+ # gymnasium
156
+ # imageio
157
+ # matplotlib
158
+ # moviepy
159
+ # pandas
160
+ # scipy
161
+ # seaborn
162
+ # tensorboard
163
+ # tueplots
164
+ nvidia-cublas-cu12==12.1.3.1 ; platform_machine == 'x86_64' and sys_platform == 'linux'
165
+ # via
166
+ # nvidia-cudnn-cu12
167
+ # nvidia-cusolver-cu12
168
+ # torch
169
+ nvidia-cuda-cupti-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
170
+ # via torch
171
+ nvidia-cuda-nvrtc-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
172
+ # via torch
173
+ nvidia-cuda-runtime-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
174
+ # via torch
175
+ nvidia-cudnn-cu12==9.1.0.70 ; platform_machine == 'x86_64' and sys_platform == 'linux'
176
+ # via torch
177
+ nvidia-cufft-cu12==11.0.2.54 ; platform_machine == 'x86_64' and sys_platform == 'linux'
178
+ # via torch
179
+ nvidia-curand-cu12==10.3.2.106 ; platform_machine == 'x86_64' and sys_platform == 'linux'
180
+ # via torch
181
+ nvidia-cusolver-cu12==11.4.5.107 ; platform_machine == 'x86_64' and sys_platform == 'linux'
182
+ # via torch
183
+ nvidia-cusparse-cu12==12.1.0.106 ; platform_machine == 'x86_64' and sys_platform == 'linux'
184
+ # via
185
+ # nvidia-cusolver-cu12
186
+ # torch
187
+ nvidia-nccl-cu12==2.20.5 ; platform_machine == 'x86_64' and sys_platform == 'linux'
188
+ # via torch
189
+ nvidia-nvjitlink-cu12==12.4.127 ; python_full_version < '3.9' and platform_machine == 'x86_64' and sys_platform == 'linux'
190
+ # via
191
+ # nvidia-cusolver-cu12
192
+ # nvidia-cusparse-cu12
193
+ nvidia-nvjitlink-cu12==12.6.85 ; python_full_version >= '3.9' and platform_machine == 'x86_64' and sys_platform == 'linux'
194
+ # via
195
+ # nvidia-cusolver-cu12
196
+ # nvidia-cusparse-cu12
197
+ nvidia-nvtx-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
198
+ # via torch
199
+ oauthlib==3.2.2
200
+ # via requests-oauthlib
201
+ openrlbenchmark==0.1.1b4
202
+ # via cleanrl
203
+ packaging==23.1
204
+ # via
205
+ # huggingface-hub
206
+ # matplotlib
207
+ # mkdocs
208
+ pandas==1.3.5
209
+ # via
210
+ # expt
211
+ # seaborn
212
+ pathtools==0.1.2
213
+ # via wandb
214
+ pillow==9.5.0
215
+ # via
216
+ # imageio
217
+ # matplotlib
218
+ pip==22.3.1
219
+ # via openrlbenchmark
220
+ platformdirs==3.5.0
221
+ # via virtualenv
222
+ pre-commit==2.21.0
223
+ proglog==0.1.10
224
+ # via moviepy
225
+ protobuf==3.20.3
226
+ # via
227
+ # tensorboard
228
+ # wandb
229
+ psutil==5.9.5
230
+ # via wandb
231
+ pyasn1==0.5.0
232
+ # via
233
+ # pyasn1-modules
234
+ # rsa
235
+ pyasn1-modules==0.3.0
236
+ # via google-auth
237
+ pygame==2.1.0
238
+ # via cleanrl
239
+ pygments==2.15.1
240
+ # via
241
+ # mkdocs-material
242
+ # rich
243
+ pymdown-extensions==9.11
244
+ # via mkdocs-material
245
+ pyparsing==3.0.9
246
+ # via matplotlib
247
+ python-dateutil==2.8.2
248
+ # via
249
+ # ghp-import
250
+ # matplotlib
251
+ # pandas
252
+ pytz==2023.3
253
+ # via pandas
254
+ pyyaml==6.0.1
255
+ # via
256
+ # huggingface-hub
257
+ # mkdocs
258
+ # pre-commit
259
+ # pymdown-extensions
260
+ # pyyaml-env-tag
261
+ # wandb
262
+ pyyaml-env-tag==0.1
263
+ # via mkdocs
264
+ requests==2.30.0
265
+ # via
266
+ # huggingface-hub
267
+ # mkdocs-material
268
+ # moviepy
269
+ # requests-oauthlib
270
+ # tensorboard
271
+ # wandb
272
+ requests-oauthlib==1.3.1
273
+ # via google-auth-oauthlib
274
+ rich==11.2.0
275
+ # via
276
+ # cleanrl
277
+ # openrlbenchmark
278
+ # tyro
279
+ rsa==4.7.2
280
+ # via google-auth
281
+ scipy==1.10.1
282
+ # via expt
283
+ seaborn==0.12.2
284
+ # via openrlbenchmark
285
+ sentry-sdk==1.22.2
286
+ # via wandb
287
+ setproctitle==1.3.2
288
+ # via wandb
289
+ setuptools==67.7.2
290
+ # via
291
+ # nodeenv
292
+ # tensorboard
293
+ # wandb
294
+ shtab==1.6.4
295
+ # via tyro
296
+ six==1.16.0
297
+ # via
298
+ # docker-pycreds
299
+ # google-auth
300
+ # python-dateutil
301
+ smmap==5.0.0
302
+ # via gitdb
303
+ sympy==1.12.1 ; python_full_version < '3.9'
304
+ # via torch
305
+ sympy==1.14.0 ; python_full_version >= '3.9'
306
+ # via torch
307
+ tabulate==0.9.0
308
+ # via openrlbenchmark
309
+ tenacity==8.2.3
310
+ # via cleanrl
311
+ tensorboard==2.11.2
312
+ # via cleanrl
313
+ tensorboard-data-server==0.6.1
314
+ # via tensorboard
315
+ tensorboard-plugin-wit==1.8.1
316
+ # via tensorboard
317
+ torch==2.4.1
318
+ # via cleanrl
319
+ tqdm==4.65.0
320
+ # via
321
+ # huggingface-hub
322
+ # moviepy
323
+ # openrlbenchmark
324
+ # proglog
325
+ triton==3.0.0 ; platform_machine == 'x86_64' and sys_platform == 'linux'
326
+ # via torch
327
+ tueplots==0.0.4
328
+ # via openrlbenchmark
329
+ typeguard==2.13.3
330
+ # via expt
331
+ typing-extensions==4.13.2 ; python_full_version < '3.9'
332
+ # via
333
+ # gymnasium
334
+ # huggingface-hub
335
+ # torch
336
+ # tyro
337
+ # wandb
338
+ typing-extensions==4.14.1 ; python_full_version >= '3.9'
339
+ # via
340
+ # gymnasium
341
+ # huggingface-hub
342
+ # torch
343
+ # tyro
344
+ # wandb
345
+ tyro==0.5.10
346
+ # via cleanrl
347
+ urllib3==1.26.15
348
+ # via
349
+ # google-auth
350
+ # requests
351
+ # sentry-sdk
352
+ virtualenv==20.21.0
353
+ # via pre-commit
354
+ wandb==0.13.11
355
+ # via
356
+ # cleanrl
357
+ # openrlbenchmark
358
+ watchdog==3.0.0
359
+ # via mkdocs
360
+ werkzeug==2.2.3
361
+ # via tensorboard
362
+ wheel==0.40.0
363
+ # via tensorboard
364
+ zipp==3.15.0
365
+ # via importlib-metadata
cleanrl/requirements/requirements-envpool.txt ADDED
@@ -0,0 +1,309 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file was autogenerated by uv via the following command:
2
+ # uv export --no-hashes --output-file requirements/requirements-envpool.txt --extra envpool
3
+ -e .
4
+ absl-py==1.4.0
5
+ # via
6
+ # dm-env
7
+ # tensorboard
8
+ appdirs==1.4.4
9
+ # via wandb
10
+ bitmath==1.3.3.1
11
+ # via hbutils
12
+ cachetools==5.3.0
13
+ # via google-auth
14
+ certifi==2023.5.7
15
+ # via
16
+ # requests
17
+ # sentry-sdk
18
+ cfgv==3.3.1
19
+ # via pre-commit
20
+ chardet==4.0.0
21
+ # via hbutils
22
+ charset-normalizer==3.1.0
23
+ # via requests
24
+ click==8.1.3
25
+ # via
26
+ # treevalue
27
+ # wandb
28
+ cloudpickle==2.2.1
29
+ # via
30
+ # gym
31
+ # gymnasium
32
+ colorama==0.4.4
33
+ # via
34
+ # click
35
+ # rich
36
+ # tqdm
37
+ # tyro
38
+ commonmark==0.9.1
39
+ # via rich
40
+ decorator==4.4.2
41
+ # via moviepy
42
+ dill==0.3.6
43
+ # via treevalue
44
+ distlib==0.3.6
45
+ # via virtualenv
46
+ dm-env==1.6
47
+ # via envpool
48
+ dm-tree==0.1.8
49
+ # via dm-env
50
+ docker-pycreds==0.4.0
51
+ # via wandb
52
+ docstring-parser==0.15
53
+ # via tyro
54
+ enum-tools==0.9.0.post1
55
+ # via treevalue
56
+ envpool==0.6.6
57
+ # via cleanrl
58
+ farama-notifications==0.0.4
59
+ # via gymnasium
60
+ filelock==3.12.0
61
+ # via
62
+ # huggingface-hub
63
+ # torch
64
+ # triton
65
+ # virtualenv
66
+ fsspec==2025.3.0 ; python_full_version < '3.9'
67
+ # via torch
68
+ fsspec==2025.5.1 ; python_full_version >= '3.9'
69
+ # via torch
70
+ gitdb==4.0.10
71
+ # via gitpython
72
+ gitpython==3.1.31
73
+ # via wandb
74
+ google-auth==2.18.0
75
+ # via
76
+ # google-auth-oauthlib
77
+ # tensorboard
78
+ google-auth-oauthlib==0.4.6
79
+ # via tensorboard
80
+ graphviz==0.20.1
81
+ # via treevalue
82
+ grpcio==1.54.0
83
+ # via tensorboard
84
+ gym==0.23.1
85
+ # via
86
+ # cleanrl
87
+ # envpool
88
+ gym-notices==0.0.8
89
+ # via gym
90
+ gymnasium==0.29.1
91
+ # via cleanrl
92
+ hbutils==0.8.6
93
+ # via treevalue
94
+ huggingface-hub==0.11.1
95
+ # via cleanrl
96
+ identify==2.5.24
97
+ # via pre-commit
98
+ idna==3.4
99
+ # via requests
100
+ imageio==2.28.1
101
+ # via moviepy
102
+ imageio-ffmpeg==0.3.0
103
+ # via moviepy
104
+ importlib-metadata==5.2.0 ; python_full_version < '3.10'
105
+ # via
106
+ # gym
107
+ # gymnasium
108
+ # markdown
109
+ jinja2==3.1.2
110
+ # via torch
111
+ markdown==3.3.7
112
+ # via tensorboard
113
+ markupsafe==2.1.2
114
+ # via
115
+ # jinja2
116
+ # werkzeug
117
+ moviepy==1.0.3
118
+ # via cleanrl
119
+ mpmath==1.3.0
120
+ # via sympy
121
+ networkx==3.1 ; python_full_version < '3.9'
122
+ # via torch
123
+ networkx==3.2.1 ; python_full_version == '3.9.*'
124
+ # via torch
125
+ networkx==3.4.2 ; python_full_version >= '3.10'
126
+ # via torch
127
+ nodeenv==1.7.0
128
+ # via pre-commit
129
+ numpy==1.24.4
130
+ # via
131
+ # dm-env
132
+ # envpool
133
+ # gym
134
+ # gymnasium
135
+ # imageio
136
+ # moviepy
137
+ # opencv-python
138
+ # tensorboard
139
+ nvidia-cublas-cu12==12.1.3.1 ; platform_machine == 'x86_64' and sys_platform == 'linux'
140
+ # via
141
+ # nvidia-cudnn-cu12
142
+ # nvidia-cusolver-cu12
143
+ # torch
144
+ nvidia-cuda-cupti-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
145
+ # via torch
146
+ nvidia-cuda-nvrtc-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
147
+ # via torch
148
+ nvidia-cuda-runtime-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
149
+ # via torch
150
+ nvidia-cudnn-cu12==9.1.0.70 ; platform_machine == 'x86_64' and sys_platform == 'linux'
151
+ # via torch
152
+ nvidia-cufft-cu12==11.0.2.54 ; platform_machine == 'x86_64' and sys_platform == 'linux'
153
+ # via torch
154
+ nvidia-curand-cu12==10.3.2.106 ; platform_machine == 'x86_64' and sys_platform == 'linux'
155
+ # via torch
156
+ nvidia-cusolver-cu12==11.4.5.107 ; platform_machine == 'x86_64' and sys_platform == 'linux'
157
+ # via torch
158
+ nvidia-cusparse-cu12==12.1.0.106 ; platform_machine == 'x86_64' and sys_platform == 'linux'
159
+ # via
160
+ # nvidia-cusolver-cu12
161
+ # torch
162
+ nvidia-nccl-cu12==2.20.5 ; platform_machine == 'x86_64' and sys_platform == 'linux'
163
+ # via torch
164
+ nvidia-nvjitlink-cu12==12.4.127 ; python_full_version < '3.9' and platform_machine == 'x86_64' and sys_platform == 'linux'
165
+ # via
166
+ # nvidia-cusolver-cu12
167
+ # nvidia-cusparse-cu12
168
+ nvidia-nvjitlink-cu12==12.6.85 ; python_full_version >= '3.9' and platform_machine == 'x86_64' and sys_platform == 'linux'
169
+ # via
170
+ # nvidia-cusolver-cu12
171
+ # nvidia-cusparse-cu12
172
+ nvidia-nvtx-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
173
+ # via torch
174
+ oauthlib==3.2.2
175
+ # via requests-oauthlib
176
+ opencv-python==4.7.0.72
177
+ # via cleanrl
178
+ packaging==23.1
179
+ # via
180
+ # envpool
181
+ # hbutils
182
+ # huggingface-hub
183
+ pathtools==0.1.2
184
+ # via wandb
185
+ pillow==9.5.0
186
+ # via imageio
187
+ platformdirs==3.5.0
188
+ # via virtualenv
189
+ pre-commit==2.21.0
190
+ proglog==0.1.10
191
+ # via moviepy
192
+ protobuf==3.20.3
193
+ # via
194
+ # tensorboard
195
+ # wandb
196
+ psutil==5.9.5
197
+ # via wandb
198
+ pyasn1==0.5.0
199
+ # via
200
+ # pyasn1-modules
201
+ # rsa
202
+ pyasn1-modules==0.3.0
203
+ # via google-auth
204
+ pygame==2.1.0
205
+ # via cleanrl
206
+ pygments==2.15.1
207
+ # via
208
+ # enum-tools
209
+ # rich
210
+ pytimeparse==1.1.8
211
+ # via hbutils
212
+ pyyaml==6.0.1
213
+ # via
214
+ # huggingface-hub
215
+ # pre-commit
216
+ # wandb
217
+ requests==2.30.0
218
+ # via
219
+ # huggingface-hub
220
+ # moviepy
221
+ # requests-oauthlib
222
+ # tensorboard
223
+ # wandb
224
+ requests-oauthlib==1.3.1
225
+ # via google-auth-oauthlib
226
+ rich==11.2.0
227
+ # via
228
+ # cleanrl
229
+ # tyro
230
+ rsa==4.7.2
231
+ # via google-auth
232
+ sentry-sdk==1.22.2
233
+ # via wandb
234
+ setproctitle==1.3.2
235
+ # via wandb
236
+ setuptools==67.7.2
237
+ # via
238
+ # hbutils
239
+ # nodeenv
240
+ # tensorboard
241
+ # wandb
242
+ shtab==1.6.4
243
+ # via tyro
244
+ six==1.16.0
245
+ # via
246
+ # docker-pycreds
247
+ # google-auth
248
+ smmap==5.0.0
249
+ # via gitdb
250
+ sympy==1.12.1 ; python_full_version < '3.9'
251
+ # via torch
252
+ sympy==1.14.0 ; python_full_version >= '3.9'
253
+ # via torch
254
+ tenacity==8.2.3
255
+ # via cleanrl
256
+ tensorboard==2.11.2
257
+ # via cleanrl
258
+ tensorboard-data-server==0.6.1
259
+ # via tensorboard
260
+ tensorboard-plugin-wit==1.8.1
261
+ # via tensorboard
262
+ torch==2.4.1
263
+ # via cleanrl
264
+ tqdm==4.65.0
265
+ # via
266
+ # huggingface-hub
267
+ # moviepy
268
+ # proglog
269
+ treevalue==1.4.10
270
+ # via envpool
271
+ triton==3.0.0 ; platform_machine == 'x86_64' and sys_platform == 'linux'
272
+ # via torch
273
+ types-protobuf==4.23.0.1
274
+ # via envpool
275
+ typing-extensions==4.13.2 ; python_full_version < '3.9'
276
+ # via
277
+ # enum-tools
278
+ # envpool
279
+ # gymnasium
280
+ # huggingface-hub
281
+ # torch
282
+ # tyro
283
+ # wandb
284
+ typing-extensions==4.14.1 ; python_full_version >= '3.9'
285
+ # via
286
+ # enum-tools
287
+ # envpool
288
+ # gymnasium
289
+ # huggingface-hub
290
+ # torch
291
+ # tyro
292
+ # wandb
293
+ tyro==0.5.10
294
+ # via cleanrl
295
+ urllib3==1.26.15
296
+ # via
297
+ # google-auth
298
+ # requests
299
+ # sentry-sdk
300
+ virtualenv==20.21.0
301
+ # via pre-commit
302
+ wandb==0.13.11
303
+ # via cleanrl
304
+ werkzeug==2.2.3
305
+ # via tensorboard
306
+ wheel==0.40.0
307
+ # via tensorboard
308
+ zipp==3.15.0 ; python_full_version < '3.10'
309
+ # via importlib-metadata
cleanrl/requirements/requirements-jax.txt ADDED
@@ -0,0 +1,358 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file was autogenerated by uv via the following command:
2
+ # uv export --no-hashes --output-file requirements/requirements-jax.txt --extra jax
3
+ -e .
4
+ absl-py==1.4.0
5
+ # via
6
+ # chex
7
+ # optax
8
+ # orbax
9
+ # tensorboard
10
+ appdirs==1.4.4
11
+ # via wandb
12
+ cached-property==1.5.2
13
+ # via orbax
14
+ cachetools==5.3.0
15
+ # via google-auth
16
+ certifi==2023.5.7
17
+ # via
18
+ # requests
19
+ # sentry-sdk
20
+ cfgv==3.3.1
21
+ # via pre-commit
22
+ charset-normalizer==3.1.0
23
+ # via requests
24
+ chex==0.1.5
25
+ # via
26
+ # cleanrl
27
+ # optax
28
+ click==8.1.3
29
+ # via wandb
30
+ cloudpickle==2.2.1
31
+ # via
32
+ # gym
33
+ # gymnasium
34
+ colorama==0.4.4
35
+ # via
36
+ # click
37
+ # pytest
38
+ # rich
39
+ # tqdm
40
+ # tyro
41
+ commonmark==0.9.1
42
+ # via rich
43
+ decorator==4.4.2
44
+ # via moviepy
45
+ distlib==0.3.6
46
+ # via virtualenv
47
+ dm-tree==0.1.8
48
+ # via chex
49
+ docker-pycreds==0.4.0
50
+ # via wandb
51
+ docstring-parser==0.15
52
+ # via tyro
53
+ etils==0.9.0
54
+ # via orbax
55
+ exceptiongroup==1.1.1
56
+ # via pytest
57
+ farama-notifications==0.0.4
58
+ # via gymnasium
59
+ filelock==3.12.0
60
+ # via
61
+ # huggingface-hub
62
+ # torch
63
+ # triton
64
+ # virtualenv
65
+ flax==0.6.8
66
+ # via
67
+ # cleanrl
68
+ # orbax
69
+ fsspec==2025.3.0 ; python_full_version < '3.9'
70
+ # via torch
71
+ fsspec==2025.5.1 ; python_full_version >= '3.9'
72
+ # via torch
73
+ gitdb==4.0.10
74
+ # via gitpython
75
+ gitpython==3.1.31
76
+ # via wandb
77
+ google-auth==2.18.0
78
+ # via
79
+ # google-auth-oauthlib
80
+ # tensorboard
81
+ google-auth-oauthlib==0.4.6
82
+ # via tensorboard
83
+ grpcio==1.54.0
84
+ # via tensorboard
85
+ gym==0.23.1
86
+ # via cleanrl
87
+ gym-notices==0.0.8
88
+ # via gym
89
+ gymnasium==0.29.1
90
+ # via cleanrl
91
+ huggingface-hub==0.11.1
92
+ # via cleanrl
93
+ identify==2.5.24
94
+ # via pre-commit
95
+ idna==3.4
96
+ # via requests
97
+ imageio==2.28.1
98
+ # via moviepy
99
+ imageio-ffmpeg==0.3.0
100
+ # via moviepy
101
+ importlib-metadata==5.2.0 ; python_full_version < '3.10'
102
+ # via
103
+ # gym
104
+ # gymnasium
105
+ # markdown
106
+ importlib-resources==5.12.0
107
+ # via orbax
108
+ iniconfig==2.0.0
109
+ # via pytest
110
+ jax==0.4.8
111
+ # via
112
+ # chex
113
+ # cleanrl
114
+ # flax
115
+ # optax
116
+ # orbax
117
+ jaxlib==0.4.7
118
+ # via
119
+ # chex
120
+ # cleanrl
121
+ # optax
122
+ # orbax
123
+ jinja2==3.1.2
124
+ # via torch
125
+ markdown==3.3.7
126
+ # via tensorboard
127
+ markupsafe==2.1.2
128
+ # via
129
+ # jinja2
130
+ # werkzeug
131
+ ml-dtypes==0.2.0 ; python_full_version < '3.10'
132
+ # via
133
+ # jax
134
+ # jaxlib
135
+ ml-dtypes==0.5.1 ; python_full_version >= '3.10'
136
+ # via
137
+ # jax
138
+ # jaxlib
139
+ moviepy==1.0.3
140
+ # via cleanrl
141
+ mpmath==1.3.0
142
+ # via sympy
143
+ msgpack==1.0.5
144
+ # via flax
145
+ networkx==3.1 ; python_full_version < '3.9'
146
+ # via torch
147
+ networkx==3.2.1 ; python_full_version == '3.9.*'
148
+ # via torch
149
+ networkx==3.4.2 ; python_full_version >= '3.10'
150
+ # via torch
151
+ nodeenv==1.7.0
152
+ # via pre-commit
153
+ numpy==1.24.4
154
+ # via
155
+ # chex
156
+ # flax
157
+ # gym
158
+ # gymnasium
159
+ # imageio
160
+ # jax
161
+ # jaxlib
162
+ # ml-dtypes
163
+ # moviepy
164
+ # opt-einsum
165
+ # optax
166
+ # orbax
167
+ # scipy
168
+ # tensorboard
169
+ # tensorstore
170
+ nvidia-cublas-cu12==12.1.3.1 ; platform_machine == 'x86_64' and sys_platform == 'linux'
171
+ # via
172
+ # nvidia-cudnn-cu12
173
+ # nvidia-cusolver-cu12
174
+ # torch
175
+ nvidia-cuda-cupti-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
176
+ # via torch
177
+ nvidia-cuda-nvrtc-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
178
+ # via torch
179
+ nvidia-cuda-runtime-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
180
+ # via torch
181
+ nvidia-cudnn-cu12==9.1.0.70 ; platform_machine == 'x86_64' and sys_platform == 'linux'
182
+ # via torch
183
+ nvidia-cufft-cu12==11.0.2.54 ; platform_machine == 'x86_64' and sys_platform == 'linux'
184
+ # via torch
185
+ nvidia-curand-cu12==10.3.2.106 ; platform_machine == 'x86_64' and sys_platform == 'linux'
186
+ # via torch
187
+ nvidia-cusolver-cu12==11.4.5.107 ; platform_machine == 'x86_64' and sys_platform == 'linux'
188
+ # via torch
189
+ nvidia-cusparse-cu12==12.1.0.106 ; platform_machine == 'x86_64' and sys_platform == 'linux'
190
+ # via
191
+ # nvidia-cusolver-cu12
192
+ # torch
193
+ nvidia-nccl-cu12==2.20.5 ; platform_machine == 'x86_64' and sys_platform == 'linux'
194
+ # via torch
195
+ nvidia-nvjitlink-cu12==12.4.127 ; python_full_version < '3.9' and platform_machine == 'x86_64' and sys_platform == 'linux'
196
+ # via
197
+ # nvidia-cusolver-cu12
198
+ # nvidia-cusparse-cu12
199
+ nvidia-nvjitlink-cu12==12.6.85 ; python_full_version >= '3.9' and platform_machine == 'x86_64' and sys_platform == 'linux'
200
+ # via
201
+ # nvidia-cusolver-cu12
202
+ # nvidia-cusparse-cu12
203
+ nvidia-nvtx-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
204
+ # via torch
205
+ oauthlib==3.2.2
206
+ # via requests-oauthlib
207
+ opt-einsum==3.3.0
208
+ # via jax
209
+ optax==0.1.4
210
+ # via
211
+ # cleanrl
212
+ # flax
213
+ orbax==0.1.0
214
+ # via flax
215
+ packaging==23.1
216
+ # via
217
+ # huggingface-hub
218
+ # pytest
219
+ pathtools==0.1.2
220
+ # via wandb
221
+ pillow==9.5.0
222
+ # via imageio
223
+ platformdirs==3.5.0
224
+ # via virtualenv
225
+ pluggy==1.0.0
226
+ # via pytest
227
+ pre-commit==2.21.0
228
+ proglog==0.1.10
229
+ # via moviepy
230
+ protobuf==3.20.3
231
+ # via
232
+ # tensorboard
233
+ # wandb
234
+ psutil==5.9.5
235
+ # via wandb
236
+ pyasn1==0.5.0
237
+ # via
238
+ # pyasn1-modules
239
+ # rsa
240
+ pyasn1-modules==0.3.0
241
+ # via google-auth
242
+ pygame==2.1.0
243
+ # via cleanrl
244
+ pygments==2.15.1
245
+ # via rich
246
+ pytest==7.3.1
247
+ # via orbax
248
+ pyyaml==6.0.1
249
+ # via
250
+ # flax
251
+ # huggingface-hub
252
+ # orbax
253
+ # pre-commit
254
+ # wandb
255
+ requests==2.30.0
256
+ # via
257
+ # huggingface-hub
258
+ # moviepy
259
+ # requests-oauthlib
260
+ # tensorboard
261
+ # wandb
262
+ requests-oauthlib==1.3.1
263
+ # via google-auth-oauthlib
264
+ rich==11.2.0
265
+ # via
266
+ # cleanrl
267
+ # flax
268
+ # tyro
269
+ rsa==4.7.2
270
+ # via google-auth
271
+ scipy==1.10.1
272
+ # via
273
+ # cleanrl
274
+ # jax
275
+ # jaxlib
276
+ sentry-sdk==1.22.2
277
+ # via wandb
278
+ setproctitle==1.3.2
279
+ # via wandb
280
+ setuptools==67.7.2
281
+ # via
282
+ # nodeenv
283
+ # tensorboard
284
+ # wandb
285
+ shtab==1.6.4
286
+ # via tyro
287
+ six==1.16.0
288
+ # via
289
+ # docker-pycreds
290
+ # google-auth
291
+ smmap==5.0.0
292
+ # via gitdb
293
+ sympy==1.12.1 ; python_full_version < '3.9'
294
+ # via torch
295
+ sympy==1.14.0 ; python_full_version >= '3.9'
296
+ # via torch
297
+ tenacity==8.2.3
298
+ # via cleanrl
299
+ tensorboard==2.11.2
300
+ # via cleanrl
301
+ tensorboard-data-server==0.6.1
302
+ # via tensorboard
303
+ tensorboard-plugin-wit==1.8.1
304
+ # via tensorboard
305
+ tensorstore==0.1.28
306
+ # via
307
+ # flax
308
+ # orbax
309
+ tomli==2.0.1
310
+ # via pytest
311
+ toolz==0.12.0
312
+ # via chex
313
+ torch==2.4.1
314
+ # via cleanrl
315
+ tqdm==4.65.0
316
+ # via
317
+ # huggingface-hub
318
+ # moviepy
319
+ # proglog
320
+ triton==3.0.0 ; platform_machine == 'x86_64' and sys_platform == 'linux'
321
+ # via torch
322
+ typing-extensions==4.13.2 ; python_full_version < '3.9'
323
+ # via
324
+ # flax
325
+ # gymnasium
326
+ # huggingface-hub
327
+ # optax
328
+ # torch
329
+ # tyro
330
+ # wandb
331
+ typing-extensions==4.14.1 ; python_full_version >= '3.9'
332
+ # via
333
+ # flax
334
+ # gymnasium
335
+ # huggingface-hub
336
+ # optax
337
+ # torch
338
+ # tyro
339
+ # wandb
340
+ tyro==0.5.10
341
+ # via cleanrl
342
+ urllib3==1.26.15
343
+ # via
344
+ # google-auth
345
+ # requests
346
+ # sentry-sdk
347
+ virtualenv==20.21.0
348
+ # via pre-commit
349
+ wandb==0.13.11
350
+ # via cleanrl
351
+ werkzeug==2.2.3
352
+ # via tensorboard
353
+ wheel==0.40.0
354
+ # via tensorboard
355
+ zipp==3.15.0 ; python_full_version < '3.10'
356
+ # via
357
+ # importlib-metadata
358
+ # importlib-resources
cleanrl/requirements/requirements-memory_gym.txt ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file was autogenerated by uv via the following command:
2
+ # uv export --no-hashes --output-file ../../requirements/requirements-memory_gym.txt
3
+ -e .
4
+ absl-py==2.3.1
5
+ # via tensorboard
6
+ appdirs==1.4.4
7
+ # via wandb
8
+ backports-shutil-get-terminal-size==1.0.0
9
+ # via reprint
10
+ certifi==2025.6.15
11
+ # via
12
+ # requests
13
+ # sentry-sdk
14
+ charset-normalizer==3.4.2
15
+ # via requests
16
+ click==8.2.1
17
+ # via wandb
18
+ cloudpickle==3.1.1
19
+ # via gymnasium
20
+ colorama==0.4.6
21
+ # via
22
+ # click
23
+ # reprint
24
+ # tyro
25
+ docker-pycreds==0.4.0
26
+ # via wandb
27
+ docstring-parser==0.16
28
+ # via tyro
29
+ einops==0.7.0
30
+ # via ppo-trxl
31
+ farama-notifications==0.0.4
32
+ # via gymnasium
33
+ filelock==3.18.0
34
+ # via torch
35
+ fsspec==2025.5.1
36
+ # via torch
37
+ gitdb==4.0.12
38
+ # via gitpython
39
+ gitpython==3.1.44
40
+ # via wandb
41
+ grpcio==1.73.1
42
+ # via tensorboard
43
+ gymnasium==0.29.0
44
+ # via
45
+ # memory-gym
46
+ # minigrid
47
+ idna==3.10
48
+ # via requests
49
+ jinja2==3.1.6
50
+ # via torch
51
+ markdown==3.8.2
52
+ # via tensorboard
53
+ markdown-it-py==3.0.0
54
+ # via rich
55
+ markupsafe==3.0.2
56
+ # via
57
+ # jinja2
58
+ # werkzeug
59
+ mdurl==0.1.2
60
+ # via markdown-it-py
61
+ memory-gym==1.0.2
62
+ # via ppo-trxl
63
+ minigrid==2.5.0
64
+ # via ppo-trxl
65
+ mpmath==1.3.0
66
+ # via sympy
67
+ networkx==3.4.2 ; python_full_version < '3.11'
68
+ # via torch
69
+ networkx==3.5 ; python_full_version >= '3.11'
70
+ # via torch
71
+ numpy==2.2.6 ; python_full_version < '3.11'
72
+ # via
73
+ # gymnasium
74
+ # minigrid
75
+ # opencv-python
76
+ # tensorboard
77
+ numpy==2.3.1 ; python_full_version >= '3.11'
78
+ # via
79
+ # gymnasium
80
+ # minigrid
81
+ # opencv-python
82
+ # tensorboard
83
+ nvidia-cublas-cu11==11.11.3.6 ; platform_machine == 'x86_64' and sys_platform == 'linux'
84
+ # via
85
+ # nvidia-cudnn-cu11
86
+ # nvidia-cusolver-cu11
87
+ # torch
88
+ nvidia-cuda-cupti-cu11==11.8.87 ; platform_machine == 'x86_64' and sys_platform == 'linux'
89
+ # via torch
90
+ nvidia-cuda-nvrtc-cu11==11.8.89 ; platform_machine == 'x86_64' and sys_platform == 'linux'
91
+ # via torch
92
+ nvidia-cuda-runtime-cu11==11.8.89 ; platform_machine == 'x86_64' and sys_platform == 'linux'
93
+ # via torch
94
+ nvidia-cudnn-cu11==9.1.0.70 ; platform_machine == 'x86_64' and sys_platform == 'linux'
95
+ # via torch
96
+ nvidia-cufft-cu11==10.9.0.58 ; platform_machine == 'x86_64' and sys_platform == 'linux'
97
+ # via torch
98
+ nvidia-curand-cu11==10.3.0.86 ; platform_machine == 'x86_64' and sys_platform == 'linux'
99
+ # via torch
100
+ nvidia-cusolver-cu11==11.4.1.48 ; platform_machine == 'x86_64' and sys_platform == 'linux'
101
+ # via torch
102
+ nvidia-cusparse-cu11==11.7.5.86 ; platform_machine == 'x86_64' and sys_platform == 'linux'
103
+ # via torch
104
+ nvidia-nccl-cu11==2.21.5 ; platform_machine == 'x86_64' and sys_platform == 'linux'
105
+ # via torch
106
+ nvidia-nvtx-cu11==11.8.86 ; platform_machine == 'x86_64' and sys_platform == 'linux'
107
+ # via torch
108
+ opencv-python==4.11.0.86
109
+ # via ppo-trxl
110
+ packaging==25.0
111
+ # via tensorboard
112
+ protobuf==4.25.8
113
+ # via
114
+ # tensorboard
115
+ # wandb
116
+ psutil==7.0.0
117
+ # via wandb
118
+ pygame==2.4.0
119
+ # via
120
+ # memory-gym
121
+ # minigrid
122
+ pygments==2.19.2
123
+ # via rich
124
+ pyyaml==6.0.2
125
+ # via wandb
126
+ reprint==0.6.0
127
+ # via ppo-trxl
128
+ requests==2.32.4
129
+ # via wandb
130
+ rich==14.0.0
131
+ # via tyro
132
+ sentry-sdk==2.32.0
133
+ # via wandb
134
+ setproctitle==1.3.6
135
+ # via wandb
136
+ setuptools==80.9.0
137
+ # via
138
+ # tensorboard
139
+ # torch
140
+ # triton
141
+ # wandb
142
+ shtab==1.7.2
143
+ # via tyro
144
+ six==1.17.0
145
+ # via
146
+ # docker-pycreds
147
+ # reprint
148
+ # tensorboard
149
+ smmap==5.0.2
150
+ # via gitdb
151
+ sympy==1.14.0
152
+ # via torch
153
+ tensorboard==2.19.0
154
+ # via ppo-trxl
155
+ tensorboard-data-server==0.7.2
156
+ # via tensorboard
157
+ torch==2.7.1+cu118
158
+ # via
159
+ # ppo-trxl
160
+ # torchaudio
161
+ torchaudio==2.7.1+cu118
162
+ # via ppo-trxl
163
+ triton==3.3.1 ; platform_machine == 'x86_64' and sys_platform == 'linux'
164
+ # via torch
165
+ typing-extensions==4.14.1
166
+ # via
167
+ # gymnasium
168
+ # rich
169
+ # torch
170
+ # tyro
171
+ tyro==0.8.14
172
+ # via ppo-trxl
173
+ urllib3==2.5.0
174
+ # via
175
+ # requests
176
+ # sentry-sdk
177
+ wandb==0.16.6
178
+ # via ppo-trxl
179
+ werkzeug==3.1.3
180
+ # via tensorboard
cleanrl/requirements/requirements-mujoco.txt ADDED
@@ -0,0 +1,275 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file was autogenerated by uv via the following command:
2
+ # uv export --no-hashes --output-file requirements/requirements-mujoco.txt --extra mujoco
3
+ -e .
4
+ absl-py==1.4.0
5
+ # via
6
+ # mujoco
7
+ # tensorboard
8
+ appdirs==1.4.4
9
+ # via wandb
10
+ cachetools==5.3.0
11
+ # via google-auth
12
+ certifi==2023.5.7
13
+ # via
14
+ # requests
15
+ # sentry-sdk
16
+ cfgv==3.3.1
17
+ # via pre-commit
18
+ charset-normalizer==3.1.0
19
+ # via requests
20
+ click==8.1.3
21
+ # via wandb
22
+ cloudpickle==2.2.1
23
+ # via
24
+ # gym
25
+ # gymnasium
26
+ colorama==0.4.4
27
+ # via
28
+ # click
29
+ # rich
30
+ # tqdm
31
+ # tyro
32
+ commonmark==0.9.1
33
+ # via rich
34
+ decorator==4.4.2
35
+ # via moviepy
36
+ distlib==0.3.6
37
+ # via virtualenv
38
+ docker-pycreds==0.4.0
39
+ # via wandb
40
+ docstring-parser==0.15
41
+ # via tyro
42
+ farama-notifications==0.0.4
43
+ # via gymnasium
44
+ filelock==3.12.0
45
+ # via
46
+ # huggingface-hub
47
+ # torch
48
+ # triton
49
+ # virtualenv
50
+ fsspec==2025.3.0 ; python_full_version < '3.9'
51
+ # via torch
52
+ fsspec==2025.5.1 ; python_full_version >= '3.9'
53
+ # via torch
54
+ gitdb==4.0.10
55
+ # via gitpython
56
+ gitpython==3.1.31
57
+ # via wandb
58
+ glfw==1.12.0
59
+ # via mujoco
60
+ google-auth==2.18.0
61
+ # via
62
+ # google-auth-oauthlib
63
+ # tensorboard
64
+ google-auth-oauthlib==0.4.6
65
+ # via tensorboard
66
+ grpcio==1.54.0
67
+ # via tensorboard
68
+ gym==0.23.1
69
+ # via cleanrl
70
+ gym-notices==0.0.8
71
+ # via gym
72
+ gymnasium==0.29.1
73
+ # via cleanrl
74
+ huggingface-hub==0.11.1
75
+ # via cleanrl
76
+ identify==2.5.24
77
+ # via pre-commit
78
+ idna==3.4
79
+ # via requests
80
+ imageio==2.28.1
81
+ # via
82
+ # cleanrl
83
+ # moviepy
84
+ imageio-ffmpeg==0.3.0
85
+ # via moviepy
86
+ importlib-metadata==5.2.0 ; python_full_version < '3.10'
87
+ # via
88
+ # gym
89
+ # gymnasium
90
+ # markdown
91
+ jinja2==3.1.2
92
+ # via torch
93
+ markdown==3.3.7
94
+ # via tensorboard
95
+ markupsafe==2.1.2
96
+ # via
97
+ # jinja2
98
+ # werkzeug
99
+ moviepy==1.0.3
100
+ # via cleanrl
101
+ mpmath==1.3.0
102
+ # via sympy
103
+ mujoco==2.3.3
104
+ # via cleanrl
105
+ networkx==3.1 ; python_full_version < '3.9'
106
+ # via torch
107
+ networkx==3.2.1 ; python_full_version == '3.9.*'
108
+ # via torch
109
+ networkx==3.4.2 ; python_full_version >= '3.10'
110
+ # via torch
111
+ nodeenv==1.7.0
112
+ # via pre-commit
113
+ numpy==1.24.4
114
+ # via
115
+ # gym
116
+ # gymnasium
117
+ # imageio
118
+ # moviepy
119
+ # mujoco
120
+ # tensorboard
121
+ nvidia-cublas-cu12==12.1.3.1 ; platform_machine == 'x86_64' and sys_platform == 'linux'
122
+ # via
123
+ # nvidia-cudnn-cu12
124
+ # nvidia-cusolver-cu12
125
+ # torch
126
+ nvidia-cuda-cupti-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
127
+ # via torch
128
+ nvidia-cuda-nvrtc-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
129
+ # via torch
130
+ nvidia-cuda-runtime-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
131
+ # via torch
132
+ nvidia-cudnn-cu12==9.1.0.70 ; platform_machine == 'x86_64' and sys_platform == 'linux'
133
+ # via torch
134
+ nvidia-cufft-cu12==11.0.2.54 ; platform_machine == 'x86_64' and sys_platform == 'linux'
135
+ # via torch
136
+ nvidia-curand-cu12==10.3.2.106 ; platform_machine == 'x86_64' and sys_platform == 'linux'
137
+ # via torch
138
+ nvidia-cusolver-cu12==11.4.5.107 ; platform_machine == 'x86_64' and sys_platform == 'linux'
139
+ # via torch
140
+ nvidia-cusparse-cu12==12.1.0.106 ; platform_machine == 'x86_64' and sys_platform == 'linux'
141
+ # via
142
+ # nvidia-cusolver-cu12
143
+ # torch
144
+ nvidia-nccl-cu12==2.20.5 ; platform_machine == 'x86_64' and sys_platform == 'linux'
145
+ # via torch
146
+ nvidia-nvjitlink-cu12==12.4.127 ; python_full_version < '3.9' and platform_machine == 'x86_64' and sys_platform == 'linux'
147
+ # via
148
+ # nvidia-cusolver-cu12
149
+ # nvidia-cusparse-cu12
150
+ nvidia-nvjitlink-cu12==12.6.85 ; python_full_version >= '3.9' and platform_machine == 'x86_64' and sys_platform == 'linux'
151
+ # via
152
+ # nvidia-cusolver-cu12
153
+ # nvidia-cusparse-cu12
154
+ nvidia-nvtx-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
155
+ # via torch
156
+ oauthlib==3.2.2
157
+ # via requests-oauthlib
158
+ packaging==23.1
159
+ # via huggingface-hub
160
+ pathtools==0.1.2
161
+ # via wandb
162
+ pillow==9.5.0
163
+ # via imageio
164
+ platformdirs==3.5.0
165
+ # via virtualenv
166
+ pre-commit==2.21.0
167
+ proglog==0.1.10
168
+ # via moviepy
169
+ protobuf==3.20.3
170
+ # via
171
+ # tensorboard
172
+ # wandb
173
+ psutil==5.9.5
174
+ # via wandb
175
+ pyasn1==0.5.0
176
+ # via
177
+ # pyasn1-modules
178
+ # rsa
179
+ pyasn1-modules==0.3.0
180
+ # via google-auth
181
+ pygame==2.1.0
182
+ # via cleanrl
183
+ pygments==2.15.1
184
+ # via rich
185
+ pyopengl==3.1.6
186
+ # via mujoco
187
+ pyyaml==6.0.1
188
+ # via
189
+ # huggingface-hub
190
+ # pre-commit
191
+ # wandb
192
+ requests==2.30.0
193
+ # via
194
+ # huggingface-hub
195
+ # moviepy
196
+ # requests-oauthlib
197
+ # tensorboard
198
+ # wandb
199
+ requests-oauthlib==1.3.1
200
+ # via google-auth-oauthlib
201
+ rich==11.2.0
202
+ # via
203
+ # cleanrl
204
+ # tyro
205
+ rsa==4.7.2
206
+ # via google-auth
207
+ sentry-sdk==1.22.2
208
+ # via wandb
209
+ setproctitle==1.3.2
210
+ # via wandb
211
+ setuptools==67.7.2
212
+ # via
213
+ # nodeenv
214
+ # tensorboard
215
+ # wandb
216
+ shtab==1.6.4
217
+ # via tyro
218
+ six==1.16.0
219
+ # via
220
+ # docker-pycreds
221
+ # google-auth
222
+ smmap==5.0.0
223
+ # via gitdb
224
+ sympy==1.12.1 ; python_full_version < '3.9'
225
+ # via torch
226
+ sympy==1.14.0 ; python_full_version >= '3.9'
227
+ # via torch
228
+ tenacity==8.2.3
229
+ # via cleanrl
230
+ tensorboard==2.11.2
231
+ # via cleanrl
232
+ tensorboard-data-server==0.6.1
233
+ # via tensorboard
234
+ tensorboard-plugin-wit==1.8.1
235
+ # via tensorboard
236
+ torch==2.4.1
237
+ # via cleanrl
238
+ tqdm==4.65.0
239
+ # via
240
+ # huggingface-hub
241
+ # moviepy
242
+ # proglog
243
+ triton==3.0.0 ; platform_machine == 'x86_64' and sys_platform == 'linux'
244
+ # via torch
245
+ typing-extensions==4.13.2 ; python_full_version < '3.9'
246
+ # via
247
+ # gymnasium
248
+ # huggingface-hub
249
+ # torch
250
+ # tyro
251
+ # wandb
252
+ typing-extensions==4.14.1 ; python_full_version >= '3.9'
253
+ # via
254
+ # gymnasium
255
+ # huggingface-hub
256
+ # torch
257
+ # tyro
258
+ # wandb
259
+ tyro==0.5.10
260
+ # via cleanrl
261
+ urllib3==1.26.15
262
+ # via
263
+ # google-auth
264
+ # requests
265
+ # sentry-sdk
266
+ virtualenv==20.21.0
267
+ # via pre-commit
268
+ wandb==0.13.11
269
+ # via cleanrl
270
+ werkzeug==2.2.3
271
+ # via tensorboard
272
+ wheel==0.40.0
273
+ # via tensorboard
274
+ zipp==3.15.0 ; python_full_version < '3.10'
275
+ # via importlib-metadata
cleanrl/requirements/requirements-optuna.txt ADDED
@@ -0,0 +1,316 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file was autogenerated by uv via the following command:
2
+ # uv export --no-hashes --output-file requirements/requirements-optuna.txt --extra optuna
3
+ -e .
4
+ absl-py==1.4.0
5
+ # via tensorboard
6
+ alembic==1.10.4
7
+ # via optuna
8
+ appdirs==1.4.4
9
+ # via wandb
10
+ bottle==0.12.25
11
+ # via optuna-dashboard
12
+ cachetools==5.3.0
13
+ # via google-auth
14
+ certifi==2023.5.7
15
+ # via
16
+ # requests
17
+ # sentry-sdk
18
+ cfgv==3.3.1
19
+ # via pre-commit
20
+ charset-normalizer==3.1.0
21
+ # via requests
22
+ click==8.1.3
23
+ # via wandb
24
+ cloudpickle==2.2.1
25
+ # via
26
+ # gym
27
+ # gymnasium
28
+ cmaes==0.10.0
29
+ # via optuna
30
+ colorama==0.4.4
31
+ # via
32
+ # click
33
+ # colorlog
34
+ # rich
35
+ # tqdm
36
+ # tyro
37
+ colorlog==6.7.0
38
+ # via optuna
39
+ commonmark==0.9.1
40
+ # via rich
41
+ decorator==4.4.2
42
+ # via moviepy
43
+ distlib==0.3.6
44
+ # via virtualenv
45
+ docker-pycreds==0.4.0
46
+ # via wandb
47
+ docstring-parser==0.15
48
+ # via tyro
49
+ farama-notifications==0.0.4
50
+ # via gymnasium
51
+ filelock==3.12.0
52
+ # via
53
+ # huggingface-hub
54
+ # torch
55
+ # triton
56
+ # virtualenv
57
+ fsspec==2025.3.0 ; python_full_version < '3.9'
58
+ # via torch
59
+ fsspec==2025.5.1 ; python_full_version >= '3.9'
60
+ # via torch
61
+ gitdb==4.0.10
62
+ # via gitpython
63
+ gitpython==3.1.31
64
+ # via wandb
65
+ google-auth==2.18.0
66
+ # via
67
+ # google-auth-oauthlib
68
+ # tensorboard
69
+ google-auth-oauthlib==0.4.6
70
+ # via tensorboard
71
+ greenlet==2.0.2 ; platform_machine == 'AMD64' or platform_machine == 'WIN32' or platform_machine == 'aarch64' or platform_machine == 'amd64' or platform_machine == 'ppc64le' or platform_machine == 'win32' or platform_machine == 'x86_64'
72
+ # via sqlalchemy
73
+ grpcio==1.54.0
74
+ # via tensorboard
75
+ gym==0.23.1
76
+ # via cleanrl
77
+ gym-notices==0.0.8
78
+ # via gym
79
+ gymnasium==0.29.1
80
+ # via cleanrl
81
+ huggingface-hub==0.11.1
82
+ # via cleanrl
83
+ identify==2.5.24
84
+ # via pre-commit
85
+ idna==3.4
86
+ # via requests
87
+ imageio==2.28.1
88
+ # via moviepy
89
+ imageio-ffmpeg==0.3.0
90
+ # via moviepy
91
+ importlib-metadata==5.2.0 ; python_full_version < '3.10'
92
+ # via
93
+ # alembic
94
+ # gym
95
+ # gymnasium
96
+ # markdown
97
+ importlib-resources==5.12.0 ; python_full_version < '3.9'
98
+ # via alembic
99
+ jinja2==3.1.2
100
+ # via torch
101
+ joblib==1.2.0
102
+ # via scikit-learn
103
+ mako==1.2.4
104
+ # via alembic
105
+ markdown==3.3.7
106
+ # via tensorboard
107
+ markupsafe==2.1.2
108
+ # via
109
+ # jinja2
110
+ # mako
111
+ # werkzeug
112
+ moviepy==1.0.3
113
+ # via cleanrl
114
+ mpmath==1.3.0
115
+ # via sympy
116
+ networkx==3.1 ; python_full_version < '3.9'
117
+ # via torch
118
+ networkx==3.2.1 ; python_full_version == '3.9.*'
119
+ # via torch
120
+ networkx==3.4.2 ; python_full_version >= '3.10'
121
+ # via torch
122
+ nodeenv==1.7.0
123
+ # via pre-commit
124
+ numpy==1.24.4
125
+ # via
126
+ # cmaes
127
+ # gym
128
+ # gymnasium
129
+ # imageio
130
+ # moviepy
131
+ # optuna
132
+ # scikit-learn
133
+ # scipy
134
+ # tensorboard
135
+ nvidia-cublas-cu12==12.1.3.1 ; platform_machine == 'x86_64' and sys_platform == 'linux'
136
+ # via
137
+ # nvidia-cudnn-cu12
138
+ # nvidia-cusolver-cu12
139
+ # torch
140
+ nvidia-cuda-cupti-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
141
+ # via torch
142
+ nvidia-cuda-nvrtc-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
143
+ # via torch
144
+ nvidia-cuda-runtime-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
145
+ # via torch
146
+ nvidia-cudnn-cu12==9.1.0.70 ; platform_machine == 'x86_64' and sys_platform == 'linux'
147
+ # via torch
148
+ nvidia-cufft-cu12==11.0.2.54 ; platform_machine == 'x86_64' and sys_platform == 'linux'
149
+ # via torch
150
+ nvidia-curand-cu12==10.3.2.106 ; platform_machine == 'x86_64' and sys_platform == 'linux'
151
+ # via torch
152
+ nvidia-cusolver-cu12==11.4.5.107 ; platform_machine == 'x86_64' and sys_platform == 'linux'
153
+ # via torch
154
+ nvidia-cusparse-cu12==12.1.0.106 ; platform_machine == 'x86_64' and sys_platform == 'linux'
155
+ # via
156
+ # nvidia-cusolver-cu12
157
+ # torch
158
+ nvidia-nccl-cu12==2.20.5 ; platform_machine == 'x86_64' and sys_platform == 'linux'
159
+ # via torch
160
+ nvidia-nvjitlink-cu12==12.4.127 ; python_full_version < '3.9' and platform_machine == 'x86_64' and sys_platform == 'linux'
161
+ # via
162
+ # nvidia-cusolver-cu12
163
+ # nvidia-cusparse-cu12
164
+ nvidia-nvjitlink-cu12==12.6.85 ; python_full_version >= '3.9' and platform_machine == 'x86_64' and sys_platform == 'linux'
165
+ # via
166
+ # nvidia-cusolver-cu12
167
+ # nvidia-cusparse-cu12
168
+ nvidia-nvtx-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
169
+ # via torch
170
+ oauthlib==3.2.2
171
+ # via requests-oauthlib
172
+ optuna==3.3.0
173
+ # via
174
+ # cleanrl
175
+ # optuna-dashboard
176
+ optuna-dashboard==0.7.3
177
+ # via cleanrl
178
+ packaging==23.1
179
+ # via
180
+ # huggingface-hub
181
+ # optuna
182
+ # optuna-dashboard
183
+ pathtools==0.1.2
184
+ # via wandb
185
+ pillow==9.5.0
186
+ # via imageio
187
+ platformdirs==3.5.0
188
+ # via virtualenv
189
+ pre-commit==2.21.0
190
+ proglog==0.1.10
191
+ # via moviepy
192
+ protobuf==3.20.3
193
+ # via
194
+ # tensorboard
195
+ # wandb
196
+ psutil==5.9.5
197
+ # via wandb
198
+ pyasn1==0.5.0
199
+ # via
200
+ # pyasn1-modules
201
+ # rsa
202
+ pyasn1-modules==0.3.0
203
+ # via google-auth
204
+ pygame==2.1.0
205
+ # via cleanrl
206
+ pygments==2.15.1
207
+ # via rich
208
+ pyyaml==6.0.1
209
+ # via
210
+ # huggingface-hub
211
+ # optuna
212
+ # pre-commit
213
+ # wandb
214
+ requests==2.30.0
215
+ # via
216
+ # huggingface-hub
217
+ # moviepy
218
+ # requests-oauthlib
219
+ # tensorboard
220
+ # wandb
221
+ requests-oauthlib==1.3.1
222
+ # via google-auth-oauthlib
223
+ rich==11.2.0
224
+ # via
225
+ # cleanrl
226
+ # tyro
227
+ rsa==4.7.2
228
+ # via google-auth
229
+ scikit-learn==1.0.2
230
+ # via optuna-dashboard
231
+ scipy==1.10.1
232
+ # via scikit-learn
233
+ sentry-sdk==1.22.2
234
+ # via wandb
235
+ setproctitle==1.3.2
236
+ # via wandb
237
+ setuptools==67.7.2
238
+ # via
239
+ # nodeenv
240
+ # tensorboard
241
+ # wandb
242
+ shtab==1.6.4
243
+ # via tyro
244
+ six==1.16.0
245
+ # via
246
+ # docker-pycreds
247
+ # google-auth
248
+ smmap==5.0.0
249
+ # via gitdb
250
+ sqlalchemy==2.0.13
251
+ # via
252
+ # alembic
253
+ # optuna
254
+ sympy==1.12.1 ; python_full_version < '3.9'
255
+ # via torch
256
+ sympy==1.14.0 ; python_full_version >= '3.9'
257
+ # via torch
258
+ tenacity==8.2.3
259
+ # via cleanrl
260
+ tensorboard==2.11.2
261
+ # via cleanrl
262
+ tensorboard-data-server==0.6.1
263
+ # via tensorboard
264
+ tensorboard-plugin-wit==1.8.1
265
+ # via tensorboard
266
+ threadpoolctl==3.1.0
267
+ # via scikit-learn
268
+ torch==2.4.1
269
+ # via cleanrl
270
+ tqdm==4.65.0
271
+ # via
272
+ # huggingface-hub
273
+ # moviepy
274
+ # optuna
275
+ # proglog
276
+ triton==3.0.0 ; platform_machine == 'x86_64' and sys_platform == 'linux'
277
+ # via torch
278
+ typing-extensions==4.13.2 ; python_full_version < '3.9'
279
+ # via
280
+ # alembic
281
+ # cleanrl
282
+ # gymnasium
283
+ # huggingface-hub
284
+ # sqlalchemy
285
+ # torch
286
+ # tyro
287
+ # wandb
288
+ typing-extensions==4.14.1 ; python_full_version >= '3.9'
289
+ # via
290
+ # alembic
291
+ # cleanrl
292
+ # gymnasium
293
+ # huggingface-hub
294
+ # sqlalchemy
295
+ # torch
296
+ # tyro
297
+ # wandb
298
+ tyro==0.5.10
299
+ # via cleanrl
300
+ urllib3==1.26.15
301
+ # via
302
+ # google-auth
303
+ # requests
304
+ # sentry-sdk
305
+ virtualenv==20.21.0
306
+ # via pre-commit
307
+ wandb==0.13.11
308
+ # via cleanrl
309
+ werkzeug==2.2.3
310
+ # via tensorboard
311
+ wheel==0.40.0
312
+ # via tensorboard
313
+ zipp==3.15.0 ; python_full_version < '3.10'
314
+ # via
315
+ # importlib-metadata
316
+ # importlib-resources
cleanrl/requirements/requirements-pettingzoo.txt ADDED
@@ -0,0 +1,280 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file was autogenerated by uv via the following command:
2
+ # uv export --no-hashes --output-file requirements/requirements-pettingzoo.txt --extra pettingzoo
3
+ -e .
4
+ absl-py==1.4.0
5
+ # via tensorboard
6
+ appdirs==1.4.4
7
+ # via wandb
8
+ cachetools==5.3.0
9
+ # via google-auth
10
+ certifi==2023.5.7
11
+ # via
12
+ # requests
13
+ # sentry-sdk
14
+ cfgv==3.3.1
15
+ # via pre-commit
16
+ charset-normalizer==3.1.0
17
+ # via requests
18
+ click==8.1.3
19
+ # via wandb
20
+ cloudpickle==2.2.1
21
+ # via
22
+ # gym
23
+ # gymnasium
24
+ colorama==0.4.4
25
+ # via
26
+ # click
27
+ # rich
28
+ # tqdm
29
+ # tyro
30
+ commonmark==0.9.1
31
+ # via rich
32
+ decorator==4.4.2
33
+ # via moviepy
34
+ distlib==0.3.6
35
+ # via virtualenv
36
+ docker-pycreds==0.4.0
37
+ # via wandb
38
+ docstring-parser==0.15
39
+ # via tyro
40
+ farama-notifications==0.0.4
41
+ # via gymnasium
42
+ filelock==3.12.0
43
+ # via
44
+ # huggingface-hub
45
+ # torch
46
+ # triton
47
+ # virtualenv
48
+ fsspec==2025.3.0 ; python_full_version < '3.9'
49
+ # via torch
50
+ fsspec==2025.5.1 ; python_full_version >= '3.9'
51
+ # via torch
52
+ gitdb==4.0.10
53
+ # via gitpython
54
+ gitpython==3.1.31
55
+ # via wandb
56
+ google-auth==2.18.0
57
+ # via
58
+ # google-auth-oauthlib
59
+ # tensorboard
60
+ google-auth-oauthlib==0.4.6
61
+ # via tensorboard
62
+ grpcio==1.54.0
63
+ # via tensorboard
64
+ gym==0.23.1
65
+ # via
66
+ # cleanrl
67
+ # pettingzoo
68
+ # supersuit
69
+ gym-notices==0.0.8
70
+ # via gym
71
+ gymnasium==0.29.1
72
+ # via cleanrl
73
+ huggingface-hub==0.11.1
74
+ # via cleanrl
75
+ identify==2.5.24
76
+ # via pre-commit
77
+ idna==3.4
78
+ # via requests
79
+ imageio==2.28.1
80
+ # via moviepy
81
+ imageio-ffmpeg==0.3.0
82
+ # via moviepy
83
+ importlib-metadata==5.2.0 ; python_full_version < '3.10'
84
+ # via
85
+ # gym
86
+ # gymnasium
87
+ # markdown
88
+ jinja2==3.1.2
89
+ # via torch
90
+ markdown==3.3.7
91
+ # via tensorboard
92
+ markupsafe==2.1.2
93
+ # via
94
+ # jinja2
95
+ # werkzeug
96
+ moviepy==1.0.3
97
+ # via cleanrl
98
+ mpmath==1.3.0
99
+ # via sympy
100
+ multi-agent-ale-py==0.1.11
101
+ # via cleanrl
102
+ networkx==3.1 ; python_full_version < '3.9'
103
+ # via torch
104
+ networkx==3.2.1 ; python_full_version == '3.9.*'
105
+ # via torch
106
+ networkx==3.4.2 ; python_full_version >= '3.10'
107
+ # via torch
108
+ nodeenv==1.7.0
109
+ # via pre-commit
110
+ numpy==1.24.4
111
+ # via
112
+ # gym
113
+ # gymnasium
114
+ # imageio
115
+ # moviepy
116
+ # multi-agent-ale-py
117
+ # pettingzoo
118
+ # tensorboard
119
+ # tinyscaler
120
+ nvidia-cublas-cu12==12.1.3.1 ; platform_machine == 'x86_64' and sys_platform == 'linux'
121
+ # via
122
+ # nvidia-cudnn-cu12
123
+ # nvidia-cusolver-cu12
124
+ # torch
125
+ nvidia-cuda-cupti-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
126
+ # via torch
127
+ nvidia-cuda-nvrtc-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
128
+ # via torch
129
+ nvidia-cuda-runtime-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
130
+ # via torch
131
+ nvidia-cudnn-cu12==9.1.0.70 ; platform_machine == 'x86_64' and sys_platform == 'linux'
132
+ # via torch
133
+ nvidia-cufft-cu12==11.0.2.54 ; platform_machine == 'x86_64' and sys_platform == 'linux'
134
+ # via torch
135
+ nvidia-curand-cu12==10.3.2.106 ; platform_machine == 'x86_64' and sys_platform == 'linux'
136
+ # via torch
137
+ nvidia-cusolver-cu12==11.4.5.107 ; platform_machine == 'x86_64' and sys_platform == 'linux'
138
+ # via torch
139
+ nvidia-cusparse-cu12==12.1.0.106 ; platform_machine == 'x86_64' and sys_platform == 'linux'
140
+ # via
141
+ # nvidia-cusolver-cu12
142
+ # torch
143
+ nvidia-nccl-cu12==2.20.5 ; platform_machine == 'x86_64' and sys_platform == 'linux'
144
+ # via torch
145
+ nvidia-nvjitlink-cu12==12.4.127 ; python_full_version < '3.9' and platform_machine == 'x86_64' and sys_platform == 'linux'
146
+ # via
147
+ # nvidia-cusolver-cu12
148
+ # nvidia-cusparse-cu12
149
+ nvidia-nvjitlink-cu12==12.6.85 ; python_full_version >= '3.9' and platform_machine == 'x86_64' and sys_platform == 'linux'
150
+ # via
151
+ # nvidia-cusolver-cu12
152
+ # nvidia-cusparse-cu12
153
+ nvidia-nvtx-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
154
+ # via torch
155
+ oauthlib==3.2.2
156
+ # via requests-oauthlib
157
+ packaging==23.1
158
+ # via huggingface-hub
159
+ pathtools==0.1.2
160
+ # via wandb
161
+ pettingzoo==1.18.1
162
+ # via
163
+ # cleanrl
164
+ # supersuit
165
+ pillow==9.5.0
166
+ # via imageio
167
+ platformdirs==3.5.0
168
+ # via virtualenv
169
+ pre-commit==2.21.0
170
+ proglog==0.1.10
171
+ # via moviepy
172
+ protobuf==3.20.3
173
+ # via
174
+ # tensorboard
175
+ # wandb
176
+ psutil==5.9.5
177
+ # via wandb
178
+ pyasn1==0.5.0
179
+ # via
180
+ # pyasn1-modules
181
+ # rsa
182
+ pyasn1-modules==0.3.0
183
+ # via google-auth
184
+ pygame==2.1.0
185
+ # via cleanrl
186
+ pygments==2.15.1
187
+ # via rich
188
+ pyyaml==6.0.1
189
+ # via
190
+ # huggingface-hub
191
+ # pre-commit
192
+ # wandb
193
+ requests==2.30.0
194
+ # via
195
+ # huggingface-hub
196
+ # moviepy
197
+ # requests-oauthlib
198
+ # tensorboard
199
+ # wandb
200
+ requests-oauthlib==1.3.1
201
+ # via google-auth-oauthlib
202
+ rich==11.2.0
203
+ # via
204
+ # cleanrl
205
+ # tyro
206
+ rsa==4.7.2
207
+ # via google-auth
208
+ sentry-sdk==1.22.2
209
+ # via wandb
210
+ setproctitle==1.3.2
211
+ # via wandb
212
+ setuptools==67.7.2
213
+ # via
214
+ # nodeenv
215
+ # tensorboard
216
+ # wandb
217
+ shtab==1.6.4
218
+ # via tyro
219
+ six==1.16.0
220
+ # via
221
+ # docker-pycreds
222
+ # google-auth
223
+ smmap==5.0.0
224
+ # via gitdb
225
+ supersuit==3.4.0
226
+ # via cleanrl
227
+ sympy==1.12.1 ; python_full_version < '3.9'
228
+ # via torch
229
+ sympy==1.14.0 ; python_full_version >= '3.9'
230
+ # via torch
231
+ tenacity==8.2.3
232
+ # via cleanrl
233
+ tensorboard==2.11.2
234
+ # via cleanrl
235
+ tensorboard-data-server==0.6.1
236
+ # via tensorboard
237
+ tensorboard-plugin-wit==1.8.1
238
+ # via tensorboard
239
+ tinyscaler==1.2.5
240
+ # via supersuit
241
+ torch==2.4.1
242
+ # via cleanrl
243
+ tqdm==4.65.0
244
+ # via
245
+ # huggingface-hub
246
+ # moviepy
247
+ # proglog
248
+ triton==3.0.0 ; platform_machine == 'x86_64' and sys_platform == 'linux'
249
+ # via torch
250
+ typing-extensions==4.13.2 ; python_full_version < '3.9'
251
+ # via
252
+ # gymnasium
253
+ # huggingface-hub
254
+ # torch
255
+ # tyro
256
+ # wandb
257
+ typing-extensions==4.14.1 ; python_full_version >= '3.9'
258
+ # via
259
+ # gymnasium
260
+ # huggingface-hub
261
+ # torch
262
+ # tyro
263
+ # wandb
264
+ tyro==0.5.10
265
+ # via cleanrl
266
+ urllib3==1.26.15
267
+ # via
268
+ # google-auth
269
+ # requests
270
+ # sentry-sdk
271
+ virtualenv==20.21.0
272
+ # via pre-commit
273
+ wandb==0.13.11
274
+ # via cleanrl
275
+ werkzeug==2.2.3
276
+ # via tensorboard
277
+ wheel==0.40.0
278
+ # via tensorboard
279
+ zipp==3.15.0 ; python_full_version < '3.10'
280
+ # via importlib-metadata
cleanrl/requirements/requirements-procgen.txt ADDED
@@ -0,0 +1,287 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file was autogenerated by uv via the following command:
2
+ # uv export --no-hashes --output-file requirements/requirements-procgen.txt --extra procgen
3
+ -e .
4
+ absl-py==1.4.0
5
+ # via tensorboard
6
+ appdirs==1.4.4
7
+ # via wandb
8
+ cachetools==5.3.0
9
+ # via google-auth
10
+ certifi==2023.5.7
11
+ # via
12
+ # requests
13
+ # sentry-sdk
14
+ cffi==1.15.1
15
+ # via gym3
16
+ cfgv==3.3.1
17
+ # via pre-commit
18
+ charset-normalizer==3.1.0
19
+ # via requests
20
+ click==8.1.3
21
+ # via wandb
22
+ cloudpickle==2.2.1
23
+ # via
24
+ # gym
25
+ # gymnasium
26
+ colorama==0.4.4
27
+ # via
28
+ # click
29
+ # rich
30
+ # tqdm
31
+ # tyro
32
+ commonmark==0.9.1
33
+ # via rich
34
+ decorator==4.4.2
35
+ # via moviepy
36
+ distlib==0.3.6
37
+ # via virtualenv
38
+ docker-pycreds==0.4.0
39
+ # via wandb
40
+ docstring-parser==0.15
41
+ # via tyro
42
+ farama-notifications==0.0.4
43
+ # via gymnasium
44
+ filelock==3.12.0
45
+ # via
46
+ # huggingface-hub
47
+ # procgen
48
+ # torch
49
+ # triton
50
+ # virtualenv
51
+ fsspec==2025.3.0 ; python_full_version < '3.9'
52
+ # via torch
53
+ fsspec==2025.5.1 ; python_full_version >= '3.9'
54
+ # via torch
55
+ gitdb==4.0.10
56
+ # via gitpython
57
+ gitpython==3.1.31
58
+ # via wandb
59
+ glcontext==2.3.7
60
+ # via moderngl
61
+ glfw==1.12.0
62
+ # via gym3
63
+ google-auth==2.18.0
64
+ # via
65
+ # google-auth-oauthlib
66
+ # tensorboard
67
+ google-auth-oauthlib==0.4.6
68
+ # via tensorboard
69
+ grpcio==1.54.0
70
+ # via tensorboard
71
+ gym==0.23.1
72
+ # via
73
+ # cleanrl
74
+ # procgen
75
+ gym-notices==0.0.8
76
+ # via gym
77
+ gym3==0.3.3
78
+ # via procgen
79
+ gymnasium==0.29.1
80
+ # via cleanrl
81
+ huggingface-hub==0.11.1
82
+ # via cleanrl
83
+ identify==2.5.24
84
+ # via pre-commit
85
+ idna==3.4
86
+ # via requests
87
+ imageio==2.28.1
88
+ # via
89
+ # gym3
90
+ # moviepy
91
+ imageio-ffmpeg==0.3.0
92
+ # via
93
+ # gym3
94
+ # moviepy
95
+ importlib-metadata==5.2.0 ; python_full_version < '3.10'
96
+ # via
97
+ # gym
98
+ # gymnasium
99
+ # markdown
100
+ jinja2==3.1.2
101
+ # via torch
102
+ markdown==3.3.7
103
+ # via tensorboard
104
+ markupsafe==2.1.2
105
+ # via
106
+ # jinja2
107
+ # werkzeug
108
+ moderngl==5.8.2
109
+ # via gym3
110
+ moviepy==1.0.3
111
+ # via cleanrl
112
+ mpmath==1.3.0
113
+ # via sympy
114
+ networkx==3.1 ; python_full_version < '3.9'
115
+ # via torch
116
+ networkx==3.2.1 ; python_full_version == '3.9.*'
117
+ # via torch
118
+ networkx==3.4.2 ; python_full_version >= '3.10'
119
+ # via torch
120
+ nodeenv==1.7.0
121
+ # via pre-commit
122
+ numpy==1.24.4
123
+ # via
124
+ # gym
125
+ # gym3
126
+ # gymnasium
127
+ # imageio
128
+ # moviepy
129
+ # procgen
130
+ # tensorboard
131
+ nvidia-cublas-cu12==12.1.3.1 ; platform_machine == 'x86_64' and sys_platform == 'linux'
132
+ # via
133
+ # nvidia-cudnn-cu12
134
+ # nvidia-cusolver-cu12
135
+ # torch
136
+ nvidia-cuda-cupti-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
137
+ # via torch
138
+ nvidia-cuda-nvrtc-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
139
+ # via torch
140
+ nvidia-cuda-runtime-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
141
+ # via torch
142
+ nvidia-cudnn-cu12==9.1.0.70 ; platform_machine == 'x86_64' and sys_platform == 'linux'
143
+ # via torch
144
+ nvidia-cufft-cu12==11.0.2.54 ; platform_machine == 'x86_64' and sys_platform == 'linux'
145
+ # via torch
146
+ nvidia-curand-cu12==10.3.2.106 ; platform_machine == 'x86_64' and sys_platform == 'linux'
147
+ # via torch
148
+ nvidia-cusolver-cu12==11.4.5.107 ; platform_machine == 'x86_64' and sys_platform == 'linux'
149
+ # via torch
150
+ nvidia-cusparse-cu12==12.1.0.106 ; platform_machine == 'x86_64' and sys_platform == 'linux'
151
+ # via
152
+ # nvidia-cusolver-cu12
153
+ # torch
154
+ nvidia-nccl-cu12==2.20.5 ; platform_machine == 'x86_64' and sys_platform == 'linux'
155
+ # via torch
156
+ nvidia-nvjitlink-cu12==12.4.127 ; python_full_version < '3.9' and platform_machine == 'x86_64' and sys_platform == 'linux'
157
+ # via
158
+ # nvidia-cusolver-cu12
159
+ # nvidia-cusparse-cu12
160
+ nvidia-nvjitlink-cu12==12.6.85 ; python_full_version >= '3.9' and platform_machine == 'x86_64' and sys_platform == 'linux'
161
+ # via
162
+ # nvidia-cusolver-cu12
163
+ # nvidia-cusparse-cu12
164
+ nvidia-nvtx-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
165
+ # via torch
166
+ oauthlib==3.2.2
167
+ # via requests-oauthlib
168
+ packaging==23.1
169
+ # via huggingface-hub
170
+ pathtools==0.1.2
171
+ # via wandb
172
+ pillow==9.5.0
173
+ # via imageio
174
+ platformdirs==3.5.0
175
+ # via virtualenv
176
+ pre-commit==2.21.0
177
+ procgen==0.10.7
178
+ # via cleanrl
179
+ proglog==0.1.10
180
+ # via moviepy
181
+ protobuf==3.20.3
182
+ # via
183
+ # tensorboard
184
+ # wandb
185
+ psutil==5.9.5
186
+ # via wandb
187
+ pyasn1==0.5.0
188
+ # via
189
+ # pyasn1-modules
190
+ # rsa
191
+ pyasn1-modules==0.3.0
192
+ # via google-auth
193
+ pycparser==2.21
194
+ # via cffi
195
+ pygame==2.1.0
196
+ # via cleanrl
197
+ pygments==2.15.1
198
+ # via rich
199
+ pyyaml==6.0.1
200
+ # via
201
+ # huggingface-hub
202
+ # pre-commit
203
+ # wandb
204
+ requests==2.30.0
205
+ # via
206
+ # huggingface-hub
207
+ # moviepy
208
+ # requests-oauthlib
209
+ # tensorboard
210
+ # wandb
211
+ requests-oauthlib==1.3.1
212
+ # via google-auth-oauthlib
213
+ rich==11.2.0
214
+ # via
215
+ # cleanrl
216
+ # tyro
217
+ rsa==4.7.2
218
+ # via google-auth
219
+ sentry-sdk==1.22.2
220
+ # via wandb
221
+ setproctitle==1.3.2
222
+ # via wandb
223
+ setuptools==67.7.2
224
+ # via
225
+ # nodeenv
226
+ # tensorboard
227
+ # wandb
228
+ shtab==1.6.4
229
+ # via tyro
230
+ six==1.16.0
231
+ # via
232
+ # docker-pycreds
233
+ # google-auth
234
+ smmap==5.0.0
235
+ # via gitdb
236
+ sympy==1.12.1 ; python_full_version < '3.9'
237
+ # via torch
238
+ sympy==1.14.0 ; python_full_version >= '3.9'
239
+ # via torch
240
+ tenacity==8.2.3
241
+ # via cleanrl
242
+ tensorboard==2.11.2
243
+ # via cleanrl
244
+ tensorboard-data-server==0.6.1
245
+ # via tensorboard
246
+ tensorboard-plugin-wit==1.8.1
247
+ # via tensorboard
248
+ torch==2.4.1
249
+ # via cleanrl
250
+ tqdm==4.65.0
251
+ # via
252
+ # huggingface-hub
253
+ # moviepy
254
+ # proglog
255
+ triton==3.0.0 ; platform_machine == 'x86_64' and sys_platform == 'linux'
256
+ # via torch
257
+ typing-extensions==4.13.2 ; python_full_version < '3.9'
258
+ # via
259
+ # gymnasium
260
+ # huggingface-hub
261
+ # torch
262
+ # tyro
263
+ # wandb
264
+ typing-extensions==4.14.1 ; python_full_version >= '3.9'
265
+ # via
266
+ # gymnasium
267
+ # huggingface-hub
268
+ # torch
269
+ # tyro
270
+ # wandb
271
+ tyro==0.5.10
272
+ # via cleanrl
273
+ urllib3==1.26.15
274
+ # via
275
+ # google-auth
276
+ # requests
277
+ # sentry-sdk
278
+ virtualenv==20.21.0
279
+ # via pre-commit
280
+ wandb==0.13.11
281
+ # via cleanrl
282
+ werkzeug==2.2.3
283
+ # via tensorboard
284
+ wheel==0.40.0
285
+ # via tensorboard
286
+ zipp==3.15.0 ; python_full_version < '3.10'
287
+ # via importlib-metadata
cleanrl/requirements/requirements.txt ADDED
@@ -0,0 +1,264 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file was autogenerated by uv via the following command:
2
+ # uv export --no-hashes --output-file requirements/requirements.txt
3
+ -e .
4
+ absl-py==1.4.0
5
+ # via tensorboard
6
+ appdirs==1.4.4
7
+ # via wandb
8
+ cachetools==5.3.0
9
+ # via google-auth
10
+ certifi==2023.5.7
11
+ # via
12
+ # requests
13
+ # sentry-sdk
14
+ cfgv==3.3.1
15
+ # via pre-commit
16
+ charset-normalizer==3.1.0
17
+ # via requests
18
+ click==8.1.3
19
+ # via wandb
20
+ cloudpickle==2.2.1
21
+ # via
22
+ # gym
23
+ # gymnasium
24
+ colorama==0.4.4
25
+ # via
26
+ # click
27
+ # rich
28
+ # tqdm
29
+ # tyro
30
+ commonmark==0.9.1
31
+ # via rich
32
+ decorator==4.4.2
33
+ # via moviepy
34
+ distlib==0.3.6
35
+ # via virtualenv
36
+ docker-pycreds==0.4.0
37
+ # via wandb
38
+ docstring-parser==0.15
39
+ # via tyro
40
+ farama-notifications==0.0.4
41
+ # via gymnasium
42
+ filelock==3.12.0
43
+ # via
44
+ # huggingface-hub
45
+ # torch
46
+ # triton
47
+ # virtualenv
48
+ fsspec==2025.3.0 ; python_full_version < '3.9'
49
+ # via torch
50
+ fsspec==2025.5.1 ; python_full_version >= '3.9'
51
+ # via torch
52
+ gitdb==4.0.10
53
+ # via gitpython
54
+ gitpython==3.1.31
55
+ # via wandb
56
+ google-auth==2.18.0
57
+ # via
58
+ # google-auth-oauthlib
59
+ # tensorboard
60
+ google-auth-oauthlib==0.4.6
61
+ # via tensorboard
62
+ grpcio==1.54.0
63
+ # via tensorboard
64
+ gym==0.23.1
65
+ # via cleanrl
66
+ gym-notices==0.0.8
67
+ # via gym
68
+ gymnasium==0.29.1
69
+ # via cleanrl
70
+ huggingface-hub==0.11.1
71
+ # via cleanrl
72
+ identify==2.5.24
73
+ # via pre-commit
74
+ idna==3.4
75
+ # via requests
76
+ imageio==2.28.1
77
+ # via moviepy
78
+ imageio-ffmpeg==0.3.0
79
+ # via moviepy
80
+ importlib-metadata==5.2.0 ; python_full_version < '3.10'
81
+ # via
82
+ # gym
83
+ # gymnasium
84
+ # markdown
85
+ jinja2==3.1.2
86
+ # via torch
87
+ markdown==3.3.7
88
+ # via tensorboard
89
+ markupsafe==2.1.2
90
+ # via
91
+ # jinja2
92
+ # werkzeug
93
+ moviepy==1.0.3
94
+ # via cleanrl
95
+ mpmath==1.3.0
96
+ # via sympy
97
+ networkx==3.1 ; python_full_version < '3.9'
98
+ # via torch
99
+ networkx==3.2.1 ; python_full_version == '3.9.*'
100
+ # via torch
101
+ networkx==3.4.2 ; python_full_version >= '3.10'
102
+ # via torch
103
+ nodeenv==1.7.0
104
+ # via pre-commit
105
+ numpy==1.24.4
106
+ # via
107
+ # gym
108
+ # gymnasium
109
+ # imageio
110
+ # moviepy
111
+ # tensorboard
112
+ nvidia-cublas-cu12==12.1.3.1 ; platform_machine == 'x86_64' and sys_platform == 'linux'
113
+ # via
114
+ # nvidia-cudnn-cu12
115
+ # nvidia-cusolver-cu12
116
+ # torch
117
+ nvidia-cuda-cupti-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
118
+ # via torch
119
+ nvidia-cuda-nvrtc-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
120
+ # via torch
121
+ nvidia-cuda-runtime-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
122
+ # via torch
123
+ nvidia-cudnn-cu12==9.1.0.70 ; platform_machine == 'x86_64' and sys_platform == 'linux'
124
+ # via torch
125
+ nvidia-cufft-cu12==11.0.2.54 ; platform_machine == 'x86_64' and sys_platform == 'linux'
126
+ # via torch
127
+ nvidia-curand-cu12==10.3.2.106 ; platform_machine == 'x86_64' and sys_platform == 'linux'
128
+ # via torch
129
+ nvidia-cusolver-cu12==11.4.5.107 ; platform_machine == 'x86_64' and sys_platform == 'linux'
130
+ # via torch
131
+ nvidia-cusparse-cu12==12.1.0.106 ; platform_machine == 'x86_64' and sys_platform == 'linux'
132
+ # via
133
+ # nvidia-cusolver-cu12
134
+ # torch
135
+ nvidia-nccl-cu12==2.20.5 ; platform_machine == 'x86_64' and sys_platform == 'linux'
136
+ # via torch
137
+ nvidia-nvjitlink-cu12==12.4.127 ; python_full_version < '3.9' and platform_machine == 'x86_64' and sys_platform == 'linux'
138
+ # via
139
+ # nvidia-cusolver-cu12
140
+ # nvidia-cusparse-cu12
141
+ nvidia-nvjitlink-cu12==12.6.85 ; python_full_version >= '3.9' and platform_machine == 'x86_64' and sys_platform == 'linux'
142
+ # via
143
+ # nvidia-cusolver-cu12
144
+ # nvidia-cusparse-cu12
145
+ nvidia-nvtx-cu12==12.1.105 ; platform_machine == 'x86_64' and sys_platform == 'linux'
146
+ # via torch
147
+ oauthlib==3.2.2
148
+ # via requests-oauthlib
149
+ packaging==23.1
150
+ # via huggingface-hub
151
+ pathtools==0.1.2
152
+ # via wandb
153
+ pillow==9.5.0
154
+ # via imageio
155
+ platformdirs==3.5.0
156
+ # via virtualenv
157
+ pre-commit==2.21.0
158
+ proglog==0.1.10
159
+ # via moviepy
160
+ protobuf==3.20.3
161
+ # via
162
+ # tensorboard
163
+ # wandb
164
+ psutil==5.9.5
165
+ # via wandb
166
+ pyasn1==0.5.0
167
+ # via
168
+ # pyasn1-modules
169
+ # rsa
170
+ pyasn1-modules==0.3.0
171
+ # via google-auth
172
+ pygame==2.1.0
173
+ # via cleanrl
174
+ pygments==2.15.1
175
+ # via rich
176
+ pyyaml==6.0.1
177
+ # via
178
+ # huggingface-hub
179
+ # pre-commit
180
+ # wandb
181
+ requests==2.30.0
182
+ # via
183
+ # huggingface-hub
184
+ # moviepy
185
+ # requests-oauthlib
186
+ # tensorboard
187
+ # wandb
188
+ requests-oauthlib==1.3.1
189
+ # via google-auth-oauthlib
190
+ rich==11.2.0
191
+ # via
192
+ # cleanrl
193
+ # tyro
194
+ rsa==4.7.2
195
+ # via google-auth
196
+ sentry-sdk==1.22.2
197
+ # via wandb
198
+ setproctitle==1.3.2
199
+ # via wandb
200
+ setuptools==67.7.2
201
+ # via
202
+ # nodeenv
203
+ # tensorboard
204
+ # wandb
205
+ shtab==1.6.4
206
+ # via tyro
207
+ six==1.16.0
208
+ # via
209
+ # docker-pycreds
210
+ # google-auth
211
+ smmap==5.0.0
212
+ # via gitdb
213
+ sympy==1.12.1 ; python_full_version < '3.9'
214
+ # via torch
215
+ sympy==1.14.0 ; python_full_version >= '3.9'
216
+ # via torch
217
+ tenacity==8.2.3
218
+ # via cleanrl
219
+ tensorboard==2.11.2
220
+ # via cleanrl
221
+ tensorboard-data-server==0.6.1
222
+ # via tensorboard
223
+ tensorboard-plugin-wit==1.8.1
224
+ # via tensorboard
225
+ torch==2.4.1
226
+ # via cleanrl
227
+ tqdm==4.65.0
228
+ # via
229
+ # huggingface-hub
230
+ # moviepy
231
+ # proglog
232
+ triton==3.0.0 ; platform_machine == 'x86_64' and sys_platform == 'linux'
233
+ # via torch
234
+ typing-extensions==4.13.2 ; python_full_version < '3.9'
235
+ # via
236
+ # gymnasium
237
+ # huggingface-hub
238
+ # torch
239
+ # tyro
240
+ # wandb
241
+ typing-extensions==4.14.1 ; python_full_version >= '3.9'
242
+ # via
243
+ # gymnasium
244
+ # huggingface-hub
245
+ # torch
246
+ # tyro
247
+ # wandb
248
+ tyro==0.5.10
249
+ # via cleanrl
250
+ urllib3==1.26.15
251
+ # via
252
+ # google-auth
253
+ # requests
254
+ # sentry-sdk
255
+ virtualenv==20.21.0
256
+ # via pre-commit
257
+ wandb==0.13.11
258
+ # via cleanrl
259
+ werkzeug==2.2.3
260
+ # via tensorboard
261
+ wheel==0.40.0
262
+ # via tensorboard
263
+ zipp==3.15.0 ; python_full_version < '3.10'
264
+ # via importlib-metadata
cleanrl/runs/Ultrahorizon-v0__ppo_ultrahorizon__1_EASY__1761810199/test_iter_732.json ADDED
The diff for this file is too large to render. See raw diff
 
cleanrl/tests/test_atari.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+
3
+
4
+ def test_ppo():
5
+ subprocess.run(
6
+ "python cleanrl/ppo_atari.py --num-envs 1 --num-steps 64 --total-timesteps 256",
7
+ shell=True,
8
+ check=True,
9
+ )
10
+
11
+
12
+ def test_ppo_lstm():
13
+ subprocess.run(
14
+ "python cleanrl/ppo_atari_lstm.py --num-envs 4 --num-steps 64 --total-timesteps 256",
15
+ shell=True,
16
+ check=True,
17
+ )
cleanrl/tests/test_atari_gymnasium.py ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+
3
+
4
+ def test_dqn():
5
+ subprocess.run(
6
+ "python cleanrl/dqn_atari.py --learning-starts 10 --total-timesteps 16 --buffer-size 10 --batch-size 4",
7
+ shell=True,
8
+ check=True,
9
+ )
10
+
11
+
12
+ def test_dqn_eval():
13
+ subprocess.run(
14
+ "python cleanrl/dqn_atari.py --save-model --learning-starts 10 --total-timesteps 16 --buffer-size 10 --batch-size 4",
15
+ shell=True,
16
+ check=True,
17
+ )
18
+
19
+
20
+ def test_qdagger_dqn_atari_impalacnn():
21
+ subprocess.run(
22
+ "python cleanrl/qdagger_dqn_atari_impalacnn.py --learning-starts 10 --total-timesteps 16 --buffer-size 10 --batch-size 4 --teacher-steps 16 --offline-steps 16 --teacher-eval-episodes 1",
23
+ shell=True,
24
+ check=True,
25
+ )
26
+
27
+
28
+ def test_qdagger_dqn_atari_impalacnn_eval():
29
+ subprocess.run(
30
+ "python cleanrl/qdagger_dqn_atari_impalacnn.py --save-model --learning-starts 10 --total-timesteps 16 --buffer-size 10 --batch-size 4 --teacher-steps 16 --offline-steps 16 --teacher-eval-episodes 1",
31
+ shell=True,
32
+ check=True,
33
+ )
34
+
35
+
36
+ def test_c51_atari():
37
+ subprocess.run(
38
+ "python cleanrl/c51_atari.py --learning-starts 10 --total-timesteps 16 --buffer-size 10 --batch-size 4",
39
+ shell=True,
40
+ check=True,
41
+ )
42
+
43
+
44
+ def test_c51_atari_eval():
45
+ subprocess.run(
46
+ "python cleanrl/c51_atari.py --save-model --learning-starts 10 --total-timesteps 16 --buffer-size 10 --batch-size 4",
47
+ shell=True,
48
+ check=True,
49
+ )
50
+
51
+
52
+ def test_rainbow_atari():
53
+ subprocess.run(
54
+ "python cleanrl/rainbow_atari.py --learning-starts 10 --total-timesteps 16 --buffer-size 10 --batch-size 4",
55
+ shell=True,
56
+ check=True,
57
+ )
58
+
59
+
60
+ def test_rainbow_atari_eval():
61
+ subprocess.run(
62
+ "python cleanrl/rainbow_atari.py --save-model --learning-starts 10 --total-timesteps 16 --buffer-size 10 --batch-size 4",
63
+ shell=True,
64
+ check=True,
65
+ )
66
+
67
+
68
+ def test_sac():
69
+ subprocess.run(
70
+ "python cleanrl/sac_atari.py --learning-starts 10 --total-timesteps 16 --buffer-size 10 --batch-size 4",
71
+ shell=True,
72
+ check=True,
73
+ )
cleanrl/tests/test_atari_jax_gymnasium.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+
3
+
4
+ def test_dqn_jax():
5
+ subprocess.run(
6
+ "python cleanrl/dqn_atari_jax.py --learning-starts 10 --total-timesteps 16 --buffer-size 10 --batch-size 4",
7
+ shell=True,
8
+ check=True,
9
+ )
10
+
11
+
12
+ def test_dqn_jax_eval():
13
+ subprocess.run(
14
+ "python cleanrl/dqn_atari_jax.py --save-model --learning-starts 10 --total-timesteps 16 --buffer-size 10 --batch-size 4",
15
+ shell=True,
16
+ check=True,
17
+ )
18
+
19
+
20
+ def test_qdagger_dqn_atari_jax_impalacnn():
21
+ subprocess.run(
22
+ "python cleanrl/qdagger_dqn_atari_jax_impalacnn.py --learning-starts 10 --total-timesteps 16 --buffer-size 10 --batch-size 4 --teacher-steps 16 --offline-steps 16 --teacher-eval-episodes 1",
23
+ shell=True,
24
+ check=True,
25
+ )
26
+
27
+
28
+ def test_qdagger_dqn_atari_jax_impalacnn_eval():
29
+ subprocess.run(
30
+ "python cleanrl/qdagger_dqn_atari_jax_impalacnn.py --save-model --learning-starts 10 --total-timesteps 16 --buffer-size 10 --batch-size 4 --teacher-steps 16 --offline-steps 16 --teacher-eval-episodes 1",
31
+ shell=True,
32
+ check=True,
33
+ )
34
+
35
+
36
+ def test_c51_atari_jax():
37
+ subprocess.run(
38
+ "python cleanrl/c51_atari_jax.py --learning-starts 10 --total-timesteps 16 --buffer-size 10 --batch-size 4",
39
+ shell=True,
40
+ check=True,
41
+ )
42
+
43
+
44
+ def test_c51_atari_jax_eval():
45
+ subprocess.run(
46
+ "python cleanrl/c51_atari_jax.py --save-model --learning-starts 10 --total-timesteps 16 --buffer-size 10 --batch-size 4",
47
+ shell=True,
48
+ check=True,
49
+ )
cleanrl/tests/test_atari_multigpu.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+
3
+
4
+ def test_ppo_multigpu():
5
+ subprocess.run(
6
+ "torchrun --standalone --nnodes=1 --nproc_per_node=2 cleanrl/ppo_atari_multigpu.py --num-envs 8 --num-steps 32 --total-timesteps 256",
7
+ shell=True,
8
+ check=True,
9
+ )
cleanrl/tests/test_classic_control.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+
3
+
4
+ def test_ppo():
5
+ subprocess.run(
6
+ "python cleanrl/ppo.py --num-envs 1 --num-steps 64 --total-timesteps 256",
7
+ shell=True,
8
+ check=True,
9
+ )
cleanrl/tests/test_classic_control_gymnasium.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+
3
+
4
+ def test_dqn():
5
+ subprocess.run(
6
+ "python cleanrl/dqn.py --learning-starts 200 --total-timesteps 205",
7
+ shell=True,
8
+ check=True,
9
+ )
10
+
11
+
12
+ def test_c51():
13
+ subprocess.run(
14
+ "python cleanrl/c51.py --learning-starts 200 --total-timesteps 205",
15
+ shell=True,
16
+ check=True,
17
+ )
18
+
19
+
20
+ def test_c51_eval():
21
+ subprocess.run(
22
+ "python cleanrl/c51.py --save-model --learning-starts 200 --total-timesteps 205",
23
+ shell=True,
24
+ check=True,
25
+ )
cleanrl/tests/test_classic_control_jax_gymnasium.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+
3
+
4
+ def test_dqn_jax():
5
+ subprocess.run(
6
+ "python cleanrl/dqn_jax.py --learning-starts 200 --total-timesteps 205",
7
+ shell=True,
8
+ check=True,
9
+ )
10
+
11
+
12
+ def test_c51_jax():
13
+ subprocess.run(
14
+ "python cleanrl/c51_jax.py --learning-starts 200 --total-timesteps 205",
15
+ shell=True,
16
+ check=True,
17
+ )
18
+
19
+
20
+ def test_c51_jax_eval():
21
+ subprocess.run(
22
+ "python cleanrl/c51_jax.py --save-model --learning-starts 200 --total-timesteps 205",
23
+ shell=True,
24
+ check=True,
25
+ )
cleanrl/tests/test_enjoy.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+
3
+
4
+ def test_dqn():
5
+ subprocess.run(
6
+ "python enjoy.py --exp-name dqn --env CartPole-v1 --eval-episodes 1",
7
+ shell=True,
8
+ check=True,
9
+ )
10
+
11
+
12
+ def test_dqn_atari():
13
+ subprocess.run(
14
+ "python enjoy.py --exp-name dqn_atari --env BreakoutNoFrameskip-v4 --eval-episodes 1",
15
+ shell=True,
16
+ check=True,
17
+ )
18
+
19
+
20
+ def test_dqn_jax():
21
+ subprocess.run(
22
+ "python enjoy.py --exp-name dqn_jax --env CartPole-v1 --eval-episodes 1",
23
+ shell=True,
24
+ check=True,
25
+ )