amv-cluster 1.0.4__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.
- ameva_cluster/__init__.py +99 -0
- ameva_cluster/adapter.py +97 -0
- ameva_cluster/cli.py +244 -0
- ameva_cluster/config.py +85 -0
- ameva_cluster/engine.py +360 -0
- ameva_cluster/exceptions.py +70 -0
- ameva_cluster/guard.py +335 -0
- ameva_cluster/hardware.py +142 -0
- ameva_cluster/master.py +237 -0
- ameva_cluster/probe.py +353 -0
- ameva_cluster/protocol.py +241 -0
- ameva_cluster/security.py +67 -0
- ameva_cluster/strategy.py +148 -0
- ameva_cluster/transport.py +148 -0
- ameva_cluster/worker.py +311 -0
- amv_cluster-1.0.4.dist-info/METADATA +273 -0
- amv_cluster-1.0.4.dist-info/RECORD +22 -0
- amv_cluster-1.0.4.dist-info/WHEEL +5 -0
- amv_cluster-1.0.4.dist-info/entry_points.txt +2 -0
- amv_cluster-1.0.4.dist-info/licenses/LICENSE +90 -0
- amv_cluster-1.0.4.dist-info/licenses/NOTICE +17 -0
- amv_cluster-1.0.4.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"""
|
|
2
|
+
AMEVA-Cluster (Unified Symmetric Mobile Disaggregated RAM Pooling Runtime)
|
|
3
|
+
Copyright (c) 2026 Eunho Kim. All rights reserved.
|
|
4
|
+
Licensed under Apache-2.0.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
__version__ = "1.0.3"
|
|
8
|
+
__author__ = "Eunho Kim"
|
|
9
|
+
|
|
10
|
+
from .exceptions import (
|
|
11
|
+
AmevaClusterError,
|
|
12
|
+
ClusterConnectionError,
|
|
13
|
+
ClusterConfigurationError,
|
|
14
|
+
ClusterLicenseRequiredError,
|
|
15
|
+
ClusterSecurityError,
|
|
16
|
+
HardwareProbeError,
|
|
17
|
+
WorkerProcessError,
|
|
18
|
+
)
|
|
19
|
+
from .config import (
|
|
20
|
+
ClusterConfig,
|
|
21
|
+
WorkerConfig,
|
|
22
|
+
MasterConfig,
|
|
23
|
+
ShardingStrategyType,
|
|
24
|
+
ModalityEngineType,
|
|
25
|
+
DEFAULT_BEACON_PORT,
|
|
26
|
+
DEFAULT_RPC_PORT,
|
|
27
|
+
DEFAULT_ISOLATED_RPC_PORT,
|
|
28
|
+
DEFAULT_PROBE_PORT,
|
|
29
|
+
DEFAULT_GUARD_BAND_MB,
|
|
30
|
+
DEFAULT_GUARD_KEY,
|
|
31
|
+
)
|
|
32
|
+
from .hardware import ClusterHardwareProbe
|
|
33
|
+
from .security import ClusterSecurityVerifier
|
|
34
|
+
from .adapter import ClusterAdapter
|
|
35
|
+
from .engine import AmevaCluster, EngineRegistry
|
|
36
|
+
from .worker import ClusterWorker
|
|
37
|
+
from .master import ClusterMaster
|
|
38
|
+
from .guard import (
|
|
39
|
+
ClusterGuardProxy,
|
|
40
|
+
MasterTunnel,
|
|
41
|
+
verify_cluster_license,
|
|
42
|
+
)
|
|
43
|
+
from .protocol import (
|
|
44
|
+
ClusterPacketType,
|
|
45
|
+
NodeTelemetry,
|
|
46
|
+
NodeRegistration,
|
|
47
|
+
HeartbeatMessage,
|
|
48
|
+
)
|
|
49
|
+
from .transport import TransportAdapter, TransportType
|
|
50
|
+
from .probe import (
|
|
51
|
+
PingStats,
|
|
52
|
+
LoopbackStats,
|
|
53
|
+
PreFlightScorecard,
|
|
54
|
+
run_preflight_probe,
|
|
55
|
+
probe_cluster_fleet,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
__all__ = [
|
|
59
|
+
"AmevaCluster",
|
|
60
|
+
"ClusterConfig",
|
|
61
|
+
"WorkerConfig",
|
|
62
|
+
"MasterConfig",
|
|
63
|
+
"ShardingStrategyType",
|
|
64
|
+
"ModalityEngineType",
|
|
65
|
+
"ClusterAdapter",
|
|
66
|
+
"ClusterHardwareProbe",
|
|
67
|
+
"ClusterSecurityVerifier",
|
|
68
|
+
"EngineRegistry",
|
|
69
|
+
"ClusterWorker",
|
|
70
|
+
"ClusterMaster",
|
|
71
|
+
"ClusterGuardProxy",
|
|
72
|
+
"MasterTunnel",
|
|
73
|
+
"verify_cluster_license",
|
|
74
|
+
"AmevaClusterError",
|
|
75
|
+
"ClusterConnectionError",
|
|
76
|
+
"ClusterConfigurationError",
|
|
77
|
+
"ClusterLicenseRequiredError",
|
|
78
|
+
"ClusterSecurityError",
|
|
79
|
+
"HardwareProbeError",
|
|
80
|
+
"WorkerProcessError",
|
|
81
|
+
"ClusterPacketType",
|
|
82
|
+
"NodeTelemetry",
|
|
83
|
+
"NodeRegistration",
|
|
84
|
+
"HeartbeatMessage",
|
|
85
|
+
"TransportAdapter",
|
|
86
|
+
"TransportType",
|
|
87
|
+
"PingStats",
|
|
88
|
+
"LoopbackStats",
|
|
89
|
+
"PreFlightScorecard",
|
|
90
|
+
"run_preflight_probe",
|
|
91
|
+
"probe_cluster_fleet",
|
|
92
|
+
"DEFAULT_BEACON_PORT",
|
|
93
|
+
"DEFAULT_RPC_PORT",
|
|
94
|
+
"DEFAULT_ISOLATED_RPC_PORT",
|
|
95
|
+
"DEFAULT_PROBE_PORT",
|
|
96
|
+
"DEFAULT_GUARD_BAND_MB",
|
|
97
|
+
"DEFAULT_GUARD_KEY",
|
|
98
|
+
]
|
|
99
|
+
|
ameva_cluster/adapter.py
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Copyright (c) 2026 Uno Kim / AMEVA Foundation. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0 OR Commercial-License
|
|
3
|
+
"""
|
|
4
|
+
AMEVA-Cluster Modality Engine Adapter Subsystem
|
|
5
|
+
Component: [AMEVA-CLUSTER-ADAPTER]
|
|
6
|
+
Standards: 6-Modality Unified Interface, Zero-Silent-Fallback
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import logging
|
|
12
|
+
from typing import List, Optional, Union, Dict, Any, Tuple
|
|
13
|
+
|
|
14
|
+
from .exceptions import ClusterConfigurationError
|
|
15
|
+
from .config import ModalityEngineType
|
|
16
|
+
|
|
17
|
+
logger = logging.getLogger(__name__)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class ClusterAdapter:
|
|
21
|
+
"""
|
|
22
|
+
Adapter bridge connecting AMEVA-Cluster to 6 major Termux AI modalities:
|
|
23
|
+
- termux-llamacpp
|
|
24
|
+
- termux-diffusion
|
|
25
|
+
- termux-vision
|
|
26
|
+
- termux-stt
|
|
27
|
+
- termux-tts
|
|
28
|
+
- termux-bitnet
|
|
29
|
+
- termux-train
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
SUPPORTED_MODALITIES = [
|
|
33
|
+
ModalityEngineType.LLAMACPP.value,
|
|
34
|
+
ModalityEngineType.DIFFUSION.value,
|
|
35
|
+
ModalityEngineType.VISION.value,
|
|
36
|
+
ModalityEngineType.STT.value,
|
|
37
|
+
ModalityEngineType.TTS.value,
|
|
38
|
+
ModalityEngineType.BITNET.value,
|
|
39
|
+
ModalityEngineType.TRAIN.value,
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
@staticmethod
|
|
43
|
+
def parse_rpc_spec(rpc_input: Optional[Union[str, List[str]]]) -> List[str]:
|
|
44
|
+
"""Parse and strictly validate distributed RPC server endpoints."""
|
|
45
|
+
if not rpc_input:
|
|
46
|
+
return []
|
|
47
|
+
|
|
48
|
+
if isinstance(rpc_input, str):
|
|
49
|
+
raw_servers = [s.strip() for s in rpc_input.split(",") if s.strip()]
|
|
50
|
+
elif isinstance(rpc_input, (list, tuple)):
|
|
51
|
+
raw_servers = [str(s).strip() for s in rpc_input if str(s).strip()]
|
|
52
|
+
else:
|
|
53
|
+
raise ClusterConfigurationError(
|
|
54
|
+
f"Invalid cluster RPC spec type: {type(rpc_input).__name__}."
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
parsed_servers: List[str] = []
|
|
58
|
+
for entry in raw_servers:
|
|
59
|
+
if ":" not in entry:
|
|
60
|
+
raise ClusterConfigurationError(
|
|
61
|
+
f"Invalid RPC endpoint format '{entry}'. Expected 'host:port'."
|
|
62
|
+
)
|
|
63
|
+
parts = entry.split(":")
|
|
64
|
+
if len(parts) != 2:
|
|
65
|
+
raise ClusterConfigurationError(
|
|
66
|
+
f"Malformed RPC endpoint '{entry}'. Exactly one colon separator required."
|
|
67
|
+
)
|
|
68
|
+
host, port_str = parts[0].strip(), parts[1].strip()
|
|
69
|
+
if not host:
|
|
70
|
+
raise ClusterConfigurationError(f"Empty hostname/IP in RPC endpoint '{entry}'.")
|
|
71
|
+
try:
|
|
72
|
+
port = int(port_str)
|
|
73
|
+
if not (1 <= port <= 65535):
|
|
74
|
+
raise ValueError()
|
|
75
|
+
except ValueError:
|
|
76
|
+
raise ClusterConfigurationError(
|
|
77
|
+
f"Invalid port '{port_str}' in RPC endpoint '{entry}'. Must be integer 1..65535."
|
|
78
|
+
)
|
|
79
|
+
parsed_servers.append(f"{host}:{port}")
|
|
80
|
+
|
|
81
|
+
return parsed_servers
|
|
82
|
+
|
|
83
|
+
@classmethod
|
|
84
|
+
def adapt_command_flags(
|
|
85
|
+
cls,
|
|
86
|
+
modality: str,
|
|
87
|
+
rpc_servers: List[str],
|
|
88
|
+
tensor_split: Optional[str] = None,
|
|
89
|
+
) -> List[str]:
|
|
90
|
+
"""Builds standardized CLI argument flags for target modality engine."""
|
|
91
|
+
mod = modality.lower()
|
|
92
|
+
flags = []
|
|
93
|
+
if rpc_servers:
|
|
94
|
+
flags.extend(["--rpc", ",".join(rpc_servers)])
|
|
95
|
+
if tensor_split:
|
|
96
|
+
flags.extend(["--tensor-split", str(tensor_split)])
|
|
97
|
+
return flags
|
ameva_cluster/cli.py
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
# Copyright (c) 2026 Uno Kim / AMEVA Foundation. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0 OR Commercial-License
|
|
3
|
+
"""
|
|
4
|
+
AMEVA-Cluster Unified CLI Entrypoint
|
|
5
|
+
Provides symmetric master/worker subcommand routing and runtime dispatching.
|
|
6
|
+
Now supports pluggable --engine and --strategy options.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import argparse
|
|
10
|
+
import os
|
|
11
|
+
import subprocess
|
|
12
|
+
import sys
|
|
13
|
+
import time
|
|
14
|
+
|
|
15
|
+
from . import __version__
|
|
16
|
+
from .protocol import DEFAULT_GUARD_BAND_MB, DEFAULT_RPC_PORT, DEFAULT_BEACON_PORT
|
|
17
|
+
from .transport import TransportType
|
|
18
|
+
from .worker import ClusterWorker
|
|
19
|
+
from .master import ClusterMaster
|
|
20
|
+
from .engine import EngineRegistry
|
|
21
|
+
from .strategy import StrategyRegistry
|
|
22
|
+
from .probe import run_preflight_probe, probe_cluster_fleet, DEFAULT_PROBE_PORT
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def run_worker(args: argparse.Namespace) -> int:
|
|
26
|
+
"""Launches local worker daemon as in-memory weight basket."""
|
|
27
|
+
worker = ClusterWorker(
|
|
28
|
+
node_id=args.node_id,
|
|
29
|
+
guard_band_mb=args.guard_band,
|
|
30
|
+
rpc_port=args.port,
|
|
31
|
+
probe_port=args.probe_port,
|
|
32
|
+
beacon_port=args.beacon_port,
|
|
33
|
+
transport_mode=TransportType(args.transport),
|
|
34
|
+
rpc_binary_path=args.rpc_bin,
|
|
35
|
+
enable_guard=not getattr(args, "no_guard", False),
|
|
36
|
+
)
|
|
37
|
+
worker.start(spawn_rpc=not args.no_rpc)
|
|
38
|
+
|
|
39
|
+
sys.stdout.write("[AMEVA-CLUSTER] Worker daemon running. Press Ctrl+C to terminate.\n")
|
|
40
|
+
try:
|
|
41
|
+
while True:
|
|
42
|
+
time.sleep(1.0)
|
|
43
|
+
except KeyboardInterrupt:
|
|
44
|
+
sys.stdout.write("\n[AMEVA-CLUSTER] Interrupted. Shutting down worker...\n")
|
|
45
|
+
worker.stop()
|
|
46
|
+
return 0
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def run_master(args: argparse.Namespace) -> int:
|
|
50
|
+
"""Launches coordinator to discover workers, compute split ratios, and execute inference."""
|
|
51
|
+
master = ClusterMaster(
|
|
52
|
+
beacon_port=args.beacon_port,
|
|
53
|
+
heartbeat_timeout_sec=args.heartbeat_timeout,
|
|
54
|
+
engine=args.engine,
|
|
55
|
+
strategy=args.strategy,
|
|
56
|
+
enable_guard=not getattr(args, "no_guard", False),
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
if getattr(args, "workers", None):
|
|
60
|
+
sys.stdout.write(f"[AMEVA-CLUSTER] Registering explicit worker endpoints: {args.workers}\n")
|
|
61
|
+
master.add_explicit_workers(args.workers)
|
|
62
|
+
else:
|
|
63
|
+
master.start_discovery()
|
|
64
|
+
sys.stdout.write(f"[AMEVA-CLUSTER] Discovering worker nodes on local network (waiting {args.wait_sec}s)...\n")
|
|
65
|
+
time.sleep(args.wait_sec)
|
|
66
|
+
|
|
67
|
+
workers = master.get_active_workers()
|
|
68
|
+
sys.stdout.write(f"[AMEVA-CLUSTER] Discovered {len(workers)} active worker basket(s).\n")
|
|
69
|
+
for idx, w in enumerate(workers, 1):
|
|
70
|
+
sys.stdout.write(
|
|
71
|
+
f" [{idx}] {w.telemetry.node_id} ({w.telemetry.ip}:{w.telemetry.rpc_port}) | Usable: {w.telemetry.safe_usable_vram_mb}MB\n"
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
try:
|
|
75
|
+
cmd = master.build_runtime_command(
|
|
76
|
+
model_path=args.model,
|
|
77
|
+
prompt=args.prompt,
|
|
78
|
+
engine_bin=args.engine_bin,
|
|
79
|
+
local_vram_mb=args.local_vram,
|
|
80
|
+
ngl=args.ngl,
|
|
81
|
+
threads=args.threads,
|
|
82
|
+
tensor_split_override=getattr(args, "tensor_split", None),
|
|
83
|
+
)
|
|
84
|
+
except Exception as e:
|
|
85
|
+
sys.stderr.write(f"[MASTER-ERROR] Command assembly failed: {e}\n")
|
|
86
|
+
master.stop_discovery()
|
|
87
|
+
return 1
|
|
88
|
+
|
|
89
|
+
sys.stdout.write(f"\n[AMEVA-CLUSTER] Executing ({master.engine.name}/{master.strategy.name}): {' '.join(cmd)}\n\n")
|
|
90
|
+
|
|
91
|
+
if args.dry_run:
|
|
92
|
+
sys.stdout.write("[AMEVA-CLUSTER] Dry-run complete. Skipping process execution.\n")
|
|
93
|
+
master.stop_discovery()
|
|
94
|
+
return 0
|
|
95
|
+
|
|
96
|
+
try:
|
|
97
|
+
proc = subprocess.run(cmd)
|
|
98
|
+
ret = proc.returncode
|
|
99
|
+
except FileNotFoundError:
|
|
100
|
+
sys.stderr.write(f"[MASTER-ERROR] Engine executable '{cmd[0]}' not found on PATH.\n")
|
|
101
|
+
ret = 127
|
|
102
|
+
finally:
|
|
103
|
+
master.stop_discovery()
|
|
104
|
+
|
|
105
|
+
return ret
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def run_status(args: argparse.Namespace) -> int:
|
|
109
|
+
"""Scans and prints live network workers."""
|
|
110
|
+
master = ClusterMaster(beacon_port=args.beacon_port)
|
|
111
|
+
master.start_discovery()
|
|
112
|
+
sys.stdout.write(f"[AMEVA-CLUSTER] Scanning active nodes for {args.duration}s...\n")
|
|
113
|
+
time.sleep(args.duration)
|
|
114
|
+
workers = master.get_active_workers()
|
|
115
|
+
master.stop_discovery()
|
|
116
|
+
|
|
117
|
+
sys.stdout.write(f"\n=== AMEVA-Cluster Fleet Status ({len(workers)} online) ===\n")
|
|
118
|
+
if not workers:
|
|
119
|
+
sys.stdout.write(" No active worker nodes detected.\n")
|
|
120
|
+
for w in workers:
|
|
121
|
+
t = w.telemetry
|
|
122
|
+
sys.stdout.write(
|
|
123
|
+
f"- Node: {t.node_id}\n"
|
|
124
|
+
f" Endpoint: {t.ip}:{t.rpc_port}\n"
|
|
125
|
+
f" Total RAM: {t.total_ram_mb}MB | Avail: {t.mem_available_mb}MB | GuardBand: {t.guard_band_mb}MB\n"
|
|
126
|
+
f" Safe Usable VRAM: {t.safe_usable_vram_mb}MB\n"
|
|
127
|
+
f" Status: {t.status} | Transport: {t.transport}\n\n"
|
|
128
|
+
)
|
|
129
|
+
return 0
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def run_probe(args: argparse.Namespace) -> int:
|
|
133
|
+
"""Runs pre-flight RTT latency ping and synthetic tensor co-working loopback diagnostics."""
|
|
134
|
+
if args.target:
|
|
135
|
+
# Target format: host:port or host
|
|
136
|
+
parts = args.target.split(":")
|
|
137
|
+
host = parts[0]
|
|
138
|
+
rpc_port = int(parts[1]) if len(parts) > 1 else DEFAULT_RPC_PORT
|
|
139
|
+
probe_port = int(parts[2]) if len(parts) > 2 else (rpc_port + 1)
|
|
140
|
+
|
|
141
|
+
sys.stdout.write(f"[AMEVA-PROBE] Executing pre-flight diagnostics on target {host}:{rpc_port}...\n")
|
|
142
|
+
report = run_preflight_probe(
|
|
143
|
+
host=host,
|
|
144
|
+
rpc_port=rpc_port,
|
|
145
|
+
probe_port=probe_port,
|
|
146
|
+
node_id=args.node_id or f"Node-{host}",
|
|
147
|
+
size_mb=args.size_mb,
|
|
148
|
+
)
|
|
149
|
+
sys.stdout.write("\n" + report.format_terminal_output() + "\n")
|
|
150
|
+
return 0 if report.status != "FAIL" else 1
|
|
151
|
+
|
|
152
|
+
sys.stdout.write(f"[AMEVA-PROBE] Scanning local cluster fleet (listening {args.duration}s)...\n")
|
|
153
|
+
reports = probe_cluster_fleet(duration=args.duration, beacon_port=args.beacon_port, size_mb=args.size_mb)
|
|
154
|
+
if not reports:
|
|
155
|
+
sys.stderr.write("[AMEVA-PROBE-WARN] No active worker nodes discovered on local subnet.\n")
|
|
156
|
+
return 1
|
|
157
|
+
|
|
158
|
+
sys.stdout.write(f"\n[AMEVA-PROBE] Discovered {len(reports)} node(s). Diagnostic reports:\n\n")
|
|
159
|
+
all_passed = True
|
|
160
|
+
for r in reports:
|
|
161
|
+
sys.stdout.write(r.format_terminal_output() + "\n\n")
|
|
162
|
+
if r.status == "FAIL":
|
|
163
|
+
all_passed = False
|
|
164
|
+
|
|
165
|
+
return 0 if all_passed else 1
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def main() -> int:
|
|
169
|
+
parser = argparse.ArgumentParser(
|
|
170
|
+
prog="ameva-cluster",
|
|
171
|
+
description="Symmetric Disaggregated Mobile RAM Pooling & On-Device AI Acceleration CLI",
|
|
172
|
+
)
|
|
173
|
+
parser.add_argument("--version", action="version", version=f"%(prog)s {__version__}")
|
|
174
|
+
|
|
175
|
+
subparsers = parser.add_subparsers(dest="subcommand", help="Cluster sub-command to execute")
|
|
176
|
+
|
|
177
|
+
# Worker sub-command
|
|
178
|
+
worker_p = subparsers.add_parser("worker", help="Start local worker node as in-memory weight basket")
|
|
179
|
+
worker_p.add_argument("--node-id", type=str, default=None, help="Custom identifier for this node")
|
|
180
|
+
worker_p.add_argument(
|
|
181
|
+
"--guard-band", type=int, default=DEFAULT_GUARD_BAND_MB, help=f"Safety guard-band in MB (default: {DEFAULT_GUARD_BAND_MB})"
|
|
182
|
+
)
|
|
183
|
+
worker_p.add_argument("--port", type=int, default=DEFAULT_RPC_PORT, help=f"RPC server port (default: {DEFAULT_RPC_PORT})")
|
|
184
|
+
worker_p.add_argument("--probe-port", type=int, default=DEFAULT_PROBE_PORT, help=f"TCP probe port (default: {DEFAULT_PROBE_PORT})")
|
|
185
|
+
worker_p.add_argument("--beacon-port", type=int, default=DEFAULT_BEACON_PORT, help=f"UDP beacon port (default: {DEFAULT_BEACON_PORT})")
|
|
186
|
+
worker_p.add_argument(
|
|
187
|
+
"--transport", choices=["auto", "wired", "wifi"], default="auto", help="Physical network mode"
|
|
188
|
+
)
|
|
189
|
+
worker_p.add_argument("--rpc-bin", type=str, default=None, help="Path to precompiled llama-rpc-server binary")
|
|
190
|
+
worker_p.add_argument("--no-rpc", action="store_true", help="Standby in beacon-only passive mode without spawning RPC server")
|
|
191
|
+
worker_p.add_argument("--no-guard", action="store_true", help="Disable AMEVA Protocol Guard mutual authentication proxy")
|
|
192
|
+
|
|
193
|
+
# Master sub-command
|
|
194
|
+
master_p = subparsers.add_parser("master", help="Execute inference across cluster workers")
|
|
195
|
+
master_p.add_argument("-m", "--model", type=str, required=True, help="Path to local .gguf model file")
|
|
196
|
+
master_p.add_argument("-p", "--prompt", type=str, default="Hello, AMEVA Cluster!", help="Inference prompt text")
|
|
197
|
+
master_p.add_argument(
|
|
198
|
+
"--engine", choices=EngineRegistry.list_available(), default="llamacpp", help="Inference engine backend (default: llamacpp)"
|
|
199
|
+
)
|
|
200
|
+
master_p.add_argument(
|
|
201
|
+
"--strategy", choices=StrategyRegistry.list_available(), default="proportional", help="Tensor sharding strategy (default: proportional)"
|
|
202
|
+
)
|
|
203
|
+
master_p.add_argument("--engine-bin", type=str, default=None, help="Custom engine executable path")
|
|
204
|
+
master_p.add_argument("--local-vram", type=int, default=2048, help="Local master execution VRAM allocation in MB")
|
|
205
|
+
master_p.add_argument("-ngl", type=int, default=99, help="Number of GPU layers to offload")
|
|
206
|
+
master_p.add_argument("-t", "--threads", type=int, default=4, help="CPU execution threads")
|
|
207
|
+
master_p.add_argument("--wait-sec", type=float, default=2.0, help="Initial discovery window in seconds")
|
|
208
|
+
master_p.add_argument("--beacon-port", type=int, default=DEFAULT_BEACON_PORT, help="UDP beacon listen port")
|
|
209
|
+
master_p.add_argument("--workers", type=str, default=None, help="Explicit worker endpoints (e.g. 192.0.2.10:50052,192.0.2.11:50052) bypassing UDP beacon discovery")
|
|
210
|
+
master_p.add_argument("-ts", "--tensor-split", type=str, default=None, help="Explicit tensor split override (e.g. 38,33,29)")
|
|
211
|
+
master_p.add_argument("--no-guard", action="store_true", help="Disable AMEVA Protocol Guard mutual authentication tunnel")
|
|
212
|
+
master_p.add_argument("--dry-run", action="store_true", help="Print assembled command without executing process")
|
|
213
|
+
|
|
214
|
+
# Status sub-command
|
|
215
|
+
status_p = subparsers.add_parser("status", help="Scan and inspect active cluster nodes")
|
|
216
|
+
status_p.add_argument("--beacon-port", type=int, default=DEFAULT_BEACON_PORT, help="UDP beacon listen port")
|
|
217
|
+
status_p.add_argument("--duration", type=float, default=3.0, help="Scan duration in seconds")
|
|
218
|
+
|
|
219
|
+
# Probe sub-command
|
|
220
|
+
probe_p = subparsers.add_parser("probe", help="Pre-flight RTT latency ping and synthetic tensor co-working diagnostics")
|
|
221
|
+
probe_p.add_argument("--target", type=str, default=None, help="Direct target IP:PORT to probe (e.g. 192.168.1.50:50052)")
|
|
222
|
+
probe_p.add_argument("--node-id", type=str, default=None, help="Identifier label for target node")
|
|
223
|
+
probe_p.add_argument("--size-mb", type=float, default=1.0, help="Synthetic tensor buffer size in MB (default: 1.0)")
|
|
224
|
+
probe_p.add_argument("--beacon-port", type=int, default=DEFAULT_BEACON_PORT, help="UDP beacon listen port for fleet scan")
|
|
225
|
+
probe_p.add_argument("--duration", type=float, default=2.5, help="Fleet discovery duration in seconds")
|
|
226
|
+
|
|
227
|
+
args = parser.parse_args()
|
|
228
|
+
if not args.subcommand:
|
|
229
|
+
parser.print_help()
|
|
230
|
+
return 0
|
|
231
|
+
|
|
232
|
+
if args.subcommand == "worker":
|
|
233
|
+
return run_worker(args)
|
|
234
|
+
elif args.subcommand == "master":
|
|
235
|
+
return run_master(args)
|
|
236
|
+
elif args.subcommand == "status":
|
|
237
|
+
return run_status(args)
|
|
238
|
+
elif args.subcommand == "probe":
|
|
239
|
+
return run_probe(args)
|
|
240
|
+
return 0
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
if __name__ == "__main__":
|
|
244
|
+
sys.exit(main())
|
ameva_cluster/config.py
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Copyright (c) 2026 Uno Kim / AMEVA Foundation. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0 OR Commercial-License
|
|
3
|
+
"""
|
|
4
|
+
AMEVA-Cluster Configuration & Spec Subsystem
|
|
5
|
+
Component: [AMEVA-CLUSTER-CONFIG]
|
|
6
|
+
Standards: Zero-Silent-Fallback, Strict Type Checking
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from dataclasses import dataclass, field
|
|
12
|
+
from enum import Enum
|
|
13
|
+
from typing import List, Optional, Dict, Any
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
DEFAULT_BEACON_PORT = 53530
|
|
17
|
+
DEFAULT_RPC_PORT = 50052
|
|
18
|
+
DEFAULT_ISOLATED_RPC_PORT = 50055
|
|
19
|
+
DEFAULT_PROBE_PORT = 50053
|
|
20
|
+
DEFAULT_GUARD_BAND_MB = 300
|
|
21
|
+
DEFAULT_GUARD_KEY = "AMEVA-COMMUNITY-CLUSTER-AUTH-TOKEN-2026"
|
|
22
|
+
DEFAULT_HANDSHAKE_TIMEOUT_SEC = 2.0
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class ShardingStrategyType(str, Enum):
|
|
26
|
+
PROPORTIONAL = "proportional"
|
|
27
|
+
UNIFORM = "uniform"
|
|
28
|
+
LATENCY_AWARE = "latency-aware"
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class ModalityEngineType(str, Enum):
|
|
32
|
+
LLAMACPP = "llamacpp"
|
|
33
|
+
DIFFUSION = "diffusion"
|
|
34
|
+
VISION = "vision"
|
|
35
|
+
STT = "stt"
|
|
36
|
+
TTS = "tts"
|
|
37
|
+
BITNET = "bitnet"
|
|
38
|
+
TRAIN = "train"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@dataclass
|
|
42
|
+
class WorkerConfig:
|
|
43
|
+
"""Configuration specification for cluster worker daemon."""
|
|
44
|
+
port: int = DEFAULT_RPC_PORT
|
|
45
|
+
isolated_port: int = DEFAULT_ISOLATED_RPC_PORT
|
|
46
|
+
guard_band_mb: int = DEFAULT_GUARD_BAND_MB
|
|
47
|
+
enable_guard: bool = True
|
|
48
|
+
secret_key: Optional[str] = None
|
|
49
|
+
rpc_server_path: Optional[str] = None
|
|
50
|
+
auto_wakelock: bool = True
|
|
51
|
+
|
|
52
|
+
def validate(self) -> None:
|
|
53
|
+
if not (1 <= self.port <= 65535):
|
|
54
|
+
raise ValueError(f"Invalid worker port: {self.port}")
|
|
55
|
+
if not (1 <= self.isolated_port <= 65535):
|
|
56
|
+
raise ValueError(f"Invalid isolated worker port: {self.isolated_port}")
|
|
57
|
+
if self.guard_band_mb < 0:
|
|
58
|
+
raise ValueError(f"guard_band_mb must be non-negative: {self.guard_band_mb}")
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
@dataclass
|
|
62
|
+
class MasterConfig:
|
|
63
|
+
"""Configuration specification for cluster master orchestrator."""
|
|
64
|
+
model_path: str = ""
|
|
65
|
+
workers: List[str] = field(default_factory=list)
|
|
66
|
+
tensor_split: Optional[str] = None
|
|
67
|
+
strategy: ShardingStrategyType = ShardingStrategyType.PROPORTIONAL
|
|
68
|
+
enable_guard: bool = True
|
|
69
|
+
secret_key: Optional[str] = None
|
|
70
|
+
failover_mode: str = "local_mmap"
|
|
71
|
+
min_guardband_mb: int = DEFAULT_GUARD_BAND_MB
|
|
72
|
+
|
|
73
|
+
def validate(self) -> None:
|
|
74
|
+
if not self.model_path:
|
|
75
|
+
raise ValueError("model_path cannot be empty for master execution.")
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
@dataclass
|
|
79
|
+
class ClusterConfig:
|
|
80
|
+
"""Global cluster runtime configuration."""
|
|
81
|
+
engine: ModalityEngineType = ModalityEngineType.LLAMACPP
|
|
82
|
+
beacon_port: int = DEFAULT_BEACON_PORT
|
|
83
|
+
probe_port: int = DEFAULT_PROBE_PORT
|
|
84
|
+
worker: WorkerConfig = field(default_factory=WorkerConfig)
|
|
85
|
+
master: MasterConfig = field(default_factory=MasterConfig)
|