@genai-fi/nanogpt 0.6.2 → 0.7.0
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 +11 -11
- package/dist/NanoGPTModel.d.ts +2 -2
- package/dist/NanoGPTModel.js +104 -136
- package/dist/{RealDiv-BYViZwhN.js → RealDiv-C4hOvYOZ.js} +26 -25
- package/dist/{Reshape-t7Kcikjk.js → Reshape-BLijOA8h.js} +5 -5
- package/dist/TeachableLLM.d.ts +3 -0
- package/dist/TeachableLLM.js +50 -47
- package/dist/{TiedEmbedding-9WeDwvjO.js → TiedEmbedding-BLltddza.js} +4 -4
- package/dist/{axis_util-Bu4h7XWV.js → axis_util-DaAl5MER.js} +3 -3
- package/dist/backend.d.ts +1 -0
- package/dist/backend.js +7 -0
- package/dist/backend_util-DWiwsi2N.js +749 -0
- package/dist/{broadcast_to-DARN-DBD.js → broadcast_to-C4v-j9yA.js} +2 -2
- package/dist/{concat-5aPGqw3Z.js → concat-CsHeR4zV.js} +8 -8
- package/dist/{dataset-pgqp-YfL.js → dataset-JDyjG3QR.js} +3 -3
- package/dist/{dropout-Bciw46HT.js → dropout-hpDwECTe.js} +7 -7
- package/dist/{gather-DjyCjmOD.js → gather-D0_gPiBz.js} +4 -4
- package/dist/gelu-uyHP1x1f.js +26 -0
- package/dist/gpgpu_math-DJm3ZTAf.js +2371 -0
- package/dist/index-BPPzKVdR.js +12099 -0
- package/dist/{index-BAzbokzv.js → index-C0dhsYom.js} +405 -389
- package/dist/{kernel_funcs_utils-CUxJCg0g.js → kernel_funcs_utils-CwRTFqrc.js} +31 -30
- package/dist/layers/BaseLayer.js +2 -2
- package/dist/layers/CausalSelfAttention.js +6 -6
- package/dist/layers/MLP.js +5 -5
- package/dist/layers/RMSNorm.js +3 -3
- package/dist/layers/RoPECache.js +4 -4
- package/dist/layers/TiedEmbedding.js +5 -5
- package/dist/layers/TransformerBlock.js +1 -1
- package/dist/loader/loadTransformers.js +1 -1
- package/dist/loader/oldZipLoad.js +5 -5
- package/dist/{log_sum_exp-YEo2h3gb.js → log_sum_exp-D086OgZJ.js} +15 -15
- package/dist/main.d.ts +2 -0
- package/dist/main.js +9 -5
- package/dist/{mat_mul-7121rsJk.js → mat_mul-1nwdPkQ_.js} +4 -4
- package/dist/{max-DtlIuVeW.js → max-BQc2Aj-I.js} +4 -4
- package/dist/{mulmat_packed_gpu-D4nKF7Je.js → mulmat_packed_gpu-Gzf3I9UV.js} +1 -1
- package/dist/non_max_suppression_impl-CsEgBuMA.js +134 -0
- package/dist/{ones-BBlSRqn1.js → ones-D63HpSF_.js} +2 -2
- package/dist/ops/appendCache.js +3 -3
- package/dist/ops/attentionMask.js +1 -1
- package/dist/ops/cpu/appendCache.js +8 -8
- package/dist/ops/cpu/attentionMask.js +9 -9
- package/dist/ops/cpu/fusedSoftmax.js +17 -11
- package/dist/ops/cpu/gatherSub.js +7 -7
- package/dist/ops/cpu/gelu.js +13 -13
- package/dist/ops/cpu/matMulGelu.js +36 -24
- package/dist/ops/cpu/matMulMul.js +14 -8
- package/dist/ops/cpu/mulDropout.js +9 -3
- package/dist/ops/cpu/normRMS.js +5 -5
- package/dist/ops/cpu/qkv.js +3 -3
- package/dist/ops/cpu/rope.js +5 -5
- package/dist/ops/cpu/scatterSub.js +11 -11
- package/dist/ops/fusedSoftmax.js +1 -1
- package/dist/ops/gatherSub.js +1 -1
- package/dist/ops/gelu.js +2 -2
- package/dist/ops/grads/attentionMask.js +1 -1
- package/dist/ops/grads/fusedSoftmax.js +2 -2
- package/dist/ops/grads/gelu.js +3 -24
- package/dist/ops/grads/matMulGelu.js +5 -5
- package/dist/ops/grads/normRMS.js +6 -6
- package/dist/ops/grads/qkv.js +1 -1
- package/dist/ops/grads/rope.js +3 -3
- package/dist/ops/matMulGelu.js +1 -1
- package/dist/ops/matMulMul.js +1 -1
- package/dist/ops/mulDrop.js +1 -1
- package/dist/ops/normRMS.js +1 -1
- package/dist/ops/qkv.js +1 -1
- package/dist/ops/rope.js +4 -4
- package/dist/ops/scatterSub.js +1 -1
- package/dist/ops/webgl/appendCache.js +1 -1
- package/dist/ops/webgl/attentionMask.js +1 -1
- package/dist/ops/webgl/fusedSoftmax.js +4 -4
- package/dist/ops/webgl/gatherSub.js +1 -1
- package/dist/ops/webgl/gelu.js +2 -2
- package/dist/ops/webgl/log.js +5 -5
- package/dist/ops/webgl/matMulGelu.js +17 -17
- package/dist/ops/webgl/matMulMul.js +1 -1
- package/dist/ops/webgl/mulDropout.js +4 -4
- package/dist/ops/webgl/normRMS.js +2 -2
- package/dist/ops/webgl/qkv.js +1 -1
- package/dist/ops/webgl/rope.js +1 -1
- package/dist/ops/webgl/scatterSub.js +1 -1
- package/dist/ops/webgpu/appendCache.js +56 -0
- package/dist/ops/webgpu/attentionMask.d.ts +1 -0
- package/dist/ops/webgpu/attentionMask.js +64 -0
- package/dist/ops/webgpu/gatherSub.d.ts +1 -0
- package/dist/ops/webgpu/gatherSub.js +37 -0
- package/dist/ops/webgpu/gelu.d.ts +14 -0
- package/dist/ops/webgpu/gelu.js +86 -0
- package/dist/ops/webgpu/index.d.ts +0 -0
- package/dist/ops/webgpu/index.js +8 -0
- package/dist/ops/webgpu/normRMS.d.ts +1 -0
- package/dist/ops/webgpu/normRMS.js +115 -0
- package/dist/ops/webgpu/qkv.d.ts +1 -0
- package/dist/ops/webgpu/qkv.js +56 -0
- package/dist/ops/webgpu/rope.d.ts +1 -0
- package/dist/ops/webgpu/rope.js +68 -0
- package/dist/ops/webgpu/scatterSub.d.ts +1 -0
- package/dist/ops/webgpu/scatterSub.js +37 -0
- package/dist/{ops-C0sQEcPw.js → ops-CIQLNshk.js} +452 -503
- package/dist/{random_width-DWzaOgrn.js → random_width-DkYP8W8N.js} +143 -144
- package/dist/{range-DYsrnfiy.js → range-CYzpQY53.js} +1 -1
- package/dist/{reciprocal-CJQeasVa.js → reciprocal-_A9yv27J.js} +1 -1
- package/dist/{register_all_kernels-BfFCQAqs.js → register_all_kernels-guvSxp7M.js} +202 -200
- package/dist/{reshape-krWGKraP.js → reshape-BMUzc1UY.js} +3 -3
- package/dist/{scatter_nd_util-93ln7Hut.js → scatter_nd_util-IRBqKz_b.js} +3 -3
- package/dist/{selu_util-sntGesxr.js → selu_util-Dt_iuXaq.js} +6 -6
- package/dist/shared-BNa2q6jD.js +69 -0
- package/dist/{shared-Ca6iDobD.js → shared-CDu9S76h.js} +541 -606
- package/dist/{sin-D_h-qCSx.js → sin-Cocju-BY.js} +6 -6
- package/dist/{softmax-fsdtf6JC.js → softmax-GPNK3o-U.js} +3 -3
- package/dist/{split-eiktj-6L.js → split-CHzJjxDv.js} +4 -4
- package/dist/{stack-dfEEz2OY.js → stack-Dpgg_1W1.js} +2 -2
- package/dist/{sum-BE_Irnim.js → sum-B8wEpKsg.js} +5 -5
- package/dist/{tensor-Xyi595sG.js → tensor-RvZVNmg0.js} +1 -1
- package/dist/{tensor2d-CPEkynbH.js → tensor2d-B_kyod7_.js} +1 -1
- package/dist/training/AdamExt.js +1 -1
- package/dist/training/DatasetBuilder.js +2 -2
- package/dist/training/Evaluator.js +1 -1
- package/dist/training/FullTrainer.js +20 -20
- package/dist/training/Trainer.d.ts +5 -6
- package/dist/training/Trainer.js +59 -60
- package/dist/training/sparseCrossEntropy.js +19 -26
- package/dist/utilities/dummy.js +19 -19
- package/dist/utilities/generate.js +15 -16
- package/dist/utilities/multinomialCPU.d.ts +2 -0
- package/dist/utilities/multinomialCPU.js +13 -0
- package/dist/utilities/performance.d.ts +2 -0
- package/dist/utilities/performance.js +16 -0
- package/dist/utilities/profile.d.ts +1 -0
- package/dist/utilities/profile.js +9 -6
- package/dist/utilities/safetensors.js +2 -2
- package/dist/utilities/weights.js +2 -2
- package/dist/{variable-wSS22xj5.js → variable-DXEUOwew.js} +1 -1
- package/dist/webgpu_util-g13LvDIv.js +625 -0
- package/dist/{zeros-YJDE7oRb.js → zeros-DCPCdFGq.js} +8 -8
- package/package.json +2 -1
- package/dist/gpgpu_math-CNslybmD.js +0 -3115
- package/dist/norm-CzltS9Fz.js +0 -86
- package/dist/ops/node/sparseCrossEntropy.js +0 -11
- /package/dist/ops/{node/sparseCrossEntropy.d.ts → webgpu/appendCache.d.ts} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { r as T } from "./reshape-
|
|
1
|
+
import { x as h, y as f, C as p, K as g, E as u, L as b } from "./index-C0dhsYom.js";
|
|
2
|
+
import { r as T } from "./reshape-BMUzc1UY.js";
|
|
3
3
|
/**
|
|
4
4
|
* @license
|
|
5
5
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { x as s, l as a, B as p, K as i, E as l, M as f } from "./index-C0dhsYom.js";
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -15,15 +15,15 @@ import { o as s, i as a, w as i, H as p, E as l, J as f } from "./index-BAzbokzv
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
* =============================================================================
|
|
17
17
|
*/
|
|
18
|
-
function h(
|
|
19
|
-
a(
|
|
20
|
-
const t =
|
|
21
|
-
if (t[0].dtype === "complex64" && t.forEach((
|
|
22
|
-
if (
|
|
18
|
+
function h(n, e = 0) {
|
|
19
|
+
a(n.length >= 1, () => "Pass at least one tensor to concat");
|
|
20
|
+
const t = p(n, "tensors", "concat", "string_or_numeric");
|
|
21
|
+
if (t[0].dtype === "complex64" && t.forEach((o) => {
|
|
22
|
+
if (o.dtype !== "complex64")
|
|
23
23
|
throw new Error(`Cannot concatenate complex64 tensors with a tensor
|
|
24
|
-
with dtype ${
|
|
24
|
+
with dtype ${o.dtype}. `);
|
|
25
25
|
}), t.length === 1)
|
|
26
|
-
return
|
|
26
|
+
return i(t[0]);
|
|
27
27
|
const r = t, c = { axis: e };
|
|
28
28
|
return l.runKernel(f, r, c);
|
|
29
29
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ad as S, T as h, ac as N, d as v, ae as o, af as p, ag as g, l as k, t as y } from "./index-C0dhsYom.js";
|
|
2
2
|
import { s as R } from "./index-C4L8Cm77.js";
|
|
3
|
-
import { s as $ } from "./stack-
|
|
4
|
-
import { t as B } from "./tensor-
|
|
3
|
+
import { s as $ } from "./stack-Dpgg_1W1.js";
|
|
4
|
+
import { t as B } from "./tensor-RvZVNmg0.js";
|
|
5
5
|
/**
|
|
6
6
|
* @license
|
|
7
7
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { x as l, y as h, E as m, ah as p, C as c, ai as d, ab as g, l as u, T as V, aj as v, a6 as N, a as w } from "./index-C0dhsYom.js";
|
|
2
2
|
import { s as f } from "./index-C4L8Cm77.js";
|
|
3
3
|
/**
|
|
4
4
|
* @license
|
|
@@ -69,7 +69,7 @@ class T {
|
|
|
69
69
|
return t <= this.upper && t >= this.lower;
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
class
|
|
72
|
+
class y {
|
|
73
73
|
constructor(t = 0, e = 1, s, n) {
|
|
74
74
|
if (this.canReturnFloat = () => this.dtype == null || this.dtype === "float32", this.min = t, this.range = e - t, this.dtype = s, n == null && (n = Math.random()), typeof n == "number" && (n = n.toString()), !this.canReturnFloat() && this.range <= 1)
|
|
75
75
|
throw new Error(`The difference between ${t} - ${e} <= 1 and dtype is not float`);
|
|
@@ -98,7 +98,7 @@ class $ {
|
|
|
98
98
|
* limitations under the License.
|
|
99
99
|
* =============================================================================
|
|
100
100
|
*/
|
|
101
|
-
function
|
|
101
|
+
function $(r, t = 0, e = 1, s, n) {
|
|
102
102
|
if (c(r), s != null && s === "bool")
|
|
103
103
|
throw new Error(`Unsupported data type ${s}`);
|
|
104
104
|
const o = new T(t, e, s, !1, n), a = d(r, s);
|
|
@@ -106,7 +106,7 @@ function y(r, t = 0, e = 1, s, n) {
|
|
|
106
106
|
a.values[i] = o.nextValue();
|
|
107
107
|
return a.toTensor();
|
|
108
108
|
}
|
|
109
|
-
const _ = /* @__PURE__ */ l({ randomNormal_:
|
|
109
|
+
const _ = /* @__PURE__ */ l({ randomNormal_: $ });
|
|
110
110
|
/**
|
|
111
111
|
* @license
|
|
112
112
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -125,7 +125,7 @@ const _ = /* @__PURE__ */ l({ randomNormal_: y });
|
|
|
125
125
|
*/
|
|
126
126
|
function M(r, t = 0, e = 1, s = "float32", n) {
|
|
127
127
|
c(r);
|
|
128
|
-
const o = d(r, s), a = new
|
|
128
|
+
const o = d(r, s), a = new y(t, e, null, n);
|
|
129
129
|
for (let i = 0; i < o.values.length; i++)
|
|
130
130
|
o.values[i] = a.nextValue();
|
|
131
131
|
return o.toTensor();
|
|
@@ -183,11 +183,11 @@ function R(r, t, e, s) {
|
|
|
183
183
|
const o = E(n, e), a = 1 - t, i = v(b(N(D(o, 0, 1, "float32", s), a)), a);
|
|
184
184
|
return w(n, i);
|
|
185
185
|
}
|
|
186
|
-
const
|
|
186
|
+
const G = /* @__PURE__ */ l({ dropout_: R });
|
|
187
187
|
export {
|
|
188
188
|
T as M,
|
|
189
189
|
D as a,
|
|
190
|
-
|
|
190
|
+
G as d,
|
|
191
191
|
b as f,
|
|
192
192
|
_ as r
|
|
193
193
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { x as g, y as t, E as h, G as x } from "./index-C0dhsYom.js";
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -15,11 +15,11 @@ import { o as g, q as t, E as h, G as p } from "./index-BAzbokzv.js";
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
* =============================================================================
|
|
17
17
|
*/
|
|
18
|
-
function
|
|
18
|
+
function p(n, s, r = 0, e = 0) {
|
|
19
19
|
const o = t(n, "x", "gather"), a = t(s, "indices", "gather", "int32"), c = { x: o, indices: a }, i = { axis: r, batchDims: e };
|
|
20
|
-
return h.runKernel(
|
|
20
|
+
return h.runKernel(x, c, i);
|
|
21
21
|
}
|
|
22
|
-
const d = /* @__PURE__ */ g({ gather_:
|
|
22
|
+
const d = /* @__PURE__ */ g({ gather_: p });
|
|
23
23
|
export {
|
|
24
24
|
d as g
|
|
25
25
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { i as t, e as n } from "./index-C0dhsYom.js";
|
|
2
|
+
import "./ops/cpu/gelu.js";
|
|
3
|
+
import "./ops/webgl/gelu.js";
|
|
4
|
+
const a = {
|
|
5
|
+
kernelName: "Gelu",
|
|
6
|
+
inputsToSave: ["x"],
|
|
7
|
+
outputsToSave: [],
|
|
8
|
+
gradFunc: (e, r) => {
|
|
9
|
+
const [u] = r;
|
|
10
|
+
return {
|
|
11
|
+
x: () => o(e, u)
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
t(a);
|
|
16
|
+
function g(e) {
|
|
17
|
+
return n().runKernel("Gelu", { x: e });
|
|
18
|
+
}
|
|
19
|
+
function o(e, r) {
|
|
20
|
+
return n().runKernel("GeluGrad", { dy: e, x: r });
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
a,
|
|
24
|
+
o as d,
|
|
25
|
+
g
|
|
26
|
+
};
|