@genai-fi/nanogpt 0.6.3 → 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.
Files changed (140) hide show
  1. package/dist/Generator.js +11 -11
  2. package/dist/NanoGPTModel.d.ts +2 -2
  3. package/dist/NanoGPTModel.js +104 -136
  4. package/dist/{RealDiv-BYViZwhN.js → RealDiv-C4hOvYOZ.js} +26 -25
  5. package/dist/{Reshape-t7Kcikjk.js → Reshape-BLijOA8h.js} +5 -5
  6. package/dist/TeachableLLM.js +5 -5
  7. package/dist/{TiedEmbedding-9WeDwvjO.js → TiedEmbedding-BLltddza.js} +4 -4
  8. package/dist/{axis_util-Bu4h7XWV.js → axis_util-DaAl5MER.js} +3 -3
  9. package/dist/backend.d.ts +1 -0
  10. package/dist/backend.js +7 -0
  11. package/dist/backend_util-DWiwsi2N.js +749 -0
  12. package/dist/{broadcast_to-DARN-DBD.js → broadcast_to-C4v-j9yA.js} +2 -2
  13. package/dist/{concat-5aPGqw3Z.js → concat-CsHeR4zV.js} +8 -8
  14. package/dist/{dataset-pgqp-YfL.js → dataset-JDyjG3QR.js} +3 -3
  15. package/dist/{dropout-Bciw46HT.js → dropout-hpDwECTe.js} +7 -7
  16. package/dist/{gather-DjyCjmOD.js → gather-D0_gPiBz.js} +4 -4
  17. package/dist/gelu-uyHP1x1f.js +26 -0
  18. package/dist/gpgpu_math-DJm3ZTAf.js +2371 -0
  19. package/dist/index-BPPzKVdR.js +12099 -0
  20. package/dist/{index-BAzbokzv.js → index-C0dhsYom.js} +405 -389
  21. package/dist/{kernel_funcs_utils-CUxJCg0g.js → kernel_funcs_utils-CwRTFqrc.js} +31 -30
  22. package/dist/layers/BaseLayer.js +2 -2
  23. package/dist/layers/CausalSelfAttention.js +6 -6
  24. package/dist/layers/MLP.js +5 -5
  25. package/dist/layers/RMSNorm.js +3 -3
  26. package/dist/layers/RoPECache.js +4 -4
  27. package/dist/layers/TiedEmbedding.js +5 -5
  28. package/dist/layers/TransformerBlock.js +1 -1
  29. package/dist/loader/loadTransformers.js +1 -1
  30. package/dist/loader/oldZipLoad.js +5 -5
  31. package/dist/{log_sum_exp-YEo2h3gb.js → log_sum_exp-D086OgZJ.js} +15 -15
  32. package/dist/main.d.ts +2 -0
  33. package/dist/main.js +9 -5
  34. package/dist/{mat_mul-7121rsJk.js → mat_mul-1nwdPkQ_.js} +4 -4
  35. package/dist/{max-DtlIuVeW.js → max-BQc2Aj-I.js} +4 -4
  36. package/dist/{mulmat_packed_gpu-D4nKF7Je.js → mulmat_packed_gpu-Gzf3I9UV.js} +1 -1
  37. package/dist/non_max_suppression_impl-CsEgBuMA.js +134 -0
  38. package/dist/{ones-BBlSRqn1.js → ones-D63HpSF_.js} +2 -2
  39. package/dist/ops/appendCache.js +3 -3
  40. package/dist/ops/attentionMask.js +1 -1
  41. package/dist/ops/cpu/appendCache.js +8 -8
  42. package/dist/ops/cpu/attentionMask.js +9 -9
  43. package/dist/ops/cpu/fusedSoftmax.js +17 -11
  44. package/dist/ops/cpu/gatherSub.js +7 -7
  45. package/dist/ops/cpu/gelu.js +13 -13
  46. package/dist/ops/cpu/matMulGelu.js +36 -24
  47. package/dist/ops/cpu/matMulMul.js +14 -8
  48. package/dist/ops/cpu/mulDropout.js +9 -3
  49. package/dist/ops/cpu/normRMS.js +5 -5
  50. package/dist/ops/cpu/qkv.js +3 -3
  51. package/dist/ops/cpu/rope.js +5 -5
  52. package/dist/ops/cpu/scatterSub.js +11 -11
  53. package/dist/ops/fusedSoftmax.js +1 -1
  54. package/dist/ops/gatherSub.js +1 -1
  55. package/dist/ops/gelu.js +2 -2
  56. package/dist/ops/grads/attentionMask.js +1 -1
  57. package/dist/ops/grads/fusedSoftmax.js +2 -2
  58. package/dist/ops/grads/gelu.js +3 -24
  59. package/dist/ops/grads/matMulGelu.js +5 -5
  60. package/dist/ops/grads/normRMS.js +6 -6
  61. package/dist/ops/grads/qkv.js +1 -1
  62. package/dist/ops/grads/rope.js +3 -3
  63. package/dist/ops/matMulGelu.js +1 -1
  64. package/dist/ops/matMulMul.js +1 -1
  65. package/dist/ops/mulDrop.js +1 -1
  66. package/dist/ops/normRMS.js +1 -1
  67. package/dist/ops/qkv.js +1 -1
  68. package/dist/ops/rope.js +4 -4
  69. package/dist/ops/scatterSub.js +1 -1
  70. package/dist/ops/webgl/appendCache.js +1 -1
  71. package/dist/ops/webgl/attentionMask.js +1 -1
  72. package/dist/ops/webgl/fusedSoftmax.js +4 -4
  73. package/dist/ops/webgl/gatherSub.js +1 -1
  74. package/dist/ops/webgl/gelu.js +2 -2
  75. package/dist/ops/webgl/log.js +5 -5
  76. package/dist/ops/webgl/matMulGelu.js +17 -17
  77. package/dist/ops/webgl/matMulMul.js +1 -1
  78. package/dist/ops/webgl/mulDropout.js +4 -4
  79. package/dist/ops/webgl/normRMS.js +2 -2
  80. package/dist/ops/webgl/qkv.js +1 -1
  81. package/dist/ops/webgl/rope.js +1 -1
  82. package/dist/ops/webgl/scatterSub.js +1 -1
  83. package/dist/ops/webgpu/appendCache.d.ts +1 -0
  84. package/dist/ops/webgpu/appendCache.js +56 -0
  85. package/dist/ops/webgpu/attentionMask.d.ts +1 -0
  86. package/dist/ops/webgpu/attentionMask.js +64 -0
  87. package/dist/ops/webgpu/gatherSub.d.ts +1 -0
  88. package/dist/ops/webgpu/gatherSub.js +37 -0
  89. package/dist/ops/webgpu/gelu.d.ts +14 -0
  90. package/dist/ops/webgpu/gelu.js +86 -0
  91. package/dist/ops/webgpu/index.d.ts +0 -0
  92. package/dist/ops/webgpu/index.js +8 -0
  93. package/dist/ops/webgpu/normRMS.d.ts +1 -0
  94. package/dist/ops/webgpu/normRMS.js +115 -0
  95. package/dist/ops/webgpu/qkv.d.ts +1 -0
  96. package/dist/ops/webgpu/qkv.js +56 -0
  97. package/dist/ops/webgpu/rope.d.ts +1 -0
  98. package/dist/ops/webgpu/rope.js +68 -0
  99. package/dist/ops/webgpu/scatterSub.d.ts +1 -0
  100. package/dist/ops/webgpu/scatterSub.js +37 -0
  101. package/dist/{ops-C0sQEcPw.js → ops-CIQLNshk.js} +452 -503
  102. package/dist/{random_width-DWzaOgrn.js → random_width-DkYP8W8N.js} +143 -144
  103. package/dist/{range-DYsrnfiy.js → range-CYzpQY53.js} +1 -1
  104. package/dist/{reciprocal-CJQeasVa.js → reciprocal-_A9yv27J.js} +1 -1
  105. package/dist/{register_all_kernels-BfFCQAqs.js → register_all_kernels-guvSxp7M.js} +202 -200
  106. package/dist/{reshape-krWGKraP.js → reshape-BMUzc1UY.js} +3 -3
  107. package/dist/{scatter_nd_util-93ln7Hut.js → scatter_nd_util-IRBqKz_b.js} +3 -3
  108. package/dist/{selu_util-sntGesxr.js → selu_util-Dt_iuXaq.js} +6 -6
  109. package/dist/shared-BNa2q6jD.js +69 -0
  110. package/dist/{shared-Ca6iDobD.js → shared-CDu9S76h.js} +541 -606
  111. package/dist/{sin-D_h-qCSx.js → sin-Cocju-BY.js} +6 -6
  112. package/dist/{softmax-fsdtf6JC.js → softmax-GPNK3o-U.js} +3 -3
  113. package/dist/{split-eiktj-6L.js → split-CHzJjxDv.js} +4 -4
  114. package/dist/{stack-dfEEz2OY.js → stack-Dpgg_1W1.js} +2 -2
  115. package/dist/{sum-BE_Irnim.js → sum-B8wEpKsg.js} +5 -5
  116. package/dist/{tensor-Xyi595sG.js → tensor-RvZVNmg0.js} +1 -1
  117. package/dist/{tensor2d-CPEkynbH.js → tensor2d-B_kyod7_.js} +1 -1
  118. package/dist/training/AdamExt.js +1 -1
  119. package/dist/training/DatasetBuilder.js +2 -2
  120. package/dist/training/Evaluator.js +1 -1
  121. package/dist/training/FullTrainer.js +20 -20
  122. package/dist/training/Trainer.d.ts +5 -6
  123. package/dist/training/Trainer.js +59 -60
  124. package/dist/training/sparseCrossEntropy.js +4 -4
  125. package/dist/utilities/dummy.js +19 -19
  126. package/dist/utilities/generate.js +15 -16
  127. package/dist/utilities/multinomialCPU.d.ts +2 -0
  128. package/dist/utilities/multinomialCPU.js +13 -0
  129. package/dist/utilities/performance.d.ts +2 -0
  130. package/dist/utilities/performance.js +16 -0
  131. package/dist/utilities/profile.d.ts +1 -0
  132. package/dist/utilities/profile.js +9 -6
  133. package/dist/utilities/safetensors.js +2 -2
  134. package/dist/utilities/weights.js +2 -2
  135. package/dist/{variable-wSS22xj5.js → variable-DXEUOwew.js} +1 -1
  136. package/dist/webgpu_util-g13LvDIv.js +625 -0
  137. package/dist/{zeros-YJDE7oRb.js → zeros-DCPCdFGq.js} +8 -8
  138. package/package.json +2 -1
  139. package/dist/gpgpu_math-CNslybmD.js +0 -3115
  140. package/dist/norm-CzltS9Fz.js +0 -86
