mujou 0.1.0__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.
Files changed (77) hide show
  1. mujou-0.1.0/Cargo.lock +267 -0
  2. mujou-0.1.0/Cargo.toml +10 -0
  3. mujou-0.1.0/LICENSE +21 -0
  4. mujou-0.1.0/PKG-INFO +123 -0
  5. mujou-0.1.0/README.md +99 -0
  6. mujou-0.1.0/crates/mujou-core/Cargo.toml +8 -0
  7. mujou-0.1.0/crates/mujou-core/src/buffer.rs +293 -0
  8. mujou-0.1.0/crates/mujou-core/src/dlpack/export.rs +147 -0
  9. mujou-0.1.0/crates/mujou-core/src/dlpack/ffi.rs +63 -0
  10. mujou-0.1.0/crates/mujou-core/src/dlpack/import.rs +353 -0
  11. mujou-0.1.0/crates/mujou-core/src/dlpack/mod.rs +13 -0
  12. mujou-0.1.0/crates/mujou-core/src/lib.rs +19 -0
  13. mujou-0.1.0/crates/mujou-core/src/runtime/control.rs +193 -0
  14. mujou-0.1.0/crates/mujou-core/src/runtime/error.rs +141 -0
  15. mujou-0.1.0/crates/mujou-core/src/runtime/hooks.rs +88 -0
  16. mujou-0.1.0/crates/mujou-core/src/runtime/lifecycle.rs +503 -0
  17. mujou-0.1.0/crates/mujou-core/src/runtime/mod.rs +368 -0
  18. mujou-0.1.0/crates/mujou-core/src/runtime/sched.rs +224 -0
  19. mujou-0.1.0/crates/mujou-core/src/runtime/shared.rs +362 -0
  20. mujou-0.1.0/crates/mujou-core/src/runtime/worker.rs +242 -0
  21. mujou-0.1.0/crates/mujou-core/src/schema.rs +199 -0
  22. mujou-0.1.0/crates/mujou-core/src/slot.rs +879 -0
  23. mujou-0.1.0/crates/mujou-core/src/time.rs +573 -0
  24. mujou-0.1.0/crates/mujou-core/tests/runtime/capture.rs +174 -0
  25. mujou-0.1.0/crates/mujou-core/tests/runtime/failure.rs +178 -0
  26. mujou-0.1.0/crates/mujou-core/tests/runtime/lifecycle.rs +190 -0
  27. mujou-0.1.0/crates/mujou-core/tests/runtime/main.rs +331 -0
  28. mujou-0.1.0/crates/mujou-core/tests/runtime/manual.rs +62 -0
  29. mujou-0.1.0/crates/mujou-core/tests/runtime/period.rs +407 -0
  30. mujou-0.1.0/crates/mujou-core/tests/runtime/restore.rs +65 -0
  31. mujou-0.1.0/crates/mujou-core/tests/runtime/sched.rs +225 -0
  32. mujou-0.1.0/crates/mujou-core/tests/time.rs +356 -0
  33. mujou-0.1.0/crates/mujou-python/Cargo.toml +18 -0
  34. mujou-0.1.0/crates/mujou-python/src/current.rs +40 -0
  35. mujou-0.1.0/crates/mujou-python/src/dlpack.rs +130 -0
  36. mujou-0.1.0/crates/mujou-python/src/errors.rs +4 -0
  37. mujou-0.1.0/crates/mujou-python/src/hint.rs +67 -0
  38. mujou-0.1.0/crates/mujou-python/src/lib.rs +47 -0
  39. mujou-0.1.0/crates/mujou-python/src/runtime.rs +458 -0
  40. mujou-0.1.0/crates/mujou-python/src/scalar.rs +136 -0
  41. mujou-0.1.0/crates/mujou-python/src/slot.rs +530 -0
  42. mujou-0.1.0/crates/mujou-python/src/time.rs +298 -0
  43. mujou-0.1.0/crates/mujou-python/src/wait.rs +52 -0
  44. mujou-0.1.0/pyproject.toml +141 -0
  45. mujou-0.1.0/src/mujou/__init__.py +43 -0
  46. mujou-0.1.0/src/mujou/_native.pyi +597 -0
  47. mujou-0.1.0/src/mujou/codec.py +299 -0
  48. mujou-0.1.0/src/mujou/component.py +43 -0
  49. mujou-0.1.0/src/mujou/current.py +52 -0
  50. mujou-0.1.0/src/mujou/driver.py +159 -0
  51. mujou-0.1.0/src/mujou/errors.py +12 -0
  52. mujou-0.1.0/src/mujou/execution.py +830 -0
  53. mujou-0.1.0/src/mujou/network.py +73 -0
  54. mujou-0.1.0/src/mujou/node.py +501 -0
  55. mujou-0.1.0/src/mujou/pc/__init__.py +81 -0
  56. mujou-0.1.0/src/mujou/pc/chain.py +192 -0
  57. mujou-0.1.0/src/mujou/pc/clock.py +189 -0
  58. mujou-0.1.0/src/mujou/pc/functional.py +308 -0
  59. mujou-0.1.0/src/mujou/pc/input.py +84 -0
  60. mujou-0.1.0/src/mujou/pc/layer.py +264 -0
  61. mujou-0.1.0/src/mujou/pc/loss.py +57 -0
  62. mujou-0.1.0/src/mujou/pc/msg.py +132 -0
  63. mujou-0.1.0/src/mujou/pc/optim.py +308 -0
  64. mujou-0.1.0/src/mujou/pc/output.py +168 -0
  65. mujou-0.1.0/src/mujou/pc/relax.py +152 -0
  66. mujou-0.1.0/src/mujou/pc/time_constants.py +81 -0
  67. mujou-0.1.0/src/mujou/port.py +374 -0
  68. mujou-0.1.0/src/mujou/py.typed +0 -0
  69. mujou-0.1.0/src/mujou/spec.py +389 -0
  70. mujou-0.1.0/src/mujou/state.py +195 -0
  71. mujou-0.1.0/src/mujou/testing.py +82 -0
  72. mujou-0.1.0/src/mujou/time.py +28 -0
  73. mujou-0.1.0/src/mujou/tree.py +200 -0
  74. mujou-0.1.0/src/mujou/types.py +28 -0
  75. mujou-0.1.0/src/mujou/viz.html +544 -0
  76. mujou-0.1.0/src/mujou/viz.py +114 -0
  77. mujou-0.1.0/src/mujou/wiring.py +222 -0
