@infernetprotocol/training 0.1.80 → 0.1.82
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/package.json +3 -3
- package/src/backends/peft.js +20 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infernetprotocol/training",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.82",
|
|
5
5
|
"description": "Training orchestration for Infernet — pluggable backends (DeepSpeed/FSDP for trusted clusters, OpenDiLoCo for cross-provider async, Petals for trustless P2P fine-tunes) over a stable async-iterator API.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"node": ">=18"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@infernetprotocol/engine": "0.1.
|
|
23
|
-
"@infernetprotocol/liquid-agent": "0.1.
|
|
22
|
+
"@infernetprotocol/engine": "0.1.82",
|
|
23
|
+
"@infernetprotocol/liquid-agent": "0.1.82"
|
|
24
24
|
},
|
|
25
25
|
"repository": {
|
|
26
26
|
"type": "git",
|
package/src/backends/peft.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import { randomUUID } from "node:crypto";
|
|
19
19
|
import { spawn } from "node:child_process";
|
|
20
20
|
import { existsSync } from "node:fs";
|
|
21
|
-
import { mkdir, mkdtemp, writeFile } from "node:fs/promises";
|
|
21
|
+
import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
22
22
|
import os from "node:os";
|
|
23
23
|
import path from "node:path";
|
|
24
24
|
import { fileURLToPath } from "node:url";
|
|
@@ -58,8 +58,26 @@ export async function setupPeftRuntime({ accelerator = "cpu", python = "python3"
|
|
|
58
58
|
const dir = peftRuntimeDir();
|
|
59
59
|
await mkdir(dir, { recursive: true });
|
|
60
60
|
const venv = path.join(dir, "venv");
|
|
61
|
-
if (!existsSync(path.join(venv, "bin", "python"))) await run(python, ["-m", "venv", venv], log);
|
|
62
61
|
const py = path.join(venv, "bin", "python");
|
|
62
|
+
if (!existsSync(py)) {
|
|
63
|
+
try {
|
|
64
|
+
await run(python, ["-m", "venv", venv], log);
|
|
65
|
+
} catch (err) {
|
|
66
|
+
// Debian/Ubuntu ship venv without ensurepip unless python3-venv is
|
|
67
|
+
// installed (needs root). A pip-less venv plus get-pip.py works anyway.
|
|
68
|
+
log?.(`python -m venv failed (${err.message}); retrying without pip`);
|
|
69
|
+
await rm(venv, { recursive: true, force: true });
|
|
70
|
+
await run(python, ["-m", "venv", "--without-pip", venv], log);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const hasPip = await run(py, ["-m", "pip", "--version"]).then(() => true, () => false);
|
|
74
|
+
if (!hasPip) {
|
|
75
|
+
const getPip = path.join(dir, "get-pip.py");
|
|
76
|
+
const res = await fetch("https://bootstrap.pypa.io/get-pip.py");
|
|
77
|
+
if (!res.ok) throw new Error(`could not download get-pip.py: HTTP ${res.status}`);
|
|
78
|
+
await writeFile(getPip, Buffer.from(await res.arrayBuffer()));
|
|
79
|
+
await run(py, [getPip, "--quiet"], log);
|
|
80
|
+
}
|
|
63
81
|
await run(py, ["-m", "pip", "install", "--upgrade", "--quiet", "pip"], log);
|
|
64
82
|
const torchIndex = accelerator === "cuda" ? [] : ["--index-url", "https://download.pytorch.org/whl/cpu"];
|
|
65
83
|
await run(py, ["-m", "pip", "install", "--quiet", "torch", ...torchIndex], log);
|