@dxo/inspect 0.0.0 → 0.0.9
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 +5 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas.d.ts +89 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +6 -0
- package/dist/schemas.js.map +1 -0
- package/dist/store.d.ts +29 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +137 -0
- package/dist/store.js.map +1 -0
- package/dist/train-adapter.d.ts +46 -0
- package/dist/train-adapter.d.ts.map +1 -0
- package/dist/train-adapter.js +97 -0
- package/dist/train-adapter.js.map +1 -0
- package/package.json +34 -8
package/README.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
# @dxo/inspect
|
|
2
2
|
|
|
3
|
-
Placeholder
|
|
3
|
+
**Placeholder — developer preview, API unstable.**
|
|
4
|
+
|
|
5
|
+
Run / metric / artifact / profile **protocol types** for Studio and Trainer adapters. Does not depend on VMZ. Append-only run store and live transport arrive in later U1 slices.
|
|
6
|
+
|
|
7
|
+
See workspace Living design for contracts (`inspect` / Studio product line).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @dxo/inspect — Run / metric / artifact / profile protocols (v0).
|
|
3
|
+
*/
|
|
4
|
+
export { type ArtifactKindV0, type ArtifactV0, INSPECT_PROTOCOL, INSPECT_PROTOCOL_VERSION, type InspectEventV0, inspectVersion, type MetricV0, type ProfileSpan, type ProfileTraceV0, type RunMetaV0, type RunStatus, } from './schemas.js';
|
|
5
|
+
export type { RunRecorderOptions, RunSummary } from './store.js';
|
|
6
|
+
export { defaultRunsRoot, listRuns, RunRecorder, readEvents, readRunMeta } from './store.js';
|
|
7
|
+
export type { RecordTrainIterOptions, TrainEventLike } from './train-adapter.js';
|
|
8
|
+
export { recordTrainIter, trainEventToInspectEvents } from './train-adapter.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACH,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,gBAAgB,EAChB,wBAAwB,EACxB,KAAK,cAAc,EACnB,cAAc,EACd,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,SAAS,GACjB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC7F,YAAY,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @dxo/inspect — Run / metric / artifact / profile protocols (v0).
|
|
3
|
+
*/
|
|
4
|
+
export { INSPECT_PROTOCOL, INSPECT_PROTOCOL_VERSION, inspectVersion, } from './schemas.js';
|
|
5
|
+
export { defaultRunsRoot, listRuns, RunRecorder, readEvents, readRunMeta } from './store.js';
|
|
6
|
+
export { recordTrainIter, trainEventToInspectEvents } from './train-adapter.js';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAGH,gBAAgB,EAChB,wBAAwB,EAExB,cAAc,GAMjB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE7F,OAAO,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
export declare const INSPECT_PROTOCOL: "dxo-inspect";
|
|
2
|
+
export declare const INSPECT_PROTOCOL_VERSION: 0;
|
|
3
|
+
export type RunStatus = 'running' | 'ok' | 'cancelled' | 'error';
|
|
4
|
+
export type RunMetaV0 = {
|
|
5
|
+
format: typeof INSPECT_PROTOCOL;
|
|
6
|
+
version: typeof INSPECT_PROTOCOL_VERSION;
|
|
7
|
+
runId: string;
|
|
8
|
+
startedAtMs: number;
|
|
9
|
+
endedAtMs?: number;
|
|
10
|
+
label?: string;
|
|
11
|
+
status: RunStatus;
|
|
12
|
+
hyperparams?: Record<string, unknown>;
|
|
13
|
+
};
|
|
14
|
+
export type MetricV0 = {
|
|
15
|
+
name: string;
|
|
16
|
+
value: number;
|
|
17
|
+
step: number;
|
|
18
|
+
wallTimeMs: number;
|
|
19
|
+
};
|
|
20
|
+
export type ArtifactKindV0 = 'checkpoint' | 'state' | 'other';
|
|
21
|
+
export type ArtifactV0 = {
|
|
22
|
+
name: string;
|
|
23
|
+
kind: ArtifactKindV0;
|
|
24
|
+
uri: string;
|
|
25
|
+
digest?: string;
|
|
26
|
+
wallTimeMs: number;
|
|
27
|
+
};
|
|
28
|
+
export type InspectEventV0 = {
|
|
29
|
+
type: 'run/start';
|
|
30
|
+
runId: string;
|
|
31
|
+
wallTimeMs: number;
|
|
32
|
+
meta?: Record<string, unknown>;
|
|
33
|
+
} | {
|
|
34
|
+
type: 'run/end';
|
|
35
|
+
runId: string;
|
|
36
|
+
wallTimeMs: number;
|
|
37
|
+
status: Exclude<RunStatus, 'running'>;
|
|
38
|
+
error?: string;
|
|
39
|
+
} | {
|
|
40
|
+
type: 'train/epoch_start';
|
|
41
|
+
runId: string;
|
|
42
|
+
wallTimeMs: number;
|
|
43
|
+
epoch: number;
|
|
44
|
+
epochs: number;
|
|
45
|
+
} | {
|
|
46
|
+
type: 'train/batch';
|
|
47
|
+
runId: string;
|
|
48
|
+
wallTimeMs: number;
|
|
49
|
+
epoch: number;
|
|
50
|
+
step: number;
|
|
51
|
+
loss: number;
|
|
52
|
+
} | {
|
|
53
|
+
type: 'train/epoch_end';
|
|
54
|
+
runId: string;
|
|
55
|
+
wallTimeMs: number;
|
|
56
|
+
epoch: number;
|
|
57
|
+
meanLoss: number;
|
|
58
|
+
steps: number;
|
|
59
|
+
} | {
|
|
60
|
+
type: 'metric/scalar';
|
|
61
|
+
runId: string;
|
|
62
|
+
wallTimeMs: number;
|
|
63
|
+
metric: MetricV0;
|
|
64
|
+
} | {
|
|
65
|
+
type: 'artifact/ref';
|
|
66
|
+
runId: string;
|
|
67
|
+
wallTimeMs: number;
|
|
68
|
+
artifact: ArtifactV0;
|
|
69
|
+
} | {
|
|
70
|
+
type: 'log';
|
|
71
|
+
runId: string;
|
|
72
|
+
wallTimeMs: number;
|
|
73
|
+
level: 'info' | 'warn' | 'error';
|
|
74
|
+
message: string;
|
|
75
|
+
};
|
|
76
|
+
export type ProfileSpan = {
|
|
77
|
+
name: string;
|
|
78
|
+
category: 'op' | 'kernel' | 'transfer' | 'readback' | 'other';
|
|
79
|
+
startMs: number;
|
|
80
|
+
endMs: number;
|
|
81
|
+
meta?: Record<string, unknown>;
|
|
82
|
+
};
|
|
83
|
+
export type ProfileTraceV0 = {
|
|
84
|
+
format: 'dxo-profile';
|
|
85
|
+
version: 0;
|
|
86
|
+
spans: ProfileSpan[];
|
|
87
|
+
};
|
|
88
|
+
export declare function inspectVersion(): string;
|
|
89
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":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AG,UAAU,GAAG,OAAO,CAAC;IAC9D,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IACzB,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,CAAC,CAAC;IACX,KAAK,EAAE,WAAW,EAAE,CAAC;CACxB,CAAC;AAEF,wBAAgB,cAAc,IAAI,MAAM,CAEvC"}
|
package/dist/schemas.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAsB,CAAC;AACvD,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAU,CAAC;AAwDnD,MAAM,UAAU,cAAc;IAC1B,OAAO,GAAG,gBAAgB,IAAI,wBAAwB,EAAE,CAAC;AAC7D,CAAC"}
|
package/dist/store.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type ArtifactKindV0, type InspectEventV0, type RunMetaV0, type RunStatus } from './schemas.js';
|
|
2
|
+
export type RunRecorderOptions = {
|
|
3
|
+
/** Root directory; default `{cwd}/.dxo/runs` or `DXO_RUNS_DIR`. */
|
|
4
|
+
root?: string;
|
|
5
|
+
runId?: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
hyperparams?: Record<string, unknown>;
|
|
8
|
+
};
|
|
9
|
+
export type RunSummary = {
|
|
10
|
+
runId: string;
|
|
11
|
+
meta: RunMetaV0;
|
|
12
|
+
};
|
|
13
|
+
export declare function defaultRunsRoot(): string;
|
|
14
|
+
export declare class RunRecorder {
|
|
15
|
+
#private;
|
|
16
|
+
readonly runId: string;
|
|
17
|
+
readonly root: string;
|
|
18
|
+
readonly runPath: string;
|
|
19
|
+
private constructor();
|
|
20
|
+
static open(options?: RunRecorderOptions): Promise<RunRecorder>;
|
|
21
|
+
append(event: InspectEventV0): Promise<void>;
|
|
22
|
+
/** Write artifact bytes and emit artifact/ref. Returns relative URI under run dir. */
|
|
23
|
+
writeArtifact(name: string, kind: ArtifactKindV0, body: string): Promise<string>;
|
|
24
|
+
close(status: Exclude<RunStatus, 'running'>, error?: string): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
export declare function listRuns(root?: string): Promise<RunSummary[]>;
|
|
27
|
+
export declare function readRunMeta(root: string, runId: string): Promise<RunMetaV0 | null>;
|
|
28
|
+
export declare function readEvents(root: string, runId: string): Promise<InspectEventV0[]>;
|
|
29
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,KAAK,cAAc,EAGnB,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,SAAS,EACjB,MAAM,cAAc,CAAC;AAMtB,MAAM,MAAM,kBAAkB,GAAG;IAC7B,mEAAmE;IACnE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,SAAS,CAAC;CACnB,CAAC;AAMF,wBAAgB,eAAe,IAAI,MAAM,CAIxC;AAMD,qBAAa,WAAW;;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAIzB,OAAO;WAOM,IAAI,CAAC,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,WAAW,CAAC;IA0BnE,MAAM,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAMlD,sFAAsF;IAChF,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAoBhF,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAcpF;AAED,wBAAsB,QAAQ,CAAC,IAAI,GAAE,MAA0B,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CActF;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAOxF;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAUvF"}
|
package/dist/store.js
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
2
|
+
import { appendFile, mkdir, readdir, readFile, writeFile } from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { INSPECT_PROTOCOL, INSPECT_PROTOCOL_VERSION, } from './schemas.js';
|
|
5
|
+
const EVENTS_FILE = 'events.jsonl';
|
|
6
|
+
const META_FILE = 'meta.json';
|
|
7
|
+
const ARTIFACTS_DIR = 'artifacts';
|
|
8
|
+
function nowMs() {
|
|
9
|
+
return Date.now();
|
|
10
|
+
}
|
|
11
|
+
export function defaultRunsRoot() {
|
|
12
|
+
const fromEnv = process.env.DXO_RUNS_DIR?.trim();
|
|
13
|
+
if (fromEnv)
|
|
14
|
+
return path.resolve(fromEnv);
|
|
15
|
+
return path.resolve(process.cwd(), '.dxo', 'runs');
|
|
16
|
+
}
|
|
17
|
+
function runDir(root, runId) {
|
|
18
|
+
return path.join(root, runId);
|
|
19
|
+
}
|
|
20
|
+
export class RunRecorder {
|
|
21
|
+
runId;
|
|
22
|
+
root;
|
|
23
|
+
runPath;
|
|
24
|
+
#closed = false;
|
|
25
|
+
#meta;
|
|
26
|
+
constructor(root, runId, meta) {
|
|
27
|
+
this.root = root;
|
|
28
|
+
this.runId = runId;
|
|
29
|
+
this.runPath = runDir(root, runId);
|
|
30
|
+
this.#meta = meta;
|
|
31
|
+
}
|
|
32
|
+
static async open(options = {}) {
|
|
33
|
+
const root = options.root ?? defaultRunsRoot();
|
|
34
|
+
const runId = options.runId ?? randomUUID();
|
|
35
|
+
const startedAtMs = nowMs();
|
|
36
|
+
const meta = {
|
|
37
|
+
format: INSPECT_PROTOCOL,
|
|
38
|
+
version: INSPECT_PROTOCOL_VERSION,
|
|
39
|
+
runId,
|
|
40
|
+
startedAtMs,
|
|
41
|
+
label: options.label,
|
|
42
|
+
status: 'running',
|
|
43
|
+
hyperparams: options.hyperparams,
|
|
44
|
+
};
|
|
45
|
+
const dir = runDir(root, runId);
|
|
46
|
+
await mkdir(path.join(dir, ARTIFACTS_DIR), { recursive: true });
|
|
47
|
+
await writeFile(path.join(dir, META_FILE), `${JSON.stringify(meta, null, 2)}\n`, 'utf8');
|
|
48
|
+
const recorder = new RunRecorder(root, runId, meta);
|
|
49
|
+
await recorder.append({
|
|
50
|
+
type: 'run/start',
|
|
51
|
+
runId,
|
|
52
|
+
wallTimeMs: startedAtMs,
|
|
53
|
+
meta: options.hyperparams,
|
|
54
|
+
});
|
|
55
|
+
return recorder;
|
|
56
|
+
}
|
|
57
|
+
async append(event) {
|
|
58
|
+
if (this.#closed)
|
|
59
|
+
throw new Error(`run ${this.runId} is closed`);
|
|
60
|
+
const line = `${JSON.stringify(event)}\n`;
|
|
61
|
+
await appendFile(path.join(this.runPath, EVENTS_FILE), line, 'utf8');
|
|
62
|
+
}
|
|
63
|
+
/** Write artifact bytes and emit artifact/ref. Returns relative URI under run dir. */
|
|
64
|
+
async writeArtifact(name, kind, body) {
|
|
65
|
+
const rel = path.join(ARTIFACTS_DIR, name);
|
|
66
|
+
const abs = path.join(this.runPath, rel);
|
|
67
|
+
await writeFile(abs, body, 'utf8');
|
|
68
|
+
const digest = createHash('sha256').update(body).digest('hex');
|
|
69
|
+
await this.append({
|
|
70
|
+
type: 'artifact/ref',
|
|
71
|
+
runId: this.runId,
|
|
72
|
+
wallTimeMs: nowMs(),
|
|
73
|
+
artifact: {
|
|
74
|
+
name,
|
|
75
|
+
kind,
|
|
76
|
+
uri: rel.replace(/\\/g, '/'),
|
|
77
|
+
digest,
|
|
78
|
+
wallTimeMs: nowMs(),
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
return rel;
|
|
82
|
+
}
|
|
83
|
+
async close(status, error) {
|
|
84
|
+
if (this.#closed)
|
|
85
|
+
return;
|
|
86
|
+
const endedAtMs = nowMs();
|
|
87
|
+
this.#meta = { ...this.#meta, status, endedAtMs };
|
|
88
|
+
await writeFile(path.join(this.runPath, META_FILE), `${JSON.stringify(this.#meta, null, 2)}\n`, 'utf8');
|
|
89
|
+
await this.append({
|
|
90
|
+
type: 'run/end',
|
|
91
|
+
runId: this.runId,
|
|
92
|
+
wallTimeMs: endedAtMs,
|
|
93
|
+
status,
|
|
94
|
+
error,
|
|
95
|
+
});
|
|
96
|
+
this.#closed = true;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
export async function listRuns(root = defaultRunsRoot()) {
|
|
100
|
+
let entries;
|
|
101
|
+
try {
|
|
102
|
+
entries = await readdir(root);
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
return [];
|
|
106
|
+
}
|
|
107
|
+
const out = [];
|
|
108
|
+
for (const runId of entries) {
|
|
109
|
+
const meta = await readRunMeta(root, runId);
|
|
110
|
+
if (meta)
|
|
111
|
+
out.push({ runId, meta });
|
|
112
|
+
}
|
|
113
|
+
out.sort((a, b) => b.meta.startedAtMs - a.meta.startedAtMs);
|
|
114
|
+
return out;
|
|
115
|
+
}
|
|
116
|
+
export async function readRunMeta(root, runId) {
|
|
117
|
+
try {
|
|
118
|
+
const text = await readFile(path.join(runDir(root, runId), META_FILE), 'utf8');
|
|
119
|
+
return JSON.parse(text);
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
export async function readEvents(root, runId) {
|
|
126
|
+
try {
|
|
127
|
+
const text = await readFile(path.join(runDir(root, runId), EVENTS_FILE), 'utf8');
|
|
128
|
+
return text
|
|
129
|
+
.split('\n')
|
|
130
|
+
.filter((line) => line.trim().length > 0)
|
|
131
|
+
.map((line) => JSON.parse(line));
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
return [];
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAEH,gBAAgB,EAChB,wBAAwB,GAI3B,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,GAAG,cAAc,CAAC;AACnC,MAAM,SAAS,GAAG,WAAW,CAAC;AAC9B,MAAM,aAAa,GAAG,WAAW,CAAC;AAelC,SAAS,KAAK;IACV,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,eAAe;IAC3B,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC;IACjD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AY,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAmB,CAAC,CAAC;IACnE,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,EAAE,CAAC;IACd,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { InspectEventV0 } from './schemas.js';
|
|
2
|
+
import { RunRecorder, type RunRecorderOptions } from './store.js';
|
|
3
|
+
/** Minimal TrainEvent shape (matches @dxo/train without a hard dependency). */
|
|
4
|
+
export type TrainEventLike = {
|
|
5
|
+
type: 'epoch_start';
|
|
6
|
+
epoch: number;
|
|
7
|
+
epochs: number;
|
|
8
|
+
} | {
|
|
9
|
+
type: 'batch';
|
|
10
|
+
epoch: number;
|
|
11
|
+
step: number;
|
|
12
|
+
loss: number;
|
|
13
|
+
} | {
|
|
14
|
+
type: 'epoch_end';
|
|
15
|
+
epoch: number;
|
|
16
|
+
meanLoss: number;
|
|
17
|
+
steps: number;
|
|
18
|
+
} | {
|
|
19
|
+
type: 'checkpoint';
|
|
20
|
+
epoch: number;
|
|
21
|
+
document: unknown;
|
|
22
|
+
state: unknown;
|
|
23
|
+
} | {
|
|
24
|
+
type: 'aborted';
|
|
25
|
+
reason: 'signal';
|
|
26
|
+
epoch: number;
|
|
27
|
+
step: number;
|
|
28
|
+
} | {
|
|
29
|
+
type: 'done';
|
|
30
|
+
epochs: number;
|
|
31
|
+
steps: number;
|
|
32
|
+
finalMeanLoss?: number;
|
|
33
|
+
};
|
|
34
|
+
export declare function trainEventToInspectEvents(runId: string, event: TrainEventLike): InspectEventV0[];
|
|
35
|
+
export type RecordTrainIterOptions = RunRecorderOptions & {
|
|
36
|
+
checkpointEncoder?: (document: unknown) => string;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Consume a Trainer fitIter stream and append inspect events to the local run store.
|
|
40
|
+
*/
|
|
41
|
+
export declare function recordTrainIter(events: AsyncIterable<TrainEventLike>, options?: RecordTrainIterOptions): Promise<{
|
|
42
|
+
runId: string;
|
|
43
|
+
recorder: RunRecorder;
|
|
44
|
+
status: 'ok' | 'cancelled';
|
|
45
|
+
}>;
|
|
46
|
+
//# sourceMappingURL=train-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"train-adapter.d.ts","sourceRoot":"","sources":["../src/train-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAElE,+EAA+E;AAC/E,MAAM,MAAM,cAAc,GACpB;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACtD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC5D;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACrE;IACI,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;CAClB,GACD;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAClE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAM9E,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,GAAG,cAAc,EAAE,CA8DhG;AAED,MAAM,MAAM,sBAAsB,GAAG,kBAAkB,GAAG;IACtD,iBAAiB,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,MAAM,CAAC;CACrD,CAAC;AAEF;;GAEG;AACH,wBAAsB,eAAe,CACjC,MAAM,EAAE,aAAa,CAAC,cAAc,CAAC,EACrC,OAAO,GAAE,sBAA2B,GACrC,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,IAAI,GAAG,WAAW,CAAA;CAAE,CAAC,CA0B/E"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { RunRecorder } from './store.js';
|
|
2
|
+
function wallTimeMs() {
|
|
3
|
+
return Date.now();
|
|
4
|
+
}
|
|
5
|
+
export function trainEventToInspectEvents(runId, event) {
|
|
6
|
+
const t = wallTimeMs();
|
|
7
|
+
switch (event.type) {
|
|
8
|
+
case 'epoch_start':
|
|
9
|
+
return [{ type: 'train/epoch_start', runId, wallTimeMs: t, epoch: event.epoch, epochs: event.epochs }];
|
|
10
|
+
case 'batch':
|
|
11
|
+
return [
|
|
12
|
+
{ type: 'train/batch', runId, wallTimeMs: t, epoch: event.epoch, step: event.step, loss: event.loss },
|
|
13
|
+
{
|
|
14
|
+
type: 'metric/scalar',
|
|
15
|
+
runId,
|
|
16
|
+
wallTimeMs: t,
|
|
17
|
+
metric: { name: 'loss', value: event.loss, step: event.step, wallTimeMs: t },
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
case 'epoch_end':
|
|
21
|
+
return [
|
|
22
|
+
{
|
|
23
|
+
type: 'train/epoch_end',
|
|
24
|
+
runId,
|
|
25
|
+
wallTimeMs: t,
|
|
26
|
+
epoch: event.epoch,
|
|
27
|
+
meanLoss: event.meanLoss,
|
|
28
|
+
steps: event.steps,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
type: 'metric/scalar',
|
|
32
|
+
runId,
|
|
33
|
+
wallTimeMs: t,
|
|
34
|
+
metric: {
|
|
35
|
+
name: 'mean_loss',
|
|
36
|
+
value: event.meanLoss,
|
|
37
|
+
step: event.epoch,
|
|
38
|
+
wallTimeMs: t,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
case 'aborted':
|
|
43
|
+
return [
|
|
44
|
+
{
|
|
45
|
+
type: 'log',
|
|
46
|
+
runId,
|
|
47
|
+
wallTimeMs: t,
|
|
48
|
+
level: 'warn',
|
|
49
|
+
message: `training aborted at epoch ${event.epoch} step ${event.step}`,
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
case 'done':
|
|
53
|
+
return [
|
|
54
|
+
{
|
|
55
|
+
type: 'log',
|
|
56
|
+
runId,
|
|
57
|
+
wallTimeMs: t,
|
|
58
|
+
level: 'info',
|
|
59
|
+
message: `training done: epochs=${event.epochs} steps=${event.steps}`,
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
case 'checkpoint':
|
|
63
|
+
return [];
|
|
64
|
+
default:
|
|
65
|
+
return [];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Consume a Trainer fitIter stream and append inspect events to the local run store.
|
|
70
|
+
*/
|
|
71
|
+
export async function recordTrainIter(events, options = {}) {
|
|
72
|
+
const recorder = await RunRecorder.open(options);
|
|
73
|
+
const encoder = options.checkpointEncoder ?? ((doc) => JSON.stringify(doc));
|
|
74
|
+
let status = 'ok';
|
|
75
|
+
try {
|
|
76
|
+
for await (const event of events) {
|
|
77
|
+
if (event.type === 'checkpoint') {
|
|
78
|
+
const name = `checkpoint-epoch-${event.epoch}.json`;
|
|
79
|
+
await recorder.writeArtifact(name, 'checkpoint', encoder(event.document));
|
|
80
|
+
}
|
|
81
|
+
if (event.type === 'aborted') {
|
|
82
|
+
status = 'cancelled';
|
|
83
|
+
}
|
|
84
|
+
for (const inspectEvent of trainEventToInspectEvents(recorder.runId, event)) {
|
|
85
|
+
await recorder.append(inspectEvent);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
await recorder.close(status);
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
92
|
+
await recorder.close('error', message);
|
|
93
|
+
throw err;
|
|
94
|
+
}
|
|
95
|
+
return { runId: recorder.runId, recorder, status };
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=train-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"train-adapter.js","sourceRoot":"","sources":["../src/train-adapter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAA2B,MAAM,YAAY,CAAC;AAgBlE,SAAS,UAAU;IACf,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,KAAa,EAAE,KAAqB;IAC1E,MAAM,CAAC,GAAG,UAAU,EAAE,CAAC;IACvB,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACjB,KAAK,aAAa;YACd,OAAO,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QAC3G,KAAK,OAAO;YACR,OAAO;gBACH,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE;gBACrG;oBACI,IAAI,EAAE,eAAe;oBACrB,KAAK;oBACL,UAAU,EAAE,CAAC;oBACb,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,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1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
|
|
2
|
+
"name": "@dxo/inspect",
|
|
3
|
+
"version": "0.0.9",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "DXO run / metric / artifact / profile event protocols (placeholder, API unstable)",
|
|
6
|
+
"license": "MIT OR Apache-2.0",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc -p tsconfig.json"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"dxo",
|
|
24
|
+
"inspect",
|
|
25
|
+
"metrics",
|
|
26
|
+
"profiler",
|
|
27
|
+
"typescript"
|
|
28
|
+
],
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/ai4waifu/dxo-framework.git"
|
|
35
|
+
}
|
|
10
36
|
}
|