amv-cluster 1.0.4__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.
- amv_cluster-1.0.4/LICENSE +90 -0
- amv_cluster-1.0.4/MANIFEST.in +14 -0
- amv_cluster-1.0.4/NOTICE +17 -0
- amv_cluster-1.0.4/PKG-INFO +273 -0
- amv_cluster-1.0.4/README.md +250 -0
- amv_cluster-1.0.4/ameva_cluster/__init__.py +99 -0
- amv_cluster-1.0.4/ameva_cluster/adapter.py +97 -0
- amv_cluster-1.0.4/ameva_cluster/cli.py +244 -0
- amv_cluster-1.0.4/ameva_cluster/config.py +85 -0
- amv_cluster-1.0.4/ameva_cluster/engine.py +360 -0
- amv_cluster-1.0.4/ameva_cluster/exceptions.py +70 -0
- amv_cluster-1.0.4/ameva_cluster/guard.py +335 -0
- amv_cluster-1.0.4/ameva_cluster/hardware.py +142 -0
- amv_cluster-1.0.4/ameva_cluster/master.py +237 -0
- amv_cluster-1.0.4/ameva_cluster/probe.py +353 -0
- amv_cluster-1.0.4/ameva_cluster/protocol.py +241 -0
- amv_cluster-1.0.4/ameva_cluster/security.py +67 -0
- amv_cluster-1.0.4/ameva_cluster/strategy.py +148 -0
- amv_cluster-1.0.4/ameva_cluster/transport.py +148 -0
- amv_cluster-1.0.4/ameva_cluster/worker.py +311 -0
- amv_cluster-1.0.4/amv_cluster.egg-info/PKG-INFO +273 -0
- amv_cluster-1.0.4/amv_cluster.egg-info/SOURCES.txt +25 -0
- amv_cluster-1.0.4/amv_cluster.egg-info/dependency_links.txt +1 -0
- amv_cluster-1.0.4/amv_cluster.egg-info/entry_points.txt +2 -0
- amv_cluster-1.0.4/amv_cluster.egg-info/top_level.txt +1 -0
- amv_cluster-1.0.4/pyproject.toml +46 -0
- amv_cluster-1.0.4/setup.cfg +4 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work.
|
|
38
|
+
|
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
|
+
form, that is based on (or derived from) the Work and for which the
|
|
41
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
43
|
+
of this License, Derivative Works shall not include works that remain
|
|
44
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
45
|
+
the Work and Derivative Works thereof.
|
|
46
|
+
|
|
47
|
+
"Contribution" shall mean any work of authorship, including
|
|
48
|
+
the original version of the Work and any modifications or additions
|
|
49
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
50
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
51
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
52
|
+
the copyright owner.
|
|
53
|
+
|
|
54
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
55
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
56
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
57
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
58
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
59
|
+
Work and such Derivative Works in Source or Object form.
|
|
60
|
+
|
|
61
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
62
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
63
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
64
|
+
(except as stated in this section) patent license to make, have made,
|
|
65
|
+
use, offer to sell, sell, import, and otherwise transfer the Work.
|
|
66
|
+
|
|
67
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
68
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
69
|
+
modifications, and in Source or Object form.
|
|
70
|
+
|
|
71
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
72
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
73
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
74
|
+
this License, without any additional terms or conditions.
|
|
75
|
+
|
|
76
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
77
|
+
names, trademarks, service marks, or product names of the Licensor.
|
|
78
|
+
|
|
79
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
80
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
81
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
82
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
83
|
+
implied.
|
|
84
|
+
|
|
85
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
86
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
87
|
+
shall any Contributor be liable to You for damages, including any
|
|
88
|
+
direct, indirect, special, incidental, or consequential damages.
|
|
89
|
+
|
|
90
|
+
END OF TERMS AND CONDITIONS
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
include LICENSE NOTICE README.md
|
|
2
|
+
recursive-include ameva_cluster *.py
|
|
3
|
+
prune tests
|
|
4
|
+
prune docs
|
|
5
|
+
prune tools
|
|
6
|
+
exclude doc.config.yaml
|
|
7
|
+
exclude CITATION.cff
|
|
8
|
+
exclude CODE_OF_CONDUCT.md
|
|
9
|
+
exclude CONTRIBUTING.md
|
|
10
|
+
exclude SECURITY.md
|
|
11
|
+
exclude README.pypi.md
|
|
12
|
+
exclude README.npm.md
|
|
13
|
+
exclude package.json
|
|
14
|
+
exclude *.bak
|
amv_cluster-1.0.4/NOTICE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
AMEVA-Cluster
|
|
2
|
+
Copyright 2026 Eunho Kim
|
|
3
|
+
|
|
4
|
+
This product includes software developed by Eunho Kim and contributors
|
|
5
|
+
as part of the AMEVA on-device AI ecosystem (https://github.com/uno-km).
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: amv-cluster
|
|
3
|
+
Version: 1.0.4
|
|
4
|
+
Summary: Symmetric Disaggregated Mobile RAM Pooling & On-Device AI Acceleration Runtime
|
|
5
|
+
Author-email: Eunho Kim <amv.foundation.kr@gmail.com>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Keywords: disaggregated-memory,memory-pooling,on-device-ai,mobile-cluster,vulkan-compute,termux,llama-cpp-rpc,tensor-sharding,fault-tolerance,distributed-inference,guardband-memory,hybrid-streaming
|
|
8
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
11
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Requires-Python: >=3.8
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
License-File: NOTICE
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
# AMEVA-Cluster
|
|
25
|
+
|
|
26
|
+
> **Renamed.** Up to 1.0.3 the PyPI project was `ameva-cluster` (frozen old account). From 1.0.4 it is **`amv-cluster`**; the import package `ameva_cluster` and the command `ameva-cluster` are unchanged. Uninstall the old distribution first: `pip uninstall ameva-cluster`.
|
|
27
|
+
|
|
28
|
+
[](https://pypi.org/project/amv-cluster/)
|
|
29
|
+
[](https://pypi.org/project/amv-cluster/)
|
|
30
|
+
[](https://www.npmjs.com/package/@ameva/cluster)
|
|
31
|
+
[](https://www.npmjs.com/package/@ameva/cluster)
|
|
32
|
+
[](https://github.com/uno-km/ameva-cluster)
|
|
33
|
+
|
|
34
|
+
> **Symmetric Disaggregated Mobile RAM Pooling & On-Device AI Acceleration Runtime with Compute-Memory Decoupling**
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 1. Executive Architecture & Threat Model
|
|
39
|
+
|
|
40
|
+
Executing frontier AI models (7B–70B parameters, 4B Flow Matching Diffusion, Multimodal Vision) on edge mobile smartphones inevitably triggers immediate **Android Low Memory Killer (LMK) `SIGKILL` terminations** and extreme battery thermal throttling.
|
|
41
|
+
|
|
42
|
+
Conventional distributed inference frameworks force every connected node to execute computational passes, causing lower-tier edge devices to overheat, desynchronize, and crash.
|
|
43
|
+
|
|
44
|
+
**AMEVA-Cluster** resolves this architectural limitation through **Compute-Memory Decoupling**:
|
|
45
|
+
- **Symmetric Single-Binary Architecture**: Both `master` and `worker` roles run from a unified binary (`ameva-cluster`), dynamically configurable via CLI flags.
|
|
46
|
+
- **Pure RAM Pooling**: Worker nodes execute **zero GPU/NPU compute passes**, serving exclusively as remote high-bandwidth LPDDR memory pools to eliminate worker thermal load.
|
|
47
|
+
- **Android LMK Safety Guard-Band (300MB)**: Automatically deducts safety buffers from active RAM metrics (`MemAvailable`) to prevent Android kernel out-of-memory kills.
|
|
48
|
+
- **Protocol Guard Proxy & MasterTunnel**: Intercepts all incoming connections with a 15-byte magic preamble and 60-second time-windowed HMAC-SHA256 mutual authentication. Drops unauthorized RPC probes in `< 0.001s` (`HTTP 403 Forbidden`).
|
|
49
|
+
- **Storage-Assisted Hybrid Failover**: Automatically recovers from worker dropouts by streaming remaining tensor weights directly from local high-speed UFS 3.1 flash memory via kernel `mmap`.
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
[ Master Node (Flagship GPU) ]
|
|
53
|
+
│
|
|
54
|
+
├── Local Compute: Flagship Adreno / Mali GPU (100% of forward passes)
|
|
55
|
+
│
|
|
56
|
+
├── MasterTunnel (Loopback: 127.0.0.1:5105X)
|
|
57
|
+
│ └── Transparently injects HMAC-SHA256 handshake token
|
|
58
|
+
│
|
|
59
|
+
├── USB 3.0 ADB / Tailscale WireGuard Transport (Encrypted)
|
|
60
|
+
│ │
|
|
61
|
+
│ ├──▶ [ Worker 1 (Galaxy S20 - 12GB LPDDR5) ] ──▶ ClusterGuardProxy ──▶ Loopback rpc-server
|
|
62
|
+
│ ├──▶ [ Worker 2 (Galaxy A35 - 8GB LPDDR4X) ] ──▶ ClusterGuardProxy ──▶ Loopback rpc-server
|
|
63
|
+
│ └──▶ [ Worker 3 (Galaxy A53 - 6GB LPDDR4X) ] ──▶ ClusterGuardProxy ──▶ Loopback rpc-server
|
|
64
|
+
│
|
|
65
|
+
└── Storage Failover: Local UFS 3.1 mmap fallback upon node disconnect
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## 2. Installation & Quickstart
|
|
71
|
+
|
|
72
|
+
### Python (PyPI)
|
|
73
|
+
```bash
|
|
74
|
+
pip install amv-cluster
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Node.js / TypeScript (npm)
|
|
78
|
+
```bash
|
|
79
|
+
npm install -g @ameva/cluster
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Termux One-Liner (Android ARM64)
|
|
83
|
+
```bash
|
|
84
|
+
pkg update && pkg install python nodejs-lts git -y
|
|
85
|
+
pip install amv-cluster
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## 3. Command Line Interface (CLI) Reference
|
|
91
|
+
|
|
92
|
+
### 1) Starting a Worker Daemon (Edge Phone)
|
|
93
|
+
Launch the worker daemon with automatic Termux WakeLock acquisition and Protocol Guard protection:
|
|
94
|
+
```bash
|
|
95
|
+
# Protected worker on public port 50052 (isolates rpc-server on loopback 50055)
|
|
96
|
+
ameva-cluster worker --port 50052 --guard-band 300
|
|
97
|
+
```
|
|
98
|
+
Key Flags:
|
|
99
|
+
- `--port <int>`: External listening port (default: `50052`).
|
|
100
|
+
- `--isolated-port <int>`: Internal isolated raw RPC loopback port (default: `50055`).
|
|
101
|
+
- `--guard-band <int>`: Memory safety guardband in MB (default: `300`).
|
|
102
|
+
- `--no-guard`: Disables HMAC authentication proxy (raw debugging only).
|
|
103
|
+
|
|
104
|
+
### 2) Running the Master Orchestrator (Workstation / Host Phone)
|
|
105
|
+
Coordinate distributed inference across multiple edge smartphones:
|
|
106
|
+
```bash
|
|
107
|
+
# Auto tensor sharding across Galaxy A35 and Galaxy A53
|
|
108
|
+
ameva-cluster master \
|
|
109
|
+
-m models/Qwen2.5-7B-Instruct-Q4_K_M.gguf \
|
|
110
|
+
--workers 192.0.2.10:50052,192.0.2.11:50052 \
|
|
111
|
+
-ts auto \
|
|
112
|
+
-p "Explain the physics of gravitational lensing."
|
|
113
|
+
```
|
|
114
|
+
Key Flags:
|
|
115
|
+
- `-m, --model <path>`: Path to target model (`.gguf`, `.safetensors`, `.bin`).
|
|
116
|
+
- `--workers <csv>`: Comma-separated list of worker endpoints (`ip:port`).
|
|
117
|
+
- `-ts, --tensor-split <ratio>`: Sharding ratio across master and workers (e.g. `50,50` or `auto`).
|
|
118
|
+
- `--engine <name>`: Backend engine: `llamacpp`, `diffusion`, `vision`, `stt`, `tts`, `bitnet`, `train`.
|
|
119
|
+
- `-p, --prompt <text>`: Inference prompt.
|
|
120
|
+
|
|
121
|
+
### 3) Pre-Flight Diagnostics & Fleet Probing
|
|
122
|
+
Inspect network round-trip time (RTT), packet jitter, and compute node availability:
|
|
123
|
+
```bash
|
|
124
|
+
ameva-cluster probe --fleet 192.0.2.10:50052,192.0.2.11:50052
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## 4. 6-Modality Distributed Integration
|
|
130
|
+
|
|
131
|
+
AMEVA-Cluster natively interconnects with the six official on-device AI modality runtimes:
|
|
132
|
+
|
|
133
|
+
### 1) Large Language Models: `termux-llamacpp`
|
|
134
|
+
```bash
|
|
135
|
+
termux-llama run -m Qwen2.5-7B-Instruct-Q4_K_M.gguf \
|
|
136
|
+
--rpc 192.0.2.10:50052,192.0.2.11:50052 \
|
|
137
|
+
--tensor-split auto \
|
|
138
|
+
-p "Synthesize distributed systems theory."
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### 2) Image Diffusion: `termux-diffusion`
|
|
142
|
+
```bash
|
|
143
|
+
termux-diffusion generate \
|
|
144
|
+
--model z_image_turbo-q4.gguf \
|
|
145
|
+
--vae taef1.gguf \
|
|
146
|
+
--prompt "Hyper-detailed cybernetic macro lens photograph" \
|
|
147
|
+
--rpc 192.0.2.11:50052 \
|
|
148
|
+
--tensor-split 50,50 \
|
|
149
|
+
--steps 8
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### 3) Multimodal Vision: `termux-vision`
|
|
153
|
+
```bash
|
|
154
|
+
termux-vision analyze \
|
|
155
|
+
--model Qwen2.5-VL-7B-Instruct-Q4_K_M.gguf \
|
|
156
|
+
--mmproj mmproj-Qwen2.5-VL-7B-Instruct-f16.gguf \
|
|
157
|
+
--image telemetry.png \
|
|
158
|
+
--rpc 192.0.2.10:50052 \
|
|
159
|
+
--prompt "Identify all memory leaks in this timeline graph."
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### 4) Speech-to-Text: `termux-stt`
|
|
163
|
+
```bash
|
|
164
|
+
termux-stt transcribe conference_call.wav \
|
|
165
|
+
--model ggml-large-v3-turbo.bin \
|
|
166
|
+
--rpc 192.0.2.10:50052 \
|
|
167
|
+
--tensor-split 50,50
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### 5) Text-to-Speech: `termux-tts`
|
|
171
|
+
```bash
|
|
172
|
+
termux-tts synthesize "Distributed edge clustering operational." \
|
|
173
|
+
--voice en_us_neutral \
|
|
174
|
+
--rpc 192.0.2.11:50052 \
|
|
175
|
+
--output alert.wav
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### 6) 1-Bit LLM & LoRA Training: `termux-bitnet` & `termux-train`
|
|
179
|
+
```bash
|
|
180
|
+
# BitNet 1.58-bit ternary inference
|
|
181
|
+
termux-bitnet run -m bitnet_b1_58-3B.gguf --rpc 192.0.2.10:50052
|
|
182
|
+
|
|
183
|
+
# Distributed LoRA fine-tuning
|
|
184
|
+
termux-train lora --base-model Qwen2.5-3B.gguf --dataset train.jsonl --rpc 192.0.2.10:50052
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## 5. Software Development Kit (SDK) API
|
|
190
|
+
|
|
191
|
+
### Python API
|
|
192
|
+
```python
|
|
193
|
+
from ameva_cluster import (
|
|
194
|
+
AmevaCluster,
|
|
195
|
+
ClusterMaster,
|
|
196
|
+
ClusterWorker,
|
|
197
|
+
ClusterHardwareProbe,
|
|
198
|
+
ClusterSecurityVerifier,
|
|
199
|
+
ClusterConfig,
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
# 1. Probe local hardware and subtract 300MB safety buffer
|
|
203
|
+
mem = ClusterHardwareProbe.get_memory_info(guard_band_mb=300)
|
|
204
|
+
print(f"Usable RAM: {mem['usable_mb']}MB / Total: {mem['total_mb']}MB")
|
|
205
|
+
|
|
206
|
+
# 2. Acquire Termux system WakeLock
|
|
207
|
+
ClusterHardwareProbe.ensure_wakelock()
|
|
208
|
+
|
|
209
|
+
# 3. Execute disaggregated cluster inference
|
|
210
|
+
AmevaCluster.run_master(
|
|
211
|
+
model_path="Qwen2.5-7B-Instruct-Q4_K_M.gguf",
|
|
212
|
+
workers=["192.0.2.10:50052", "192.0.2.11:50052"],
|
|
213
|
+
tensor_split="40,30,30",
|
|
214
|
+
prompt="Explain quantum entanglement."
|
|
215
|
+
)
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Node.js / TypeScript API
|
|
219
|
+
```javascript
|
|
220
|
+
const { AmevaCluster } = require('@ameva/cluster');
|
|
221
|
+
|
|
222
|
+
// 1. Launch protected worker daemon
|
|
223
|
+
const worker = AmevaCluster.startWorker({
|
|
224
|
+
port: 50052,
|
|
225
|
+
guardBandMb: 300,
|
|
226
|
+
enableGuard: true
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
// 2. Launch master orchestrator
|
|
230
|
+
const master = AmevaCluster.runMaster({
|
|
231
|
+
modelPath: "Qwen2.5-7B-Instruct-Q4_K_M.gguf",
|
|
232
|
+
workers: ["192.0.2.10:50052", "192.0.2.11:50052"],
|
|
233
|
+
tensorSplit: "auto",
|
|
234
|
+
prompt: "Demonstrate distributed Node.js tensor coordination."
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
master.stdout.on('data', (chunk) => process.stdout.write(chunk));
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## 6. Security Gating & License Verification (Fail-Fast E403)
|
|
243
|
+
|
|
244
|
+
Multi-device distributed clustering is an exclusive capability governed by the AMEVA-Cluster protocol.
|
|
245
|
+
|
|
246
|
+
When standalone execution is attempted without official licensing or package presence, the runtime halts with code **`E403_CLUSTER_LICENSE_REQUIRED`**:
|
|
247
|
+
```
|
|
248
|
+
================================================================================
|
|
249
|
+
[AMEVA-CLUSTER] CLUSTER LICENSE REQUIRED (E403)
|
|
250
|
+
================================================================================
|
|
251
|
+
Multi-device distributed clustering is an exclusive capability of 'ameva-cluster'.
|
|
252
|
+
Standalone distributed execution without the official AMEVA-Cluster package is prohibited.
|
|
253
|
+
================================================================================
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Community Tier Inclusion
|
|
257
|
+
The official package distribution comes pre-configured with the default community authorization key (`AMEVA-COMMUNITY-CLUSTER-AUTH-TOKEN-2026`). Developers can immediately link consumer phones without manual credential injection, while external unauthorized clients are blocked at the network barrier.
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## 7. Official Documentation & Portal
|
|
262
|
+
|
|
263
|
+
- **Web Documentation**: [https://ameva.pro/lib/cluster/](https://ameva.pro/lib/cluster/)
|
|
264
|
+
- **Guard Protocol Specification**: [https://ameva.pro/lib/cluster/guard-protocol.html](https://ameva.pro/lib/cluster/guard-protocol.html)
|
|
265
|
+
- **6-Modality Sharding Guide**: [https://ameva.pro/lib/cluster/modalities-guide.html](https://ameva.pro/lib/cluster/modalities-guide.html)
|
|
266
|
+
- **Fleet Topology & Tuning**: [https://ameva.pro/lib/cluster/fleet-optimization.html](https://ameva.pro/lib/cluster/fleet-optimization.html)
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## 8. License
|
|
271
|
+
|
|
272
|
+
Licensed under the Apache-2.0 License. Copyright (c) 2026 Eunho Kim ([@uno-km](https://github.com/uno-km)).
|
|
273
|
+
All rights reserved.
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
# AMEVA-Cluster
|
|
2
|
+
|
|
3
|
+
> **Renamed.** Up to 1.0.3 the PyPI project was `ameva-cluster` (frozen old account). From 1.0.4 it is **`amv-cluster`**; the import package `ameva_cluster` and the command `ameva-cluster` are unchanged. Uninstall the old distribution first: `pip uninstall ameva-cluster`.
|
|
4
|
+
|
|
5
|
+
[](https://pypi.org/project/amv-cluster/)
|
|
6
|
+
[](https://pypi.org/project/amv-cluster/)
|
|
7
|
+
[](https://www.npmjs.com/package/@ameva/cluster)
|
|
8
|
+
[](https://www.npmjs.com/package/@ameva/cluster)
|
|
9
|
+
[](https://github.com/uno-km/ameva-cluster)
|
|
10
|
+
|
|
11
|
+
> **Symmetric Disaggregated Mobile RAM Pooling & On-Device AI Acceleration Runtime with Compute-Memory Decoupling**
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 1. Executive Architecture & Threat Model
|
|
16
|
+
|
|
17
|
+
Executing frontier AI models (7B–70B parameters, 4B Flow Matching Diffusion, Multimodal Vision) on edge mobile smartphones inevitably triggers immediate **Android Low Memory Killer (LMK) `SIGKILL` terminations** and extreme battery thermal throttling.
|
|
18
|
+
|
|
19
|
+
Conventional distributed inference frameworks force every connected node to execute computational passes, causing lower-tier edge devices to overheat, desynchronize, and crash.
|
|
20
|
+
|
|
21
|
+
**AMEVA-Cluster** resolves this architectural limitation through **Compute-Memory Decoupling**:
|
|
22
|
+
- **Symmetric Single-Binary Architecture**: Both `master` and `worker` roles run from a unified binary (`ameva-cluster`), dynamically configurable via CLI flags.
|
|
23
|
+
- **Pure RAM Pooling**: Worker nodes execute **zero GPU/NPU compute passes**, serving exclusively as remote high-bandwidth LPDDR memory pools to eliminate worker thermal load.
|
|
24
|
+
- **Android LMK Safety Guard-Band (300MB)**: Automatically deducts safety buffers from active RAM metrics (`MemAvailable`) to prevent Android kernel out-of-memory kills.
|
|
25
|
+
- **Protocol Guard Proxy & MasterTunnel**: Intercepts all incoming connections with a 15-byte magic preamble and 60-second time-windowed HMAC-SHA256 mutual authentication. Drops unauthorized RPC probes in `< 0.001s` (`HTTP 403 Forbidden`).
|
|
26
|
+
- **Storage-Assisted Hybrid Failover**: Automatically recovers from worker dropouts by streaming remaining tensor weights directly from local high-speed UFS 3.1 flash memory via kernel `mmap`.
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
[ Master Node (Flagship GPU) ]
|
|
30
|
+
│
|
|
31
|
+
├── Local Compute: Flagship Adreno / Mali GPU (100% of forward passes)
|
|
32
|
+
│
|
|
33
|
+
├── MasterTunnel (Loopback: 127.0.0.1:5105X)
|
|
34
|
+
│ └── Transparently injects HMAC-SHA256 handshake token
|
|
35
|
+
│
|
|
36
|
+
├── USB 3.0 ADB / Tailscale WireGuard Transport (Encrypted)
|
|
37
|
+
│ │
|
|
38
|
+
│ ├──▶ [ Worker 1 (Galaxy S20 - 12GB LPDDR5) ] ──▶ ClusterGuardProxy ──▶ Loopback rpc-server
|
|
39
|
+
│ ├──▶ [ Worker 2 (Galaxy A35 - 8GB LPDDR4X) ] ──▶ ClusterGuardProxy ──▶ Loopback rpc-server
|
|
40
|
+
│ └──▶ [ Worker 3 (Galaxy A53 - 6GB LPDDR4X) ] ──▶ ClusterGuardProxy ──▶ Loopback rpc-server
|
|
41
|
+
│
|
|
42
|
+
└── Storage Failover: Local UFS 3.1 mmap fallback upon node disconnect
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## 2. Installation & Quickstart
|
|
48
|
+
|
|
49
|
+
### Python (PyPI)
|
|
50
|
+
```bash
|
|
51
|
+
pip install amv-cluster
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Node.js / TypeScript (npm)
|
|
55
|
+
```bash
|
|
56
|
+
npm install -g @ameva/cluster
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Termux One-Liner (Android ARM64)
|
|
60
|
+
```bash
|
|
61
|
+
pkg update && pkg install python nodejs-lts git -y
|
|
62
|
+
pip install amv-cluster
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## 3. Command Line Interface (CLI) Reference
|
|
68
|
+
|
|
69
|
+
### 1) Starting a Worker Daemon (Edge Phone)
|
|
70
|
+
Launch the worker daemon with automatic Termux WakeLock acquisition and Protocol Guard protection:
|
|
71
|
+
```bash
|
|
72
|
+
# Protected worker on public port 50052 (isolates rpc-server on loopback 50055)
|
|
73
|
+
ameva-cluster worker --port 50052 --guard-band 300
|
|
74
|
+
```
|
|
75
|
+
Key Flags:
|
|
76
|
+
- `--port <int>`: External listening port (default: `50052`).
|
|
77
|
+
- `--isolated-port <int>`: Internal isolated raw RPC loopback port (default: `50055`).
|
|
78
|
+
- `--guard-band <int>`: Memory safety guardband in MB (default: `300`).
|
|
79
|
+
- `--no-guard`: Disables HMAC authentication proxy (raw debugging only).
|
|
80
|
+
|
|
81
|
+
### 2) Running the Master Orchestrator (Workstation / Host Phone)
|
|
82
|
+
Coordinate distributed inference across multiple edge smartphones:
|
|
83
|
+
```bash
|
|
84
|
+
# Auto tensor sharding across Galaxy A35 and Galaxy A53
|
|
85
|
+
ameva-cluster master \
|
|
86
|
+
-m models/Qwen2.5-7B-Instruct-Q4_K_M.gguf \
|
|
87
|
+
--workers 192.0.2.10:50052,192.0.2.11:50052 \
|
|
88
|
+
-ts auto \
|
|
89
|
+
-p "Explain the physics of gravitational lensing."
|
|
90
|
+
```
|
|
91
|
+
Key Flags:
|
|
92
|
+
- `-m, --model <path>`: Path to target model (`.gguf`, `.safetensors`, `.bin`).
|
|
93
|
+
- `--workers <csv>`: Comma-separated list of worker endpoints (`ip:port`).
|
|
94
|
+
- `-ts, --tensor-split <ratio>`: Sharding ratio across master and workers (e.g. `50,50` or `auto`).
|
|
95
|
+
- `--engine <name>`: Backend engine: `llamacpp`, `diffusion`, `vision`, `stt`, `tts`, `bitnet`, `train`.
|
|
96
|
+
- `-p, --prompt <text>`: Inference prompt.
|
|
97
|
+
|
|
98
|
+
### 3) Pre-Flight Diagnostics & Fleet Probing
|
|
99
|
+
Inspect network round-trip time (RTT), packet jitter, and compute node availability:
|
|
100
|
+
```bash
|
|
101
|
+
ameva-cluster probe --fleet 192.0.2.10:50052,192.0.2.11:50052
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## 4. 6-Modality Distributed Integration
|
|
107
|
+
|
|
108
|
+
AMEVA-Cluster natively interconnects with the six official on-device AI modality runtimes:
|
|
109
|
+
|
|
110
|
+
### 1) Large Language Models: `termux-llamacpp`
|
|
111
|
+
```bash
|
|
112
|
+
termux-llama run -m Qwen2.5-7B-Instruct-Q4_K_M.gguf \
|
|
113
|
+
--rpc 192.0.2.10:50052,192.0.2.11:50052 \
|
|
114
|
+
--tensor-split auto \
|
|
115
|
+
-p "Synthesize distributed systems theory."
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### 2) Image Diffusion: `termux-diffusion`
|
|
119
|
+
```bash
|
|
120
|
+
termux-diffusion generate \
|
|
121
|
+
--model z_image_turbo-q4.gguf \
|
|
122
|
+
--vae taef1.gguf \
|
|
123
|
+
--prompt "Hyper-detailed cybernetic macro lens photograph" \
|
|
124
|
+
--rpc 192.0.2.11:50052 \
|
|
125
|
+
--tensor-split 50,50 \
|
|
126
|
+
--steps 8
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### 3) Multimodal Vision: `termux-vision`
|
|
130
|
+
```bash
|
|
131
|
+
termux-vision analyze \
|
|
132
|
+
--model Qwen2.5-VL-7B-Instruct-Q4_K_M.gguf \
|
|
133
|
+
--mmproj mmproj-Qwen2.5-VL-7B-Instruct-f16.gguf \
|
|
134
|
+
--image telemetry.png \
|
|
135
|
+
--rpc 192.0.2.10:50052 \
|
|
136
|
+
--prompt "Identify all memory leaks in this timeline graph."
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### 4) Speech-to-Text: `termux-stt`
|
|
140
|
+
```bash
|
|
141
|
+
termux-stt transcribe conference_call.wav \
|
|
142
|
+
--model ggml-large-v3-turbo.bin \
|
|
143
|
+
--rpc 192.0.2.10:50052 \
|
|
144
|
+
--tensor-split 50,50
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### 5) Text-to-Speech: `termux-tts`
|
|
148
|
+
```bash
|
|
149
|
+
termux-tts synthesize "Distributed edge clustering operational." \
|
|
150
|
+
--voice en_us_neutral \
|
|
151
|
+
--rpc 192.0.2.11:50052 \
|
|
152
|
+
--output alert.wav
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### 6) 1-Bit LLM & LoRA Training: `termux-bitnet` & `termux-train`
|
|
156
|
+
```bash
|
|
157
|
+
# BitNet 1.58-bit ternary inference
|
|
158
|
+
termux-bitnet run -m bitnet_b1_58-3B.gguf --rpc 192.0.2.10:50052
|
|
159
|
+
|
|
160
|
+
# Distributed LoRA fine-tuning
|
|
161
|
+
termux-train lora --base-model Qwen2.5-3B.gguf --dataset train.jsonl --rpc 192.0.2.10:50052
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## 5. Software Development Kit (SDK) API
|
|
167
|
+
|
|
168
|
+
### Python API
|
|
169
|
+
```python
|
|
170
|
+
from ameva_cluster import (
|
|
171
|
+
AmevaCluster,
|
|
172
|
+
ClusterMaster,
|
|
173
|
+
ClusterWorker,
|
|
174
|
+
ClusterHardwareProbe,
|
|
175
|
+
ClusterSecurityVerifier,
|
|
176
|
+
ClusterConfig,
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
# 1. Probe local hardware and subtract 300MB safety buffer
|
|
180
|
+
mem = ClusterHardwareProbe.get_memory_info(guard_band_mb=300)
|
|
181
|
+
print(f"Usable RAM: {mem['usable_mb']}MB / Total: {mem['total_mb']}MB")
|
|
182
|
+
|
|
183
|
+
# 2. Acquire Termux system WakeLock
|
|
184
|
+
ClusterHardwareProbe.ensure_wakelock()
|
|
185
|
+
|
|
186
|
+
# 3. Execute disaggregated cluster inference
|
|
187
|
+
AmevaCluster.run_master(
|
|
188
|
+
model_path="Qwen2.5-7B-Instruct-Q4_K_M.gguf",
|
|
189
|
+
workers=["192.0.2.10:50052", "192.0.2.11:50052"],
|
|
190
|
+
tensor_split="40,30,30",
|
|
191
|
+
prompt="Explain quantum entanglement."
|
|
192
|
+
)
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Node.js / TypeScript API
|
|
196
|
+
```javascript
|
|
197
|
+
const { AmevaCluster } = require('@ameva/cluster');
|
|
198
|
+
|
|
199
|
+
// 1. Launch protected worker daemon
|
|
200
|
+
const worker = AmevaCluster.startWorker({
|
|
201
|
+
port: 50052,
|
|
202
|
+
guardBandMb: 300,
|
|
203
|
+
enableGuard: true
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
// 2. Launch master orchestrator
|
|
207
|
+
const master = AmevaCluster.runMaster({
|
|
208
|
+
modelPath: "Qwen2.5-7B-Instruct-Q4_K_M.gguf",
|
|
209
|
+
workers: ["192.0.2.10:50052", "192.0.2.11:50052"],
|
|
210
|
+
tensorSplit: "auto",
|
|
211
|
+
prompt: "Demonstrate distributed Node.js tensor coordination."
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
master.stdout.on('data', (chunk) => process.stdout.write(chunk));
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## 6. Security Gating & License Verification (Fail-Fast E403)
|
|
220
|
+
|
|
221
|
+
Multi-device distributed clustering is an exclusive capability governed by the AMEVA-Cluster protocol.
|
|
222
|
+
|
|
223
|
+
When standalone execution is attempted without official licensing or package presence, the runtime halts with code **`E403_CLUSTER_LICENSE_REQUIRED`**:
|
|
224
|
+
```
|
|
225
|
+
================================================================================
|
|
226
|
+
[AMEVA-CLUSTER] CLUSTER LICENSE REQUIRED (E403)
|
|
227
|
+
================================================================================
|
|
228
|
+
Multi-device distributed clustering is an exclusive capability of 'ameva-cluster'.
|
|
229
|
+
Standalone distributed execution without the official AMEVA-Cluster package is prohibited.
|
|
230
|
+
================================================================================
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Community Tier Inclusion
|
|
234
|
+
The official package distribution comes pre-configured with the default community authorization key (`AMEVA-COMMUNITY-CLUSTER-AUTH-TOKEN-2026`). Developers can immediately link consumer phones without manual credential injection, while external unauthorized clients are blocked at the network barrier.
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## 7. Official Documentation & Portal
|
|
239
|
+
|
|
240
|
+
- **Web Documentation**: [https://ameva.pro/lib/cluster/](https://ameva.pro/lib/cluster/)
|
|
241
|
+
- **Guard Protocol Specification**: [https://ameva.pro/lib/cluster/guard-protocol.html](https://ameva.pro/lib/cluster/guard-protocol.html)
|
|
242
|
+
- **6-Modality Sharding Guide**: [https://ameva.pro/lib/cluster/modalities-guide.html](https://ameva.pro/lib/cluster/modalities-guide.html)
|
|
243
|
+
- **Fleet Topology & Tuning**: [https://ameva.pro/lib/cluster/fleet-optimization.html](https://ameva.pro/lib/cluster/fleet-optimization.html)
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## 8. License
|
|
248
|
+
|
|
249
|
+
Licensed under the Apache-2.0 License. Copyright (c) 2026 Eunho Kim ([@uno-km](https://github.com/uno-km)).
|
|
250
|
+
All rights reserved.
|