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