@genai-fi/nanogpt 0.20.6 → 0.20.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/dist/Generator.js +1 -1
- package/dist/TeachableLLM.js +1 -1
- package/dist/Trainer.js +1 -1
- package/dist/checks/rope.js +5 -5
- package/dist/loader/load.js +1 -1
- package/dist/loader/loadHF.js +1 -1
- package/dist/loader/loadTransformers.js +1 -1
- package/dist/loader/newZipLoad.js +1 -1
- package/dist/loader/oldZipLoad.js +1 -1
- package/dist/loader/save.js +1 -1
- package/dist/{main-C0YUnw98.js → main-BTmbwF1h.js} +6 -4
- package/dist/main.js +1 -1
- package/dist/models/NanoGPTV1.js +1 -1
- package/dist/models/NanoGPTV2.js +1 -1
- package/dist/models/factory.js +1 -1
- package/dist/models/model.js +1 -1
- package/dist/ops/webgl/adamMoments.js +2 -2
- package/dist/ops/webgl/matMul16.js +7 -3
- package/dist/ops/webgpu/matMul16.js +7 -3
- package/dist/ops/webgpu/normRMS.js +1 -1
- package/dist/training/BasicTrainer.js +1 -1
- package/dist/training/validation.js +1 -1
- package/dist/utilities/arrayClose.d.ts +1 -0
- package/dist/utilities/arrayClose.js +13 -1
- package/package.json +1 -1
package/dist/Generator.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { c as e, s as t } from "./main-
|
|
1
|
+
import { c as e, s as t } from "./main-BTmbwF1h.js";
|
|
2
2
|
export { t as default, e as isConversation };
|
package/dist/TeachableLLM.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as e } from "./main-
|
|
1
|
+
import { i as e } from "./main-BTmbwF1h.js";
|
|
2
2
|
export { e as default };
|
package/dist/Trainer.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as e } from "./main-
|
|
1
|
+
import { a as e } from "./main-BTmbwF1h.js";
|
|
2
2
|
export { e as default };
|
package/dist/checks/rope.js
CHANGED
|
@@ -19,11 +19,11 @@ async function i(i) {
|
|
|
19
19
|
useRope: !0
|
|
20
20
|
});
|
|
21
21
|
o.ensureRopeCache(120);
|
|
22
|
-
let s = t().runKernel("Rope", {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
22
|
+
let s = t().runKernel("Rope", { x: a }, {
|
|
23
|
+
pastLen: 20,
|
|
24
|
+
ropeCache: o,
|
|
25
|
+
negSin: !1
|
|
26
|
+
});
|
|
27
27
|
return Array.isArray(s) ? s.map((e) => e.array()) : s.array();
|
|
28
28
|
}
|
|
29
29
|
//#endregion
|
package/dist/loader/load.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { d as e, u as t } from "../main-
|
|
1
|
+
import { d as e, u as t } from "../main-BTmbwF1h.js";
|
|
2
2
|
export { t as VERSION, e as loadModel };
|
package/dist/loader/loadHF.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { f as e } from "../main-
|
|
1
|
+
import { f as e } from "../main-BTmbwF1h.js";
|
|
2
2
|
export { e as default };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { h as e, m as t } from "../main-
|
|
1
|
+
import { h as e, m as t } from "../main-BTmbwF1h.js";
|
|
2
2
|
export { t as default, e as mapTransformersConfigToGPTConfig };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { p as e } from "../main-
|
|
1
|
+
import { p as e } from "../main-BTmbwF1h.js";
|
|
2
2
|
export { e as default };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { g as e } from "../main-
|
|
1
|
+
import { g as e } from "../main-BTmbwF1h.js";
|
|
2
2
|
export { e as default };
|
package/dist/loader/save.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { l as e } from "../main-
|
|
1
|
+
import { l as e } from "../main-BTmbwF1h.js";
|
|
2
2
|
export { e as saveModel };
|
|
@@ -13163,13 +13163,15 @@ var DS = class e extends hc {
|
|
|
13163
13163
|
}
|
|
13164
13164
|
if (!n) throw Error("Tokeniser must be provided when initializing Trainer with a model");
|
|
13165
13165
|
if (!t) throw Error("Model must be provided when initializing Trainer");
|
|
13166
|
-
|
|
13166
|
+
this.options = i || {
|
|
13167
13167
|
batchSize: 32,
|
|
13168
13168
|
sftMode: "full"
|
|
13169
|
-
}
|
|
13170
|
-
|
|
13169
|
+
};
|
|
13170
|
+
let o = this.options.mixedPrecision && tc();
|
|
13171
|
+
if (this.options.lossScaling = o ? t.lossScaling : 1, r === "sft") {
|
|
13172
|
+
let e = new Ac(t, n, this.options, a);
|
|
13171
13173
|
this.trainer = e, e.loraName = i?.loraName;
|
|
13172
|
-
} else this.trainer = new kc(t, n,
|
|
13174
|
+
} else this.trainer = new kc(t, n, this.options, a);
|
|
13173
13175
|
this.trainingType = r || "pretraining", this.tokenizer = n;
|
|
13174
13176
|
}
|
|
13175
13177
|
get model() {
|
package/dist/main.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as e, b as t, i as n, n as r, r as i, s as a, t as o, y as s } from "./main-
|
|
1
|
+
import { a as e, b as t, i as n, n as r, r as i, s as a, t as o, y as s } from "./main-BTmbwF1h.js";
|
|
2
2
|
import c from "./tokeniser/CharTokeniser.js";
|
|
3
3
|
import l from "./tokeniser/bpe.js";
|
|
4
4
|
import { AdamWOptimizer as u } from "./training/AdamW.js";
|
package/dist/models/NanoGPTV1.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { y as e } from "../main-
|
|
1
|
+
import { y as e } from "../main-BTmbwF1h.js";
|
|
2
2
|
export { e as default };
|
package/dist/models/NanoGPTV2.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { v as e } from "../main-
|
|
1
|
+
import { v as e } from "../main-BTmbwF1h.js";
|
|
2
2
|
export { e as default };
|
package/dist/models/factory.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as e } from "../main-
|
|
1
|
+
import { _ as e } from "../main-BTmbwF1h.js";
|
|
2
2
|
export { e as default };
|
package/dist/models/model.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { b as e } from "../main-
|
|
1
|
+
import { b as e } from "../main-BTmbwF1h.js";
|
|
2
2
|
export { e as default };
|
|
@@ -19,8 +19,8 @@ var t = class {
|
|
|
19
19
|
float m = getMomentsAtOutCoords();
|
|
20
20
|
${n} coords = getOutputCoords();
|
|
21
21
|
|
|
22
|
-
// Add
|
|
23
|
-
float g =
|
|
22
|
+
// TODO: Add scaling
|
|
23
|
+
float g = getGradient(${i});
|
|
24
24
|
int which = ${r};
|
|
25
25
|
|
|
26
26
|
float beta = which == 0 ? beta1 : beta2;
|
|
@@ -7,12 +7,16 @@ function d(e) {
|
|
|
7
7
|
let { A: d, B: f } = e.inputs, { transposeA: p, transposeB: m, scale: h, activation: g, scaleA: _, scaleB: v, forceOutputShape: y, perm: b } = e.attrs, x = !c(d), S = !c(f);
|
|
8
8
|
if (x && S) {
|
|
9
9
|
let e = _ === void 0 ? d : t(d, n(_)), c = v === void 0 ? f : t(f, n(v)), x;
|
|
10
|
-
if (
|
|
11
|
-
else if (g === "gelu") x = u(e, c);
|
|
10
|
+
if (g === "gelu") x = u(e, c);
|
|
12
11
|
else if (g === "relu2") {
|
|
13
12
|
let t = i(e, c, p, m), n = o(t);
|
|
14
13
|
t.dispose(), x = a(n), n.dispose();
|
|
15
|
-
} else
|
|
14
|
+
} else if (g === "relu") {
|
|
15
|
+
if (x = o(i(e, c, p, m)), h !== void 0) {
|
|
16
|
+
let e = t(x, n(h));
|
|
17
|
+
x.dispose(), x = e;
|
|
18
|
+
}
|
|
19
|
+
} else x = h === void 0 ? i(e, c, p, m) : l(e, c, n(h), p, m);
|
|
16
20
|
if (b) if (y) {
|
|
17
21
|
let e = r(x, y);
|
|
18
22
|
x.dispose();
|
|
@@ -11,12 +11,16 @@ function h(e) {
|
|
|
11
11
|
let e = x === void 0 ? h : n(h, r(x)), t = S === void 0 ? g : n(g, r(S));
|
|
12
12
|
if (T) throw Error("Causal mask is not supported for unpacked MatMul16.");
|
|
13
13
|
let c;
|
|
14
|
-
if (
|
|
15
|
-
else if (b === "gelu") c = p(e, t);
|
|
14
|
+
if (b === "gelu") c = p(e, t);
|
|
16
15
|
else if (b === "relu2") {
|
|
17
16
|
let n = a(e, t, _, v), r = s(n);
|
|
18
17
|
n.dispose(), c = o(r), r.dispose();
|
|
19
|
-
} else
|
|
18
|
+
} else if (b === "relu") {
|
|
19
|
+
if (c = s(a(e, t, _, v)), y !== void 0) {
|
|
20
|
+
let e = n(c, r(y));
|
|
21
|
+
c.dispose(), c = e;
|
|
22
|
+
}
|
|
23
|
+
} else c = y === void 0 ? a(e, t, _, v) : f(e, t, r(y), _, v);
|
|
20
24
|
if (w) if (C) {
|
|
21
25
|
let e = i(c, C);
|
|
22
26
|
c.dispose();
|
|
@@ -7,7 +7,7 @@ import s from "./normRMS32_program.js";
|
|
|
7
7
|
import c from "./normRMS16_program.js";
|
|
8
8
|
//#region lib/ops/webgpu/normRMS.ts
|
|
9
9
|
function l(t) {
|
|
10
|
-
let { x: l, gamma: u } = t.inputs, d = t.backend, f = o(d), p = n(l), m = u ? n(u) : !1, h = p || m, g = !h ||
|
|
10
|
+
let { x: l, gamma: u } = t.inputs, d = t.backend, f = o(d), p = n(l), m = u ? n(u) : !1, h = p || m, g = !h || p ? l : r(l), _ = u && (!h || m ? u : r(u)), v = _ ? [g, _] : [g], y = i(v, -1), b = h ? new c(f, y, !!u) : new s(f, y, !!u);
|
|
11
11
|
if (_ && e(_.shape, [g.shape[g.shape.length - 1]], "Error in RMSNorm: "), l.shape.length !== 3) throw Error(`rmsNormGPU: input rank ${l.shape.length} not supported, only rank 3 is supported`);
|
|
12
12
|
if (y.inSize !== g.shape[g.shape.length - 1]) throw Error(`rmsNormGPU: reduction size ${y.inSize} does not match expected size ${g.shape[g.shape.length - 1]}`);
|
|
13
13
|
if (y.batchSize !== l.shape[0] * l.shape[1]) throw Error(`rmsNormGPU: batch size ${y.batchSize} does not match expected size ${l.shape[0] * l.shape[1]}`);
|
|
@@ -39,7 +39,7 @@ var f = {
|
|
|
39
39
|
this.tokenizer = t, this.model = e, this.optimizerConfig = {
|
|
40
40
|
...p,
|
|
41
41
|
...n,
|
|
42
|
-
lossScaling: e.lossScaling
|
|
42
|
+
lossScaling: n?.lossScaling ?? e.lossScaling
|
|
43
43
|
};
|
|
44
44
|
let i = r || new o(this.optimizerConfig);
|
|
45
45
|
r && r.updateConfig(this.optimizerConfig), this.optimizer = i;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { o as e } from "../main-
|
|
1
|
+
import { o as e } from "../main-BTmbwF1h.js";
|
|
2
2
|
export { e as createTrainValidationSplit };
|
|
@@ -12,5 +12,17 @@ function e(t, n) {
|
|
|
12
12
|
return r = Math.max(r, e), r;
|
|
13
13
|
} else return Infinity;
|
|
14
14
|
}
|
|
15
|
+
function t(e, t, n = .99) {
|
|
16
|
+
let r = [];
|
|
17
|
+
function i(e, t) {
|
|
18
|
+
if ((Array.isArray(e) || e instanceof Float32Array) && (Array.isArray(t) || t instanceof Float32Array)) {
|
|
19
|
+
if (e.length !== t.length) return !1;
|
|
20
|
+
for (let n = 0; n < e.length; n++) if (!i(e[n], t[n])) return !1;
|
|
21
|
+
return !0;
|
|
22
|
+
}
|
|
23
|
+
return typeof e == "number" && typeof t == "number" ? Number.isNaN(e) && Number.isNaN(t) ? (r.push(0), !0) : !Number.isFinite(e) || !Number.isFinite(t) ? e === t : (r.push(Math.abs(e - t)), !0) : !1;
|
|
24
|
+
}
|
|
25
|
+
return !i(e, t) || r.length === 0 ? Infinity : (r.sort((e, t) => e - t), r[Math.min(r.length - 1, Math.floor(n * r.length))]);
|
|
26
|
+
}
|
|
15
27
|
//#endregion
|
|
16
|
-
export { e as arraysClose };
|
|
28
|
+
export { e as arraysClose, t as arraysClosePercentile };
|