worldparticle 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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from worldparticle.worldparticle import WorldParticle
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import torch
|
|
2
|
+
from torch.nn import Module, ModuleList
|
|
3
|
+
|
|
4
|
+
# helpers
|
|
5
|
+
|
|
6
|
+
def exists(v):
|
|
7
|
+
return v is not None
|
|
8
|
+
|
|
9
|
+
def default(v, d):
|
|
10
|
+
return v if exists(v) else d
|
|
11
|
+
|
|
12
|
+
# attention
|
|
13
|
+
|
|
14
|
+
class Attention(Module):
|
|
15
|
+
def __init__(
|
|
16
|
+
self,
|
|
17
|
+
dim,
|
|
18
|
+
dim_head = 64,
|
|
19
|
+
heads = 8
|
|
20
|
+
):
|
|
21
|
+
super().__init__()
|
|
22
|
+
dim_inner = dim_head * heads
|
|
23
|
+
self.scale = dim_head ** -0.5
|
|
24
|
+
|
|
25
|
+
self.to_queries = Linear(dim, dim_inner, bias = False)
|
|
26
|
+
self.to_keys_values = Linear(dim, dim_inner * 2, bias = False)
|
|
27
|
+
|
|
28
|
+
self.to_out = Linear(dim_inner, dim)
|
|
29
|
+
|
|
30
|
+
self.split_heads = Rearrange('b n (h d) -> b h n d', h = heads)
|
|
31
|
+
self.merge_heads = Rearrange('b h n d -> b n (h d)')
|
|
32
|
+
|
|
33
|
+
def forward(
|
|
34
|
+
self,
|
|
35
|
+
tokens,
|
|
36
|
+
context = None
|
|
37
|
+
):
|
|
38
|
+
context = default(context, tokens)
|
|
39
|
+
|
|
40
|
+
queries, keys, values = (
|
|
41
|
+
self.to_queries(tokens),
|
|
42
|
+
*self.to_keys_values(context).chunk(2, dim = -1)
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
queries, keys, values = (self.split_heads(t) for t in (queries, keys, values))
|
|
46
|
+
|
|
47
|
+
queries = queries * self.scale
|
|
48
|
+
|
|
49
|
+
sim = einsum(queries, keys, 'b h i d, b h j d -> b h i j')
|
|
50
|
+
|
|
51
|
+
attn = sim.softmax(dim = -1)
|
|
52
|
+
|
|
53
|
+
out = einsum(attn, values, 'b h i j, b h j d -> b h i d')
|
|
54
|
+
|
|
55
|
+
out = self.merge_heads(out)
|
|
56
|
+
|
|
57
|
+
return self.to_out(out)
|
|
58
|
+
|
|
59
|
+
# classes
|
|
60
|
+
|
|
61
|
+
class ParticleTransformer(Module):
|
|
62
|
+
def __init__(
|
|
63
|
+
self,
|
|
64
|
+
dim,
|
|
65
|
+
depth,
|
|
66
|
+
dim_head = 64,
|
|
67
|
+
heads = 8
|
|
68
|
+
):
|
|
69
|
+
super().__init__()
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: worldparticle
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Implementation of World Particle
|
|
5
|
+
Project-URL: Homepage, https://pypi.org/project/worldparticle/
|
|
6
|
+
Project-URL: Repository, https://codeberg.org/lucidrains/worldparticle
|
|
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,attention mechanisms,deep learning,particles,physics,transformers
|
|
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.1.0
|
|
40
|
+
Requires-Dist: torch>=2.5
|
|
41
|
+
Requires-Dist: x-mlps-pytorch
|
|
42
|
+
Provides-Extra: examples
|
|
43
|
+
Provides-Extra: test
|
|
44
|
+
Requires-Dist: pytest; extra == 'test'
|
|
45
|
+
Description-Content-Type: text/markdown
|
|
46
|
+
|
|
47
|
+
<img src="./fig2.png" width="400px"></img>
|
|
48
|
+
|
|
49
|
+
## WorldParticle (wip)
|
|
50
|
+
|
|
51
|
+
Implementation of [WorldParticle](https://arxiv.org/abs/2605.15305), Unified World Simulation of Lagrangian Particle Dynamics via Transformer
|
|
52
|
+
|
|
53
|
+
## Citations
|
|
54
|
+
|
|
55
|
+
```bibtex
|
|
56
|
+
@misc{wang2026unifiedsimulationlagrangianparticle,
|
|
57
|
+
title = {Unified Simulation of Lagrangian Particle Dynamics via Transformer},
|
|
58
|
+
author = {Caoliwen Wang and Minghao Guo and Siyuan Chen and Heng Zhang and Mengdi Wang and Xingyu Ni and Hanson Sun and Kunyi Wang and Zherong Pan and Kui Wu and Lingjie Liu and Yin Yang and Chenfanfu Jiang and Taku Komura and Wojciech Matusik and Peter Yichen Chen},
|
|
59
|
+
year = {2026},
|
|
60
|
+
eprint = {2605.15305},
|
|
61
|
+
archivePrefix = {arXiv},
|
|
62
|
+
primaryClass = {cs.GR},
|
|
63
|
+
url = {https://arxiv.org/abs/2605.15305},
|
|
64
|
+
}
|
|
65
|
+
```
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
worldparticle/__init__.py,sha256=9gM5Sobpxk1PoVE2MkwS4xuQyTXuaVh8H4HVUZBh24I,54
|
|
2
|
+
worldparticle/worldparticle.py,sha256=8vhzRZkCI62axzRg8QOF87gCCbGjVQio7XV7g2ys7HY,1524
|
|
3
|
+
worldparticle-0.0.1.dist-info/METADATA,sha256=wAnJWkrqAVNAYVRzxQcpqrOBAL3YbEFpIVYeIeMxRpI,3006
|
|
4
|
+
worldparticle-0.0.1.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
5
|
+
worldparticle-0.0.1.dist-info/licenses/LICENSE,sha256=e6AOF7Z8EFdK3IdcL0x0fLw4cY7Q0d0kNR0o0TmBewM,1066
|
|
6
|
+
worldparticle-0.0.1.dist-info/RECORD,,
|
|
@@ -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.
|