@tuned-tensor/cli 0.13.1-beta.5 → 0.13.1-beta.7
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/README.md +24 -6
- package/dist/{chunk-AVMRHDFY.js → chunk-AKJ5WZ2S.js} +75 -52
- package/dist/chunk-AKJ5WZ2S.js.map +1 -0
- package/dist/index.js +142 -22
- package/dist/index.js.map +1 -1
- package/dist/local-runtime.js +71 -6
- package/dist/local-runtime.js.map +1 -1
- package/docs/local-runtime/architecture.md +24 -6
- package/docs/local-runtime/foundation-long-runs.md +108 -0
- package/package.json +1 -1
- package/training/foundation/src/checkpoint.py +235 -0
- package/training/foundation/src/common.py +30 -2
- package/training/foundation/src/data.py +154 -6
- package/training/foundation/src/evaluate.py +43 -9
- package/training/foundation/src/pretrain.py +439 -27
- package/training/foundation/src/rl.py +11 -3
- package/training/foundation/src/train_tokenizer.py +38 -5
- package/dist/chunk-AVMRHDFY.js.map +0 -1
package/dist/local-runtime.js
CHANGED
|
@@ -8,7 +8,9 @@ import {
|
|
|
8
8
|
assessHardware,
|
|
9
9
|
baseModelRevisionSchema,
|
|
10
10
|
behaviorSpecExampleSchema,
|
|
11
|
+
behaviorSpecSchema,
|
|
11
12
|
buildBundledPythonCommand,
|
|
13
|
+
buildFoundationPythonCommand,
|
|
12
14
|
buildModelPrefetchPayload,
|
|
13
15
|
buildSystemMessage,
|
|
14
16
|
canonicalLocalPipeline,
|
|
@@ -47,6 +49,7 @@ import {
|
|
|
47
49
|
localAdapterSpecFileSchema,
|
|
48
50
|
localBehaviorSpecFileSchema,
|
|
49
51
|
localFoundationSpecFileSchema,
|
|
52
|
+
localPathsOverlap,
|
|
50
53
|
localRunnerConfigSchema,
|
|
51
54
|
localRuntimePackageRoot,
|
|
52
55
|
localStorePaths,
|
|
@@ -71,10 +74,11 @@ import {
|
|
|
71
74
|
verifyLocalBaseModel,
|
|
72
75
|
verifyModelPrefetchCacheReport,
|
|
73
76
|
withBundledPythonEnvironment,
|
|
77
|
+
withFoundationPythonEnvironment,
|
|
74
78
|
withHuggingFaceCacheEnvironment,
|
|
75
79
|
withOfflineHuggingFaceCacheEnvironment,
|
|
76
80
|
writePrivateJsonAtomic
|
|
77
|
-
} from "./chunk-
|
|
81
|
+
} from "./chunk-AKJ5WZ2S.js";
|
|
78
82
|
|
|
79
83
|
// src/local-runtime/index.ts
|
|
80
84
|
import { readFileSync, realpathSync } from "fs";
|
|
@@ -146,7 +150,7 @@ function compareRuns(a, b) {
|
|
|
146
150
|
|
|
147
151
|
// src/local-runtime/doctor.ts
|
|
148
152
|
import { constants } from "fs";
|
|
149
|
-
import { access, mkdir, statfs, unlink, writeFile } from "fs/promises";
|
|
153
|
+
import { access, lstat, mkdir, statfs, unlink, writeFile } from "fs/promises";
|
|
150
154
|
import { homedir } from "os";
|
|
151
155
|
import { join, resolve } from "path";
|
|
152
156
|
import { spawn } from "child_process";
|
|
@@ -266,6 +270,23 @@ async function writableDirectoryCheck(name, path) {
|
|
|
266
270
|
};
|
|
267
271
|
}
|
|
268
272
|
}
|
|
273
|
+
function foundationPythonProbePlan(requireBf16) {
|
|
274
|
+
const source = [
|
|
275
|
+
"import json",
|
|
276
|
+
"import numpy, safetensors, tokenizers, torch",
|
|
277
|
+
"assert torch.cuda.is_available(), 'TT Foundation training requires CUDA but torch.cuda.is_available() is false'",
|
|
278
|
+
...requireBf16 ? ["assert torch.cuda.is_bf16_supported(), 'TT Foundation BF16 training was requested but this device does not support BF16'"] : [],
|
|
279
|
+
"props = torch.cuda.get_device_properties(0)",
|
|
280
|
+
"print(json.dumps({'python_ok': True, 'torch': torch.__version__, 'cuda_available': True, 'bf16': torch.cuda.is_bf16_supported(), 'cuda_device': torch.cuda.get_device_name(0), 'compute_capability': list(torch.cuda.get_device_capability(0)), 'total_memory_bytes': props.total_memory}))"
|
|
281
|
+
].join("; ");
|
|
282
|
+
const entrypoint = buildFoundationPythonCommand("-c", [source]);
|
|
283
|
+
return {
|
|
284
|
+
name: "python-runtime",
|
|
285
|
+
command: entrypoint.command,
|
|
286
|
+
args: entrypoint.commandArgs,
|
|
287
|
+
env: withFoundationPythonEnvironment(process.env)
|
|
288
|
+
};
|
|
289
|
+
}
|
|
269
290
|
function pythonProbeSource(device) {
|
|
270
291
|
return [
|
|
271
292
|
"import json",
|
|
@@ -311,6 +332,26 @@ function foundationPlaceholderCheck(spec) {
|
|
|
311
332
|
message: issues.length > 0 ? "The spec still contains generated placeholder content; edit it before training." : `${spec.examples.length} spec example(s); foundation engine`
|
|
312
333
|
};
|
|
313
334
|
}
|
|
335
|
+
async function foundationCorpusCheck(name, path) {
|
|
336
|
+
const resolvedPath = resolve(path);
|
|
337
|
+
try {
|
|
338
|
+
const info = await lstat(resolvedPath);
|
|
339
|
+
const supported = info.isFile() || info.isDirectory();
|
|
340
|
+
return {
|
|
341
|
+
name,
|
|
342
|
+
ok: supported && !info.isSymbolicLink(),
|
|
343
|
+
message: supported && !info.isSymbolicLink() ? `${resolvedPath} is available for streaming.` : `${resolvedPath} must be a regular file or directory, not a symbolic link.`,
|
|
344
|
+
details: { path: resolvedPath }
|
|
345
|
+
};
|
|
346
|
+
} catch (error) {
|
|
347
|
+
return {
|
|
348
|
+
name,
|
|
349
|
+
ok: false,
|
|
350
|
+
message: `${resolvedPath}: ${error instanceof Error ? error.message : String(error)}`,
|
|
351
|
+
details: { path: resolvedPath }
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
}
|
|
314
355
|
function placeholderSpecCheck(request) {
|
|
315
356
|
const placeholder = request.spec_snapshot.examples.some(
|
|
316
357
|
(example) => /replace this with/i.test(example.input) || /replace this with/i.test(example.output)
|
|
@@ -360,11 +401,33 @@ async function runDoctor(config, request, foundationSpec) {
|
|
|
360
401
|
}
|
|
361
402
|
if (foundationSpec) {
|
|
362
403
|
checks.push(foundationPlaceholderCheck(foundationSpec));
|
|
404
|
+
if (foundationSpec.foundation.corpus_path) {
|
|
405
|
+
checks.push(await foundationCorpusCheck("pretraining-corpus", foundationSpec.foundation.corpus_path));
|
|
406
|
+
}
|
|
407
|
+
if (foundationSpec.foundation.validation_path) {
|
|
408
|
+
checks.push(await foundationCorpusCheck("validation-corpus", foundationSpec.foundation.validation_path));
|
|
409
|
+
}
|
|
410
|
+
if (foundationSpec.foundation.corpus_path && foundationSpec.foundation.validation_path && localPathsOverlap(
|
|
411
|
+
foundationSpec.foundation.corpus_path,
|
|
412
|
+
foundationSpec.foundation.validation_path
|
|
413
|
+
)) {
|
|
414
|
+
checks.push({
|
|
415
|
+
name: "held-out-corpus",
|
|
416
|
+
ok: false,
|
|
417
|
+
message: "foundation.corpus_path and foundation.validation_path must be distinct."
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
if (foundationSpec.foundation.checkpoint_backup_dir) {
|
|
421
|
+
checks.push(await writableDirectoryCheck(
|
|
422
|
+
"checkpoint-backup",
|
|
423
|
+
foundationSpec.foundation.checkpoint_backup_dir
|
|
424
|
+
));
|
|
425
|
+
}
|
|
363
426
|
} else if (request) {
|
|
364
427
|
checks.push(placeholderSpecCheck(request));
|
|
365
428
|
resolveTrainingModel(request.spec_snapshot.base_model);
|
|
366
429
|
}
|
|
367
|
-
const pythonPlans = buildDoctorPythonPlans(config);
|
|
430
|
+
const pythonPlans = foundationSpec && !config.dryRun ? [foundationPythonProbePlan(foundationSpec.foundation.bf16 !== false)] : buildDoctorPythonPlans(config);
|
|
368
431
|
if (pythonPlans.length > 0) {
|
|
369
432
|
const uvVersion = await runCommand("uv", ["--version"]);
|
|
370
433
|
checks.push({
|
|
@@ -417,20 +480,20 @@ async function runDoctor(config, request, foundationSpec) {
|
|
|
417
480
|
message: config.dryRun ? "GPU checks skipped because dryRun is enabled." : `nvidia-smi is not required for device=${device}.`
|
|
418
481
|
});
|
|
419
482
|
}
|
|
420
|
-
const trainingCommand = buildBundledPythonCommand("train.py").displayCommand;
|
|
483
|
+
const trainingCommand = foundationSpec ? buildFoundationPythonCommand("pretrain.py").displayCommand : buildBundledPythonCommand("train.py").displayCommand;
|
|
421
484
|
checks.push({
|
|
422
485
|
name: "effective-plan",
|
|
423
486
|
ok: true,
|
|
424
487
|
message: "Resolved the configured training and evaluation plan.",
|
|
425
488
|
details: {
|
|
426
489
|
training_command: trainingCommand ?? null,
|
|
427
|
-
evaluation_provider: "transformers",
|
|
490
|
+
evaluation_provider: foundationSpec ? "foundation" : "transformers",
|
|
428
491
|
evaluation_device: device,
|
|
429
492
|
artifact_root: resolve(config.artifactRoot),
|
|
430
493
|
store_root: resolve(config.storeRoot ?? defaultLocalHome()),
|
|
431
494
|
model_cache: resolve(config.paths.modelCache ?? process.env.HF_HOME ?? join(homedir(), ".cache", "huggingface")),
|
|
432
495
|
base_model: request?.spec_snapshot.base_model ?? null,
|
|
433
|
-
scoring_mode: config.evaluation.scoring.mode
|
|
496
|
+
scoring_mode: foundationSpec ? "bpb/chat" : config.evaluation.scoring.mode
|
|
434
497
|
}
|
|
435
498
|
});
|
|
436
499
|
return checks;
|
|
@@ -1746,6 +1809,7 @@ export {
|
|
|
1746
1809
|
assertLocalRunInputReady,
|
|
1747
1810
|
baseModelRevisionSchema,
|
|
1748
1811
|
behaviorSpecExampleSchema,
|
|
1812
|
+
behaviorSpecSchema,
|
|
1749
1813
|
buildLocalBaseModelServerLaunch,
|
|
1750
1814
|
buildLocalModelServerLaunch,
|
|
1751
1815
|
buildModelPrefetchPayload,
|
|
@@ -1788,6 +1852,7 @@ export {
|
|
|
1788
1852
|
localAdapterSpecFileSchema,
|
|
1789
1853
|
localBehaviorSpecFileSchema,
|
|
1790
1854
|
localFoundationSpecFileSchema,
|
|
1855
|
+
localPathsOverlap,
|
|
1791
1856
|
localRunnerConfigSchema,
|
|
1792
1857
|
localStorePaths,
|
|
1793
1858
|
normalizeChatJsonlForRelocation,
|