@infernetprotocol/cli 0.1.35 → 0.1.37
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.
- package/commands/inference.js +207 -0
- package/commands/start.js +96 -1
- package/commands/train.js +51 -13
- package/index.js +3 -2
- package/package.json +6 -6
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `infernet inference` — distributed inference serving (IPIP-0031).
|
|
3
|
+
*
|
|
4
|
+
* infernet inference serve --backend petals --model <hf-id>
|
|
5
|
+
* Starts a Petals server contributing this node's VRAM to the
|
|
6
|
+
* public swarm for the given model. Re-registers with the control
|
|
7
|
+
* plane so the dashboard learns this node is petals-serving X.
|
|
8
|
+
*
|
|
9
|
+
* infernet inference status
|
|
10
|
+
* Shows whether a Petals server is running locally + which blocks
|
|
11
|
+
* it's holding for which model.
|
|
12
|
+
*
|
|
13
|
+
* infernet inference stop
|
|
14
|
+
* Stops the locally-running Petals server.
|
|
15
|
+
*
|
|
16
|
+
* Petals (https://github.com/bigscience-workshop/petals) splits a
|
|
17
|
+
* Llama-style transformer by layer across DHT-discovered volunteer
|
|
18
|
+
* nodes. Each node holds N transformer blocks; activations flow through.
|
|
19
|
+
* Bandwidth-tolerant — designed for residential connections.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import fs from "node:fs";
|
|
23
|
+
import fsp from "node:fs/promises";
|
|
24
|
+
import path from "node:path";
|
|
25
|
+
import { spawn } from "node:child_process";
|
|
26
|
+
import { loadConfig } from "../lib/config.js";
|
|
27
|
+
import { startPetalsServer } from "../lib/inference/petals-engine.js";
|
|
28
|
+
|
|
29
|
+
const HELP = `infernet inference — distributed inference serving (Petals swarm)
|
|
30
|
+
|
|
31
|
+
Usage:
|
|
32
|
+
infernet inference serve --model <hf-id> [flags]
|
|
33
|
+
infernet inference status
|
|
34
|
+
infernet inference stop
|
|
35
|
+
|
|
36
|
+
Flags (serve):
|
|
37
|
+
--model <hf-id> Required. e.g. meta-llama/Llama-3.1-70B-Instruct
|
|
38
|
+
--backend <name> petals (default; only supported backend today)
|
|
39
|
+
--num-blocks <n> How many transformer blocks to host (auto if omitted)
|
|
40
|
+
--port <n> Petals server port (default: 31330)
|
|
41
|
+
--dht-prefix <str> DHT initial peers (default: /petals/v3-public)
|
|
42
|
+
--help
|
|
43
|
+
|
|
44
|
+
Examples:
|
|
45
|
+
# Contribute to a Llama 3.1 70B swarm — node holds whatever blocks fit
|
|
46
|
+
infernet inference serve --model meta-llama/Llama-3.1-70B-Instruct
|
|
47
|
+
|
|
48
|
+
# Same but only host 6 blocks (smaller VRAM footprint)
|
|
49
|
+
infernet inference serve --model meta-llama/Llama-3.1-70B-Instruct --num-blocks 6
|
|
50
|
+
|
|
51
|
+
What this means for the network:
|
|
52
|
+
When you serve a model via Petals, the control plane registers your
|
|
53
|
+
node as part of the swarm for that model. Inference requests with
|
|
54
|
+
the "Distribute across all nodes" checkbox set on /chat will route
|
|
55
|
+
through a Petals client that fans out across all swarm participants
|
|
56
|
+
(you + everyone else serving the same model). Per-token receipts
|
|
57
|
+
pay you for the blocks you contributed.
|
|
58
|
+
|
|
59
|
+
Prerequisites:
|
|
60
|
+
pip install -U petals # Python 3.10+
|
|
61
|
+
Inbound port \${port} reachable (cloudflared works for residential setups)
|
|
62
|
+
`;
|
|
63
|
+
|
|
64
|
+
const STATE_DIR = path.join(process.env.HOME ?? "/tmp", ".infernet", "inference");
|
|
65
|
+
|
|
66
|
+
async function ensureStateDir() {
|
|
67
|
+
await fsp.mkdir(STATE_DIR, { recursive: true });
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async function readState() {
|
|
71
|
+
try {
|
|
72
|
+
const raw = await fsp.readFile(path.join(STATE_DIR, "state.json"), "utf8");
|
|
73
|
+
return JSON.parse(raw);
|
|
74
|
+
} catch { return null; }
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async function writeState(s) {
|
|
78
|
+
await ensureStateDir();
|
|
79
|
+
await fsp.writeFile(path.join(STATE_DIR, "state.json"), JSON.stringify(s, null, 2));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function pythonHasPetals() {
|
|
83
|
+
return new Promise((resolve) => {
|
|
84
|
+
const p = spawn("python3", ["-c", "import petals"], { stdio: "ignore" });
|
|
85
|
+
p.on("exit", (code) => resolve(code === 0));
|
|
86
|
+
p.on("error", () => resolve(false));
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async function cmdServe(args) {
|
|
91
|
+
const model = args.get("model");
|
|
92
|
+
if (!model) {
|
|
93
|
+
process.stderr.write("error: --model <hf-id> is required\n");
|
|
94
|
+
return 2;
|
|
95
|
+
}
|
|
96
|
+
const backend = args.get("backend") ?? "petals";
|
|
97
|
+
if (backend !== "petals") {
|
|
98
|
+
process.stderr.write(`error: only --backend petals is supported today (got ${backend})\n`);
|
|
99
|
+
return 2;
|
|
100
|
+
}
|
|
101
|
+
const numBlocks = args.get("num-blocks") ? Number.parseInt(args.get("num-blocks"), 10) : null;
|
|
102
|
+
const port = Number.parseInt(args.get("port") ?? "31330", 10);
|
|
103
|
+
const prefix = args.get("dht-prefix") ?? "/petals/v3-public";
|
|
104
|
+
|
|
105
|
+
if (!(await pythonHasPetals())) {
|
|
106
|
+
process.stderr.write(
|
|
107
|
+
"error: petals isn't installed. Run:\n pip install -U petals\n" +
|
|
108
|
+
" python3 -c 'import petals' # verify\n"
|
|
109
|
+
);
|
|
110
|
+
return 1;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
process.stdout.write(`Starting Petals server for ${model} on :${port} (${numBlocks ?? "auto"} blocks)…\n`);
|
|
114
|
+
process.stdout.write("Initial DHT peers: " + prefix + "\n");
|
|
115
|
+
|
|
116
|
+
const child = startPetalsServer({ model, numBlocks, port, prefix });
|
|
117
|
+
if (!child?.pid) {
|
|
118
|
+
process.stderr.write("error: failed to spawn petals server\n");
|
|
119
|
+
return 1;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
await writeState({
|
|
123
|
+
backend,
|
|
124
|
+
model,
|
|
125
|
+
port,
|
|
126
|
+
prefix,
|
|
127
|
+
num_blocks: numBlocks,
|
|
128
|
+
pid: child.pid,
|
|
129
|
+
started_at: new Date().toISOString()
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// Pipe child output so the operator sees Petals' own startup logs
|
|
133
|
+
// (which blocks it grabbed, DHT peers, etc).
|
|
134
|
+
child.stdout?.pipe(process.stdout);
|
|
135
|
+
child.stderr?.pipe(process.stderr);
|
|
136
|
+
|
|
137
|
+
process.stdout.write(
|
|
138
|
+
`\n✓ Petals server pid=${child.pid} started.\n` +
|
|
139
|
+
` Re-register your node so the control plane learns about this:\n` +
|
|
140
|
+
` infernet register\n\n` +
|
|
141
|
+
` Stop with: infernet inference stop\n`
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
// Stay attached so the user sees logs; Ctrl-C will SIGTERM the child.
|
|
145
|
+
process.on("SIGINT", () => { try { child.kill("SIGTERM"); } catch { /* ignore */ } });
|
|
146
|
+
return new Promise((resolve) => {
|
|
147
|
+
child.on("exit", async (code) => {
|
|
148
|
+
await writeState({ backend, model, port, prefix, num_blocks: numBlocks, pid: null, exited_with: code, exited_at: new Date().toISOString() });
|
|
149
|
+
resolve(code === 0 ? 0 : 1);
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async function cmdStatus() {
|
|
155
|
+
const state = await readState();
|
|
156
|
+
if (!state) {
|
|
157
|
+
process.stdout.write("(no inference server running locally)\n");
|
|
158
|
+
return 0;
|
|
159
|
+
}
|
|
160
|
+
process.stdout.write(`backend: ${state.backend}\n`);
|
|
161
|
+
process.stdout.write(`model: ${state.model}\n`);
|
|
162
|
+
process.stdout.write(`port: ${state.port}\n`);
|
|
163
|
+
process.stdout.write(`pid: ${state.pid ?? "(exited)"}\n`);
|
|
164
|
+
if (state.pid) {
|
|
165
|
+
const alive = (() => { try { process.kill(state.pid, 0); return true; } catch { return false; } })();
|
|
166
|
+
process.stdout.write(`alive: ${alive ? "yes" : "no — pid stale"}\n`);
|
|
167
|
+
}
|
|
168
|
+
if (state.exited_at) {
|
|
169
|
+
process.stdout.write(`exited: ${state.exited_at} (code ${state.exited_with})\n`);
|
|
170
|
+
}
|
|
171
|
+
return 0;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
async function cmdStop() {
|
|
175
|
+
const state = await readState();
|
|
176
|
+
if (!state?.pid) {
|
|
177
|
+
process.stdout.write("(nothing to stop)\n");
|
|
178
|
+
return 0;
|
|
179
|
+
}
|
|
180
|
+
try {
|
|
181
|
+
process.kill(state.pid, "SIGTERM");
|
|
182
|
+
process.stdout.write(`SIGTERM sent to pid ${state.pid}\n`);
|
|
183
|
+
} catch (err) {
|
|
184
|
+
process.stderr.write(`could not kill pid ${state.pid}: ${err?.message ?? err}\n`);
|
|
185
|
+
return 1;
|
|
186
|
+
}
|
|
187
|
+
return 0;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export default async function inference(args) {
|
|
191
|
+
if (args.has("help") || args.has("h")) {
|
|
192
|
+
process.stdout.write(HELP);
|
|
193
|
+
return 0;
|
|
194
|
+
}
|
|
195
|
+
const sub = args.positional?.[0];
|
|
196
|
+
switch (sub) {
|
|
197
|
+
case "serve": case "start": return cmdServe(args);
|
|
198
|
+
case "status": return cmdStatus();
|
|
199
|
+
case "stop": return cmdStop();
|
|
200
|
+
default:
|
|
201
|
+
process.stderr.write(sub ? `unknown subcommand: ${sub}\n\n` : "error: missing subcommand\n\n");
|
|
202
|
+
process.stderr.write(HELP);
|
|
203
|
+
return 2;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export { HELP };
|
package/commands/start.js
CHANGED
|
@@ -776,6 +776,81 @@ async function runDaemon(args, ctx) {
|
|
|
776
776
|
};
|
|
777
777
|
}
|
|
778
778
|
|
|
779
|
+
/**
|
|
780
|
+
* IPIP-0030: shard-hosting routes layered on top of /healthz.
|
|
781
|
+
* Returns true if the request matched and was handled.
|
|
782
|
+
*/
|
|
783
|
+
async function handleTrainingHttp(req, res) {
|
|
784
|
+
if (!req.url) return false;
|
|
785
|
+
const url = new URL(req.url, 'http://localhost');
|
|
786
|
+
const pathname = url.pathname;
|
|
787
|
+
|
|
788
|
+
// GET /v1/training/shards/<run_id>/<shard_index>.jsonl
|
|
789
|
+
const shardMatch = pathname.match(/^\/v1\/training\/shards\/([A-Za-z0-9_-]+)\/shard-(\d+)\.jsonl$/);
|
|
790
|
+
if (shardMatch && req.method === 'GET') {
|
|
791
|
+
const fs = await import('node:fs');
|
|
792
|
+
const path = await import('node:path');
|
|
793
|
+
const [, runId, idx] = shardMatch;
|
|
794
|
+
const filePath = path.join(
|
|
795
|
+
process.env.HOME ?? '/tmp',
|
|
796
|
+
'.infernet', 'training-runs', runId, 'shards', `shard-${idx}.jsonl`
|
|
797
|
+
);
|
|
798
|
+
if (!fs.existsSync(filePath)) {
|
|
799
|
+
res.writeHead(404, { 'content-type': 'text/plain' });
|
|
800
|
+
res.end('shard not found\n');
|
|
801
|
+
return true;
|
|
802
|
+
}
|
|
803
|
+
res.writeHead(200, {
|
|
804
|
+
'content-type': 'application/jsonl',
|
|
805
|
+
'content-length': fs.statSync(filePath).size,
|
|
806
|
+
'cache-control': 'no-store'
|
|
807
|
+
});
|
|
808
|
+
fs.createReadStream(filePath).pipe(res);
|
|
809
|
+
return true;
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
// PUT /v1/training/adapters/<run_id>/<shard_index>?token=<t>
|
|
813
|
+
const adapterMatch = pathname.match(/^\/v1\/training\/adapters\/([A-Za-z0-9_-]+)\/(\d+)$/);
|
|
814
|
+
if (adapterMatch && req.method === 'PUT') {
|
|
815
|
+
const fsp = await import('node:fs/promises');
|
|
816
|
+
const fs = await import('node:fs');
|
|
817
|
+
const path = await import('node:path');
|
|
818
|
+
const [, runId, idx] = adapterMatch;
|
|
819
|
+
const runDir = path.join(process.env.HOME ?? '/tmp', '.infernet', 'training-runs', runId);
|
|
820
|
+
const manifestPath = path.join(runDir, 'manifest.json');
|
|
821
|
+
if (!fs.existsSync(manifestPath)) {
|
|
822
|
+
res.writeHead(404, { 'content-type': 'text/plain' });
|
|
823
|
+
res.end('run not found\n');
|
|
824
|
+
return true;
|
|
825
|
+
}
|
|
826
|
+
// Token check: only accept PUTs whose ?token=<t> matches the
|
|
827
|
+
// run's manifest. The submitter mints the token at run-start
|
|
828
|
+
// and shares it with the control plane only via upload_url.
|
|
829
|
+
const manifest = JSON.parse(await fsp.readFile(manifestPath, 'utf8'));
|
|
830
|
+
const presentedToken = url.searchParams.get('token');
|
|
831
|
+
if (!presentedToken || presentedToken !== manifest.upload_token) {
|
|
832
|
+
res.writeHead(403, { 'content-type': 'text/plain' });
|
|
833
|
+
res.end('bad token\n');
|
|
834
|
+
return true;
|
|
835
|
+
}
|
|
836
|
+
const adapterDir = path.join(runDir, 'adapters');
|
|
837
|
+
await fsp.mkdir(adapterDir, { recursive: true });
|
|
838
|
+
const outPath = path.join(adapterDir, `shard-${idx}.adapter.safetensors`);
|
|
839
|
+
await new Promise((resolve, reject) => {
|
|
840
|
+
const ws = fs.createWriteStream(outPath);
|
|
841
|
+
req.pipe(ws);
|
|
842
|
+
ws.on('finish', resolve);
|
|
843
|
+
ws.on('error', reject);
|
|
844
|
+
req.on('error', reject);
|
|
845
|
+
});
|
|
846
|
+
res.writeHead(200, { 'content-type': 'application/json' });
|
|
847
|
+
res.end(JSON.stringify({ ok: true, path: outPath }));
|
|
848
|
+
return true;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
return false;
|
|
852
|
+
}
|
|
853
|
+
|
|
779
854
|
function snapshot() {
|
|
780
855
|
return {
|
|
781
856
|
pid: process.pid,
|
|
@@ -946,7 +1021,7 @@ async function runDaemon(args, ctx) {
|
|
|
946
1021
|
// firewalled). Returns 200 + a JSON daemon snapshot.
|
|
947
1022
|
const healthPort = Number.parseInt(process.env.PORT ?? '', 10) || 8080;
|
|
948
1023
|
try {
|
|
949
|
-
healthServer = http.createServer((req, res) => {
|
|
1024
|
+
healthServer = http.createServer(async (req, res) => {
|
|
950
1025
|
if (req.url === '/healthz' || req.url === '/health' || req.url === '/') {
|
|
951
1026
|
const snap = snapshot();
|
|
952
1027
|
const body = JSON.stringify({
|
|
@@ -968,6 +1043,26 @@ async function runDaemon(args, ctx) {
|
|
|
968
1043
|
res.end(body);
|
|
969
1044
|
return;
|
|
970
1045
|
}
|
|
1046
|
+
|
|
1047
|
+
// IPIP-0030: serve training shards directly from this node's
|
|
1048
|
+
// local filesystem. The submitter's CLI writes shards to
|
|
1049
|
+
// ~/.infernet/training-runs/<run_id>/shards/shard-<i>.jsonl
|
|
1050
|
+
// and posts the URL referencing this same daemon's endpoint.
|
|
1051
|
+
// No third-party storage, no separate ports, no signup —
|
|
1052
|
+
// the daemon's already on a reachable port.
|
|
1053
|
+
//
|
|
1054
|
+
// Routes:
|
|
1055
|
+
// GET /v1/training/shards/<run_id>/<shard_index>.jsonl
|
|
1056
|
+
// PUT /v1/training/adapters/<run_id>/<shard_index>?token=<t>
|
|
1057
|
+
try {
|
|
1058
|
+
const handled = await handleTrainingHttp(req, res);
|
|
1059
|
+
if (handled) return;
|
|
1060
|
+
} catch (err) {
|
|
1061
|
+
res.writeHead(500, { 'content-type': 'text/plain' });
|
|
1062
|
+
res.end(`training http error: ${err?.message ?? err}\n`);
|
|
1063
|
+
return;
|
|
1064
|
+
}
|
|
1065
|
+
|
|
971
1066
|
res.writeHead(404, { 'content-type': 'text/plain' });
|
|
972
1067
|
res.end('not found\n');
|
|
973
1068
|
});
|
package/commands/train.js
CHANGED
|
@@ -359,6 +359,13 @@ async function cmdRun(args) {
|
|
|
359
359
|
* IPIP-0030: post a training job to the open market. Any operator on
|
|
360
360
|
* the network running with --accept-training claims shards and reports
|
|
361
361
|
* back; we poll until all shards complete, then FedAvg the adapters.
|
|
362
|
+
*
|
|
363
|
+
* Shards are hosted by the SUBMITTER'S OWN DAEMON — no S3, no HF, no
|
|
364
|
+
* IPFS, no third-party storage. The local daemon's HTTP server already
|
|
365
|
+
* has a reachable endpoint registered with the control plane; we just
|
|
366
|
+
* drop shard files in ~/.infernet/training-runs/<run_id>/shards/ and
|
|
367
|
+
* the daemon serves them at /v1/training/shards/<run_id>/shard-<i>.jsonl
|
|
368
|
+
* (handler in commands/start.js handleTrainingHttp).
|
|
362
369
|
*/
|
|
363
370
|
async function runOpenMarket({ trainConfig, runDir, runId, args }) {
|
|
364
371
|
const cfg = await loadConfig().catch(() => ({}));
|
|
@@ -368,15 +375,27 @@ async function runOpenMarket({ trainConfig, runDir, runId, args }) {
|
|
|
368
375
|
process.stderr.write(`error: open-market training needs a logged-in session — run \`infernet login\` first\n`);
|
|
369
376
|
return 1;
|
|
370
377
|
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
378
|
+
|
|
379
|
+
// Discover this submitter's own daemon endpoint. The daemon
|
|
380
|
+
// registered an endpoint_url at startup; it's stored locally in
|
|
381
|
+
// config under node.endpoint_url OR can be derived from advertised
|
|
382
|
+
// address + PORT (default 8080 — the same /healthz HTTP server).
|
|
383
|
+
const advertised = cfg?.node?.advertised_endpoint
|
|
384
|
+
?? cfg?.node?.endpoint_url
|
|
385
|
+
?? process.env.INFERNET_DAEMON_ENDPOINT;
|
|
386
|
+
if (!advertised) {
|
|
374
387
|
process.stderr.write(
|
|
375
|
-
`error:
|
|
376
|
-
`
|
|
388
|
+
`error: can't find this node's public endpoint. Either:\n` +
|
|
389
|
+
` - run \`infernet start\` so the daemon registers an endpoint, OR\n` +
|
|
390
|
+
` - set INFERNET_DAEMON_ENDPOINT=http://<your-public-ip>:8080\n` +
|
|
391
|
+
`\nThe submitter's daemon hosts the shards directly — no S3, no HF.\n` +
|
|
392
|
+
`If your machine is behind NAT, run a tunnel:\n` +
|
|
393
|
+
` cloudflared tunnel --url http://localhost:8080\n` +
|
|
394
|
+
`and set INFERNET_DAEMON_ENDPOINT to the cloudflared URL.\n`
|
|
377
395
|
);
|
|
378
396
|
return 1;
|
|
379
397
|
}
|
|
398
|
+
|
|
380
399
|
const numShards = Number.parseInt(args.get("max-nodes") ?? args.get("num-shards") ?? "5", 10);
|
|
381
400
|
const budget = Number.parseFloat(args.get("budget") ?? "0");
|
|
382
401
|
const pricePerShard = numShards > 0 ? budget / numShards : 0;
|
|
@@ -387,12 +406,31 @@ async function runOpenMarket({ trainConfig, runDir, runId, args }) {
|
|
|
387
406
|
return 1;
|
|
388
407
|
}
|
|
389
408
|
|
|
390
|
-
// Split the local JSONL into N shards
|
|
409
|
+
// Split the local JSONL into N shards under ~/.infernet/training-runs/<run_id>/.
|
|
410
|
+
// The daemon's HTTP server reads from this exact path.
|
|
391
411
|
const { splitJsonl } = await import("../lib/training/p2p-coordinator.js");
|
|
392
|
-
const
|
|
412
|
+
const home = process.env.HOME ?? "/tmp";
|
|
413
|
+
const localRunDir = path.join(home, ".infernet", "training-runs", runId);
|
|
414
|
+
const shardsDir = path.join(localRunDir, "shards");
|
|
393
415
|
process.stdout.write(`Splitting ${datasetPath} into ${numShards} shard(s)…\n`);
|
|
394
416
|
const shards = await splitJsonl({ inputPath: datasetPath, outDir: shardsDir, numShards });
|
|
395
|
-
|
|
417
|
+
|
|
418
|
+
// Mint a per-run upload token so operators that complete a shard
|
|
419
|
+
// can PUT their adapter back to the submitter's daemon, and only
|
|
420
|
+
// those who claimed the shard via the control plane have the token.
|
|
421
|
+
const uploadToken = (await import("node:crypto")).randomBytes(16).toString("hex");
|
|
422
|
+
await fs.writeFile(
|
|
423
|
+
path.join(localRunDir, "manifest.json"),
|
|
424
|
+
JSON.stringify({ run_id: runId, num_shards: shards.length, upload_token: uploadToken, created_at: new Date().toISOString() }, null, 2)
|
|
425
|
+
);
|
|
426
|
+
|
|
427
|
+
// Build the canonical URLs the control plane will hand out to claimers.
|
|
428
|
+
const base = advertised.replace(/\/$/, "");
|
|
429
|
+
const datasetBaseUrl = `${base}/v1/training/shards/${runId}`;
|
|
430
|
+
const uploadBaseUrl = `${base}/v1/training/adapters/${runId}?token=${uploadToken}`;
|
|
431
|
+
|
|
432
|
+
process.stdout.write(` shard URLs: ${datasetBaseUrl}/shard-N.jsonl\n`);
|
|
433
|
+
process.stdout.write(` adapter PUT URL: ${uploadBaseUrl.replace(uploadToken, "<token>")}\n`);
|
|
396
434
|
|
|
397
435
|
// Submit the job
|
|
398
436
|
process.stdout.write(`\nPosting job to the open market…\n`);
|
|
@@ -419,11 +457,11 @@ async function runOpenMarket({ trainConfig, runDir, runId, args }) {
|
|
|
419
457
|
return 1;
|
|
420
458
|
}
|
|
421
459
|
const { data } = await res.json();
|
|
422
|
-
process.stdout.write(
|
|
423
|
-
process.stdout.write(
|
|
424
|
-
process.stdout.write(`
|
|
425
|
-
process.stdout.write(
|
|
426
|
-
process.stdout.write(`
|
|
460
|
+
process.stdout.write(`\n✓ job ${data.job.id} posted (${data.shards.length} shards · $${pricePerShard.toFixed(4)}/shard · $${budget.toFixed(2)} budget)\n`);
|
|
461
|
+
process.stdout.write(`Shards hosted by your local daemon at ${base}\n`);
|
|
462
|
+
process.stdout.write(`Adapters land in ${path.join(localRunDir, "adapters")} as operators report\n`);
|
|
463
|
+
process.stdout.write(`\nKeep the daemon running until all shards complete. When done:\n`);
|
|
464
|
+
process.stdout.write(` python3 ${path.join(runDir, "_fedavg.py")} --out ${path.join(runDir, "checkpoint-final")} ${path.join(localRunDir, "adapters")}/*\n`);
|
|
427
465
|
|
|
428
466
|
await fs.writeFile(path.join(runDir, "open-market-job.json"), JSON.stringify(data, null, 2));
|
|
429
467
|
return 0;
|
package/index.js
CHANGED
|
@@ -45,6 +45,7 @@ import deploy from './commands/deploy.js';
|
|
|
45
45
|
import consoleCmd from './commands/console.js';
|
|
46
46
|
import train from './commands/train.js';
|
|
47
47
|
import publish from './commands/publish.js';
|
|
48
|
+
import inference from './commands/inference.js';
|
|
48
49
|
import uncensored from './commands/uncensored.js';
|
|
49
50
|
|
|
50
51
|
function parseArgs(argv) {
|
|
@@ -107,11 +108,11 @@ const COMMANDS = {
|
|
|
107
108
|
// aliases
|
|
108
109
|
uninstall: remove,
|
|
109
110
|
start, status, stop, restart, stats, logs,
|
|
110
|
-
payout, payments, gpu, firewall, chat, setup, model, train, publish, uncensored, tui, doctor, service, pubkey, debug, deploy, console: consoleCmd, help
|
|
111
|
+
payout, payments, gpu, firewall, chat, setup, model, train, publish, inference, uncensored, tui, doctor, service, pubkey, debug, deploy, console: consoleCmd, help
|
|
111
112
|
};
|
|
112
113
|
|
|
113
114
|
// Commands that can run without a loaded config.
|
|
114
|
-
const NO_CONFIG = new Set(['init', 'login', 'help', 'stats', 'logs', 'stop', 'restart', 'gpu', 'firewall', 'chat', 'setup', 'model', 'train', 'publish', 'uncensored', 'tui', 'doctor', 'service', 'pubkey', 'debug', 'deploy', 'console', 'upgrade', 'update', 'remove', 'uninstall']);
|
|
115
|
+
const NO_CONFIG = new Set(['init', 'login', 'help', 'stats', 'logs', 'stop', 'restart', 'gpu', 'firewall', 'chat', 'setup', 'model', 'train', 'publish', 'inference', 'uncensored', 'tui', 'doctor', 'service', 'pubkey', 'debug', 'deploy', 'console', 'upgrade', 'update', 'remove', 'uninstall']);
|
|
115
116
|
// Commands that need a config but not a control-plane client (none today
|
|
116
117
|
// — kept as a future escape hatch).
|
|
117
118
|
const NO_CLIENT = new Set();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infernetprotocol/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.37",
|
|
4
4
|
"description": "GPU-node CLI / daemon for the Infernet Protocol — register a GPU server with a Supabase control plane and start earning.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
"ora": "^9.4.0",
|
|
31
31
|
"react": "^17.0.2",
|
|
32
32
|
"react-blessed": "^0.7.2",
|
|
33
|
-
"@infernetprotocol/auth": "0.1.
|
|
34
|
-
"@infernetprotocol/engine": "0.1.
|
|
35
|
-
"@infernetprotocol/deploy-providers": "0.1.
|
|
36
|
-
"@infernetprotocol/
|
|
37
|
-
"@infernetprotocol/
|
|
33
|
+
"@infernetprotocol/auth": "0.1.37",
|
|
34
|
+
"@infernetprotocol/engine": "0.1.37",
|
|
35
|
+
"@infernetprotocol/deploy-providers": "0.1.37",
|
|
36
|
+
"@infernetprotocol/gpu": "0.1.37",
|
|
37
|
+
"@infernetprotocol/config": "0.1.37"
|
|
38
38
|
},
|
|
39
39
|
"repository": {
|
|
40
40
|
"type": "git",
|