odant-work 1.0.30 → 1.0.32
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/#system/package-manifest.json +12 -12
- package/MODELS/$ai/$folder/$class/$provider/handlers/pages/form/trainer/$handler/trainer.js +5 -3
- package/package.json +1 -1
- package/sources/data/progress.md +7 -0
- package/sources/modules/trainer/halogen.js +398 -74
- package/sources/modules/trainer/huggingface.js +120 -29
- package/sources/modules/trainer/index.js +20 -4
- package/sources/modules/trainer/paths.js +1 -1
- package/sources/modules/trainer/providers.js +9 -0
- package/sources/modules/trainer/runner.js +102 -25
|
@@ -29,7 +29,6 @@ import {
|
|
|
29
29
|
migrateLocalModelsLayoutSync,
|
|
30
30
|
hasReadyWeightFilesSync,
|
|
31
31
|
LINUX_ONLY_HALOGEN_EXT_RE,
|
|
32
|
-
getFreeDiskSpaceGb,
|
|
33
32
|
} from './paths.js';
|
|
34
33
|
|
|
35
34
|
const HF_ORIGIN = DEFAULT_HF_ORIGIN;
|
|
@@ -73,6 +72,22 @@ export const MODEL_CAPABILITIES = Object.freeze({
|
|
|
73
72
|
*/
|
|
74
73
|
export const CURATED_HF_MODELS = Object.freeze([
|
|
75
74
|
// --- ТЕКСТ И КОД (LLM / АГЕНТЫ) ---
|
|
75
|
+
{
|
|
76
|
+
id: 'Qwen/Qwen3-0.6B',
|
|
77
|
+
author: 'Qwen',
|
|
78
|
+
modelName: 'Qwen3-0.6B (Сверхлёгкий маршрутизатор)',
|
|
79
|
+
modality: 'llm',
|
|
80
|
+
format: 'safetensors',
|
|
81
|
+
paramsB: 0.6,
|
|
82
|
+
ramRequiredGb: 1.0,
|
|
83
|
+
trainRamGb: 2.2,
|
|
84
|
+
capabilities: ['chat', 'classify', 'decide'],
|
|
85
|
+
whatItDoes: 'Мгновенная классификация запросов, маршрутизация и быстрые короткие ответы на CPU/GPU',
|
|
86
|
+
recommendedFor: 'Работает на любом ПК (<1 ГБ памяти)',
|
|
87
|
+
tags: ['qwen3', '0.6b', 'safetensors', 'fast'],
|
|
88
|
+
downloads: 190000,
|
|
89
|
+
likes: 720,
|
|
90
|
+
},
|
|
76
91
|
{
|
|
77
92
|
id: 'Qwen/Qwen3-4B',
|
|
78
93
|
author: 'Qwen',
|
|
@@ -1126,8 +1141,12 @@ async function writeDownloadStateSafe(stagingDir, job, extra = {}) {
|
|
|
1126
1141
|
threads: Number(job.threads) || 1,
|
|
1127
1142
|
registerInWork: extra.registerInWork !== false,
|
|
1128
1143
|
nodeMeta: extra.nodeMeta || null,
|
|
1144
|
+
customFilesDir: extra.customFilesDir || '',
|
|
1145
|
+
buboFinalize: Boolean(extra.buboFinalize),
|
|
1129
1146
|
files: (job.files || []).map(f => ({
|
|
1130
1147
|
name: f.name,
|
|
1148
|
+
...(f.url ? { url: f.url } : {}),
|
|
1149
|
+
...(f.destRelPath ? { destRelPath: f.destRelPath } : {}),
|
|
1131
1150
|
size: Number(f.size) || 0,
|
|
1132
1151
|
downloaded: Number(f.downloaded) || 0,
|
|
1133
1152
|
done: Boolean(f.done),
|
|
@@ -1195,6 +1214,9 @@ export function computeDownloadEta({ remainingBytes = 0, avgBytesPerSec = 0, sho
|
|
|
1195
1214
|
export async function startHuggingFaceDownload({
|
|
1196
1215
|
repoId,
|
|
1197
1216
|
files = null,
|
|
1217
|
+
customFiles = null,
|
|
1218
|
+
customFilesDir = '',
|
|
1219
|
+
onComplete = null,
|
|
1198
1220
|
quant = 'Q8_0',
|
|
1199
1221
|
revision = 'main',
|
|
1200
1222
|
token = '',
|
|
@@ -1240,15 +1262,28 @@ export async function startHuggingFaceDownload({
|
|
|
1240
1262
|
const effToken = token || netCfg.token || '';
|
|
1241
1263
|
const netFetch = createNetworkFetch({ proxyUrl: effProxy, fetchImpl });
|
|
1242
1264
|
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1265
|
+
let repoMeta = { modality: nodeMeta?.modality || 'llm', capabilities: nodeMeta?.capabilities || ['chat'], files: [] };
|
|
1266
|
+
let selected = [];
|
|
1267
|
+
if (Array.isArray(customFiles) && customFiles.length) {
|
|
1268
|
+
selected = customFiles.map(cf => ({
|
|
1269
|
+
name: String(cf.name || ''),
|
|
1270
|
+
url: String(cf.url || ''),
|
|
1271
|
+
destRelPath: String(cf.destRelPath || path.basename(cf.name || '')),
|
|
1272
|
+
size: Number(cf.size) || 0,
|
|
1273
|
+
kind: /\.gguf$/i.test(cf.name || '') ? 'gguf' : 'safetensors',
|
|
1274
|
+
}));
|
|
1275
|
+
}
|
|
1276
|
+
else {
|
|
1277
|
+
repoMeta = await inspectHuggingFaceRepo(cleanId, {
|
|
1278
|
+
revision,
|
|
1279
|
+
token: effToken,
|
|
1280
|
+
rootDir,
|
|
1281
|
+
endpointUrl: effEndpoint,
|
|
1282
|
+
proxyUrl: effProxy,
|
|
1283
|
+
fetchImpl,
|
|
1284
|
+
});
|
|
1285
|
+
selected = selectFilesToDownload(repoMeta, { files, quant });
|
|
1286
|
+
}
|
|
1252
1287
|
if (!selected.length)
|
|
1253
1288
|
throw new Error(`В репозитории ${cleanId} не найдено подходящих файлов весов (.gguf / .safetensors)`);
|
|
1254
1289
|
|
|
@@ -1258,15 +1293,6 @@ export async function startHuggingFaceDownload({
|
|
|
1258
1293
|
throw new Error(`В репозитории ${cleanId} найдены только веса Linux (.hgn/.hnpw), несовместимые с Windows.`);
|
|
1259
1294
|
}
|
|
1260
1295
|
|
|
1261
|
-
const totalExpectedBytes = selected.reduce((acc, f) => acc + (Number(f.size) || 0), 0);
|
|
1262
|
-
if (totalExpectedBytes > 512 * 1024 * 1024) {
|
|
1263
|
-
const freeGb = getFreeDiskSpaceGb(rootDir);
|
|
1264
|
-
const needGb = +(totalExpectedBytes / (1024 ** 3)).toFixed(1);
|
|
1265
|
-
if (freeGb !== null && freeGb < needGb + 1) {
|
|
1266
|
-
throw new Error(`Недостаточно свободного места на диске для загрузки ${cleanId}: свободно ${freeGb} ГБ, требуется не менее ${needGb} ГБ.`);
|
|
1267
|
-
}
|
|
1268
|
-
}
|
|
1269
|
-
|
|
1270
1296
|
const folderName = targetNodeName
|
|
1271
1297
|
? String(targetNodeName).replace(/[<>:"/\\|?*]/g, '-')
|
|
1272
1298
|
: safeModelFolderName(cleanId, quant && selected.some(f => f.kind === 'gguf') ? quant : '');
|
|
@@ -1276,6 +1302,8 @@ export async function startHuggingFaceDownload({
|
|
|
1276
1302
|
const modelDir = getModelDir(rootDir, folderName, safeProvider);
|
|
1277
1303
|
const weightsDir = getModelWeightsDir(rootDir, folderName, safeProvider);
|
|
1278
1304
|
const stagingDir = weightsDir;
|
|
1305
|
+
const filesRootDir = customFilesDir ? path.resolve(rootDir, customFilesDir) : stagingDir;
|
|
1306
|
+
const customFilesDirRel = customFilesDir ? path.relative(rootDir, filesRootDir).replace(/\\/g, '/') : '';
|
|
1279
1307
|
const primary = selected.find(f => f.name.endsWith('.gguf'))?.name
|
|
1280
1308
|
|| selected.find(f => f.name.endsWith('.safetensors') || f.name.endsWith('.hgn') || f.name.endsWith('.hnpw'))?.name
|
|
1281
1309
|
|| selected[0]?.name || '';
|
|
@@ -1284,6 +1312,8 @@ export async function startHuggingFaceDownload({
|
|
|
1284
1312
|
|| `${cleanId.split('/')[1] || cleanId}${quant && primary.endsWith('.gguf') ? ' (' + quant + ')' : ''}`;
|
|
1285
1313
|
|
|
1286
1314
|
await fsp.mkdir(weightsDir, { recursive: true });
|
|
1315
|
+
if (filesRootDir !== stagingDir)
|
|
1316
|
+
await fsp.mkdir(filesRootDir, { recursive: true });
|
|
1287
1317
|
|
|
1288
1318
|
// Если осталась недокачанная старая папка в #downloads/<folderName>, аккуратно перенесём её в $ai/#weights
|
|
1289
1319
|
const legacyStaging = path.join(rootDir, 'MODELS', safeProvider, '#downloads', folderName);
|
|
@@ -1329,7 +1359,8 @@ export async function startHuggingFaceDownload({
|
|
|
1329
1359
|
const jobFiles = [];
|
|
1330
1360
|
for (const f of selected) {
|
|
1331
1361
|
const size = Number(f.size) || 0;
|
|
1332
|
-
const
|
|
1362
|
+
const destRelPath = f.destRelPath || path.basename(f.name);
|
|
1363
|
+
const stagedFile = path.join(filesRootDir, destRelPath);
|
|
1333
1364
|
const partFile = stagedFile + '.part';
|
|
1334
1365
|
let downloaded = 0;
|
|
1335
1366
|
let done = false;
|
|
@@ -1361,7 +1392,15 @@ export async function startHuggingFaceDownload({
|
|
|
1361
1392
|
}
|
|
1362
1393
|
catch { /* .part ещё нет */ }
|
|
1363
1394
|
}
|
|
1364
|
-
jobFiles.push({
|
|
1395
|
+
jobFiles.push({
|
|
1396
|
+
name: f.name,
|
|
1397
|
+
...(f.url ? { url: f.url } : {}),
|
|
1398
|
+
...(f.destRelPath ? { destRelPath: f.destRelPath } : {}),
|
|
1399
|
+
size: size || (done ? downloaded : 0),
|
|
1400
|
+
downloaded,
|
|
1401
|
+
done,
|
|
1402
|
+
ranges,
|
|
1403
|
+
});
|
|
1365
1404
|
}
|
|
1366
1405
|
|
|
1367
1406
|
const jobId = 'hf_' + crypto.randomUUID().slice(0, 8);
|
|
@@ -1391,6 +1430,8 @@ export async function startHuggingFaceDownload({
|
|
|
1391
1430
|
rootDir,
|
|
1392
1431
|
stagingDir,
|
|
1393
1432
|
weightsDir,
|
|
1433
|
+
filesRootDir,
|
|
1434
|
+
customFilesDir: customFilesDirRel,
|
|
1394
1435
|
endpointUrl: effEndpoint,
|
|
1395
1436
|
sourceLabel: describeSourceLabel(effEndpoint),
|
|
1396
1437
|
threads: effThreads,
|
|
@@ -1422,12 +1463,15 @@ export async function startHuggingFaceDownload({
|
|
|
1422
1463
|
registerInWork,
|
|
1423
1464
|
quant,
|
|
1424
1465
|
files,
|
|
1466
|
+
customFiles: Array.isArray(customFiles) && customFiles.length ? customFiles : null,
|
|
1467
|
+
customFilesDir: customFilesDirRel,
|
|
1468
|
+
onComplete,
|
|
1425
1469
|
fetchImpl,
|
|
1426
1470
|
runPromise: null,
|
|
1427
1471
|
setKeepFiles: (v) => { keepFilesOnAbort = Boolean(v); },
|
|
1428
1472
|
};
|
|
1429
1473
|
_downloads.set(jobId, entryMeta);
|
|
1430
|
-
await writeDownloadStateSafe(stagingDir, job, { nodeMeta, registerInWork });
|
|
1474
|
+
await writeDownloadStateSafe(stagingDir, job, { nodeMeta, registerInWork, customFilesDir: customFilesDirRel, buboFinalize: Boolean(onComplete) });
|
|
1431
1475
|
|
|
1432
1476
|
const runPromise = (async () => {
|
|
1433
1477
|
const t0 = Date.now();
|
|
@@ -1443,7 +1487,7 @@ export async function startHuggingFaceDownload({
|
|
|
1443
1487
|
stateWriteChain = stateWriteChain.then(() => {
|
|
1444
1488
|
if (downloadFinished)
|
|
1445
1489
|
return;
|
|
1446
|
-
return writeDownloadStateSafe(weightsDir, job, { nodeMeta, registerInWork });
|
|
1490
|
+
return writeDownloadStateSafe(weightsDir, job, { nodeMeta, registerInWork, customFilesDir: customFilesDirRel, buboFinalize: Boolean(onComplete) });
|
|
1447
1491
|
}).catch(() => {});
|
|
1448
1492
|
};
|
|
1449
1493
|
|
|
@@ -1511,10 +1555,18 @@ export async function startHuggingFaceDownload({
|
|
|
1511
1555
|
if (controller.signal.aborted)
|
|
1512
1556
|
throw new Error('Загрузка приостановлена пользователем');
|
|
1513
1557
|
job.currentFile = fileEntry.name;
|
|
1514
|
-
const
|
|
1558
|
+
const destRelPath = fileEntry.destRelPath || path.basename(fileEntry.name);
|
|
1559
|
+
const stagedFile = path.join(filesRootDir, destRelPath);
|
|
1560
|
+
await fsp.mkdir(path.dirname(stagedFile), { recursive: true });
|
|
1515
1561
|
const partFile = stagedFile + '.part';
|
|
1516
|
-
|
|
1517
|
-
|
|
1562
|
+
let url;
|
|
1563
|
+
if (fileEntry.url) {
|
|
1564
|
+
url = String(fileEntry.url).replace(/^https:\/\/huggingface\.co(?=\/)/i, effEndpoint);
|
|
1565
|
+
}
|
|
1566
|
+
else {
|
|
1567
|
+
const encodedPath = fileEntry.name.split('/').map(encodeURIComponent).join('/');
|
|
1568
|
+
url = `${effEndpoint}/${cleanId}/resolve/${encodeURIComponent(job.revision)}/${encodedPath}`;
|
|
1569
|
+
}
|
|
1518
1570
|
const headers = hfHeaders(effToken, url, effEndpoint);
|
|
1519
1571
|
|
|
1520
1572
|
const res = await downloadFileMultipart({
|
|
@@ -1607,11 +1659,16 @@ export async function startHuggingFaceDownload({
|
|
|
1607
1659
|
maxTokens: nodeMeta?.maxTokens,
|
|
1608
1660
|
maxOutput: nodeMeta?.maxOutput,
|
|
1609
1661
|
baseUrl: nodeMeta?.baseUrl,
|
|
1610
|
-
weightsDir,
|
|
1611
|
-
primaryFile: path.basename(primary),
|
|
1662
|
+
weightsDir: filesRootDir,
|
|
1663
|
+
primaryFile: nodeMeta?.primaryFile || path.basename(primary),
|
|
1612
1664
|
});
|
|
1613
1665
|
}
|
|
1614
1666
|
|
|
1667
|
+
if (typeof onComplete === 'function') {
|
|
1668
|
+
job.currentFile = 'Настройка встроенного движка…';
|
|
1669
|
+
await onComplete({ job, weightsDir, filesRootDir, rootDir });
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1615
1672
|
job.progress = 100;
|
|
1616
1673
|
job.etaSeconds = 0;
|
|
1617
1674
|
job.status = 'completed';
|
|
@@ -1739,6 +1796,11 @@ export function listHuggingFaceDownloads(rootDir = process.cwd()) {
|
|
|
1739
1796
|
}
|
|
1740
1797
|
catch { /* ignore */ }
|
|
1741
1798
|
}
|
|
1799
|
+
if (diskBytes <= 0 && Array.isArray(state.files)) {
|
|
1800
|
+
for (const sf of state.files) {
|
|
1801
|
+
diskBytes += Number(sf?.downloaded) || 0;
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1742
1804
|
if (diskBytes <= 0 && !state.repoId)
|
|
1743
1805
|
continue;
|
|
1744
1806
|
const totalBytes = Number(state.totalBytes) || 0;
|
|
@@ -1791,7 +1853,12 @@ export function pauseHuggingFaceDownload(jobId) {
|
|
|
1791
1853
|
entry.job.status = 'paused';
|
|
1792
1854
|
entry.job.etaSeconds = null;
|
|
1793
1855
|
entry.job.finishedAt = Date.now();
|
|
1794
|
-
writeDownloadStateSafe(entry.job.stagingDir, entry.job, {
|
|
1856
|
+
writeDownloadStateSafe(entry.job.stagingDir, entry.job, {
|
|
1857
|
+
nodeMeta: entry.nodeMeta,
|
|
1858
|
+
registerInWork: entry.registerInWork,
|
|
1859
|
+
customFilesDir: entry.customFilesDir || '',
|
|
1860
|
+
buboFinalize: Boolean(entry.onComplete),
|
|
1861
|
+
});
|
|
1795
1862
|
return { ...entry.job };
|
|
1796
1863
|
}
|
|
1797
1864
|
|
|
@@ -1810,6 +1877,18 @@ export async function discardHuggingFaceDownload({ jobId = '', folderName = '',
|
|
|
1810
1877
|
targetFolder = key.slice(5);
|
|
1811
1878
|
if (targetFolder) {
|
|
1812
1879
|
const weightsDir = getModelWeightsDir(rootDir, targetFolder, 'Local');
|
|
1880
|
+
let customDirAbs = entry?.customFilesDir ? path.resolve(rootDir, entry.customFilesDir) : '';
|
|
1881
|
+
if (!customDirAbs && fs.existsSync(path.join(weightsDir, DOWNLOAD_STATE_FILE))) {
|
|
1882
|
+
try {
|
|
1883
|
+
const st = JSON.parse(await fsp.readFile(path.join(weightsDir, DOWNLOAD_STATE_FILE), 'utf-8'));
|
|
1884
|
+
if (st?.customFilesDir)
|
|
1885
|
+
customDirAbs = path.resolve(rootDir, st.customFilesDir);
|
|
1886
|
+
}
|
|
1887
|
+
catch { /* ignore */ }
|
|
1888
|
+
}
|
|
1889
|
+
if (customDirAbs && fs.existsSync(customDirAbs)) {
|
|
1890
|
+
await fsp.rm(customDirAbs, { recursive: true, force: true }).catch(() => {});
|
|
1891
|
+
}
|
|
1813
1892
|
if (fs.existsSync(weightsDir)) {
|
|
1814
1893
|
await fsp.rm(path.join(weightsDir, DOWNLOAD_STATE_FILE), { force: true }).catch(() => {});
|
|
1815
1894
|
const files = await fsp.readdir(weightsDir).catch(() => []);
|
|
@@ -1831,6 +1910,9 @@ export async function resumeHuggingFaceDownload({
|
|
|
1831
1910
|
folderName = '',
|
|
1832
1911
|
repoId = '',
|
|
1833
1912
|
files = null,
|
|
1913
|
+
customFiles = null,
|
|
1914
|
+
customFilesDir = '',
|
|
1915
|
+
onComplete = null,
|
|
1834
1916
|
quant = 'Q8_0',
|
|
1835
1917
|
token = '',
|
|
1836
1918
|
nodeMeta = null,
|
|
@@ -1859,6 +1941,9 @@ export async function resumeHuggingFaceDownload({
|
|
|
1859
1941
|
if (!resolvedRepo)
|
|
1860
1942
|
throw new Error(`Не удалось определить репозиторий Hugging Face для докачки «${cleanFolder || key}»`);
|
|
1861
1943
|
|
|
1944
|
+
const stateHasCustomUrls = Array.isArray(state.files) && state.files.some(f => f?.url || f?.destRelPath);
|
|
1945
|
+
const resolvedCustomFiles = customFiles ?? entry?.customFiles ?? (stateHasCustomUrls ? state.files : null);
|
|
1946
|
+
const resolvedCustomDir = customFilesDir || entry?.customFilesDir || state.customFilesDir || '';
|
|
1862
1947
|
const stateFileNames = Array.isArray(state.files) && state.files.length
|
|
1863
1948
|
? state.files.map(f => f?.name).filter(Boolean)
|
|
1864
1949
|
: null;
|
|
@@ -1866,6 +1951,9 @@ export async function resumeHuggingFaceDownload({
|
|
|
1866
1951
|
return startHuggingFaceDownload({
|
|
1867
1952
|
repoId: resolvedRepo,
|
|
1868
1953
|
files: files ?? entry?.files ?? stateFileNames ?? null,
|
|
1954
|
+
customFiles: resolvedCustomFiles,
|
|
1955
|
+
customFilesDir: resolvedCustomDir,
|
|
1956
|
+
onComplete: onComplete || entry?.onComplete || null,
|
|
1869
1957
|
quant: quant || entry?.quant || 'Q8_0',
|
|
1870
1958
|
revision: entry?.job?.revision || state.revision || 'main',
|
|
1871
1959
|
token,
|
|
@@ -1898,6 +1986,9 @@ export async function restartActiveHuggingFaceDownloads({ rootDir = '' } = {}) {
|
|
|
1898
1986
|
folderName: entry.job.folderName,
|
|
1899
1987
|
repoId: entry.job.repoId,
|
|
1900
1988
|
files: entry.files ?? null,
|
|
1989
|
+
customFiles: entry.customFiles ?? null,
|
|
1990
|
+
customFilesDir: entry.customFilesDir || '',
|
|
1991
|
+
onComplete: entry.onComplete || null,
|
|
1901
1992
|
quant: entry.quant || 'Q8_0',
|
|
1902
1993
|
nodeMeta: entry.nodeMeta || null,
|
|
1903
1994
|
rootDir: entry.job.rootDir || process.cwd(),
|
|
@@ -54,6 +54,7 @@ import {
|
|
|
54
54
|
HALOGEN_IMAGE_TAG,
|
|
55
55
|
BUBO_WINDOWS_RELEASE,
|
|
56
56
|
HALOGEN_MODELS_CATALOG,
|
|
57
|
+
HALOGEN_WINDOWS_COMPANIONS,
|
|
57
58
|
HALOGEN_TTS_VOICES,
|
|
58
59
|
getHalogenCatalogForPlatform,
|
|
59
60
|
checkWindowsHalogenPreflight,
|
|
@@ -64,6 +65,9 @@ import {
|
|
|
64
65
|
computeHalogenMemoryPlan,
|
|
65
66
|
inspectWindowsHalogenEnvironment,
|
|
66
67
|
prepareWindowsBuboRuntime,
|
|
68
|
+
finalizeWindowsBuboModel,
|
|
69
|
+
BUBO_ORIGINAL_MODEL_DIR_REL,
|
|
70
|
+
BUBO_ORIGINAL_MODEL_FILES,
|
|
67
71
|
probeHalogenServer,
|
|
68
72
|
startHalogenBackend,
|
|
69
73
|
stopHalogenBackend,
|
|
@@ -161,6 +165,7 @@ export {
|
|
|
161
165
|
HALOGEN_IMAGE_TAG,
|
|
162
166
|
BUBO_WINDOWS_RELEASE,
|
|
163
167
|
HALOGEN_MODELS_CATALOG,
|
|
168
|
+
HALOGEN_WINDOWS_COMPANIONS,
|
|
164
169
|
HALOGEN_TTS_VOICES,
|
|
165
170
|
getHalogenCatalogForPlatform,
|
|
166
171
|
checkWindowsHalogenPreflight,
|
|
@@ -171,6 +176,9 @@ export {
|
|
|
171
176
|
computeHalogenMemoryPlan,
|
|
172
177
|
inspectWindowsHalogenEnvironment,
|
|
173
178
|
prepareWindowsBuboRuntime,
|
|
179
|
+
finalizeWindowsBuboModel,
|
|
180
|
+
BUBO_ORIGINAL_MODEL_DIR_REL,
|
|
181
|
+
BUBO_ORIGINAL_MODEL_FILES,
|
|
174
182
|
probeHalogenServer,
|
|
175
183
|
startHalogenBackend,
|
|
176
184
|
stopHalogenBackend,
|
|
@@ -760,27 +768,35 @@ export const TRAINER_METHODS = Object.freeze({
|
|
|
760
768
|
fn: async function (p = {}) {
|
|
761
769
|
const args = mergeTrainerArgs(p);
|
|
762
770
|
const folderName = args.folderName || '';
|
|
763
|
-
const
|
|
771
|
+
const platformCatalog = getHalogenCatalogForPlatform(os.platform());
|
|
772
|
+
const haloSpec = platformCatalog.find(m =>
|
|
764
773
|
(folderName && m.nodeName === folderName)
|
|
765
774
|
|| (args.repoId && m.hfRepo === args.repoId)
|
|
766
775
|
);
|
|
776
|
+
const isWinBubo = os.platform() === 'win32' && (haloSpec?.runtimeType === 'bubo' || folderName === 'Qwen3.8-Flash-Next');
|
|
767
777
|
const job = await resumeHuggingFaceDownload({
|
|
768
778
|
jobId: args.jobId ?? args.id ?? '',
|
|
769
779
|
folderName,
|
|
770
|
-
repoId: args.repoId || haloSpec?.hfRepo || '',
|
|
780
|
+
repoId: isWinBubo ? (haloSpec?.windowsBuboRepo || 'unsloth/Qwen3.8-Flash-Next-GGUF') : (args.repoId || haloSpec?.hfRepo || ''),
|
|
781
|
+
...(isWinBubo ? {
|
|
782
|
+
customFiles: BUBO_ORIGINAL_MODEL_FILES,
|
|
783
|
+
customFilesDir: BUBO_ORIGINAL_MODEL_DIR_REL,
|
|
784
|
+
onComplete: ({ rootDir: rd }) => finalizeWindowsBuboModel({ rootDir: rd }),
|
|
785
|
+
} : {}),
|
|
771
786
|
quant: args.quant || 'Q8_0',
|
|
772
787
|
token: args.token || '',
|
|
773
788
|
nodeMeta: haloSpec ? {
|
|
774
789
|
label: haloSpec.label || haloSpec.nodeName,
|
|
775
790
|
model: haloSpec.model,
|
|
776
|
-
protocol: '
|
|
791
|
+
protocol: haloSpec.protocol || 'local',
|
|
777
792
|
icon: haloSpec.icon || 'ai:qwen',
|
|
778
793
|
modality: haloSpec.modality,
|
|
779
794
|
capabilities: haloSpec.capabilities,
|
|
780
795
|
efforts: haloSpec.efforts,
|
|
781
796
|
maxTokens: haloSpec.maxTokens,
|
|
782
797
|
maxOutput: haloSpec.maxOutput,
|
|
783
|
-
baseUrl: haloSpec.baseUrl
|
|
798
|
+
baseUrl: haloSpec.baseUrl ?? '',
|
|
799
|
+
...(isWinBubo ? { primaryFile: 'bubo-package.json' } : {}),
|
|
784
800
|
} : null,
|
|
785
801
|
});
|
|
786
802
|
try {
|
|
@@ -142,7 +142,7 @@ export function inspectWeightsDirectorySync(dirPath, platform = os.platform()) {
|
|
|
142
142
|
weightFormat = 'other';
|
|
143
143
|
|
|
144
144
|
const isWin = platform === 'win32';
|
|
145
|
-
const incompatibleOnPlatform = isWin && (hasHgn || hasHnpw) && !hasGguf && !hasBuboManifest
|
|
145
|
+
const incompatibleOnPlatform = isWin && (hasHgn || hasHnpw) && !hasGguf && !hasBuboManifest;
|
|
146
146
|
const incompatibleReason = incompatibleOnPlatform
|
|
147
147
|
? 'Скачаны веса формата Linux (.hgn/.hnpw), несовместимые с Windows. Удалите их и установите Windows-версию (GGUF / .safetensors).'
|
|
148
148
|
: '';
|
|
@@ -908,6 +908,15 @@ export function evaluateAiNodeActivitySync(item, rootDir = process.cwd()) {
|
|
|
908
908
|
path.resolve(rootDir, adapterRel),
|
|
909
909
|
], platform);
|
|
910
910
|
|
|
911
|
+
const isHalogenLinuxRepo = /^peonist-ai\/halogen-/i.test(String(data.hfRepo || ''));
|
|
912
|
+
if (platform === 'win32' && isHalogenLinuxRepo && !(isFlashNext && hasBuboGlobal) && !check.info?.hasGguf && !check.info?.hasBuboManifest) {
|
|
913
|
+
return {
|
|
914
|
+
active: false,
|
|
915
|
+
reason: check.info?.incompatibleReason || 'Веса формата Linux (.hgn/.hnpw) несовместимы с Windows',
|
|
916
|
+
incompatibleOnPlatform: true,
|
|
917
|
+
configuredKey: false,
|
|
918
|
+
};
|
|
919
|
+
}
|
|
911
920
|
if (check.ready || (isFlashNext && hasBuboGlobal)) {
|
|
912
921
|
return { active: true, reason: 'Активна (веса модели на диске)', configuredKey: true };
|
|
913
922
|
}
|
|
@@ -103,6 +103,81 @@ export function computeAdaptiveDefaults(usableMemoryGb) {
|
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
function parseRegMemoryBytes(regType, rawValue) {
|
|
107
|
+
const val = String(rawValue || '').trim();
|
|
108
|
+
if (!val)
|
|
109
|
+
return 0;
|
|
110
|
+
try {
|
|
111
|
+
if (/REG_QWORD|REG_DWORD/i.test(regType)) {
|
|
112
|
+
return Number(BigInt(val));
|
|
113
|
+
}
|
|
114
|
+
if (/REG_BINARY/i.test(regType)) {
|
|
115
|
+
const hex = val.replace(/[^0-9a-f]/gi, '');
|
|
116
|
+
if (hex.length >= 16) {
|
|
117
|
+
const buf = Buffer.from(hex.slice(0, 16), 'hex');
|
|
118
|
+
return Number(buf.readBigUInt64LE(0));
|
|
119
|
+
}
|
|
120
|
+
if (hex.length >= 8) {
|
|
121
|
+
const buf = Buffer.from(hex.slice(0, 8), 'hex');
|
|
122
|
+
return buf.readUInt32LE(0);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
catch { /* ignore */ }
|
|
127
|
+
return 0;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function parseWindowsVideoRegistry(output) {
|
|
131
|
+
const byKey = new Map();
|
|
132
|
+
let cur = null;
|
|
133
|
+
for (const rawLine of String(output || '').split(/\r?\n/)) {
|
|
134
|
+
const line = rawLine.trim();
|
|
135
|
+
if (!line)
|
|
136
|
+
continue;
|
|
137
|
+
if (/^HKEY_/i.test(line)) {
|
|
138
|
+
const key = line.toLowerCase();
|
|
139
|
+
cur = byKey.get(key) || { name: '', qwBytes: 0, dwBytes: 0 };
|
|
140
|
+
byKey.set(key, cur);
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
if (!cur)
|
|
144
|
+
continue;
|
|
145
|
+
const mDesc = line.match(/^DriverDesc\s+REG_SZ\s+(.+)$/i);
|
|
146
|
+
if (mDesc) {
|
|
147
|
+
cur.name = mDesc[1].trim();
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
const mQw = line.match(/^HardwareInformation\.qwMemorySize\s+(REG_\w+)\s+(.+)$/i);
|
|
151
|
+
if (mQw) {
|
|
152
|
+
cur.qwBytes = parseRegMemoryBytes(mQw[1], mQw[2]);
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
const mDw = line.match(/^HardwareInformation\.MemorySize\s+(REG_\w+)\s+(.+)$/i);
|
|
156
|
+
if (mDw) {
|
|
157
|
+
cur.dwBytes = parseRegMemoryBytes(mDw[1], mDw[2]);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
let bestName = '';
|
|
162
|
+
let maxBytes = 0;
|
|
163
|
+
for (const a of byKey.values()) {
|
|
164
|
+
if (/Basic Display|Virtual|Indirect/i.test(a.name))
|
|
165
|
+
continue;
|
|
166
|
+
const bytes = a.qwBytes || a.dwBytes || 0;
|
|
167
|
+
if (bytes > maxBytes) {
|
|
168
|
+
maxBytes = bytes;
|
|
169
|
+
bestName = a.name || bestName;
|
|
170
|
+
}
|
|
171
|
+
else if (!bestName && a.name) {
|
|
172
|
+
bestName = a.name;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return {
|
|
176
|
+
gpuName: bestName,
|
|
177
|
+
vramGb: maxBytes > 0 ? +(maxBytes / (1024 ** 3)).toFixed(1) : 0,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
106
181
|
/**
|
|
107
182
|
* Определить реальный аппаратный профиль текущей машины (CPU, RAM, GPU/VRAM/UMA, Python + Unsloth, llama-server)
|
|
108
183
|
* и адаптировать все бюджеты памяти и рекомендации под фактическое железо.
|
|
@@ -126,19 +201,17 @@ export async function detectHardware({ force = false } = {}) {
|
|
|
126
201
|
const platform = os.platform();
|
|
127
202
|
const arch = os.arch();
|
|
128
203
|
|
|
129
|
-
const
|
|
130
|
-
'$pm = (Get-CimInstance Win32_PhysicalMemory -ErrorAction SilentlyContinue | Measure-Object Capacity -Sum).Sum',
|
|
131
|
-
'$gpu = Get-CimInstance Win32_VideoController -ErrorAction SilentlyContinue | Where-Object { $_.Name -notmatch "Basic Display|Virtual" } | Select-Object -First 1 Name',
|
|
132
|
-
'$qw = (Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\\SYSTEM\\ControlSet001\\Control\\Class\\{4d36e968-e325-11ce-bfc1-08002be10318}\\0*" -Name "HardwareInformation.qwMemorySize" -ErrorAction SilentlyContinue | Measure-Object "HardwareInformation.qwMemorySize" -Maximum).Maximum',
|
|
133
|
-
'[PSCustomObject]@{phys=$pm;gpu=$gpu.Name;vram=$qw} | ConvertTo-Json -Compress',
|
|
134
|
-
].join('\n');
|
|
204
|
+
const winVideoRegKey = 'HKLM\\SYSTEM\\CurrentControlSet\\Control\\Class\\{4d36e968-e325-11ce-bfc1-08002be10318}';
|
|
135
205
|
|
|
136
|
-
// Параллельно опрашиваем видеокарту (NVIDIA / AMD ROCm / Windows
|
|
137
|
-
const [nvidiaProbe, rocmProbe,
|
|
206
|
+
// Параллельно опрашиваем видеокарту (NVIDIA / AMD ROCm / нативный reg query на Windows за ~50 мс) и Python / llama-server
|
|
207
|
+
const [nvidiaProbe, rocmProbe, winRegDesc, winRegMem, pyProbe, llamaProbe] = await Promise.all([
|
|
138
208
|
probeCommand('nvidia-smi', ['--query-gpu=name,memory.total', '--format=csv,noheader,nounits']),
|
|
139
209
|
probeCommand('rocm-smi', ['--showproductname', '--showmeminfo', 'vram', '--json']),
|
|
140
210
|
platform === 'win32'
|
|
141
|
-
? probeCommand('
|
|
211
|
+
? probeCommand('reg', ['query', winVideoRegKey, '/s', '/v', 'DriverDesc'], 2500)
|
|
212
|
+
: Promise.resolve({ ok: false, output: '' }),
|
|
213
|
+
platform === 'win32'
|
|
214
|
+
? probeCommand('reg', ['query', winVideoRegKey, '/s', '/v', 'HardwareInformation.*MemorySize'], 2500)
|
|
142
215
|
: Promise.resolve({ ok: false, output: '' }),
|
|
143
216
|
probeCommand('python', ['-c', 'import json, torch; import unsloth; print(json.dumps({"torch": torch.__version__, "cuda": torch.cuda.is_available(), "hip": getattr(torch.version, "hip", None)}))']),
|
|
144
217
|
probeCommand('llama-server', ['--version']),
|
|
@@ -146,22 +219,15 @@ export async function detectHardware({ force = false } = {}) {
|
|
|
146
219
|
|
|
147
220
|
let gpuName = '';
|
|
148
221
|
let vramGb = 0;
|
|
149
|
-
|
|
222
|
+
const physicalRamGb = osTotalRamGb;
|
|
150
223
|
let memoryType = 'System RAM / UMA';
|
|
151
224
|
|
|
152
|
-
if (
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
const vramB = Number(w.vram) || 0;
|
|
159
|
-
if (vramB > 0)
|
|
160
|
-
vramGb = +(vramB / (1024 ** 3)).toFixed(1);
|
|
161
|
-
if (w.gpu && typeof w.gpu === 'string')
|
|
162
|
-
gpuName = w.gpu.trim();
|
|
163
|
-
}
|
|
164
|
-
catch { /* ignore */ }
|
|
225
|
+
if (winRegDesc.ok || winRegMem.ok) {
|
|
226
|
+
const parsed = parseWindowsVideoRegistry(`${winRegDesc.output || ''}\n${winRegMem.output || ''}`);
|
|
227
|
+
if (parsed.gpuName)
|
|
228
|
+
gpuName = parsed.gpuName;
|
|
229
|
+
if (parsed.vramGb > 0)
|
|
230
|
+
vramGb = parsed.vramGb;
|
|
165
231
|
}
|
|
166
232
|
|
|
167
233
|
if (nvidiaProbe.ok && nvidiaProbe.output) {
|
|
@@ -365,7 +431,9 @@ export async function listLocalModelsAndAdapters(rootDir = process.cwd()) {
|
|
|
365
431
|
|
|
366
432
|
if (hasRealWeightBinary || isAdapterNode || hasBuboExternal) {
|
|
367
433
|
const enabled = meta.enabled !== false;
|
|
368
|
-
const
|
|
434
|
+
const isHalogenLinuxRepo = platform === 'win32' && /^peonist-ai\/halogen-/i.test(String(meta.hfRepo || ''));
|
|
435
|
+
const incompatible = !hasBuboExternal && (wInsp.incompatibleOnPlatform || (isHalogenLinuxRepo && !wInsp.hasGguf && !wInsp.hasBuboManifest));
|
|
436
|
+
const incompatibleReason = wInsp.incompatibleReason || (incompatible ? 'Веса формата Linux (.hgn/.hnpw) несовместимы с Windows. Удалите их и установите Windows-версию.' : '');
|
|
369
437
|
models.push({
|
|
370
438
|
id: e.name,
|
|
371
439
|
label: meta.label || e.name,
|
|
@@ -378,7 +446,7 @@ export async function listLocalModelsAndAdapters(rootDir = process.cwd()) {
|
|
|
378
446
|
enabled,
|
|
379
447
|
active: enabled && (hasRealWeightBinary || isAdapterNode || hasBuboExternal) && !incompatible,
|
|
380
448
|
incompatibleOnPlatform: incompatible,
|
|
381
|
-
incompatibleReason: incompatible ?
|
|
449
|
+
incompatibleReason: incompatible ? incompatibleReason : '',
|
|
382
450
|
weightFormat: hasBuboExternal ? 'bubo' : wInsp.weightFormat,
|
|
383
451
|
path: `/MODELS/Local/${e.name}`,
|
|
384
452
|
hasClass: fs.existsSync(aiClassFile),
|
|
@@ -405,6 +473,13 @@ export async function deleteLocalModel({ rootDir = process.cwd(), modelId } = {}
|
|
|
405
473
|
if (fs.existsSync(targetDir)) {
|
|
406
474
|
await fsp.rm(targetDir, { recursive: true, force: true });
|
|
407
475
|
}
|
|
476
|
+
if (cleanId === 'Qwen3.8-Flash-Next') {
|
|
477
|
+
for (const sub of ['qwen38-flash-next-base-ud-q4-k-xl-v1', 'huihui-qwen38-flash-next-ud-q4-k-xl-v1']) {
|
|
478
|
+
const buboDir = path.join(localRoot, 'models', sub);
|
|
479
|
+
if (fs.existsSync(buboDir))
|
|
480
|
+
await fsp.rm(buboDir, { recursive: true, force: true }).catch(() => {});
|
|
481
|
+
}
|
|
482
|
+
}
|
|
408
483
|
return { ok: true, deletedId: cleanId, deletedPath: `/MODELS/Local/${cleanId}` };
|
|
409
484
|
}
|
|
410
485
|
|
|
@@ -664,3 +739,5 @@ export async function publishTrainedAdapter(jobId, {
|
|
|
664
739
|
job.publishedPath = res.modelPath;
|
|
665
740
|
return res;
|
|
666
741
|
}
|
|
742
|
+
|
|
743
|
+
export { parseWindowsVideoRegistry };
|