mujou-0.1.0/Cargo.lock ADDED
@@ -0,0 +1,267 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 4
4
+
5
+ [[package]]
6
+ name = "anyhow"
7
+ version = "1.0.104"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470"
10
+
11
+ [[package]]
12
+ name = "goblin"
13
+ version = "0.10.7"
14
+ source = "registry+https://github.com/rust-lang/crates.io-index"
15
+ checksum = "17582616a7718cca54cec18e534a76c7c4aec11a8b9a85695712f262fd15a4c8"
16
+ dependencies = [
17
+ "log",
18
+ "plain",
19
+ "scroll",
20
+ ]
21
+
22
+ [[package]]
23
+ name = "heck"
24
+ version = "0.5.0"
25
+ source = "registry+https://github.com/rust-lang/crates.io-index"
26
+ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
27
+
28
+ [[package]]
29
+ name = "itoa"
30
+ version = "1.0.18"
31
+ source = "registry+https://github.com/rust-lang/crates.io-index"
32
+ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
33
+
34
+ [[package]]
35
+ name = "libc"
36
+ version = "0.2.190"
37
+ source = "registry+https://github.com/rust-lang/crates.io-index"
38
+ checksum = "ce5d3ddc6d3fa000eb1536d85e147bfe31aacaba692ed6a876f95cb7c855be78"
39
+
40
+ [[package]]
41
+ name = "log"
42
+ version = "0.4.34"
43
+ source = "registry+https://github.com/rust-lang/crates.io-index"
44
+ checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6"
45
+
46
+ [[package]]
47
+ name = "memchr"
48
+ version = "2.8.3"
49
+ source = "registry+https://github.com/rust-lang/crates.io-index"
50
+ checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
51
+
52
+ [[package]]
53
+ name = "mujou-core"
54
+ version = "0.1.0"
55
+
56
+ [[package]]
57
+ name = "mujou-python"
58
+ version = "0.1.0"
59
+ dependencies = [
60
+ "mujou-core",
61
+ "pyo3",
62
+ ]
63
+
64
+ [[package]]
65
+ name = "mujou-stubgen"
66
+ version = "0.1.0"
67
+ dependencies = [
68
+ "anyhow",
69
+ "pyo3-introspection",
70
+ ]
71
+
72
+ [[package]]
73
+ name = "once_cell"
74
+ version = "1.21.4"
75
+ source = "registry+https://github.com/rust-lang/crates.io-index"
76
+ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
77
+
78
+ [[package]]
79
+ name = "plain"
80
+ version = "0.2.3"
81
+ source = "registry+https://github.com/rust-lang/crates.io-index"
82
+ checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6"
83
+
84
+ [[package]]
85
+ name = "portable-atomic"
86
+ version = "1.15.0"
87
+ source = "registry+https://github.com/rust-lang/crates.io-index"
88
+ checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
89
+
90
+ [[package]]
91
+ name = "proc-macro2"
92
+ version = "1.0.107"
93
+ source = "registry+https://github.com/rust-lang/crates.io-index"
94
+ checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
95
+ dependencies = [
96
+ "unicode-ident",
97
+ ]
98
+
99
+ [[package]]
100
+ name = "pyo3"
101
+ version = "0.30.1"
102
+ source = "registry+https://github.com/rust-lang/crates.io-index"
103
+ checksum = "229ca13b8a15bb0d1487b81ab975bfcd97513416499a8312011b6036e42e0de4"
104
+ dependencies = [
105
+ "libc",
106
+ "once_cell",
107
+ "portable-atomic",
108
+ "pyo3-build-config",
109
+ "pyo3-ffi",
110
+ "pyo3-macros",
111
+ ]
112
+
113
+ [[package]]
114
+ name = "pyo3-build-config"
115
+ version = "0.30.1"
116
+ source = "registry+https://github.com/rust-lang/crates.io-index"
117
+ checksum = "70130e2b6dd1ee589a8788026a429561ca5c40fa7a2fa7914c2282eddae24700"
118
+ dependencies = [
119
+ "target-lexicon",
120
+ ]
121
+
122
+ [[package]]
123
+ name = "pyo3-ffi"
124
+ version = "0.30.1"
125
+ source = "registry+https://github.com/rust-lang/crates.io-index"
126
+ checksum = "5e7ff73c555c286d212d4ce7e5fbda845a973c4f61bd5f160f5f2c3c2a04d1c4"
127
+ dependencies = [
128
+ "libc",
129
+ "pyo3-build-config",
130
+ ]
131
+
132
+ [[package]]
133
+ name = "pyo3-introspection"
134
+ version = "0.30.1"
135
+ source = "registry+https://github.com/rust-lang/crates.io-index"
136
+ checksum = "3b2ac30f128e6ab4ca1c464d6eabd30c84c7adc5955c3bb2eb7d203ea24ebd18"
137
+ dependencies = [
138
+ "anyhow",
139
+ "goblin",
140
+ "serde",
141
+ "serde_json",
142
+ ]
143
+
144
+ [[package]]
145
+ name = "pyo3-macros"
146
+ version = "0.30.1"
147
+ source = "registry+https://github.com/rust-lang/crates.io-index"
148
+ checksum = "c46d2e5862c7bb8207e3b639f713dda3c499933444784154c11d013c5a691b60"
149
+ dependencies = [
150
+ "proc-macro2",
151
+ "pyo3-macros-backend",
152
+ "quote",
153
+ "syn",
154
+ ]
155
+
156
+ [[package]]
157
+ name = "pyo3-macros-backend"
158
+ version = "0.30.1"
159
+ source = "registry+https://github.com/rust-lang/crates.io-index"
160
+ checksum = "38b89f066f2ae72a2aef52d1537ca2fcd104440ebfadee06e97aa90738a25b9b"
161
+ dependencies = [
162
+ "heck",
163
+ "proc-macro2",
164
+ "quote",
165
+ "syn",
166
+ ]
167
+
168
+ [[package]]
169
+ name = "quote"
170
+ version = "1.0.47"
171
+ source = "registry+https://github.com/rust-lang/crates.io-index"
172
+ checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
173
+ dependencies = [
174
+ "proc-macro2",
175
+ ]
176
+
177
+ [[package]]
178
+ name = "scroll"
179
+ version = "0.13.0"
180
+ source = "registry+https://github.com/rust-lang/crates.io-index"
181
+ checksum = "c1257cd4248b4132760d6524d6dda4e053bc648c9070b960929bf50cfb1e7add"
182
+ dependencies = [
183
+ "scroll_derive",
184
+ ]
185
+
186
+ [[package]]
187
+ name = "scroll_derive"
188
+ version = "0.13.2"
189
+ source = "registry+https://github.com/rust-lang/crates.io-index"
190
+ checksum = "e1a36a382ed65dbcc0ab47fd5e9a94112417ccd34560a392ef3b7b0f0ec39148"
191
+ dependencies = [
192
+ "proc-macro2",
193
+ "quote",
194
+ "syn",
195
+ ]
196
+
197
+ [[package]]
198
+ name = "serde"
199
+ version = "1.0.229"
200
+ source = "registry+https://github.com/rust-lang/crates.io-index"
201
+ checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
202
+ dependencies = [
203
+ "serde_core",
204
+ "serde_derive",
205
+ ]
206
+
207
+ [[package]]
208
+ name = "serde_core"
209
+ version = "1.0.229"
210
+ source = "registry+https://github.com/rust-lang/crates.io-index"
211
+ checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
212
+ dependencies = [
213
+ "serde_derive",
214
+ ]
215
+
216
+ [[package]]
217
+ name = "serde_derive"
218
+ version = "1.0.229"
219
+ source = "registry+https://github.com/rust-lang/crates.io-index"
220
+ checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
221
+ dependencies = [
222
+ "proc-macro2",
223
+ "quote",
224
+ "syn",
225
+ ]
226
+
227
+ [[package]]
228
+ name = "serde_json"
229
+ version = "1.0.154"
230
+ source = "registry+https://github.com/rust-lang/crates.io-index"
231
+ checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6"
232
+ dependencies = [
233
+ "itoa",
234
+ "memchr",
235
+ "serde",
236
+ "serde_core",
237
+ "zmij",
238
+ ]
239
+
240
+ [[package]]
241
+ name = "syn"
242
+ version = "3.0.9"
243
+ source = "registry+https://github.com/rust-lang/crates.io-index"
244
+ checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b"
245
+ dependencies = [
246
+ "proc-macro2",
247
+ "quote",
248
+ "unicode-ident",
249
+ ]
250
+
251
+ [[package]]
252
+ name = "target-lexicon"
253
+ version = "0.13.5"
254
+ source = "registry+https://github.com/rust-lang/crates.io-index"
255
+ checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
256
+
257
+ [[package]]
258
+ name = "unicode-ident"
259
+ version = "1.0.27"
260
+ source = "registry+https://github.com/rust-lang/crates.io-index"
261
+ checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
262
+
263
+ [[package]]
264
+ name = "zmij"
265
+ version = "1.0.23"
266
+ source = "registry+https://github.com/rust-lang/crates.io-index"
267
+ checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
mujou-0.1.0/Cargo.toml ADDED
@@ -0,0 +1,10 @@
1
+ [workspace]
2
+ members = ["crates/*"]
3
+ resolver = "3"
4
+
5
+ # The version of the Python package `mujou` too (maturin reads it).
6
+ [workspace.package]
7
+ version = "0.1.0"
8
+ edition = "2024"
9
+ rust-version = "1.85"
10
+ license = "MIT"
mujou-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Geson-anko
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.
mujou-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,123 @@
1
+ Metadata-Version: 2.4
2
+ Name: mujou
3
+ Version: 0.1.0
4
+ Classifier: Development Status :: 3 - Alpha
5
+ Classifier: Intended Audience :: Science/Research
6
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3 :: Only
9
+ Classifier: Programming Language :: Python :: 3.14
10
+ Classifier: Programming Language :: Python :: Free Threading
11
+ Classifier: Programming Language :: Python :: Implementation :: CPython
12
+ Classifier: Programming Language :: Rust
13
+ Requires-Dist: torch>=2.14.1
14
+ License-File: LICENSE
15
+ Summary: Asynchronous Distributed Deep Learning Library for Continuous Learning
16
+ License-Expression: MIT
17
+ Requires-Python: >=3.14
18
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
19
+ Project-URL: Changelog, https://github.com/Geson-anko/mujou/blob/main/CHANGELOG.md
20
+ Project-URL: Documentation, https://geson-anko.github.io/mujou/
21
+ Project-URL: Issues, https://github.com/Geson-anko/mujou/issues
22
+ Project-URL: Repository, https://github.com/Geson-anko/mujou
23
+
24
+ # Mujou
25
+
26
+ **Asynchronous Distributed Deep Learning Library for Continuous Learning.**
27
+
28
+ [![Test](https://github.com/Geson-anko/mujou/actions/workflows/test.yml/badge.svg)](https://github.com/Geson-anko/mujou/actions/workflows/test.yml)
29
+ [![Type Check](https://github.com/Geson-anko/mujou/actions/workflows/type-check.yml/badge.svg)](https://github.com/Geson-anko/mujou/actions/workflows/type-check.yml)
30
+ [![Format & Lint](https://github.com/Geson-anko/mujou/actions/workflows/pre-commit.yml/badge.svg)](https://github.com/Geson-anko/mujou/actions/workflows/pre-commit.yml)
31
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/Geson-anko/mujou/blob/main/LICENSE)
32
+ [![Python 3.14](https://img.shields.io/badge/python-3.14-blue.svg)](https://www.python.org/)
33
+
34
+ Mujou (無常, "impermanence") is a deep learning framework where inference and learning happen at the same time. You write nodes in PyTorch code and connect them into a network that runs in the background. Most models are trained once and then frozen; Mujou is for machines that keep learning from a stream, such as real-time systems and robots.
35
+
36
+ > **Status: early development (0.x).** The API works but will still change; a minor release (0.x.0) may break it. See the [changelog](https://github.com/Geson-anko/mujou/blob/main/CHANGELOG.md).
37
+
38
+ ## Key ideas
39
+
40
+ - **No epochs, no train/inference modes.** A running network takes input, produces output and learns, all at once.
41
+ - **Synchronous inside, asynchronous outside.** Each node computes synchronously in ordinary PyTorch code. Nodes never wait for each other; a node reads the latest value its neighbour sent.
42
+ - **One time axis per run.** A node updates by an amount proportional to `dt`, the time since its last update, so nodes that update at different rates share one flow of time.
43
+ - **Any update rule.** The rule is written inside the nodes: [PC-ALM](https://pub.sakana.ai/pc-alm/) (Augmented Lagrangian Predictive Coding, the nodes of `mujou.pc`), which learns with updates local to each node, backpropagation kept inside one node, or a rule of your own.
44
+
45
+ ## Install
46
+
47
+ Mujou is on PyPI. It needs Python 3.14 or later; the free-threaded build 3.14t is recommended, because the nodes run on several threads at once.
48
+
49
+ ```sh
50
+ uv add mujou # in a uv project
51
+ pip install mujou # or in a virtual environment with Python 3.14
52
+ ```
53
+
54
+ Wheels are built for Linux (x86_64, aarch64), macOS (arm64) and Windows (x86_64), for both 3.14 and 3.14t. PyTorch is installed as a dependency. On other platforms, pip builds Mujou from the source, which needs a Rust toolchain ([rustup](https://rustup.rs/)). The [installation guide](https://geson-anko.github.io/mujou/latest/install/) also explains how to build from a clone of the repository.
55
+
56
+ ## Example
57
+
58
+ Two nodes compute `y = 2x + 1` in the background; the program writes `x` and waits for `y` ([`examples/quickstart.py`](https://github.com/Geson-anko/mujou/blob/main/examples/quickstart.py)).
59
+
60
+ ```python
61
+ from typing import override
62
+
63
+ import torch
64
+
65
+ import mujou
66
+ from mujou import Network, Node, Port, TensorSpec
67
+
68
+ VECTOR = TensorSpec((3,)) # every message here is a float32 vector of 3
69
+
70
+
71
+ class Affine(Node):
72
+ """Sends ``a * x + b``, where ``x`` is the latest input."""
73
+
74
+ def __init__(self, a: float, b: float) -> None:
75
+ super().__init__()
76
+ self.a, self.b = a, b # settings, not state
77
+ self.prev = Port(recv=VECTOR) # receives from the previous node
78
+ self.next = Port(send=VECTOR) # sends to the next node
79
+
80
+ @override
81
+ def on_update(self, dt: float) -> None:
82
+ super().on_update(dt)
83
+ self.next.send(self.a * self.prev.recv() + self.b) # recv() never waits
84
+
85
+
86
+ class Pipeline(Network):
87
+ """``x -> scale -> shift ->``: y = 2 x + 1."""
88
+
89
+ def __init__(self) -> None:
90
+ super().__init__()
91
+ self.scale = Affine(2.0, 0.0)
92
+ self.shift = Affine(1.0, 1.0)
93
+ self.scale.next.connect(self.shift.prev)
94
+ self.prev, self.next = self.scale.prev, self.shift.next # exposed as its own
95
+
96
+
97
+ net = Pipeline()
98
+ x = torch.tensor([1.0, 2.0, 3.0])
99
+ # The nodes run on the run's worker threads until the end of the `with` block.
100
+ with mujou.run(net) as run:
101
+ run.write({net.prev: x})
102
+ # x takes a few updates to pass through the nodes: wait until y arrives, with
103
+ # the time it was sent (TimeoutError after 5 s of real time).
104
+ y, t = run.wait_for(net.next, lambda y: torch.equal(y, 2 * x + 1), timeout=5.0)
105
+ assert t is not None # None only for the zeros before the first send
106
+
107
+ print(f"y = {y} at t = {float(t):.3f} s")
108
+ ```
109
+
110
+ More programs, from writing a node to learning MNIST with PC-ALM, are in [`examples/`](https://github.com/Geson-anko/mujou/blob/main/examples/).
111
+
112
+ ## Documentation
113
+
114
+ The documentation is at <https://geson-anko.github.io/mujou/> (English and Japanese). To serve it locally, run `just docs` (needs [just](https://just.systems/)) and open <http://127.0.0.1:8000>. You can also read the Markdown in [`docs/en/`](https://github.com/Geson-anko/mujou/blob/main/docs/en/) (English) and [`docs/ja/`](https://github.com/Geson-anko/mujou/blob/main/docs/ja/) (Japanese).
115
+
116
+ ## Contributing
117
+
118
+ Issues and pull requests are welcome. See [CONTRIBUTING.md](https://github.com/Geson-anko/mujou/blob/main/CONTRIBUTING.md) for the development setup, the dev container, the commands and the rules.
119
+
120
+ ## License
121
+
122
+ MIT. See [LICENSE](https://github.com/Geson-anko/mujou/blob/main/LICENSE).
123
+
mujou-0.1.0/README.md ADDED
@@ -0,0 +1,99 @@
1
+ # Mujou
2
+
3
+ **Asynchronous Distributed Deep Learning Library for Continuous Learning.**
4
+
5
+ [![Test](https://github.com/Geson-anko/mujou/actions/workflows/test.yml/badge.svg)](https://github.com/Geson-anko/mujou/actions/workflows/test.yml)
6
+ [![Type Check](https://github.com/Geson-anko/mujou/actions/workflows/type-check.yml/badge.svg)](https://github.com/Geson-anko/mujou/actions/workflows/type-check.yml)
7
+ [![Format & Lint](https://github.com/Geson-anko/mujou/actions/workflows/pre-commit.yml/badge.svg)](https://github.com/Geson-anko/mujou/actions/workflows/pre-commit.yml)
8
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/Geson-anko/mujou/blob/main/LICENSE)
9
+ [![Python 3.14](https://img.shields.io/badge/python-3.14-blue.svg)](https://www.python.org/)
10
+
11
+ Mujou (無常, "impermanence") is a deep learning framework where inference and learning happen at the same time. You write nodes in PyTorch code and connect them into a network that runs in the background. Most models are trained once and then frozen; Mujou is for machines that keep learning from a stream, such as real-time systems and robots.
12
+
13
+ > **Status: early development (0.x).** The API works but will still change; a minor release (0.x.0) may break it. See the [changelog](https://github.com/Geson-anko/mujou/blob/main/CHANGELOG.md).
14
+
15
+ ## Key ideas
16
+
17
+ - **No epochs, no train/inference modes.** A running network takes input, produces output and learns, all at once.
18
+ - **Synchronous inside, asynchronous outside.** Each node computes synchronously in ordinary PyTorch code. Nodes never wait for each other; a node reads the latest value its neighbour sent.
19
+ - **One time axis per run.** A node updates by an amount proportional to `dt`, the time since its last update, so nodes that update at different rates share one flow of time.
20
+ - **Any update rule.** The rule is written inside the nodes: [PC-ALM](https://pub.sakana.ai/pc-alm/) (Augmented Lagrangian Predictive Coding, the nodes of `mujou.pc`), which learns with updates local to each node, backpropagation kept inside one node, or a rule of your own.
21
+
22
+ ## Install
23
+
24
+ Mujou is on PyPI. It needs Python 3.14 or later; the free-threaded build 3.14t is recommended, because the nodes run on several threads at once.
25
+
26
+ ```sh
27
+ uv add mujou # in a uv project
28
+ pip install mujou # or in a virtual environment with Python 3.14
29
+ ```
30
+
31
+ Wheels are built for Linux (x86_64, aarch64), macOS (arm64) and Windows (x86_64), for both 3.14 and 3.14t. PyTorch is installed as a dependency. On other platforms, pip builds Mujou from the source, which needs a Rust toolchain ([rustup](https://rustup.rs/)). The [installation guide](https://geson-anko.github.io/mujou/latest/install/) also explains how to build from a clone of the repository.
32
+
33
+ ## Example
34
+
35
+ Two nodes compute `y = 2x + 1` in the background; the program writes `x` and waits for `y` ([`examples/quickstart.py`](https://github.com/Geson-anko/mujou/blob/main/examples/quickstart.py)).
36
+
37
+ ```python
38
+ from typing import override
39
+
40
+ import torch
41
+
42
+ import mujou
43
+ from mujou import Network, Node, Port, TensorSpec
44
+
45
+ VECTOR = TensorSpec((3,)) # every message here is a float32 vector of 3
46
+
47
+
48
+ class Affine(Node):
49
+ """Sends ``a * x + b``, where ``x`` is the latest input."""
50
+
51
+ def __init__(self, a: float, b: float) -> None:
52
+ super().__init__()
53
+ self.a, self.b = a, b # settings, not state
54
+ self.prev = Port(recv=VECTOR) # receives from the previous node
55
+ self.next = Port(send=VECTOR) # sends to the next node
56
+
57
+ @override
58
+ def on_update(self, dt: float) -> None:
59
+ super().on_update(dt)
60
+ self.next.send(self.a * self.prev.recv() + self.b) # recv() never waits
61
+
62
+
63
+ class Pipeline(Network):
64
+ """``x -> scale -> shift ->``: y = 2 x + 1."""
65
+
66
+ def __init__(self) -> None:
67
+ super().__init__()
68
+ self.scale = Affine(2.0, 0.0)
69
+ self.shift = Affine(1.0, 1.0)
70
+ self.scale.next.connect(self.shift.prev)
71
+ self.prev, self.next = self.scale.prev, self.shift.next # exposed as its own
72
+
73
+
74
+ net = Pipeline()
75
+ x = torch.tensor([1.0, 2.0, 3.0])
76
+ # The nodes run on the run's worker threads until the end of the `with` block.
77
+ with mujou.run(net) as run:
78
+ run.write({net.prev: x})
79
+ # x takes a few updates to pass through the nodes: wait until y arrives, with
80
+ # the time it was sent (TimeoutError after 5 s of real time).
81
+ y, t = run.wait_for(net.next, lambda y: torch.equal(y, 2 * x + 1), timeout=5.0)
82
+ assert t is not None # None only for the zeros before the first send
83
+
84
+ print(f"y = {y} at t = {float(t):.3f} s")
85
+ ```
86
+
87
+ More programs, from writing a node to learning MNIST with PC-ALM, are in [`examples/`](https://github.com/Geson-anko/mujou/blob/main/examples/).
88
+
89
+ ## Documentation
90
+
91
+ The documentation is at <https://geson-anko.github.io/mujou/> (English and Japanese). To serve it locally, run `just docs` (needs [just](https://just.systems/)) and open <http://127.0.0.1:8000>. You can also read the Markdown in [`docs/en/`](https://github.com/Geson-anko/mujou/blob/main/docs/en/) (English) and [`docs/ja/`](https://github.com/Geson-anko/mujou/blob/main/docs/ja/) (Japanese).
92
+
93
+ ## Contributing
94
+
95
+ Issues and pull requests are welcome. See [CONTRIBUTING.md](https://github.com/Geson-anko/mujou/blob/main/CONTRIBUTING.md) for the development setup, the dev container, the commands and the rules.
96
+
97
+ ## License
98
+
99
+ MIT. See [LICENSE](https://github.com/Geson-anko/mujou/blob/main/LICENSE).
@@ -0,0 +1,8 @@
1
+ [package]
2
+ name = "mujou-core"
3
+ version.workspace = true
4
+ edition.workspace = true
5
+ rust-version.workspace = true
6
+ license.workspace = true
7
+
8
+ [dependencies]