SEA-pytorch 0.0.1__tar.gz

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.
@@ -0,0 +1,225 @@
1
+ *.sh
2
+
3
+ # Byte-compiled / optimized / DLL files
4
+ __pycache__/
5
+ *.py[codz]
6
+ *$py.class
7
+
8
+ # C extensions
9
+ *.so
10
+
11
+ # Distribution / packaging
12
+ .Python
13
+ build/
14
+ develop-eggs/
15
+ dist/
16
+ downloads/
17
+ eggs/
18
+ .eggs/
19
+ lib/
20
+ lib64/
21
+ parts/
22
+ sdist/
23
+ var/
24
+ wheels/
25
+ share/python-wheels/
26
+ *.egg-info/
27
+ .installed.cfg
28
+ *.egg
29
+ MANIFEST
30
+
31
+ # PyInstaller
32
+ # Usually these files are written by a python script from a template
33
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
34
+ *.manifest
35
+ *.spec
36
+
37
+ # Installer logs
38
+ pip-log.txt
39
+ pip-delete-this-directory.txt
40
+
41
+ # Unit test / coverage reports
42
+ htmlcov/
43
+ .tox/
44
+ .nox/
45
+ .coverage
46
+ .coverage.*
47
+ .cache
48
+ nosetests.xml
49
+ coverage.xml
50
+ *.cover
51
+ *.py.cover
52
+ *.lcov
53
+ .hypothesis/
54
+ .pytest_cache/
55
+ cover/
56
+
57
+ # Translations
58
+ *.mo
59
+ *.pot
60
+
61
+ # Django stuff:
62
+ *.log
63
+ local_settings.py
64
+ db.sqlite3
65
+ db.sqlite3-journal
66
+
67
+ # Flask stuff:
68
+ instance/
69
+ .webassets-cache
70
+
71
+ # Scrapy stuff:
72
+ .scrapy
73
+
74
+ # Sphinx documentation
75
+ docs/_build/
76
+
77
+ # PyBuilder
78
+ .pybuilder/
79
+ target/
80
+
81
+ # Jupyter Notebook
82
+ .ipynb_checkpoints
83
+
84
+ # IPython
85
+ profile_default/
86
+ ipython_config.py
87
+
88
+ # pyenv
89
+ # For a library or package, you might want to ignore these files since the code is
90
+ # intended to run in multiple environments; otherwise, check them in:
91
+ # .python-version
92
+
93
+ # pipenv
94
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
95
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
96
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
97
+ # install all needed dependencies.
98
+ # Pipfile.lock
99
+
100
+ # uv
101
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
102
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
103
+ # commonly ignored for libraries.
104
+ # uv.lock
105
+
106
+ # poetry
107
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
108
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
109
+ # commonly ignored for libraries.
110
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
111
+ # poetry.lock
112
+ # poetry.toml
113
+
114
+ # pdm
115
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
116
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
117
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
118
+ # pdm.lock
119
+ # pdm.toml
120
+ .pdm-python
121
+ .pdm-build/
122
+
123
+ # pixi
124
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
125
+ # pixi.lock
126
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
127
+ # in the .venv directory. It is recommended not to include this directory in version control.
128
+ .pixi/*
129
+ !.pixi/config.toml
130
+
131
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
132
+ __pypackages__/
133
+
134
+ # Celery stuff
135
+ celerybeat-schedule*
136
+ celerybeat.pid
137
+
138
+ # Redis
139
+ *.rdb
140
+ *.aof
141
+ *.pid
142
+
143
+ # RabbitMQ
144
+ mnesia/
145
+ rabbitmq/
146
+ rabbitmq-data/
147
+
148
+ # ActiveMQ
149
+ activemq-data/
150
+
151
+ # SageMath parsed files
152
+ *.sage.py
153
+
154
+ # Environments
155
+ .env
156
+ .envrc
157
+ .venv
158
+ env/
159
+ venv/
160
+ ENV/
161
+ env.bak/
162
+ venv.bak/
163
+
164
+ # Conda environments
165
+ conda-meta/
166
+
167
+ # Spyder project settings
168
+ .spyderproject
169
+ .spyproject
170
+
171
+ # Rope project settings
172
+ .ropeproject
173
+
174
+ # mkdocs/Zensical documentation
175
+ /site
176
+
177
+ # mypy
178
+ .mypy_cache/
179
+ .dmypy.json
180
+ dmypy.json
181
+
182
+ # Pyre type checker
183
+ .pyre/
184
+
185
+ # pytype static type analyzer
186
+ .pytype/
187
+
188
+ # Cython debug symbols
189
+ cython_debug/
190
+
191
+ # PyCharm
192
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
193
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
194
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
195
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
196
+ # .idea/
197
+
198
+ # Abstra
199
+ # Abstra is an AI-powered process automation framework.
200
+ # Ignore directories containing user credentials, local state, and settings.
201
+ # Learn more at https://abstra.io/docs
202
+ .abstra/
203
+
204
+ # Visual Studio Code
205
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore that
206
+ # can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
207
+ # and can be added to the global gitignore or merged into this file. However, if you prefer, you
208
+ # could uncomment the following to ignore the entire vscode folder
209
+ # .vscode/
210
+ # Temporary file for partial code execution
211
+ tempCodeRunnerFile.py
212
+
213
+ # Ruff stuff:
214
+ .ruff_cache/
215
+
216
+ # PyPI configuration file
217
+ .pypirc
218
+
219
+ # Marimo
220
+ marimo/_static/
221
+ marimo/_lsp/
222
+ __marimo__/
223
+
224
+ # Streamlit
225
+ .streamlit/secrets.toml
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 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.
@@ -0,0 +1,75 @@
1
+ Metadata-Version: 2.5
2
+ Name: SEA-pytorch
3
+ Version: 0.0.1
4
+ Summary: Explorations into Scaling Empowered Agents
5
+ Project-URL: Homepage, https://pypi.org/project/SEA-pytorch/
6
+ Project-URL: Repository, https://github.com/lucidrains/SEA-pytorch
7
+ Author-email: Phil Wang <lucidrains@gmail.com>
8
+ License: MIT License
9
+
10
+ Copyright (c) 2026 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,empowerment,unsupervised skill discovery
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: einops>=0.8.1
38
+ Requires-Dist: einx>=0.4.0
39
+ Requires-Dist: torch-einops-utils>=0.2.8
40
+ Requires-Dist: torch>=2.5
41
+ Provides-Extra: examples
42
+ Provides-Extra: test
43
+ Requires-Dist: pytest; extra == 'test'
44
+ Description-Content-Type: text/markdown
45
+
46
+
47
+ ## SEA-pytorch (wip)
48
+
49
+ Explorations into [Scaling Empowered Agents](https://arxiv.org/abs/2610.13002), from [Catherine Ji](https://cj7280.github.io/cathyji/) et al. of Benjamin Eysenbach's group
50
+
51
+ ## Citations
52
+
53
+ ```bibtex
54
+ @misc{ji2026scalingempoweredagents,
55
+ title = {Scaling Empowered Agents},
56
+ author = {Catherine Ji and Vivek Myers and Joshua Lin and Alexandra Wingate and Sergey Levine and Benjamin Eysenbach},
57
+ year = {2026},
58
+ eprint = {2610.13002},
59
+ archivePrefix = {arXiv},
60
+ primaryClass = {cs.AI},
61
+ url = {https://arxiv.org/abs/2610.13002},
62
+ }
63
+ ```
64
+
65
+ ```bibtex
66
+ @misc{zheng2025mislflyanalysisingredients,
67
+ title = {Can a MISL Fly? Analysis and Ingredients for Mutual Information Skill Learning},
68
+ author = {Chongyi Zheng and Jens Tuyls and Joanne Peng and Benjamin Eysenbach},
69
+ year = {2025},
70
+ eprint = {2412.08021},
71
+ archivePrefix = {arXiv},
72
+ primaryClass = {cs.LG},
73
+ url = {https://arxiv.org/abs/2412.08021},
74
+ }
75
+ ```
@@ -0,0 +1,30 @@
1
+
2
+ ## SEA-pytorch (wip)
3
+
4
+ Explorations into [Scaling Empowered Agents](https://arxiv.org/abs/2610.13002), from [Catherine Ji](https://cj7280.github.io/cathyji/) et al. of Benjamin Eysenbach's group
5
+
6
+ ## Citations
7
+
8
+ ```bibtex
9
+ @misc{ji2026scalingempoweredagents,
10
+ title = {Scaling Empowered Agents},
11
+ author = {Catherine Ji and Vivek Myers and Joshua Lin and Alexandra Wingate and Sergey Levine and Benjamin Eysenbach},
12
+ year = {2026},
13
+ eprint = {2610.13002},
14
+ archivePrefix = {arXiv},
15
+ primaryClass = {cs.AI},
16
+ url = {https://arxiv.org/abs/2610.13002},
17
+ }
18
+ ```
19
+
20
+ ```bibtex
21
+ @misc{zheng2025mislflyanalysisingredients,
22
+ title = {Can a MISL Fly? Analysis and Ingredients for Mutual Information Skill Learning},
23
+ author = {Chongyi Zheng and Jens Tuyls and Joanne Peng and Benjamin Eysenbach},
24
+ year = {2025},
25
+ eprint = {2412.08021},
26
+ archivePrefix = {arXiv},
27
+ primaryClass = {cs.LG},
28
+ url = {https://arxiv.org/abs/2412.08021},
29
+ }
30
+ ```
@@ -0,0 +1,96 @@
1
+ from __future__ import annotations
2
+
3
+ import torch
4
+ from torch import nn, is_tensor, Tensor
5
+ from torch.nn import Module, ModuleList
6
+ import torch.nn.functional as F
7
+
8
+ # ein equations
9
+
10
+ import einx
11
+ from einops import rearrange, repeat, pack, unpack
12
+ from torch_einops_utils import cast_tensor
13
+ from torch_einops_utils.shape import size, shape
14
+
15
+ # functions
16
+
17
+ def exists(v):
18
+ return v is not None
19
+
20
+ def default(v, d):
21
+ return v if exists(v) else d
22
+
23
+ def cast_tuple(t, length = 1):
24
+ return t if isinstance(t, tuple) else ((t,) * length)
25
+
26
+ # truncated geometric sampling
27
+
28
+ def sample_truncated_geometric(
29
+ max_steps: Tensor | int,
30
+ discount: float | Tensor,
31
+ *,
32
+ allow_zero: bool = False,
33
+ sample_shape: tuple[int, ...] | int = (),
34
+ rand_uniform: Tensor | None = None,
35
+ device: torch.device | None = None,
36
+ generator: torch.Generator | None = None
37
+ ) -> Tensor:
38
+ # device
39
+
40
+ device = default(device, next((t.device for t in (max_steps, discount, rand_uniform) if is_tensor(t)), None))
41
+
42
+ max_steps = cast_tensor(max_steps, device = device, dtype = torch.long)
43
+ discount = cast_tensor(discount, device = device, dtype = torch.float32)
44
+
45
+ assert ((discount >= 0.) & (discount <= 1.)).all(), 'discount must be in [0, 1]'
46
+
47
+ # uniform draws
48
+
49
+ out_shape = (*cast_tuple(sample_shape), *torch.broadcast_shapes(max_steps.shape, discount.shape))
50
+
51
+ if exists(rand_uniform):
52
+ out_shape = torch.broadcast_shapes(out_shape, rand_uniform.shape)
53
+ rand_uniform = rand_uniform.to(device = device, dtype = torch.float32).expand(out_shape)
54
+ else:
55
+ rand_uniform = torch.rand(out_shape, device = device, dtype = torch.float32, generator = generator)
56
+
57
+ # inverse cdf
58
+
59
+ num_steps = (max_steps + int(allow_zero)).clamp(min = 1)
60
+ max_zero_based = num_steps - 1
61
+
62
+ is_zero = discount == 0.
63
+ is_undiscounted = discount == 1.
64
+
65
+ safe_discount = torch.where(is_zero | is_undiscounted, 0.5, discount)
66
+
67
+ log_discount = torch.where(safe_discount < 0.5, safe_discount.log(), torch.log1p(safe_discount - 1.))
68
+ prob_reach = -torch.expm1(num_steps * log_discount)
69
+
70
+ delta = torch.where(
71
+ is_undiscounted,
72
+ rand_uniform * num_steps,
73
+ torch.log1p(-rand_uniform * prob_reach) / log_discount
74
+ )
75
+
76
+ delta = torch.where(is_zero, 0., delta)
77
+
78
+ # clamp before long cast
79
+
80
+ delta = delta.floor().clamp(min = 0.).minimum(max_zero_based).long().minimum(max_zero_based)
81
+
82
+ return delta if allow_zero else (delta + 1)
83
+
84
+ # classes
85
+
86
+ class SEA(Module):
87
+ def __init__(
88
+ self
89
+ ):
90
+ super().__init__()
91
+
92
+ def forward(
93
+ self,
94
+ x
95
+ ):
96
+ return x
@@ -0,0 +1,4 @@
1
+ from SEA_pytorch.SEA import (
2
+ SEA,
3
+ sample_truncated_geometric
4
+ )
@@ -0,0 +1,68 @@
1
+ [project]
2
+ name = "SEA-pytorch"
3
+ version = "0.0.1"
4
+ description = "Explorations into Scaling Empowered Agents"
5
+ authors = [
6
+ { name = "Phil Wang", email = "lucidrains@gmail.com" }
7
+ ]
8
+ readme = "README.md"
9
+ requires-python = ">= 3.10"
10
+ license = { file = "LICENSE" }
11
+ keywords = [
12
+ 'artificial intelligence',
13
+ 'deep learning',
14
+ 'empowerment',
15
+ 'unsupervised skill discovery'
16
+ ]
17
+
18
+ classifiers=[
19
+ 'Development Status :: 4 - Beta',
20
+ 'Intended Audience :: Developers',
21
+ 'Topic :: Scientific/Engineering :: Artificial Intelligence',
22
+ 'License :: OSI Approved :: MIT License',
23
+ 'Programming Language :: Python :: 3.10',
24
+ ]
25
+
26
+ dependencies = [
27
+ "einops>=0.8.1",
28
+ "einx>=0.4.0",
29
+ "torch>=2.5",
30
+ "torch-einops-utils>=0.2.8"
31
+ ]
32
+
33
+ [project.urls]
34
+ Homepage = "https://pypi.org/project/SEA-pytorch/"
35
+ Repository = "https://github.com/lucidrains/SEA-pytorch"
36
+
37
+ [project.optional-dependencies]
38
+ examples = []
39
+ test = [
40
+ "pytest"
41
+ ]
42
+
43
+ [tool.pytest.ini_options]
44
+ pythonpath = [
45
+ "."
46
+ ]
47
+
48
+ [build-system]
49
+ requires = ["hatchling"]
50
+ build-backend = "hatchling.build"
51
+
52
+ [tool.rye]
53
+ managed = true
54
+ dev-dependencies = []
55
+
56
+ [tool.hatch.metadata]
57
+ allow-direct-references = true
58
+
59
+ [tool.hatch.build]
60
+ include = [
61
+ "SEA_pytorch",
62
+ "pyproject.toml",
63
+ "README.md",
64
+ "LICENSE"
65
+ ]
66
+
67
+ [tool.hatch.build.targets.wheel]
68
+ packages = ["SEA_pytorch"]