@@ -1,5 +1,5 @@
1
- import { o as h, q as f, x as p, H as g, E as u, I as b } from "./index-BAzbokzv.js";
2
- import { r as T } from "./reshape-krWGKraP.js";
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 { o as s, i as a, w as i, H as p, E as l, J as f } from "./index-BAzbokzv.js";
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(o, e = 0) {
19
- a(o.length >= 1, () => "Pass at least one tensor to concat");
20
- const t = i(o, "tensors", "concat", "string_or_numeric");
21
- if (t[0].dtype === "complex64" && t.forEach((n) => {
22
- if (n.dtype !== "complex64")
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 ${n.dtype}. `);
24
+ with dtype ${o.dtype}. `);
25
25
  }), t.length === 1)
26
- return p(t[0]);
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 { ab as S, T as h, ac as N, d as v, ad as o, ae as p, af as g, i as k, t as y } from "./index-BAzbokzv.js";
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-dfEEz2OY.js";
4
- import { t as B } from "./tensor-Xyi595sG.js";
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 { o as l, q as h, E as m, ag as p, x as c, ah as d, ai as g, i as u, T as V, aj as v, a7 as N, a as w } from "./index-BAzbokzv.js";
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 y(r, t = 0, e = 1, s, n) {
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_: y });
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 $(t, e, null, n);
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 q = /* @__PURE__ */ l({ dropout_: R });
186
+ const G = /* @__PURE__ */ l({ dropout_: R });
187
187
  export {
188
188
  T as M,
189
189
  D as a,
190
- q as d,
190
+ G as d,
191
191
  b as f,
192
192
  _ as r
193
193
  };
@@ -1,4 +1,4 @@
1
- import { o as g, q as t, E as h, G as p } from "./index-BAzbokzv.js";
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 u(n, s, r = 0, e = 0) {
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(p, c, i);
20
+ return h.runKernel(x, c, i);
21
21
  }
22
- const d = /* @__PURE__ */ g({ gather_: u });
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
+ };