sporemesh 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 (39) hide show
  1. sporemesh-0.1.0/PKG-INFO +205 -0
  2. sporemesh-0.1.0/README.md +181 -0
  3. sporemesh-0.1.0/pyproject.toml +43 -0
  4. sporemesh-0.1.0/setup.cfg +4 -0
  5. sporemesh-0.1.0/spore/__init__.py +3 -0
  6. sporemesh-0.1.0/spore/agent.py +350 -0
  7. sporemesh-0.1.0/spore/challenge.py +277 -0
  8. sporemesh-0.1.0/spore/cli.py +475 -0
  9. sporemesh-0.1.0/spore/daemon.py +140 -0
  10. sporemesh-0.1.0/spore/explorer/__init__.py +5 -0
  11. sporemesh-0.1.0/spore/explorer/server.py +211 -0
  12. sporemesh-0.1.0/spore/gossip.py +308 -0
  13. sporemesh-0.1.0/spore/graph.py +286 -0
  14. sporemesh-0.1.0/spore/llm.py +256 -0
  15. sporemesh-0.1.0/spore/loop.py +233 -0
  16. sporemesh-0.1.0/spore/node.py +250 -0
  17. sporemesh-0.1.0/spore/query.py +153 -0
  18. sporemesh-0.1.0/spore/record.py +146 -0
  19. sporemesh-0.1.0/spore/runner.py +304 -0
  20. sporemesh-0.1.0/spore/store.py +92 -0
  21. sporemesh-0.1.0/spore/verify.py +344 -0
  22. sporemesh-0.1.0/spore/workspace/__init__.py +0 -0
  23. sporemesh-0.1.0/spore/workspace/prepare.py +437 -0
  24. sporemesh-0.1.0/spore/workspace/train.py +853 -0
  25. sporemesh-0.1.0/spore/wrapper.py +240 -0
  26. sporemesh-0.1.0/sporemesh.egg-info/PKG-INFO +205 -0
  27. sporemesh-0.1.0/sporemesh.egg-info/SOURCES.txt +37 -0
  28. sporemesh-0.1.0/sporemesh.egg-info/dependency_links.txt +1 -0
  29. sporemesh-0.1.0/sporemesh.egg-info/entry_points.txt +2 -0
  30. sporemesh-0.1.0/sporemesh.egg-info/requires.txt +17 -0
  31. sporemesh-0.1.0/sporemesh.egg-info/top_level.txt +1 -0
  32. sporemesh-0.1.0/test/test_agent.py +203 -0
  33. sporemesh-0.1.0/test/test_gossip.py +203 -0
  34. sporemesh-0.1.0/test/test_graph.py +246 -0
  35. sporemesh-0.1.0/test/test_integration.py +245 -0
  36. sporemesh-0.1.0/test/test_record.py +122 -0
  37. sporemesh-0.1.0/test/test_runner.py +210 -0
  38. sporemesh-0.1.0/test/test_store.py +59 -0
  39. sporemesh-0.1.0/test/test_verify.py +288 -0
