x-ppo 0.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
x_ppo/__init__.py ADDED
@@ -0,0 +1 @@
1
+ from x_ppo.ppo import ppo_actor_loss
x_ppo/ppo.py ADDED
@@ -0,0 +1,30 @@
1
+ import torch
2
+ from torch_einops_utils import z_score, masked_mean
3
+
4
+ # helpers
5
+
6
+ def exists(val):
7
+ return val is not None
8
+
9
+ def ppo_actor_loss(
10
+ action_log_probs,
11
+ old_action_log_probs,
12
+ advantages,
13
+ eps_clip = 0.2,
14
+ mask = None,
15
+ normalize_advantages = False
16
+ ):
17
+ if normalize_advantages:
18
+ advantages = z_score(advantages, mask = mask)
19
+
20
+ ratios = (action_log_probs - old_action_log_probs).exp()
21
+
22
+ surr1 = ratios * advantages
23
+ surr2 = ratios.clamp(1. - eps_clip, 1. + eps_clip) * advantages
24
+
25
+ loss = - torch.min(surr1, surr2)
26
+
27
+ if not exists(mask):
28
+ return loss
29
+
30
+ return masked_mean(loss, mask = mask)
@@ -0,0 +1,278 @@
1
+ Metadata-Version: 2.5
2
+ Name: x-ppo
3
+ Version: 0.0.1
4
+ Summary: PPO
5
+ Project-URL: Homepage, https://pypi.org/project/x-ppo/
6
+ Project-URL: Repository, https://github.com/lucidrains/x-ppo
7
+ Author-email: Phil Wang <lucidrains@gmail.com>
8
+ License: MIT License
9
+
10
+ Copyright (c) 2020 Phil Wang
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
29
+ License-File: LICENSE
30
+ Keywords: artificial intelligence,deep learning,proximal policy optimization,reinforcement learning
31
+ Classifier: Development Status :: 4 - Beta
32
+ Classifier: Intended Audience :: Developers
33
+ Classifier: License :: OSI Approved :: MIT License
34
+ Classifier: Programming Language :: Python :: 3.10
35
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
36
+ Requires-Python: >=3.10
37
+ Requires-Dist: torch-einops-utils>=0.1.24
38
+ Requires-Dist: torch>=2.4
39
+ Provides-Extra: examples
40
+ Provides-Extra: test
41
+ Requires-Dist: pytest; extra == 'test'
42
+ Description-Content-Type: text/markdown
43
+
44
+ <img src="./lunar.gif" width="400px"></img>
45
+
46
+ *1k steps*
47
+
48
+ ## PPO
49
+
50
+ An implementation of PPO with recent random improvements
51
+
52
+ The phasic part has been removed, repository to be renamed. I do not think it does anything
53
+
54
+ ## Install
55
+
56
+ ```bash
57
+ $ pip install -r requirements.txt
58
+ ```
59
+
60
+ You may need to install `swig`
61
+
62
+ ```bash
63
+ $ apt install swig
64
+ ```
65
+
66
+ ## Use
67
+
68
+ ```bash
69
+ $ python train.py
70
+ ```
71
+
72
+ ## Citations
73
+
74
+ ```bibtex
75
+ @article{Schulman2017ProximalPO,
76
+ title = {Proximal Policy Optimization Algorithms},
77
+ author = {John Schulman and Filip Wolski and Prafulla Dhariwal and Alec Radford and Oleg Klimov},
78
+ journal = {ArXiv},
79
+ year = {2017},
80
+ volume = {abs/1707.06347},
81
+ url = {https://api.semanticscholar.org/CorpusID:28695052}
82
+ }
83
+ ```
84
+
85
+ ```bibtex
86
+ @article{Zhang2024ReLU2WD,
87
+ title = {ReLU2 Wins: Discovering Efficient Activation Functions for Sparse LLMs},
88
+ author = {Zhengyan Zhang and Yixin Song and Guanghui Yu and Xu Han and Yankai Lin and Chaojun Xiao and Chenyang Song and Zhiyuan Liu and Zeyu Mi and Maosong Sun},
89
+ journal = {ArXiv},
90
+ year = {2024},
91
+ volume = {abs/2402.03804},
92
+ url = {https://api.semanticscholar.org/CorpusID:267499856}
93
+ }
94
+ ```
95
+
96
+ ```bibtex
97
+ @inproceedings{Lee2024SimBaSB,
98
+ title = {SimBa: Simplicity Bias for Scaling Up Parameters in Deep Reinforcement Learning},
99
+ author = {Hojoon Lee and Dongyoon Hwang and Donghu Kim and Hyunseung Kim and Jun Jet Tai and Kaushik Subramanian and Peter R. Wurman and Jaegul Choo and Peter Stone and Takuma Seno},
100
+ year = {2024},
101
+ url = {https://api.semanticscholar.org/CorpusID:273346233}
102
+ }
103
+ ```
104
+
105
+ ```bibtex
106
+ @inproceedings{anonymous2024the,
107
+ title = {The Complexity Dynamics of Grokking},
108
+ author = {Anonymous},
109
+ booktitle = {Submitted to The Thirteenth International Conference on Learning Representations},
110
+ year = {2024},
111
+ url = {https://openreview.net/forum?id=07N9jCfIE4},
112
+ note = {under review}
113
+ }
114
+ ```
115
+
116
+ ```bibtex
117
+ @article{Yang2020LearningLD,
118
+ title = {Learning Low-rank Deep Neural Networks via Singular Vector Orthogonality Regularization and Singular Value Sparsification},
119
+ author = {Huanrui Yang and Minxue Tang and Wei Wen and Feng Yan and Daniel Hu and Ang Li and Hai Helen Li and Yiran Chen},
120
+ journal = {2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops (CVPRW)},
121
+ year = {2020},
122
+ pages = {2899-2908},
123
+ url = {https://api.semanticscholar.org/CorpusID:213940794}
124
+ }
125
+ ```
126
+
127
+ ```bibtex
128
+ @article{Farebrother2024StopRT,
129
+ title = {Stop Regressing: Training Value Functions via Classification for Scalable Deep RL},
130
+ author = {Jesse Farebrother and Jordi Orbay and Quan Ho Vuong and Adrien Ali Taiga and Yevgen Chebotar and Ted Xiao and Alex Irpan and Sergey Levine and Pablo Samuel Castro and Aleksandra Faust and Aviral Kumar and Rishabh Agarwal},
131
+ journal = {ArXiv},
132
+ year = {2024},
133
+ volume = {abs/2403.03950},
134
+ url = {https://api.semanticscholar.org/CorpusID:268253088}
135
+ }
136
+ ```
137
+
138
+ ```bibtex
139
+ @article{Lee2024AnalysisClippedCritic,
140
+ title = {On Analysis of Clipped Critic Loss in Proximal Policy Gradient},
141
+ author = {Yongjin Lee, Moonyoung Chung},
142
+ journal = {Authorea},
143
+ year = {2024}
144
+ }
145
+ ```
146
+
147
+ ```bibtex
148
+ @inproceedings{Felizardo2025ARL,
149
+ title = {A Reinforcement Learning Method for Environments with Stochastic Variables: Post-Decision Proximal Policy Optimization with Dual Critic Networks},
150
+ author = {Leonardo Kanashiro Felizardo and Edoardo Fadda and Paolo Brandimarte and Emilio Del-Moral-Hernandez and Mari'a Cristina Vasconcelos Nascimento},
151
+ year = {2025},
152
+ url = {https://api.semanticscholar.org/CorpusID:277621941}
153
+ }
154
+ ```
155
+
156
+ ```bibtex
157
+ @misc{xie2025simplepolicyoptimization,
158
+ title = {Simple Policy Optimization},
159
+ author = {Zhengpeng Xie and Qiang Zhang and Fan Yang and Marco Hutter and Renjing Xu},
160
+ year = {2025},
161
+ eprint = {2401.16025},
162
+ archivePrefix = {arXiv},
163
+ primaryClass = {cs.LG},
164
+ url = {https://arxiv.org/abs/2401.16025},
165
+ }
166
+ ```
167
+
168
+ ```bibtex
169
+ @inproceedings{anonymous2025flow,
170
+ title = {Flow Policy Gradients for Legged Robots},
171
+ author = {Anonymous},
172
+ booktitle = {Submitted to The Fourteenth International Conference on Learning Representations},
173
+ year = {2025},
174
+ url = {https://openreview.net/forum?id=BA6n0nmagi},
175
+ note = {under review}
176
+ }
177
+ ```
178
+
179
+ ```bibtex
180
+ @inproceedings{Seitzer2022Pitfalls,
181
+ title = {On the Pitfalls of Heteroscedastic Uncertainty Estimation with Probabilistic Neural Networks},
182
+ author = {Maximilian Seitzer and Abdul-Saboor Sheikh and Georg Martius},
183
+ booktitle = {International Conference on Learning Representations},
184
+ year = {2022},
185
+ url = {https://openreview.net/forum?id=9O_xF9y7A-}
186
+ }
187
+ ```
188
+
189
+ ```bibtex
190
+ @inproceedings{Wang2025EvolutionaryPO,
191
+ title = {Evolutionary Policy Optimization},
192
+ author = {Jianren Wang and Yifan Su and Abhinav Gupta and Deepak Pathak},
193
+ booktitle = {Advances in Neural Information Processing Systems},
194
+ year = {2025},
195
+ url = {https://arxiv.org/abs/2503.19037}
196
+ }
197
+ ```
198
+
199
+ ```bibtex
200
+ @misc{osband2026delightfulpolicygradient,
201
+ title = {Delightful Policy Gradient},
202
+ author = {Ian Osband},
203
+ year = {2026},
204
+ eprint = {2603.14608},
205
+ archivePrefix = {arXiv},
206
+ primaryClass = {cs.LG},
207
+ url = {https://arxiv.org/abs/2603.14608},
208
+ }
209
+ ```
210
+
211
+ ```bibtex
212
+ @misc{eysenbach2018diversityneedlearningskills,
213
+ title = {Diversity is All You Need: Learning Skills without a Reward Function},
214
+ author = {Benjamin Eysenbach and Abhishek Gupta and Julian Ibarz and Sergey Levine},
215
+ year = {2018},
216
+ eprint = {1802.06070},
217
+ archivePrefix = {arXiv},
218
+ primaryClass = {cs.AI},
219
+ url = {https://arxiv.org/abs/1802.06070},
220
+ }
221
+ ```
222
+
223
+ ```bibtex
224
+ @misc{mustafaoglu2025evolutionarypolicyoptimization,
225
+ title = {Evolutionary Policy Optimization},
226
+ author = {Zelal Su "Lain" Mustafaoglu and Keshav Pingali and Risto Miikkulainen},
227
+ year = {2025},
228
+ eprint = {2504.12568},
229
+ archivePrefix = {arXiv},
230
+ primaryClass = {cs.LG},
231
+ url = {https://arxiv.org/abs/2504.12568},
232
+ }
233
+ ```
234
+
235
+ ```bibtex
236
+ @misc{han2026firefrobeniusisometryreinitializationbalancing,
237
+ title = {FIRE: Frobenius-Isometry Reinitialization for Balancing the Stability-Plasticity Tradeoff},
238
+ author = {Isaac Han and Sangyeon Park and Seungwon Oh and Donghu Kim and Hojoon Lee and Kyung-Joong Kim},
239
+ year = {2026},
240
+ eprint = {2602.08040},
241
+ archivePrefix = {arXiv},
242
+ primaryClass = {cs.LG},
243
+ url = {https://arxiv.org/abs/2602.08040},
244
+ }
245
+ ```
246
+
247
+ ```bibtex
248
+ @misc{tian2026chunkingcritic,
249
+ title = {Chunking the Critic: A Transformer-based Soft Actor-Critic with N-Step Returns},
250
+ author = {Dong Tian and Onur Celik and Gerhard Neumann},
251
+ year = {2026},
252
+ eprint = {2503.03660},
253
+ archivePrefix = {arXiv},
254
+ primaryClass = {cs.LG},
255
+ url = {https://arxiv.org/abs/2503.03660},
256
+ }
257
+ ```
258
+
259
+ ```bibtex
260
+ @misc{hahn2025action,
261
+ title = {Action Chunking Proximal Policy Optimization for Universal Robotic Dexterous Grasping},
262
+ author = {Sanghyun Hahn and Jonghyun Choi},
263
+ year = {2025},
264
+ url = {https://openreview.net/forum?id=WFQnqY1c39}
265
+ }
266
+ ```
267
+
268
+ ```bibtex
269
+ @misc{shin2026adaptiveactionchunkingmultichunk,
270
+ title = {Adaptive Action Chunking via Multi-Chunk Q Value Estimation},
271
+ author = {Yongjae Shin and Jongseong Chae and Seongmin Kim and Jongeui Park and Youngchul Sung},
272
+ year = {2026},
273
+ eprint = {2605.10044},
274
+ archivePrefix = {arXiv},
275
+ primaryClass = {cs.LG},
276
+ url = {https://arxiv.org/abs/2605.10044},
277
+ }
278
+ ```
@@ -0,0 +1,6 @@
1
+ x_ppo/__init__.py,sha256=Ojy4-7PYWDZuEs-nkHDlfOmxs93EWXN95B6msFfGD7g,37
2
+ x_ppo/ppo.py,sha256=pHG8HNAAsUnX2iM-8d_Skg6e3MZeFUOFDRshc2yCFJ4,652
3
+ x_ppo-0.0.1.dist-info/METADATA,sha256=YNnsxA3o37mj6V0jmaTUqb9KIuHi_4FmG5exnvdor5U,9704
4
+ x_ppo-0.0.1.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
5
+ x_ppo-0.0.1.dist-info/licenses/LICENSE,sha256=As9u198X-U-vph5noInuUfqsAG2zX_oXPHDmdjwlPPY,1066
6
+ x_ppo-0.0.1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.32.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Phil Wang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ 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 THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.