@orkestrel/train 0.0.0-stage → 0.0.2

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.
@@ -0,0 +1,223 @@
1
+ import type { ByteSinkInterface } from '@orkestrel/train';
2
+ import type { CheckpointEntry } from '@orkestrel/train';
3
+ import type { CheckpointStoreInterface } from '@orkestrel/train';
4
+ import type { FileHandle } from 'node:fs/promises';
5
+ import type { MergeGGUFOptions } from '@orkestrel/train';
6
+ import type { MergeSafetensorsOptions } from '@orkestrel/train';
7
+ import type { TrainerRow } from '@orkestrel/train';
8
+
9
+ /**
10
+ * Wraps an open Node `FileHandle` as a `ByteSinkInterface` that writes each chunk sequentially and
11
+ * closes the handle at most once on `close` or `abort`.
12
+ *
13
+ * @param handle - The open file handle to wrap
14
+ * @returns The `ByteSinkInterface` backed by `handle`
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * const sink = buildFileByteSink(handle)
19
+ * ```
20
+ */
21
+ export declare function buildFileByteSink(handle: FileHandle): ByteSinkInterface;
22
+
23
+ /**
24
+ * Creates a filesystem-backed checkpoint store over a local directory.
25
+ *
26
+ * @param options - The directory configuration
27
+ * @returns A {@link CheckpointStoreInterface} backed by atomic GGUF files
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * const store = createFileCheckpointStore({ directory: 'checkpoints' })
32
+ * await store.list() // []
33
+ * ```
34
+ */
35
+ export declare function createFileCheckpointStore(options: FileCheckpointStoreOptions): CheckpointStoreInterface;
36
+
37
+ /**
38
+ * Persists training checkpoints as atomic GGUF v3 files in a local directory.
39
+ *
40
+ * @remarks
41
+ * Validates every checkpoint identifier against `CHECKPOINT_ID_PATTERN` before touching the
42
+ * filesystem. Writes bytes to `<directory>/<id>.<uuid>.part` with exclusive creation (`flag: 'wx'`)
43
+ * and atomically renames over `<directory>/<id>.gguf`, unlinking the temporary `.part` file on any
44
+ * error or `AbortSignal`. Removing a missing identifier is a no-op, and loading one returns
45
+ * `undefined`.
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * import { createFileCheckpointStore } from '@orkestrel/train/server'
50
+ *
51
+ * const store = createFileCheckpointStore({ directory: 'checkpoints' })
52
+ * await store.save({ id: 'step-10', bytes })
53
+ * await store.has('step-10') // true
54
+ * ```
55
+ */
56
+ export declare class FileCheckpointStore implements CheckpointStoreInterface {
57
+ #private;
58
+ /**
59
+ * Creates a filesystem-backed checkpoint store rooted at `options.directory`.
60
+ *
61
+ * @param options - The directory configuration
62
+ */
63
+ constructor(options: FileCheckpointStoreOptions);
64
+ /**
65
+ * Writes a checkpoint entry atomically under its validated identifier.
66
+ *
67
+ * @param entry - The identifier and serialized GGUF v3 checkpoint bytes
68
+ * @param signal - Cancels the write and removes any temporary part file
69
+ */
70
+ save(entry: CheckpointEntry, signal?: AbortSignal): Promise<void>;
71
+ /**
72
+ * Loads a stored checkpoint entry by identifier, or `undefined` when absent.
73
+ *
74
+ * @param id - The validated checkpoint identifier
75
+ * @param signal - Cancels the read
76
+ * @returns The stored entry, or `undefined` when missing
77
+ */
78
+ load(id: string, signal?: AbortSignal): Promise<CheckpointEntry | undefined>;
79
+ /**
80
+ * Checks whether a checkpoint identifier is present in the store.
81
+ *
82
+ * @param id - The validated checkpoint identifier
83
+ * @param signal - Cancels the presence check
84
+ * @returns True if the checkpoint file exists; false otherwise
85
+ */
86
+ has(id: string, signal?: AbortSignal): Promise<boolean>;
87
+ /**
88
+ * Lists the stored checkpoint identifiers in ascending order.
89
+ *
90
+ * @param signal - Cancels the directory listing
91
+ * @returns The sorted checkpoint identifiers
92
+ */
93
+ list(signal?: AbortSignal): Promise<readonly string[]>;
94
+ /**
95
+ * Deletes a stored checkpoint by identifier; a missing identifier is a no-op.
96
+ *
97
+ * @param id - The validated checkpoint identifier
98
+ * @param signal - Cancels the removal
99
+ */
100
+ remove(id: string, signal?: AbortSignal): Promise<void>;
101
+ /**
102
+ * Deletes every stored checkpoint in the store directory.
103
+ *
104
+ * @param signal - Cancels the clear operation
105
+ */
106
+ clear(signal?: AbortSignal): Promise<void>;
107
+ }
108
+
109
+ /**
110
+ * Configures a filesystem-backed checkpoint store.
111
+ *
112
+ * @example
113
+ * ```ts
114
+ * const options: FileCheckpointStoreOptions = { directory: 'checkpoints' }
115
+ * ```
116
+ */
117
+ export declare interface FileCheckpointStoreOptions {
118
+ /** Holds the directory where checkpoint files are stored. */
119
+ readonly directory: string;
120
+ }
121
+
122
+ /**
123
+ * Reads training rows from an NDJSON file, one row per line.
124
+ *
125
+ * @remarks
126
+ * Streams the file as UTF-8 text into `readTrainerRows`, which reads it through `@orkestrel/ndjson` and
127
+ * rejects as it states. Rejects with the file system's error when the file cannot be read; an early
128
+ * rejection closes the file, and an aborted signal rejects before the file opens.
129
+ *
130
+ * @param path - The NDJSON file
131
+ * @param signal - Cancels the read between chunks; it then rejects with the `ABORT` code
132
+ * @returns The rows, in line order
133
+ *
134
+ * @example
135
+ * ```ts
136
+ * const rows = await readRowFile('rows/train.ndjson')
137
+ * const result = await trainer.execute(rows)
138
+ * ```
139
+ */
140
+ export declare function readRowFile(path: string | URL, signal?: AbortSignal): Promise<readonly TrainerRow[]>;
141
+
142
+ /**
143
+ * Writes a head file into a directory under its content name, and returns its path.
144
+ *
145
+ * @remarks
146
+ * The name is `computeHeadName` of the bytes, the digest `@orkestrel/infer`'s head reports, so writing the same
147
+ * head twice leaves one file. The bytes go to a fresh temporary file beside it that is then renamed
148
+ * over the name, so a reader never sees a partial head; on a failure the temporary file is removed and
149
+ * the write's failure rethrown, never one from that removal. Rejects with the file system's error when
150
+ * the directory is missing or refuses the write.
151
+ *
152
+ * @param directory - The directory to write into
153
+ * @param bytes - The head file's bytes
154
+ * @returns The written file's path
155
+ *
156
+ * @example
157
+ * ```ts
158
+ * const path = await writeHeadFile('heads', result.bytes) // 'heads/3f2a…9c.gguf'
159
+ * ```
160
+ */
161
+ export declare function writeHeadFile(directory: string, bytes: Uint8Array<ArrayBuffer>): Promise<string>;
162
+
163
+ /**
164
+ * Streams an async iterable of byte chunks into an exclusive temporary `.part` file beside `path`,
165
+ * atomically renames it over `path` on completion, and removes the `.part` file on error or abort.
166
+ *
167
+ * @remarks
168
+ * Opens `<path>.<uuid>.part` with `flag: 'wx'` so concurrent writers never collide and readers
169
+ * never observe partial output. Checks `signal` before opening and between chunks.
170
+ *
171
+ * @param path - The final destination file path
172
+ * @param chunks - The async iterable of byte chunks to persist
173
+ * @param signal - Cancels the write; rejects with the `ABORT` code and removes the `.part` file
174
+ * @returns The written destination `path`
175
+ *
176
+ * @example
177
+ * ```ts
178
+ * await writeMergedFile('merged.gguf', mergeGGUF({ source, adapter }))
179
+ * ```
180
+ */
181
+ export declare function writeMergedFile(path: string, chunks: AsyncIterable<Uint8Array>, signal?: AbortSignal): Promise<string>;
182
+
183
+ /**
184
+ * Streams an adapter- or section-merged GGUF v3 file to `path` atomically through an exclusive
185
+ * `.part` file.
186
+ *
187
+ * @remarks
188
+ * Uses `mergeGGUF` so base metadata copies verbatim, untargeted quantized tensors stream
189
+ * byte-for-byte unchanged, and targeted tensors merge strip-by-strip into `F32`, `BF16`, `Q8_0`, or
190
+ * `Q4_K`. Unlinks `<path>.<uuid>.part` on error or `AbortSignal`.
191
+ *
192
+ * @param path - The destination GGUF file path
193
+ * @param options - The streaming merge options
194
+ * @returns The written destination `path`
195
+ *
196
+ * @example
197
+ * ```ts
198
+ * await writeMergedGGUFFile('model.gguf', { source, adapter, format: 'F32' })
199
+ * ```
200
+ */
201
+ export declare function writeMergedGGUFFile(path: string, options: MergeGGUFOptions): Promise<string>;
202
+
203
+ /**
204
+ * Streams an adapter- or section-merged safetensors file to `path` atomically through an exclusive
205
+ * `.part` file.
206
+ *
207
+ * @remarks
208
+ * Uses `mergeSafetensors` so untargeted tensors stream in bounded slices and targeted tensors merge
209
+ * strip-by-strip without holding the base checkpoint in memory. Unlinks `<path>.<uuid>.part` on
210
+ * error or `AbortSignal`.
211
+ *
212
+ * @param path - The destination safetensors file path
213
+ * @param options - The streaming merge options
214
+ * @returns The written destination `path`
215
+ *
216
+ * @example
217
+ * ```ts
218
+ * await writeMergedSafetensorsFile('model.safetensors', { source, adapter, architecture })
219
+ * ```
220
+ */
221
+ export declare function writeMergedSafetensorsFile(path: string, options: MergeSafetensorsOptions): Promise<string>;
222
+
223
+ export { }
@@ -0,0 +1,345 @@
1
+ import { InferError, checkSignal } from "@orkestrel/infer";
2
+ import { CHECKPOINT_FILE_EXTENSION, checkCheckpointId, computeHeadName, isCheckpointId, mergeGGUF, mergeSafetensors, readTrainerRows, writeByteSink } from "../core/index.js";
3
+ import { randomUUID } from "node:crypto";
4
+ import { createReadStream } from "node:fs";
5
+ import { mkdir, open, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
6
+ import { join } from "node:path";
7
+ import { isCodedError, isRecord, isString, isUint8Array } from "@orkestrel/contract";
8
+ // src/server/helpers.ts
9
+ /**
10
+ * Reads training rows from an NDJSON file, one row per line.
11
+ *
12
+ * @remarks
13
+ * Streams the file as UTF-8 text into `readTrainerRows`, which reads it through `@orkestrel/ndjson` and
14
+ * rejects as it states. Rejects with the file system's error when the file cannot be read; an early
15
+ * rejection closes the file, and an aborted signal rejects before the file opens.
16
+ *
17
+ * @param path - The NDJSON file
18
+ * @param signal - Cancels the read between chunks; it then rejects with the `ABORT` code
19
+ * @returns The rows, in line order
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * const rows = await readRowFile('rows/train.ndjson')
24
+ * const result = await trainer.execute(rows)
25
+ * ```
26
+ */
27
+ async function readRowFile(path, signal) {
28
+ checkSignal(signal, "The row read");
29
+ return readTrainerRows(createReadStream(path, { encoding: "utf8" }), signal);
30
+ }
31
+ /**
32
+ * Writes a head file into a directory under its content name, and returns its path.
33
+ *
34
+ * @remarks
35
+ * The name is `computeHeadName` of the bytes, the digest `@orkestrel/infer`'s head reports, so writing the same
36
+ * head twice leaves one file. The bytes go to a fresh temporary file beside it that is then renamed
37
+ * over the name, so a reader never sees a partial head; on a failure the temporary file is removed and
38
+ * the write's failure rethrown, never one from that removal. Rejects with the file system's error when
39
+ * the directory is missing or refuses the write.
40
+ *
41
+ * @param directory - The directory to write into
42
+ * @param bytes - The head file's bytes
43
+ * @returns The written file's path
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * const path = await writeHeadFile('heads', result.bytes) // 'heads/3f2a…9c.gguf'
48
+ * ```
49
+ */
50
+ async function writeHeadFile(directory, bytes) {
51
+ const path = join(directory, await computeHeadName(bytes));
52
+ const part = `${path}.${randomUUID()}.part`;
53
+ try {
54
+ await writeFile(part, bytes, { flag: "wx" });
55
+ await rename(part, path);
56
+ } catch (error) {
57
+ await rm(part, {
58
+ force: true,
59
+ maxRetries: 3
60
+ }).catch(() => void 0);
61
+ throw error;
62
+ }
63
+ return path;
64
+ }
65
+ /**
66
+ * Wraps an open Node `FileHandle` as a `ByteSinkInterface` that writes each chunk sequentially and
67
+ * closes the handle at most once on `close` or `abort`.
68
+ *
69
+ * @param handle - The open file handle to wrap
70
+ * @returns The `ByteSinkInterface` backed by `handle`
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * const sink = buildFileByteSink(handle)
75
+ * ```
76
+ */
77
+ function buildFileByteSink(handle) {
78
+ const closed = /* @__PURE__ */ new Set();
79
+ return {
80
+ async write(chunk) {
81
+ await handle.writeFile(chunk);
82
+ },
83
+ async close() {
84
+ if (!closed.has(handle)) {
85
+ closed.add(handle);
86
+ await handle.close();
87
+ }
88
+ },
89
+ async abort() {
90
+ if (!closed.has(handle)) {
91
+ closed.add(handle);
92
+ await handle.close();
93
+ }
94
+ }
95
+ };
96
+ }
97
+ /**
98
+ * Streams an async iterable of byte chunks into an exclusive temporary `.part` file beside `path`,
99
+ * atomically renames it over `path` on completion, and removes the `.part` file on error or abort.
100
+ *
101
+ * @remarks
102
+ * Opens `<path>.<uuid>.part` with `flag: 'wx'` so concurrent writers never collide and readers
103
+ * never observe partial output. Checks `signal` before opening and between chunks.
104
+ *
105
+ * @param path - The final destination file path
106
+ * @param chunks - The async iterable of byte chunks to persist
107
+ * @param signal - Cancels the write; rejects with the `ABORT` code and removes the `.part` file
108
+ * @returns The written destination `path`
109
+ *
110
+ * @example
111
+ * ```ts
112
+ * await writeMergedFile('merged.gguf', mergeGGUF({ source, adapter }))
113
+ * ```
114
+ */
115
+ async function writeMergedFile(path, chunks, signal) {
116
+ checkSignal(signal, "The merged file write");
117
+ const part = `${path}.${randomUUID()}.part`;
118
+ const sink = buildFileByteSink(await open(part, "wx"));
119
+ try {
120
+ await writeByteSink(chunks, sink, signal);
121
+ await rename(part, path);
122
+ } catch (error) {
123
+ await sink.abort?.(error);
124
+ await rm(part, {
125
+ force: true,
126
+ maxRetries: 3
127
+ }).catch(() => void 0);
128
+ throw error;
129
+ }
130
+ return path;
131
+ }
132
+ /**
133
+ * Streams an adapter- or section-merged safetensors file to `path` atomically through an exclusive
134
+ * `.part` file.
135
+ *
136
+ * @remarks
137
+ * Uses `mergeSafetensors` so untargeted tensors stream in bounded slices and targeted tensors merge
138
+ * strip-by-strip without holding the base checkpoint in memory. Unlinks `<path>.<uuid>.part` on
139
+ * error or `AbortSignal`.
140
+ *
141
+ * @param path - The destination safetensors file path
142
+ * @param options - The streaming merge options
143
+ * @returns The written destination `path`
144
+ *
145
+ * @example
146
+ * ```ts
147
+ * await writeMergedSafetensorsFile('model.safetensors', { source, adapter, architecture })
148
+ * ```
149
+ */
150
+ async function writeMergedSafetensorsFile(path, options) {
151
+ return writeMergedFile(path, mergeSafetensors(options), options.signal);
152
+ }
153
+ /**
154
+ * Streams an adapter- or section-merged GGUF v3 file to `path` atomically through an exclusive
155
+ * `.part` file.
156
+ *
157
+ * @remarks
158
+ * Uses `mergeGGUF` so base metadata copies verbatim, untargeted quantized tensors stream
159
+ * byte-for-byte unchanged, and targeted tensors merge strip-by-strip into `F32`, `BF16`, `Q8_0`, or
160
+ * `Q4_K`. Unlinks `<path>.<uuid>.part` on error or `AbortSignal`.
161
+ *
162
+ * @param path - The destination GGUF file path
163
+ * @param options - The streaming merge options
164
+ * @returns The written destination `path`
165
+ *
166
+ * @example
167
+ * ```ts
168
+ * await writeMergedGGUFFile('model.gguf', { source, adapter, format: 'F32' })
169
+ * ```
170
+ */
171
+ async function writeMergedGGUFFile(path, options) {
172
+ return writeMergedFile(path, mergeGGUF(options), options.signal);
173
+ }
174
+ // src/server/stores/FileCheckpointStore.ts
175
+ /**
176
+ * Persists training checkpoints as atomic GGUF v3 files in a local directory.
177
+ *
178
+ * @remarks
179
+ * Validates every checkpoint identifier against `CHECKPOINT_ID_PATTERN` before touching the
180
+ * filesystem. Writes bytes to `<directory>/<id>.<uuid>.part` with exclusive creation (`flag: 'wx'`)
181
+ * and atomically renames over `<directory>/<id>.gguf`, unlinking the temporary `.part` file on any
182
+ * error or `AbortSignal`. Removing a missing identifier is a no-op, and loading one returns
183
+ * `undefined`.
184
+ *
185
+ * @example
186
+ * ```ts
187
+ * import { createFileCheckpointStore } from '@orkestrel/train/server'
188
+ *
189
+ * const store = createFileCheckpointStore({ directory: 'checkpoints' })
190
+ * await store.save({ id: 'step-10', bytes })
191
+ * await store.has('step-10') // true
192
+ * ```
193
+ */
194
+ var FileCheckpointStore = class {
195
+ #directory;
196
+ /**
197
+ * Creates a filesystem-backed checkpoint store rooted at `options.directory`.
198
+ *
199
+ * @param options - The directory configuration
200
+ */
201
+ constructor(options) {
202
+ if (!isRecord(options) || !isString(options.directory) || options.directory.trim().length === 0) throw new InferError("A file checkpoint store requires a non-empty directory path in options.directory.", { code: "ARGUMENT" });
203
+ this.#directory = options.directory;
204
+ }
205
+ /**
206
+ * Writes a checkpoint entry atomically under its validated identifier.
207
+ *
208
+ * @param entry - The identifier and serialized GGUF v3 checkpoint bytes
209
+ * @param signal - Cancels the write and removes any temporary part file
210
+ */
211
+ async save(entry, signal) {
212
+ checkSignal(signal, "The checkpoint save");
213
+ if (!isRecord(entry) || !isUint8Array(entry["bytes"])) throw new InferError("A checkpoint entry requires a valid id and Uint8Array bytes.", { code: "ARGUMENT" });
214
+ checkCheckpointId(entry.id);
215
+ await mkdir(this.#directory, { recursive: true });
216
+ checkSignal(signal, "The checkpoint save");
217
+ const target = this.#path(entry.id);
218
+ const part = this.#part(entry.id);
219
+ try {
220
+ await writeFile(part, entry.bytes, {
221
+ flag: "wx",
222
+ signal
223
+ });
224
+ checkSignal(signal, "The checkpoint save");
225
+ await rename(part, target);
226
+ } catch (error) {
227
+ await rm(part, {
228
+ force: true,
229
+ maxRetries: 3
230
+ }).catch(() => void 0);
231
+ checkSignal(signal, "The checkpoint save");
232
+ throw error;
233
+ }
234
+ }
235
+ /**
236
+ * Loads a stored checkpoint entry by identifier, or `undefined` when absent.
237
+ *
238
+ * @param id - The validated checkpoint identifier
239
+ * @param signal - Cancels the read
240
+ * @returns The stored entry, or `undefined` when missing
241
+ */
242
+ async load(id, signal) {
243
+ checkSignal(signal, "The checkpoint load");
244
+ checkCheckpointId(id);
245
+ try {
246
+ const bytes = await readFile(this.#path(id), { signal });
247
+ checkSignal(signal, "The checkpoint load");
248
+ return {
249
+ id,
250
+ bytes: new Uint8Array(bytes)
251
+ };
252
+ } catch (error) {
253
+ checkSignal(signal, "The checkpoint load");
254
+ if (isCodedError(error) && (error.code === "ENOENT" || error.code === "ENOTDIR")) return;
255
+ throw error;
256
+ }
257
+ }
258
+ /**
259
+ * Checks whether a checkpoint identifier is present in the store.
260
+ *
261
+ * @param id - The validated checkpoint identifier
262
+ * @param signal - Cancels the presence check
263
+ * @returns True if the checkpoint file exists; false otherwise
264
+ */
265
+ async has(id, signal) {
266
+ checkSignal(signal, "The checkpoint check");
267
+ checkCheckpointId(id);
268
+ try {
269
+ const info = await stat(this.#path(id));
270
+ checkSignal(signal, "The checkpoint check");
271
+ return info.isFile();
272
+ } catch (error) {
273
+ checkSignal(signal, "The checkpoint check");
274
+ if (isCodedError(error) && (error.code === "ENOENT" || error.code === "ENOTDIR")) return false;
275
+ throw error;
276
+ }
277
+ }
278
+ /**
279
+ * Lists the stored checkpoint identifiers in ascending order.
280
+ *
281
+ * @param signal - Cancels the directory listing
282
+ * @returns The sorted checkpoint identifiers
283
+ */
284
+ async list(signal) {
285
+ checkSignal(signal, "The checkpoint list");
286
+ try {
287
+ const entries = await readdir(this.#directory, { withFileTypes: true });
288
+ checkSignal(signal, "The checkpoint list");
289
+ return entries.filter((entry) => entry.isFile() && entry.name.endsWith(CHECKPOINT_FILE_EXTENSION)).map((entry) => entry.name.slice(0, -CHECKPOINT_FILE_EXTENSION.length)).filter((id) => isCheckpointId(id)).toSorted();
290
+ } catch (error) {
291
+ checkSignal(signal, "The checkpoint list");
292
+ if (isCodedError(error) && error.code === "ENOENT") return [];
293
+ throw error;
294
+ }
295
+ }
296
+ /**
297
+ * Deletes a stored checkpoint by identifier; a missing identifier is a no-op.
298
+ *
299
+ * @param id - The validated checkpoint identifier
300
+ * @param signal - Cancels the removal
301
+ */
302
+ async remove(id, signal) {
303
+ checkSignal(signal, "The checkpoint removal");
304
+ checkCheckpointId(id);
305
+ await rm(this.#path(id), { force: true });
306
+ }
307
+ /**
308
+ * Deletes every stored checkpoint in the store directory.
309
+ *
310
+ * @param signal - Cancels the clear operation
311
+ */
312
+ async clear(signal) {
313
+ checkSignal(signal, "The checkpoint clear");
314
+ const ids = await this.list(signal);
315
+ for (const id of ids) {
316
+ checkSignal(signal, "The checkpoint clear");
317
+ await rm(this.#path(id), { force: true });
318
+ }
319
+ }
320
+ #path(id) {
321
+ return join(this.#directory, `${id}${CHECKPOINT_FILE_EXTENSION}`);
322
+ }
323
+ #part(id) {
324
+ return `${join(this.#directory, id)}.${randomUUID()}.part`;
325
+ }
326
+ };
327
+ // src/server/factories.ts
328
+ /**
329
+ * Creates a filesystem-backed checkpoint store over a local directory.
330
+ *
331
+ * @param options - The directory configuration
332
+ * @returns A {@link CheckpointStoreInterface} backed by atomic GGUF files
333
+ *
334
+ * @example
335
+ * ```ts
336
+ * const store = createFileCheckpointStore({ directory: 'checkpoints' })
337
+ * await store.list() // []
338
+ * ```
339
+ */
340
+ function createFileCheckpointStore(options) {
341
+ return new FileCheckpointStore(options);
342
+ }
343
+ export { FileCheckpointStore, buildFileByteSink, createFileCheckpointStore, readRowFile, writeHeadFile, writeMergedFile, writeMergedGGUFFile, writeMergedSafetensorsFile };
344
+
345
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/server/helpers.ts","../../../src/server/stores/FileCheckpointStore.ts","../../../src/server/factories.ts"],"sourcesContent":["import type { FileHandle } from 'node:fs/promises'\nimport type {\n\tByteSinkInterface,\n\tMergeGGUFOptions,\n\tMergeSafetensorsOptions,\n\tTrainerRow,\n} from '@src/core'\nimport { checkSignal } from '@orkestrel/infer'\nimport {\n\tcomputeHeadName,\n\tmergeGGUF,\n\tmergeSafetensors,\n\treadTrainerRows,\n\twriteByteSink,\n} from '@src/core'\nimport { randomUUID } from 'node:crypto'\nimport { createReadStream } from 'node:fs'\nimport { open, rename, rm, writeFile } from 'node:fs/promises'\nimport { join } from 'node:path'\n\n/**\n * Reads training rows from an NDJSON file, one row per line.\n *\n * @remarks\n * Streams the file as UTF-8 text into `readTrainerRows`, which reads it through `@orkestrel/ndjson` and\n * rejects as it states. Rejects with the file system's error when the file cannot be read; an early\n * rejection closes the file, and an aborted signal rejects before the file opens.\n *\n * @param path - The NDJSON file\n * @param signal - Cancels the read between chunks; it then rejects with the `ABORT` code\n * @returns The rows, in line order\n *\n * @example\n * ```ts\n * const rows = await readRowFile('rows/train.ndjson')\n * const result = await trainer.execute(rows)\n * ```\n */\nexport async function readRowFile(\n\tpath: string | URL,\n\tsignal?: AbortSignal,\n): Promise<readonly TrainerRow[]> {\n\tcheckSignal(signal, 'The row read')\n\treturn readTrainerRows(createReadStream(path, { encoding: 'utf8' }), signal)\n}\n\n/**\n * Writes a head file into a directory under its content name, and returns its path.\n *\n * @remarks\n * The name is `computeHeadName` of the bytes, the digest `@orkestrel/infer`'s head reports, so writing the same\n * head twice leaves one file. The bytes go to a fresh temporary file beside it that is then renamed\n * over the name, so a reader never sees a partial head; on a failure the temporary file is removed and\n * the write's failure rethrown, never one from that removal. Rejects with the file system's error when\n * the directory is missing or refuses the write.\n *\n * @param directory - The directory to write into\n * @param bytes - The head file's bytes\n * @returns The written file's path\n *\n * @example\n * ```ts\n * const path = await writeHeadFile('heads', result.bytes) // 'heads/3f2a…9c.gguf'\n * ```\n */\nexport async function writeHeadFile(\n\tdirectory: string,\n\tbytes: Uint8Array<ArrayBuffer>,\n): Promise<string> {\n\tconst path = join(directory, await computeHeadName(bytes))\n\tconst part = `${path}.${randomUUID()}.part`\n\ttry {\n\t\tawait writeFile(part, bytes, { flag: 'wx' })\n\t\tawait rename(part, path)\n\t} catch (error) {\n\t\t// A path under a non-directory refuses the removal too; the write's failure is the one to report.\n\t\tawait rm(part, { force: true, maxRetries: 3 }).catch(() => undefined)\n\t\tthrow error\n\t}\n\treturn path\n}\n\n/**\n * Wraps an open Node `FileHandle` as a `ByteSinkInterface` that writes each chunk sequentially and\n * closes the handle at most once on `close` or `abort`.\n *\n * @param handle - The open file handle to wrap\n * @returns The `ByteSinkInterface` backed by `handle`\n *\n * @example\n * ```ts\n * const sink = buildFileByteSink(handle)\n * ```\n */\nexport function buildFileByteSink(handle: FileHandle): ByteSinkInterface {\n\tconst closed = new Set<FileHandle>()\n\treturn {\n\t\tasync write(chunk) {\n\t\t\tawait handle.writeFile(chunk)\n\t\t},\n\t\tasync close() {\n\t\t\tif (!closed.has(handle)) {\n\t\t\t\tclosed.add(handle)\n\t\t\t\tawait handle.close()\n\t\t\t}\n\t\t},\n\t\tasync abort() {\n\t\t\tif (!closed.has(handle)) {\n\t\t\t\tclosed.add(handle)\n\t\t\t\tawait handle.close()\n\t\t\t}\n\t\t},\n\t}\n}\n\n/**\n * Streams an async iterable of byte chunks into an exclusive temporary `.part` file beside `path`,\n * atomically renames it over `path` on completion, and removes the `.part` file on error or abort.\n *\n * @remarks\n * Opens `<path>.<uuid>.part` with `flag: 'wx'` so concurrent writers never collide and readers\n * never observe partial output. Checks `signal` before opening and between chunks.\n *\n * @param path - The final destination file path\n * @param chunks - The async iterable of byte chunks to persist\n * @param signal - Cancels the write; rejects with the `ABORT` code and removes the `.part` file\n * @returns The written destination `path`\n *\n * @example\n * ```ts\n * await writeMergedFile('merged.gguf', mergeGGUF({ source, adapter }))\n * ```\n */\nexport async function writeMergedFile(\n\tpath: string,\n\tchunks: AsyncIterable<Uint8Array>,\n\tsignal?: AbortSignal,\n): Promise<string> {\n\tcheckSignal(signal, 'The merged file write')\n\tconst part = `${path}.${randomUUID()}.part`\n\tconst handle = await open(part, 'wx')\n\tconst sink = buildFileByteSink(handle)\n\ttry {\n\t\tawait writeByteSink(chunks, sink, signal)\n\t\tawait rename(part, path)\n\t} catch (error) {\n\t\tawait sink.abort?.(error)\n\t\tawait rm(part, { force: true, maxRetries: 3 }).catch(() => undefined)\n\t\tthrow error\n\t}\n\treturn path\n}\n\n/**\n * Streams an adapter- or section-merged safetensors file to `path` atomically through an exclusive\n * `.part` file.\n *\n * @remarks\n * Uses `mergeSafetensors` so untargeted tensors stream in bounded slices and targeted tensors merge\n * strip-by-strip without holding the base checkpoint in memory. Unlinks `<path>.<uuid>.part` on\n * error or `AbortSignal`.\n *\n * @param path - The destination safetensors file path\n * @param options - The streaming merge options\n * @returns The written destination `path`\n *\n * @example\n * ```ts\n * await writeMergedSafetensorsFile('model.safetensors', { source, adapter, architecture })\n * ```\n */\nexport async function writeMergedSafetensorsFile(\n\tpath: string,\n\toptions: MergeSafetensorsOptions,\n): Promise<string> {\n\treturn writeMergedFile(path, mergeSafetensors(options), options.signal)\n}\n\n/**\n * Streams an adapter- or section-merged GGUF v3 file to `path` atomically through an exclusive\n * `.part` file.\n *\n * @remarks\n * Uses `mergeGGUF` so base metadata copies verbatim, untargeted quantized tensors stream\n * byte-for-byte unchanged, and targeted tensors merge strip-by-strip into `F32`, `BF16`, `Q8_0`, or\n * `Q4_K`. Unlinks `<path>.<uuid>.part` on error or `AbortSignal`.\n *\n * @param path - The destination GGUF file path\n * @param options - The streaming merge options\n * @returns The written destination `path`\n *\n * @example\n * ```ts\n * await writeMergedGGUFFile('model.gguf', { source, adapter, format: 'F32' })\n * ```\n */\nexport async function writeMergedGGUFFile(\n\tpath: string,\n\toptions: MergeGGUFOptions,\n): Promise<string> {\n\treturn writeMergedFile(path, mergeGGUF(options), options.signal)\n}\n","import type { CheckpointEntry, CheckpointStoreInterface } from '@src/core'\nimport type { FileCheckpointStoreOptions } from '../types.js'\nimport { isCodedError, isRecord, isString, isUint8Array } from '@orkestrel/contract'\nimport { checkSignal, InferError } from '@orkestrel/infer'\nimport { checkCheckpointId, CHECKPOINT_FILE_EXTENSION, isCheckpointId } from '@src/core'\nimport { randomUUID } from 'node:crypto'\nimport { mkdir, readdir, readFile, rename, rm, stat, writeFile } from 'node:fs/promises'\nimport { join } from 'node:path'\n\n/**\n * Persists training checkpoints as atomic GGUF v3 files in a local directory.\n *\n * @remarks\n * Validates every checkpoint identifier against `CHECKPOINT_ID_PATTERN` before touching the\n * filesystem. Writes bytes to `<directory>/<id>.<uuid>.part` with exclusive creation (`flag: 'wx'`)\n * and atomically renames over `<directory>/<id>.gguf`, unlinking the temporary `.part` file on any\n * error or `AbortSignal`. Removing a missing identifier is a no-op, and loading one returns\n * `undefined`.\n *\n * @example\n * ```ts\n * import { createFileCheckpointStore } from '@orkestrel/train/server'\n *\n * const store = createFileCheckpointStore({ directory: 'checkpoints' })\n * await store.save({ id: 'step-10', bytes })\n * await store.has('step-10') // true\n * ```\n */\nexport class FileCheckpointStore implements CheckpointStoreInterface {\n\treadonly #directory: string\n\n\t/**\n\t * Creates a filesystem-backed checkpoint store rooted at `options.directory`.\n\t *\n\t * @param options - The directory configuration\n\t */\n\tconstructor(options: FileCheckpointStoreOptions) {\n\t\tif (\n\t\t\t!isRecord(options) ||\n\t\t\t!isString(options.directory) ||\n\t\t\toptions.directory.trim().length === 0\n\t\t) {\n\t\t\tthrow new InferError(\n\t\t\t\t'A file checkpoint store requires a non-empty directory path in options.directory.',\n\t\t\t\t{ code: 'ARGUMENT' },\n\t\t\t)\n\t\t}\n\t\tthis.#directory = options.directory\n\t}\n\n\t/**\n\t * Writes a checkpoint entry atomically under its validated identifier.\n\t *\n\t * @param entry - The identifier and serialized GGUF v3 checkpoint bytes\n\t * @param signal - Cancels the write and removes any temporary part file\n\t */\n\tasync save(entry: CheckpointEntry, signal?: AbortSignal): Promise<void> {\n\t\tcheckSignal(signal, 'The checkpoint save')\n\t\tif (!isRecord(entry) || !isUint8Array(entry['bytes'])) {\n\t\t\tthrow new InferError('A checkpoint entry requires a valid id and Uint8Array bytes.', {\n\t\t\t\tcode: 'ARGUMENT',\n\t\t\t})\n\t\t}\n\t\tcheckCheckpointId(entry.id)\n\t\tawait mkdir(this.#directory, { recursive: true })\n\t\tcheckSignal(signal, 'The checkpoint save')\n\t\tconst target = this.#path(entry.id)\n\t\tconst part = this.#part(entry.id)\n\t\ttry {\n\t\t\tawait writeFile(part, entry.bytes, { flag: 'wx', signal })\n\t\t\tcheckSignal(signal, 'The checkpoint save')\n\t\t\tawait rename(part, target)\n\t\t} catch (error) {\n\t\t\t// Remove any partial or aborted temporary file beside committed checkpoints.\n\t\t\tawait rm(part, { force: true, maxRetries: 3 }).catch(() => undefined)\n\t\t\tcheckSignal(signal, 'The checkpoint save')\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t/**\n\t * Loads a stored checkpoint entry by identifier, or `undefined` when absent.\n\t *\n\t * @param id - The validated checkpoint identifier\n\t * @param signal - Cancels the read\n\t * @returns The stored entry, or `undefined` when missing\n\t */\n\tasync load(id: string, signal?: AbortSignal): Promise<CheckpointEntry | undefined> {\n\t\tcheckSignal(signal, 'The checkpoint load')\n\t\tcheckCheckpointId(id)\n\t\ttry {\n\t\t\tconst bytes = await readFile(this.#path(id), { signal })\n\t\t\tcheckSignal(signal, 'The checkpoint load')\n\t\t\treturn { id, bytes: new Uint8Array(bytes) }\n\t\t} catch (error) {\n\t\t\tcheckSignal(signal, 'The checkpoint load')\n\t\t\tif (isCodedError(error) && (error.code === 'ENOENT' || error.code === 'ENOTDIR')) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t/**\n\t * Checks whether a checkpoint identifier is present in the store.\n\t *\n\t * @param id - The validated checkpoint identifier\n\t * @param signal - Cancels the presence check\n\t * @returns True if the checkpoint file exists; false otherwise\n\t */\n\tasync has(id: string, signal?: AbortSignal): Promise<boolean> {\n\t\tcheckSignal(signal, 'The checkpoint check')\n\t\tcheckCheckpointId(id)\n\t\ttry {\n\t\t\tconst info = await stat(this.#path(id))\n\t\t\tcheckSignal(signal, 'The checkpoint check')\n\t\t\treturn info.isFile()\n\t\t} catch (error) {\n\t\t\tcheckSignal(signal, 'The checkpoint check')\n\t\t\tif (isCodedError(error) && (error.code === 'ENOENT' || error.code === 'ENOTDIR')) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t/**\n\t * Lists the stored checkpoint identifiers in ascending order.\n\t *\n\t * @param signal - Cancels the directory listing\n\t * @returns The sorted checkpoint identifiers\n\t */\n\tasync list(signal?: AbortSignal): Promise<readonly string[]> {\n\t\tcheckSignal(signal, 'The checkpoint list')\n\t\ttry {\n\t\t\tconst entries = await readdir(this.#directory, { withFileTypes: true })\n\t\t\tcheckSignal(signal, 'The checkpoint list')\n\t\t\treturn entries\n\t\t\t\t.filter((entry) => entry.isFile() && entry.name.endsWith(CHECKPOINT_FILE_EXTENSION))\n\t\t\t\t.map((entry) => entry.name.slice(0, -CHECKPOINT_FILE_EXTENSION.length))\n\t\t\t\t.filter((id) => isCheckpointId(id))\n\t\t\t\t.toSorted()\n\t\t} catch (error) {\n\t\t\tcheckSignal(signal, 'The checkpoint list')\n\t\t\tif (isCodedError(error) && error.code === 'ENOENT') return []\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t/**\n\t * Deletes a stored checkpoint by identifier; a missing identifier is a no-op.\n\t *\n\t * @param id - The validated checkpoint identifier\n\t * @param signal - Cancels the removal\n\t */\n\tasync remove(id: string, signal?: AbortSignal): Promise<void> {\n\t\tcheckSignal(signal, 'The checkpoint removal')\n\t\tcheckCheckpointId(id)\n\t\tawait rm(this.#path(id), { force: true })\n\t}\n\n\t/**\n\t * Deletes every stored checkpoint in the store directory.\n\t *\n\t * @param signal - Cancels the clear operation\n\t */\n\tasync clear(signal?: AbortSignal): Promise<void> {\n\t\tcheckSignal(signal, 'The checkpoint clear')\n\t\tconst ids = await this.list(signal)\n\t\tfor (const id of ids) {\n\t\t\tcheckSignal(signal, 'The checkpoint clear')\n\t\t\tawait rm(this.#path(id), { force: true })\n\t\t}\n\t}\n\n\t// Resolves the committed GGUF file path for a validated checkpoint id.\n\t#path(id: string): string {\n\t\treturn join(this.#directory, `${id}${CHECKPOINT_FILE_EXTENSION}`)\n\t}\n\n\t// Resolves a unique temporary part file path inside the store directory.\n\t#part(id: string): string {\n\t\treturn `${join(this.#directory, id)}.${randomUUID()}.part`\n\t}\n}\n","import type { CheckpointStoreInterface } from '@src/core'\nimport type { FileCheckpointStoreOptions } from './types.js'\nimport { FileCheckpointStore } from './stores/FileCheckpointStore.js'\n\n/**\n * Creates a filesystem-backed checkpoint store over a local directory.\n *\n * @param options - The directory configuration\n * @returns A {@link CheckpointStoreInterface} backed by atomic GGUF files\n *\n * @example\n * ```ts\n * const store = createFileCheckpointStore({ directory: 'checkpoints' })\n * await store.list() // []\n * ```\n */\nexport function createFileCheckpointStore(\n\toptions: FileCheckpointStoreOptions,\n): CheckpointStoreInterface {\n\treturn new FileCheckpointStore(options)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,eAAsB,YACrB,MACA,QACiC;CACjC,YAAY,QAAQ,cAAc;CAClC,OAAO,gBAAgB,iBAAiB,MAAM,EAAE,UAAU,OAAO,CAAC,GAAG,MAAM;AAC5E;;;;;;;;;;;;;;;;;;;;AAqBA,eAAsB,cAC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