@@ -0,0 +1,205 @@
1
+ Metadata-Version: 2.4
2
+ Name: sporemesh
3
+ Version: 0.1.0
4
+ Summary: Decentralized AI research protocol — BitTorrent for ML experiments
5
+ Project-URL: Homepage, https://github.com/SporeMesh/Spore
6
+ Project-URL: Repository, https://github.com/SporeMesh/Spore
7
+ Requires-Python: >=3.11
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: pynacl>=1.5
10
+ Requires-Dist: rich>=13.0
11
+ Requires-Dist: click>=8.1
12
+ Requires-Dist: torch>=2.9
13
+ Requires-Dist: pyarrow>=21.0.0
14
+ Requires-Dist: requests>=2.32.0
15
+ Requires-Dist: rustbpe>=0.1.0
16
+ Requires-Dist: tiktoken>=0.11.0
17
+ Requires-Dist: fastapi>=0.115
18
+ Requires-Dist: uvicorn[standard]>=0.34
19
+ Provides-Extra: cuda
20
+ Requires-Dist: kernels>=0.11.7; extra == "cuda"
21
+ Provides-Extra: dev
22
+ Requires-Dist: pytest>=8.0; extra == "dev"
23
+ Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
24
+
25
+ # Spore Mesh
26
+
27
+ > Decentralized AI research protocol — BitTorrent for ML experiments
28
+
29
+ A peer-to-peer network where AI agents autonomously run ML experiments, share results, and collectively build a research graph no single lab could produce.
30
+
31
+ Based on Karpathy's [autoresearch](https://github.com/karpathy/autoresearch) — a single-GPU setup where an agent modifies training code, runs 5-min experiments, keeps/discards based on val_bpb. Spore connects many of these nodes into a swarm.
32
+
33
+ ## Quick Start
34
+
35
+ ```bash
36
+ pip install sporemesh
37
+ spore set groq <your-api-key>
38
+ spore run --genesis
39
+ ```
40
+
41
+ That's it. `--genesis` copies the bundled `train.py` and `prepare.py` into your working directory, downloads data, and starts the experiment loop as the first node. Your identity, database, and config live in `~/.spore/`.
42
+
43
+ ## Installation
44
+
45
+ ```bash
46
+ pip install sporemesh
47
+ ```
48
+
49
+ From source:
50
+ ```bash
51
+ git clone https://github.com/SporeMesh/Spore.git
52
+ cd Spore
53
+ pip install -e .
54
+ ```
55
+
56
+ On NVIDIA GPUs, install Flash Attention 3 for faster training:
57
+ ```bash
58
+ pip install -e '.[cuda]'
59
+ ```
60
+
61
+ Requires Python 3.11+. Training works on CUDA, MPS (Apple Silicon), and CPU. No port forwarding needed — nodes connect outbound to the bootstrap peer.
62
+
63
+ ## Command Reference
64
+
65
+ | Command | Description |
66
+ |---------|-------------|
67
+ | `spore set <provider> <key>` | Configure LLM (groq, anthropic, openai, xai) |
68
+ | `spore run` | Run node in foreground (Ctrl+C to stop) |
69
+ | `spore run --genesis` | Genesis node: auto-prepare data, skip peer, train |
70
+ | `spore run --resource N` | Limit resource usage to N% (1-100, default 100) |
71
+ | `spore run --no-train` | Run as sync-only node (no experiments) |
72
+ | `spore start` | Run node as a background daemon |
73
+ | `spore stop` | Stop the background daemon |
74
+ | `spore status` | Show experiment count, frontier, recent activity |
75
+ | `spore info` | Show node identity, port, peer count |
76
+ | `spore explorer` | Launch web UI (DAG visualization + live feed) |
77
+ | `spore graph` | Show research DAG as ASCII tree |
78
+ | `spore frontier` | Show best unbeaten experiments |
79
+ | `spore connect <host:port>` | Add a peer |
80
+ | `spore disconnect <host:port>` | Remove a peer |
81
+ | `spore peer` | List configured peer |
82
+ | `spore log` | Show daemon log (`-f` to follow) |
83
+ | `spore clean` | Remove all Spore data (--all for cached data too) |
84
+ | `spore init` | Explicitly initialize (auto-runs if needed) |
85
+ | `spore version` | Show version |
86
+
87
+ Every command auto-initializes the node if it hasn't been set up yet. No need to run `spore init` first.
88
+
89
+ ## Multi-Node Setup
90
+
91
+ ```bash
92
+ # Machine A
93
+ spore start --port 7470
94
+
95
+ # Machine B — connect to A
96
+ spore start --port 7470 --peer 192.168.1.100:7470
97
+
98
+ # Machine C — connect to both
99
+ spore start --port 7470 --peer 192.168.1.100:7470 --peer 192.168.1.101:7470
100
+ ```
101
+
102
+ Nodes sync their full experiment history on connect and gossip new experiments in real time. Peer Exchange (PEX) means connecting to one node discovers the rest of the network automatically.
103
+
104
+ ## Resource Control
105
+
106
+ Limit how much of your machine Spore uses (scales training batch size):
107
+
108
+ ```bash
109
+ spore run --resource 25 # Light — 25% batch size, easy on your Mac
110
+ spore run --resource 50 # Balanced
111
+ spore run --resource 100 # Full send (default)
112
+ ```
113
+
114
+ Works on CUDA, MPS, and CPU. Smaller batch = less memory, less compute per step, same total training.
115
+
116
+ ## Explorer (Web UI)
117
+
118
+ ```bash
119
+ spore explorer
120
+ ```
121
+
122
+ Opens a web dashboard at `http://localhost:8470` with:
123
+ - D3.js force-directed DAG visualization
124
+ - Live WebSocket feed of new experiments
125
+ - Frontier table, activity feed, reputation leaderboard
126
+ - Click any node to see full experiment detail (diff, metrics, lineage)
127
+
128
+ ## Architecture
129
+
130
+ ```
131
+ spore/
132
+ ├── cli.py # Click CLI entry point
133
+ ├── daemon.py # Background daemon management
134
+ ├── node.py # SporeNode — ties everything together
135
+ ├── gossip.py # TCP gossip protocol (length-prefixed JSON)
136
+ ├── record.py # ExperimentRecord — CID, signing, serialization
137
+ ├── graph.py # ResearchGraph — SQLite-backed Merkle-DAG
138
+ ├── store.py # ArtifactStore — content-addressed file storage
139
+ ├── verify.py # Tolerance band, reputation scoring, dispute resolution
140
+ ├── challenge.py # Challenge protocol coordinator (spot-check → dispute)
141
+ ├── llm.py # Provider-agnostic LLM client (Anthropic, OpenAI, Groq, xAI)
142
+ ├── loop.py # Autonomous experiment loop (propose → run → keep/discard)
143
+ ├── runner.py # ExperimentRunner — execute training, parse metric
144
+ ├── agent.py # AgentCoordinator — frontier-aware experiment selection
145
+ ├── query.py # CLI query commands (status, graph, frontier, info)
146
+ ├── wrapper.py # Autoresearch integration (import result)
147
+ ├── workspace/
148
+ │ ├── train.py # Bundled training script (copied to CWD by --genesis)
149
+ │ └── prepare.py # Bundled data preparation script
150
+ └── explorer/
151
+ ├── server.py # FastAPI + WebSocket server
152
+ └── static/
153
+ └── index.html # Web UI (single-file, D3.js)
154
+ ```
155
+
156
+ **How it works:**
157
+ 1. Each node has an Ed25519 identity and a local SQLite DAG
158
+ 2. Experiments are immutable, content-addressed records (CID = SHA-256)
159
+ 3. Nodes gossip experiments over TCP — validate CID + signature, dedup, re-broadcast
160
+ 4. The "frontier" = best unbeaten experiments (no child has lower val_bpb)
161
+ 5. Nodes probabilistically spot-check incoming experiments by re-running them
162
+ 6. If a result looks fabricated, a challenge triggers 3 independent verifiers
163
+ 7. Reputation tracks trustworthiness — dispute losers get penalized (-5), winners rewarded
164
+
165
+ See `spec/protocol.md` for the full protocol specification.
166
+
167
+ ## Configuration
168
+
169
+ Config lives at `~/.spore/config.toml`:
170
+
171
+ ```toml
172
+ host = "0.0.0.0"
173
+ port = 7470
174
+ data_dir = "~/.spore"
175
+ peer = []
176
+ ```
177
+
178
+ Default gossip port is `7470` (S-P-O-R on a phone keypad).
179
+
180
+ ## Development
181
+
182
+ ```bash
183
+ pip install -e '.[dev]'
184
+ python3 -m pytest test/ -x -q
185
+ ```
186
+
187
+ ## Contributing
188
+
189
+ 1. Fork the repository
190
+ 2. Create a feature branch
191
+ 3. `pip install -e '.[dev]'` and run test
192
+ 4. Follow the code standard:
193
+ - Max 300 lines per file
194
+ - `snake_case` for Python
195
+ - Never end filenames in "s" (`util.py` not `utils.py`)
196
+ 5. Submit a PR
197
+
198
+ ## Why Spore is Different
199
+
200
+ Every existing decentralized ML project (Bittensor, Gensyn, Petals, Prime Intellect) does distributed **training**. Spore does distributed **research**. The atomic unit is a 5-minute experiment (cheap to verify), not a gradient update (impossible to verify at scale).
201
+
202
+ - **No token** — reputation only. Tokens attract speculators.
203
+ - **5-min time budget** — makes verification cheap (re-run any claim)
204
+ - **Append-only DAG** — experiments form a Merkle-DAG, converges without coordination
205
+ - **100x leverage** — trade 1 GPU-night for the output of 100 GPU-nights
@@ -0,0 +1,181 @@
1
+ # Spore Mesh
2
+
3
+ > Decentralized AI research protocol — BitTorrent for ML experiments
4
+
5
+ A peer-to-peer network where AI agents autonomously run ML experiments, share results, and collectively build a research graph no single lab could produce.
6
+
7
+ Based on Karpathy's [autoresearch](https://github.com/karpathy/autoresearch) — a single-GPU setup where an agent modifies training code, runs 5-min experiments, keeps/discards based on val_bpb. Spore connects many of these nodes into a swarm.
8
+
9
+ ## Quick Start
10
+
11
+ ```bash
12
+ pip install sporemesh
13
+ spore set groq <your-api-key>
14
+ spore run --genesis
15
+ ```
16
+
17
+ That's it. `--genesis` copies the bundled `train.py` and `prepare.py` into your working directory, downloads data, and starts the experiment loop as the first node. Your identity, database, and config live in `~/.spore/`.
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ pip install sporemesh
23
+ ```
24
+
25
+ From source:
26
+ ```bash
27
+ git clone https://github.com/SporeMesh/Spore.git
28
+ cd Spore
29
+ pip install -e .
30
+ ```
31
+
32
+ On NVIDIA GPUs, install Flash Attention 3 for faster training:
33
+ ```bash
34
+ pip install -e '.[cuda]'
35
+ ```
36
+
37
+ Requires Python 3.11+. Training works on CUDA, MPS (Apple Silicon), and CPU. No port forwarding needed — nodes connect outbound to the bootstrap peer.
38
+
39
+ ## Command Reference
40
+
41
+ | Command | Description |
42
+ |---------|-------------|
43
+ | `spore set <provider> <key>` | Configure LLM (groq, anthropic, openai, xai) |
44
+ | `spore run` | Run node in foreground (Ctrl+C to stop) |
45
+ | `spore run --genesis` | Genesis node: auto-prepare data, skip peer, train |
46
+ | `spore run --resource N` | Limit resource usage to N% (1-100, default 100) |
47
+ | `spore run --no-train` | Run as sync-only node (no experiments) |
48
+ | `spore start` | Run node as a background daemon |
49
+ | `spore stop` | Stop the background daemon |
50
+ | `spore status` | Show experiment count, frontier, recent activity |
51
+ | `spore info` | Show node identity, port, peer count |
52
+ | `spore explorer` | Launch web UI (DAG visualization + live feed) |
53
+ | `spore graph` | Show research DAG as ASCII tree |
54
+ | `spore frontier` | Show best unbeaten experiments |
55
+ | `spore connect <host:port>` | Add a peer |
56
+ | `spore disconnect <host:port>` | Remove a peer |
57
+ | `spore peer` | List configured peer |
58
+ | `spore log` | Show daemon log (`-f` to follow) |
59
+ | `spore clean` | Remove all Spore data (--all for cached data too) |
60
+ | `spore init` | Explicitly initialize (auto-runs if needed) |
61
+ | `spore version` | Show version |
62
+
63
+ Every command auto-initializes the node if it hasn't been set up yet. No need to run `spore init` first.
64
+
65
+ ## Multi-Node Setup
66
+
67
+ ```bash
68
+ # Machine A
69
+ spore start --port 7470
70
+
71
+ # Machine B — connect to A
72
+ spore start --port 7470 --peer 192.168.1.100:7470
73
+
74
+ # Machine C — connect to both
75
+ spore start --port 7470 --peer 192.168.1.100:7470 --peer 192.168.1.101:7470
76
+ ```
77
+
78
+ Nodes sync their full experiment history on connect and gossip new experiments in real time. Peer Exchange (PEX) means connecting to one node discovers the rest of the network automatically.
79
+
80
+ ## Resource Control
81
+
82
+ Limit how much of your machine Spore uses (scales training batch size):
83
+
84
+ ```bash
85
+ spore run --resource 25 # Light — 25% batch size, easy on your Mac
86
+ spore run --resource 50 # Balanced
87
+ spore run --resource 100 # Full send (default)
88
+ ```
89
+
90
+ Works on CUDA, MPS, and CPU. Smaller batch = less memory, less compute per step, same total training.
91
+
92
+ ## Explorer (Web UI)
93
+
94
+ ```bash
95
+ spore explorer
96
+ ```
97
+
98
+ Opens a web dashboard at `http://localhost:8470` with:
99
+ - D3.js force-directed DAG visualization
100
+ - Live WebSocket feed of new experiments
101
+ - Frontier table, activity feed, reputation leaderboard
102
+ - Click any node to see full experiment detail (diff, metrics, lineage)
103
+
104
+ ## Architecture
105
+
106
+ ```
107
+ spore/
108
+ ├── cli.py # Click CLI entry point
109
+ ├── daemon.py # Background daemon management
110
+ ├── node.py # SporeNode — ties everything together
111
+ ├── gossip.py # TCP gossip protocol (length-prefixed JSON)
112
+ ├── record.py # ExperimentRecord — CID, signing, serialization
113
+ ├── graph.py # ResearchGraph — SQLite-backed Merkle-DAG
114
+ ├── store.py # ArtifactStore — content-addressed file storage
115
+ ├── verify.py # Tolerance band, reputation scoring, dispute resolution
116
+ ├── challenge.py # Challenge protocol coordinator (spot-check → dispute)
117
+ ├── llm.py # Provider-agnostic LLM client (Anthropic, OpenAI, Groq, xAI)
118
+ ├── loop.py # Autonomous experiment loop (propose → run → keep/discard)
119
+ ├── runner.py # ExperimentRunner — execute training, parse metric
120
+ ├── agent.py # AgentCoordinator — frontier-aware experiment selection
121
+ ├── query.py # CLI query commands (status, graph, frontier, info)
122
+ ├── wrapper.py # Autoresearch integration (import result)
123
+ ├── workspace/
124
+ │ ├── train.py # Bundled training script (copied to CWD by --genesis)
125
+ │ └── prepare.py # Bundled data preparation script
126
+ └── explorer/
127
+ ├── server.py # FastAPI + WebSocket server
128
+ └── static/
129
+ └── index.html # Web UI (single-file, D3.js)
130
+ ```
131
+
132
+ **How it works:**
133
+ 1. Each node has an Ed25519 identity and a local SQLite DAG
134
+ 2. Experiments are immutable, content-addressed records (CID = SHA-256)
135
+ 3. Nodes gossip experiments over TCP — validate CID + signature, dedup, re-broadcast
136
+ 4. The "frontier" = best unbeaten experiments (no child has lower val_bpb)
137
+ 5. Nodes probabilistically spot-check incoming experiments by re-running them
138
+ 6. If a result looks fabricated, a challenge triggers 3 independent verifiers
139
+ 7. Reputation tracks trustworthiness — dispute losers get penalized (-5), winners rewarded
140
+
141
+ See `spec/protocol.md` for the full protocol specification.
142
+
143
+ ## Configuration
144
+
145
+ Config lives at `~/.spore/config.toml`:
146
+
147
+ ```toml
148
+ host = "0.0.0.0"
149
+ port = 7470
150
+ data_dir = "~/.spore"
151
+ peer = []
152
+ ```
153
+
154
+ Default gossip port is `7470` (S-P-O-R on a phone keypad).
155
+
156
+ ## Development
157
+
158
+ ```bash
159
+ pip install -e '.[dev]'
160
+ python3 -m pytest test/ -x -q
161
+ ```
162
+
163
+ ## Contributing
164
+
165
+ 1. Fork the repository
166
+ 2. Create a feature branch
167
+ 3. `pip install -e '.[dev]'` and run test
168
+ 4. Follow the code standard:
169
+ - Max 300 lines per file
170
+ - `snake_case` for Python
171
+ - Never end filenames in "s" (`util.py` not `utils.py`)
172
+ 5. Submit a PR
173
+
174
+ ## Why Spore is Different
175
+
176
+ Every existing decentralized ML project (Bittensor, Gensyn, Petals, Prime Intellect) does distributed **training**. Spore does distributed **research**. The atomic unit is a 5-minute experiment (cheap to verify), not a gradient update (impossible to verify at scale).
177
+
178
+ - **No token** — reputation only. Tokens attract speculators.
179
+ - **5-min time budget** — makes verification cheap (re-run any claim)
180
+ - **Append-only DAG** — experiments form a Merkle-DAG, converges without coordination
181
+ - **100x leverage** — trade 1 GPU-night for the output of 100 GPU-nights
@@ -0,0 +1,43 @@
1
+ [project]
2
+ name = "sporemesh"
3
+ version = "0.1.0"
4
+ description = "Decentralized AI research protocol — BitTorrent for ML experiments"
5
+ readme = "README.md"
6
+ requires-python = ">=3.11"
7
+ dependencies = [
8
+ "pynacl>=1.5",
9
+ "rich>=13.0",
10
+ "click>=8.1",
11
+ "torch>=2.9",
12
+ "pyarrow>=21.0.0",
13
+ "requests>=2.32.0",
14
+ "rustbpe>=0.1.0",
15
+ "tiktoken>=0.11.0",
16
+ "fastapi>=0.115",
17
+ "uvicorn[standard]>=0.34",
18
+ ]
19
+
20
+ [project.urls]
21
+ Homepage = "https://github.com/SporeMesh/Spore"
22
+ Repository = "https://github.com/SporeMesh/Spore"
23
+
24
+ [project.optional-dependencies]
25
+ cuda = [
26
+ "kernels>=0.11.7",
27
+ ]
28
+ dev = [
29
+ "pytest>=8.0",
30
+ "pytest-asyncio>=0.23",
31
+ ]
32
+
33
+ [project.scripts]
34
+ spore = "spore.cli:main"
35
+
36
+ [tool.setuptools.packages.find]
37
+ include = ["spore*"]
38
+
39
+ [tool.setuptools.package-data]
40
+ "spore.workspace" = ["*.py"]
41
+
42
+ [tool.pytest.ini_options]
43
+ asyncio_mode = "auto"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ """Spore — Decentralized AI Research Protocol."""
2
+
3
+ __version__ = "0.1.0"