@orkestrel/train 0.0.1 → 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.
package/dist/src/core/index.cjs
CHANGED
|
@@ -902,6 +902,20 @@ var FINETUNER_LIMIT = 2048;
|
|
|
902
902
|
*/
|
|
903
903
|
var FINETUNER_SEED = 0;
|
|
904
904
|
/**
|
|
905
|
+
* Lists every boundary timing metric name emitted by `Finetuner`, in milliseconds.
|
|
906
|
+
*
|
|
907
|
+
* @example
|
|
908
|
+
* ```ts
|
|
909
|
+
* TRAIN_METRICS.includes('step') // true
|
|
910
|
+
* ```
|
|
911
|
+
*/
|
|
912
|
+
var TRAIN_METRICS = Object.freeze([
|
|
913
|
+
"step",
|
|
914
|
+
"accumulate",
|
|
915
|
+
"update",
|
|
916
|
+
"rotation"
|
|
917
|
+
]);
|
|
918
|
+
/**
|
|
905
919
|
* Holds the `general.type` value written into every GGUF v3 section patch file.
|
|
906
920
|
*
|
|
907
921
|
* @example
|
|
@@ -7804,6 +7818,8 @@ var Finetuner = class {
|
|
|
7804
7818
|
let epochTokens = 0;
|
|
7805
7819
|
for (let stepOffset = 0; stepOffset < remainingSteps; stepOffset += 1) {
|
|
7806
7820
|
(0, _orkestrel_infer.checkSignal)(signal, "The fine-tuning");
|
|
7821
|
+
const metered = this.#emitter.count("metric") > 0;
|
|
7822
|
+
const begun = metered ? performance.now() : 0;
|
|
7807
7823
|
const [batch, epochFinished] = this.#drawBatch(trainIndices, settings.loop.batch);
|
|
7808
7824
|
await this.#backward.zero();
|
|
7809
7825
|
let batchLossWeighted = 0;
|
|
@@ -7813,13 +7829,16 @@ var Finetuner = class {
|
|
|
7813
7829
|
const rowIndex = batch[slot];
|
|
7814
7830
|
const span = rowIndex === void 0 ? void 0 : spans[rowIndex];
|
|
7815
7831
|
if (span === void 0) continue;
|
|
7832
|
+
const accumulating = metered ? performance.now() : 0;
|
|
7816
7833
|
const reading = await this.#backward.accumulate(span, signal);
|
|
7834
|
+
if (metered) this.#emitter.emit("metric", "accumulate", performance.now() - accumulating);
|
|
7817
7835
|
batchLossWeighted += reading.loss * reading.count;
|
|
7818
7836
|
batchTokens += reading.count;
|
|
7819
7837
|
}
|
|
7820
7838
|
(0, _orkestrel_infer.checkSignal)(signal, "The fine-tuning");
|
|
7821
7839
|
const nextStep = this.#step + 1;
|
|
7822
7840
|
const rate = computeFinetunerRate(nextStep, totalSteps, settings.optimizer.rate, settings.optimizer.warmup, settings.optimizer.schedule);
|
|
7841
|
+
const updating = metered ? performance.now() : 0;
|
|
7823
7842
|
const norm = await this.#backward.step({
|
|
7824
7843
|
step: nextStep,
|
|
7825
7844
|
rate,
|
|
@@ -7830,6 +7849,13 @@ var Finetuner = class {
|
|
|
7830
7849
|
clip: settings.optimizer.clip,
|
|
7831
7850
|
scale: 1 / batch.length
|
|
7832
7851
|
}, signal);
|
|
7852
|
+
if (metered) {
|
|
7853
|
+
const interval = settings.section?.interval;
|
|
7854
|
+
const rotates = settings.mode === "section" && interval !== void 0 && nextStep % interval === 0;
|
|
7855
|
+
const finished = performance.now();
|
|
7856
|
+
this.#emitter.emit("metric", rotates ? "rotation" : "update", finished - updating);
|
|
7857
|
+
this.#emitter.emit("metric", "step", finished - begun);
|
|
7858
|
+
}
|
|
7833
7859
|
this.#step = nextStep;
|
|
7834
7860
|
const stepLoss = batchTokens > 0 ? batchLossWeighted / batchTokens : 0;
|
|
7835
7861
|
totalLossWeighted += batchLossWeighted;
|
|
@@ -8318,6 +8344,7 @@ exports.TRAINER_FOLD_FLOOR = TRAINER_FOLD_FLOOR;
|
|
|
8318
8344
|
exports.TRAINER_PENALTIES = TRAINER_PENALTIES;
|
|
8319
8345
|
exports.TRAINER_REPEATS = TRAINER_REPEATS;
|
|
8320
8346
|
exports.TRAINER_SEED = TRAINER_SEED;
|
|
8347
|
+
exports.TRAIN_METRICS = TRAIN_METRICS;
|
|
8321
8348
|
exports.ThreadFitter = ThreadFitter;
|
|
8322
8349
|
exports.Trainer = Trainer;
|
|
8323
8350
|
exports.addLoRAStrip = addLoRAStrip;
|