@genai-fi/nanogpt 1.6.0 → 1.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 (426) hide show
  1. package/dist/{binary_op_util-WY9YIl0q.js → Reshape-CqftURg0.js} +75 -60
  2. package/dist/TeachableLLM.d.ts +12 -12
  3. package/dist/api/beamer.d.ts +4 -4
  4. package/dist/api/responses.d.ts +4 -4
  5. package/dist/api/training.d.ts +9 -9
  6. package/dist/backend.d.ts +1 -1
  7. package/dist/backend_util-DZIc6pyV.js +1081 -0
  8. package/dist/checks/index.d.ts +11 -11
  9. package/dist/checks/weights.d.ts +1 -1
  10. package/dist/data/docx.d.ts +1 -1
  11. package/dist/data/pdf.d.ts +1 -1
  12. package/dist/data/stream.d.ts +1 -1
  13. package/dist/data/textLoader.d.ts +1 -1
  14. package/dist/data.d.ts +3 -3
  15. package/dist/device-CZPGtQBU.js +9 -0
  16. package/dist/device.d.ts +2 -0
  17. package/dist/{dist-DeVH1nGn.js → dist-DiszGjH-.js} +1833 -1844
  18. package/dist/{dist-CMMLi-qO.js → dist-JOPw9zTN.js} +69 -11
  19. package/dist/inference/Beamer.d.ts +3 -3
  20. package/dist/inference/Generator.d.ts +4 -4
  21. package/dist/inference/tokenisePrompt.d.ts +2 -2
  22. package/dist/inference/types.d.ts +1 -1
  23. package/dist/inference/utilities.d.ts +1 -1
  24. package/dist/layers/BaseLayer.d.ts +5 -4
  25. package/dist/layers/GQA.d.ts +24 -26
  26. package/dist/layers/HeadLayer.d.ts +2 -2
  27. package/dist/layers/LoRA.d.ts +1 -1
  28. package/dist/layers/MHA.d.ts +3 -4
  29. package/dist/layers/MLP.d.ts +2 -2
  30. package/dist/layers/PositionEmbedding.d.ts +3 -3
  31. package/dist/layers/RMSNorm.d.ts +2 -2
  32. package/dist/layers/RoPECache.d.ts +2 -1
  33. package/dist/layers/TiedEmbedding.d.ts +2 -2
  34. package/dist/layers/TransformerBlock.d.ts +9 -6
  35. package/dist/layers.d.ts +4 -4
  36. package/dist/loader/load.d.ts +1 -1
  37. package/dist/loader/loadHF.d.ts +3 -3
  38. package/dist/loader/loadTransformers.d.ts +2 -2
  39. package/dist/loader/loadZipMeta.d.ts +2 -2
  40. package/dist/loader/newZipLoad.d.ts +2 -2
  41. package/dist/loader/oldZipLoad.d.ts +4 -4
  42. package/dist/loader/save.d.ts +5 -5
  43. package/dist/loader/types.d.ts +23 -10
  44. package/dist/main.d.ts +40 -24
  45. package/dist/matMul16-CiMKJM8v.js +2610 -0
  46. package/dist/models/Llama.d.ts +2 -2
  47. package/dist/models/LoopNano.d.ts +16 -0
  48. package/dist/models/NanoGPTV1.d.ts +2 -2
  49. package/dist/models/NanoGPTV2.d.ts +2 -2
  50. package/dist/models/Qwen3.d.ts +2 -2
  51. package/dist/models/config.d.ts +11 -1
  52. package/dist/models/factory.d.ts +2 -2
  53. package/dist/models/model.d.ts +6 -6
  54. package/dist/models.d.ts +4 -4
  55. package/dist/nanogpt.js +37041 -0
  56. package/dist/ops/adamAdjust.d.ts +2 -0
  57. package/dist/ops/adamMoments.d.ts +2 -0
  58. package/dist/ops/adamW.d.ts +2 -0
  59. package/dist/ops/add16.d.ts +1 -0
  60. package/dist/ops/appendCache.d.ts +2 -0
  61. package/dist/ops/attentionMask.d.ts +11 -1
  62. package/dist/ops/dropout16.d.ts +2 -0
  63. package/dist/ops/gatherSub.d.ts +2 -0
  64. package/dist/ops/gelu.d.ts +3 -0
  65. package/dist/ops/log.d.ts +1 -0
  66. package/dist/ops/matMul16.d.ts +4 -0
  67. package/dist/ops/matMulGelu.d.ts +3 -0
  68. package/dist/ops/matMulMul.d.ts +2 -0
  69. package/dist/ops/mul16.d.ts +1 -0
  70. package/dist/ops/mulDrop.d.ts +2 -0
  71. package/dist/ops/normRMS.d.ts +3 -0
  72. package/dist/ops/pack16.d.ts +1 -0
  73. package/dist/ops/qkv.d.ts +13 -1
  74. package/dist/ops/rope.d.ts +4 -1
  75. package/dist/ops/scatterSub.d.ts +4 -1
  76. package/dist/ops/silu.d.ts +1 -0
  77. package/dist/ops/softmax16.d.ts +1 -0
  78. package/dist/ops/sparseCrossEntropy.d.ts +15 -0
  79. package/dist/ops/unpack16.d.ts +1 -0
  80. package/dist/ops/webgl/sparseCrossEntropy.d.ts +1 -0
  81. package/dist/ops/webgpu/adamW.d.ts +1 -0
  82. package/dist/ops/webgpu/concat16.d.ts +16 -0
  83. package/dist/ops/webgpu/index.d.ts +29 -0
  84. package/dist/ops/webgpu/normRMS16_program.d.ts +2 -2
  85. package/dist/ops/webgpu/normRMS32_program.d.ts +2 -2
  86. package/dist/ops/webgpu/pack16_program.d.ts +1 -1
  87. package/dist/ops/webgpu/softmax16_program.d.ts +16 -0
  88. package/dist/ops/webgpu/sparseCrossEntropy.d.ts +1 -0
  89. package/dist/ops/webgpu/utils/binary_op.d.ts +16 -0
  90. package/dist/ops/webgpu/utils/deviceInfo.d.ts +1 -1
  91. package/dist/ops/webgpu/utils/reductions.d.ts +1 -1
  92. package/dist/patches/webgpu_backend.d.ts +2 -1
  93. package/dist/patches/webgpu_base.d.ts +0 -1
  94. package/dist/patches/webgpu_program.d.ts +21 -0
  95. package/dist/{shared-BIDMUBCs.js → shared-BARkvvG4.js} +587 -505
  96. package/dist/tokenise.d.ts +4 -4
  97. package/dist/tokeniser/BaseTokeniser.d.ts +3 -3
  98. package/dist/tokeniser/CharTokeniser.d.ts +2 -2
  99. package/dist/tokeniser/bpe.d.ts +2 -2
  100. package/dist/tokeniser/type.d.ts +2 -2
  101. package/dist/training/AdamW.d.ts +19 -2
  102. package/dist/training/BasicTrainer.d.ts +5 -5
  103. package/dist/training/DatasetBuilder.d.ts +2 -2
  104. package/dist/training/Evaluator.d.ts +1 -1
  105. package/dist/training/LRScheduler.d.ts +1 -1
  106. package/dist/training/PreTrainer.d.ts +6 -6
  107. package/dist/training/SFTTrainer.d.ts +6 -6
  108. package/dist/training/configure.d.ts +2 -2
  109. package/dist/training/factory.d.ts +6 -5
  110. package/dist/training/prepareData.d.ts +6 -6
  111. package/dist/training/tasks/tokenStream.d.ts +3 -3
  112. package/dist/training/types.d.ts +6 -5
  113. package/dist/training/validateOptions.d.ts +1 -1
  114. package/dist/training/validation.d.ts +3 -3
  115. package/dist/utilities/datasetID.d.ts +1 -1
  116. package/dist/utilities/dummy.d.ts +1 -1
  117. package/dist/utilities/packed.d.ts +1 -1
  118. package/dist/utilities/parameters.d.ts +1 -1
  119. package/dist/utilities/sentences.d.ts +1 -1
  120. package/dist/utilities/waitForModel.d.ts +1 -1
  121. package/dist/webgpu-D4syGmzo.js +3221 -0
  122. package/dist/webgpu-wUCQopBN.js +1007 -0
  123. package/dist/{webgpu_program-DvkFqRlR.js → webgpu_backend-CzY9TzvA.js} +174 -223
  124. package/dist/{patches/webgpu_base.js → webgpu_base-Bjg7okYf.js} +6 -9
  125. package/package.json +12 -9
  126. package/dist/DatasetBuilder-DRDW8tcM.js +0 -731
  127. package/dist/Generator-BcR_14Cj.js +0 -316
  128. package/dist/RealDiv-Cl8k3YTx.js +0 -354
  129. package/dist/Reshape-CKxKPKqi.js +0 -91
  130. package/dist/Reshape-H5zZRgr9.js +0 -16
  131. package/dist/RoPECache-dYscFINl.js +0 -722
  132. package/dist/TeachableLLM.js +0 -220
  133. package/dist/api/beamer.js +0 -61
  134. package/dist/api/responses.js +0 -177
  135. package/dist/api/training.js +0 -215
  136. package/dist/axis_util-rF9RnwKE.js +0 -37
  137. package/dist/backend.js +0 -12
  138. package/dist/backend_util-Cpp0Gwlp.js +0 -394
  139. package/dist/broadcast_to-CGvLNiQ0.js +0 -20
  140. package/dist/checks/appendCache.js +0 -55
  141. package/dist/checks/attentionMask.js +0 -57
  142. package/dist/checks/check.js +0 -31
  143. package/dist/checks/gelu.js +0 -46
  144. package/dist/checks/index.js +0 -27
  145. package/dist/checks/matMulGelu.js +0 -84
  146. package/dist/checks/normRMS.js +0 -30
  147. package/dist/checks/normRMSGrad.js +0 -23
  148. package/dist/checks/packUnpack.js +0 -46
  149. package/dist/checks/qkv.js +0 -1
  150. package/dist/checks/rope.js +0 -30
  151. package/dist/checks/weights.js +0 -26
  152. package/dist/clip_by_value-D-UX9am5.js +0 -13
  153. package/dist/complex-Cl904TqN.js +0 -13
  154. package/dist/complex_util-BBlPAm-s.js +0 -59
  155. package/dist/concat-Oip5acVY.js +0 -14
  156. package/dist/concat_util-CY45Hf4F.js +0 -18
  157. package/dist/data/docx.js +0 -17
  158. package/dist/data/pdf.js +0 -14
  159. package/dist/data/stream.js +0 -1
  160. package/dist/data/textLoader.js +0 -575
  161. package/dist/data-CV_i_H6B.js +0 -11
  162. package/dist/data.js +0 -5
  163. package/dist/dist-DyL7qSLJ.js +0 -7809
  164. package/dist/dropout16-CA31Ud5a.js +0 -20
  165. package/dist/dropout_util-SiFMbFXz.js +0 -22
  166. package/dist/eventemitter3-wmfmOP_f.js +0 -90
  167. package/dist/expand_dims-Dh3Fulyn.js +0 -10
  168. package/dist/floor-BwjmUb7X.js +0 -8
  169. package/dist/gather-B5Z1RFt5.js +0 -14
  170. package/dist/gatherSub-CRUfUzBa.js +0 -22
  171. package/dist/gelu-Xx9-ohH9.js +0 -25
  172. package/dist/gpgpu_math-48m8q3jI.js +0 -1591
  173. package/dist/inference/Beamer.js +0 -215
  174. package/dist/inference/Generator.js +0 -1
  175. package/dist/inference/tokenisePrompt.js +0 -17
  176. package/dist/inference/types.js +0 -0
  177. package/dist/inference/utilities.js +0 -31
  178. package/dist/jszip.min-Btv48m44.js +0 -3037
  179. package/dist/kernel_funcs_utils-BYRpSfV_.js +0 -229
  180. package/dist/layers/BaseLayer.js +0 -75
  181. package/dist/layers/GQA.js +0 -102
  182. package/dist/layers/HeadLayer.js +0 -28
  183. package/dist/layers/LoRA.js +0 -45
  184. package/dist/layers/MHA.js +0 -102
  185. package/dist/layers/MLP.js +0 -47
  186. package/dist/layers/PositionEmbedding.js +0 -28
  187. package/dist/layers/RMSNorm.js +0 -25
  188. package/dist/layers/RoPECache.js +0 -1
  189. package/dist/layers/TiedEmbedding.js +0 -33
  190. package/dist/layers/TransformerBlock.js +0 -50
  191. package/dist/layers/WeightStore.js +0 -68
  192. package/dist/layers-CFqEip3s.js +0 -13
  193. package/dist/layers.js +0 -6
  194. package/dist/loader/load.js +0 -63
  195. package/dist/loader/loadHF.js +0 -17
  196. package/dist/loader/loadTransformers.js +0 -61
  197. package/dist/loader/loadZipMeta.js +0 -15
  198. package/dist/loader/newZipLoad.js +0 -24
  199. package/dist/loader/oldZipLoad.js +0 -36
  200. package/dist/loader/save.js +0 -89
  201. package/dist/loader/types.js +0 -0
  202. package/dist/main.js +0 -12145
  203. package/dist/matMul16-tE26fnhf.js +0 -87
  204. package/dist/matMulGelu-ASUWlKqu.js +0 -162
  205. package/dist/mat_mul-R9_DWmIT.js +0 -16
  206. package/dist/models/Llama.js +0 -88
  207. package/dist/models/NanoGPTV1.js +0 -94
  208. package/dist/models/NanoGPTV2.js +0 -85
  209. package/dist/models/Qwen3.js +0 -88
  210. package/dist/models/config.js +0 -32
  211. package/dist/models/factory.js +0 -16
  212. package/dist/models/model.js +0 -75
  213. package/dist/models-DyBpJJwM.js +0 -13
  214. package/dist/models.js +0 -6
  215. package/dist/mul16-C7sqgqik.js +0 -41
  216. package/dist/non_max_suppression_impl-B0H318rb.js +0 -72
  217. package/dist/not_equal-Bu3O8rh_.js +0 -67
  218. package/dist/one_hot-TEMPumJj.js +0 -14
  219. package/dist/ones-DpPXWa6A.js +0 -13
  220. package/dist/ops/adamAdjust.js +0 -17
  221. package/dist/ops/adamMoments.js +0 -15
  222. package/dist/ops/add16.js +0 -11
  223. package/dist/ops/appendCache.js +0 -26
  224. package/dist/ops/attentionMask.js +0 -19
  225. package/dist/ops/concat16.js +0 -8
  226. package/dist/ops/cpu/adamAdjust.js +0 -15
  227. package/dist/ops/cpu/adamMoments.js +0 -16
  228. package/dist/ops/cpu/appendCache.js +0 -65
  229. package/dist/ops/cpu/attentionMask.js +0 -20
  230. package/dist/ops/cpu/fusedSoftmax.js +0 -22
  231. package/dist/ops/cpu/gatherSub.js +0 -1
  232. package/dist/ops/cpu/gelu.js +0 -35
  233. package/dist/ops/cpu/matMul16.js +0 -14
  234. package/dist/ops/cpu/matMulGelu.js +0 -44
  235. package/dist/ops/cpu/matMulMul.js +0 -19
  236. package/dist/ops/cpu/mulDropout.js +0 -19
  237. package/dist/ops/cpu/normRMS.js +0 -34
  238. package/dist/ops/cpu/qkv.js +0 -74
  239. package/dist/ops/cpu/rope.js +0 -84
  240. package/dist/ops/cpu/scatterSub.js +0 -1
  241. package/dist/ops/dot16.js +0 -28
  242. package/dist/ops/dropout.js +0 -12
  243. package/dist/ops/dropout16.js +0 -1
  244. package/dist/ops/gatherSub.js +0 -12
  245. package/dist/ops/gelu.js +0 -1
  246. package/dist/ops/globalNorm.js +0 -19
  247. package/dist/ops/grads/add16.js +0 -26
  248. package/dist/ops/grads/attentionMask.js +0 -25
  249. package/dist/ops/grads/dropout16.js +0 -1
  250. package/dist/ops/grads/gelu.js +0 -1
  251. package/dist/ops/grads/matMul16.js +0 -1
  252. package/dist/ops/grads/matMulGelu.js +0 -21
  253. package/dist/ops/grads/mul16.js +0 -1
  254. package/dist/ops/grads/normRMS.js +0 -36
  255. package/dist/ops/grads/pack16.js +0 -1
  256. package/dist/ops/grads/qkv.js +0 -46
  257. package/dist/ops/grads/rope.js +0 -1
  258. package/dist/ops/grads/silu.js +0 -1
  259. package/dist/ops/grads/softmax16.js +0 -22
  260. package/dist/ops/grads/unpack16.js +0 -1
  261. package/dist/ops/grads/utils.js +0 -11
  262. package/dist/ops/log.js +0 -1
  263. package/dist/ops/matMul16.js +0 -1
  264. package/dist/ops/matMulGelu.js +0 -19
  265. package/dist/ops/matMulMul.js +0 -15
  266. package/dist/ops/mul16.js +0 -1
  267. package/dist/ops/mulDrop.js +0 -14
  268. package/dist/ops/normRMS.js +0 -21
  269. package/dist/ops/pack16.js +0 -1
  270. package/dist/ops/qkv.js +0 -15
  271. package/dist/ops/reshape16.js +0 -33
  272. package/dist/ops/rope.js +0 -1
  273. package/dist/ops/scatterSub.js +0 -12
  274. package/dist/ops/silu.js +0 -1
  275. package/dist/ops/slice16.js +0 -11
  276. package/dist/ops/softmax16.js +0 -8
  277. package/dist/ops/sub16.js +0 -10
  278. package/dist/ops/sum16.js +0 -13
  279. package/dist/ops/transpose16.js +0 -33
  280. package/dist/ops/unpack16.js +0 -1
  281. package/dist/ops/webgl/adamAdjust.js +0 -81
  282. package/dist/ops/webgl/adamMoments.js +0 -43
  283. package/dist/ops/webgl/appendCache.js +0 -52
  284. package/dist/ops/webgl/attentionMask.js +0 -63
  285. package/dist/ops/webgl/dropout16.js +0 -11
  286. package/dist/ops/webgl/fusedSoftmax.js +0 -70
  287. package/dist/ops/webgl/gatherSub.js +0 -27
  288. package/dist/ops/webgl/gelu.js +0 -47
  289. package/dist/ops/webgl/log.js +0 -14
  290. package/dist/ops/webgl/matMul16.js +0 -48
  291. package/dist/ops/webgl/matMulGelu.js +0 -1
  292. package/dist/ops/webgl/matMulMul.js +0 -23
  293. package/dist/ops/webgl/mulDropout.js +0 -31
  294. package/dist/ops/webgl/normRMS.js +0 -115
  295. package/dist/ops/webgl/qkv.js +0 -53
  296. package/dist/ops/webgl/rope.js +0 -73
  297. package/dist/ops/webgl/scatterSub.js +0 -27
  298. package/dist/ops/webgpu/adamAdjust.js +0 -76
  299. package/dist/ops/webgpu/adamMoments.js +0 -75
  300. package/dist/ops/webgpu/add16.js +0 -13
  301. package/dist/ops/webgpu/appendCache.js +0 -129
  302. package/dist/ops/webgpu/attentionMask.js +0 -41
  303. package/dist/ops/webgpu/attentionMask32_program.js +0 -61
  304. package/dist/ops/webgpu/clipScale.js +0 -44
  305. package/dist/ops/webgpu/concat16.js +0 -110
  306. package/dist/ops/webgpu/dropout16.js +0 -58
  307. package/dist/ops/webgpu/gatherSub.js +0 -51
  308. package/dist/ops/webgpu/gelu.js +0 -146
  309. package/dist/ops/webgpu/index.js +0 -27
  310. package/dist/ops/webgpu/matMul16.js +0 -91
  311. package/dist/ops/webgpu/matMul16_program.js +0 -311
  312. package/dist/ops/webgpu/mul16.js +0 -13
  313. package/dist/ops/webgpu/norm2.js +0 -45
  314. package/dist/ops/webgpu/normRMS.js +0 -25
  315. package/dist/ops/webgpu/normRMS16_program.js +0 -28
  316. package/dist/ops/webgpu/normRMS32_program.js +0 -28
  317. package/dist/ops/webgpu/normRMSGrad.js +0 -225
  318. package/dist/ops/webgpu/pack16.js +0 -20
  319. package/dist/ops/webgpu/pack16_program.js +0 -92
  320. package/dist/ops/webgpu/qkv.js +0 -63
  321. package/dist/ops/webgpu/rope.js +0 -227
  322. package/dist/ops/webgpu/scatterSub.js +0 -52
  323. package/dist/ops/webgpu/silu.js +0 -117
  324. package/dist/ops/webgpu/slice16.js +0 -73
  325. package/dist/ops/webgpu/softmax16.js +0 -18
  326. package/dist/ops/webgpu/softmax16_program.js +0 -88
  327. package/dist/ops/webgpu/softmax16_subgroup_program.js +0 -69
  328. package/dist/ops/webgpu/softmax16grad.js +0 -30
  329. package/dist/ops/webgpu/sub16.js +0 -13
  330. package/dist/ops/webgpu/sum16.js +0 -30
  331. package/dist/ops/webgpu/transpose16.js +0 -38
  332. package/dist/ops/webgpu/transpose16_program.js +0 -50
  333. package/dist/ops/webgpu/transpose16_shared_program.js +0 -78
  334. package/dist/ops/webgpu/unpack16.js +0 -59
  335. package/dist/ops/webgpu/utils/binary_op.js +0 -140
  336. package/dist/ops/webgpu/utils/deviceInfo.js +0 -10
  337. package/dist/ops/webgpu/utils/reductions.js +0 -264
  338. package/dist/ops-Be5ACU5R.js +0 -13
  339. package/dist/ops-C1UpdEYM.js +0 -509
  340. package/dist/pack16-BHO4t1-M.js +0 -36
  341. package/dist/pad-Dy-1IP3A.js +0 -13
  342. package/dist/patches/webgpu_backend.js +0 -42
  343. package/dist/patches/webgpu_program.js +0 -292
  344. package/dist/picomatch--TW6gyBJ.js +0 -999
  345. package/dist/qkv-BQfNPucX.js +0 -42
  346. package/dist/rand_util-_vCY93Uw.js +0 -44
  347. package/dist/random_normal-DUIT8kyC.js +0 -11
  348. package/dist/range-CYvQC3fW.js +0 -13
  349. package/dist/relu-C4XULT8A.js +0 -8
  350. package/dist/reshape-DJb1jgMt.js +0 -8
  351. package/dist/resize_nearest_neighbor-DAqcTYUe.js +0 -188
  352. package/dist/rope-JjBVufF_.js +0 -24
  353. package/dist/scatterSub-BOnqk-uY.js +0 -27
  354. package/dist/scatter_nd_util-BepMCpLY.js +0 -34
  355. package/dist/seedrandom-SHEGFK6H.js +0 -282
  356. package/dist/selu_util-DeOTf-sc.js +0 -27
  357. package/dist/shared-CX_iPI5K.js +0 -4
  358. package/dist/silu-DsAE2cJ5.js +0 -23
  359. package/dist/slice-Dlb1FlzG.js +0 -13
  360. package/dist/slice_util-BVgPRoij.js +0 -207
  361. package/dist/softmax-Dpav_dWw.js +0 -10
  362. package/dist/split-DYnT8chz.js +0 -11
  363. package/dist/squeeze-B3XYGAlg.js +0 -9
  364. package/dist/stack-Dbbt9mIk.js +0 -10
  365. package/dist/step-DA-5DNu9.js +0 -348
  366. package/dist/stream-BBe2apn4.js +0 -2280
  367. package/dist/sum-C8qNbFNp.js +0 -13
  368. package/dist/tensor-ALxWZfmz.js +0 -7
  369. package/dist/tensor1d-BHgkkhTE.js +0 -9
  370. package/dist/tensor2d-ARItvqVn.js +0 -10
  371. package/dist/tensor4d-D1zRBipJ.js +0 -10
  372. package/dist/tfjs_backend-CsXOum0h.js +0 -685
  373. package/dist/tile-DfyQ0KX-.js +0 -10
  374. package/dist/tokenise-DbS2Ea-T.js +0 -14
  375. package/dist/tokenise.js +0 -6
  376. package/dist/tokeniser/BaseTokeniser.js +0 -137
  377. package/dist/tokeniser/CharTokeniser.js +0 -85
  378. package/dist/tokeniser/bpe.js +0 -156
  379. package/dist/tokeniser/messages.js +0 -0
  380. package/dist/tokeniser/type.js +0 -0
  381. package/dist/topk-BrU2pkrR.js +0 -19
  382. package/dist/training/AdamW.js +0 -132
  383. package/dist/training/BasicTrainer.js +0 -274
  384. package/dist/training/DatasetBuilder.js +0 -1
  385. package/dist/training/Evaluator.js +0 -51
  386. package/dist/training/LRScheduler.js +0 -37
  387. package/dist/training/PreTrainer.js +0 -21
  388. package/dist/training/SFTTrainer.js +0 -23
  389. package/dist/training/configure.js +0 -33
  390. package/dist/training/factory.js +0 -7
  391. package/dist/training/loss.js +0 -18
  392. package/dist/training/orthoGrad.js +0 -9
  393. package/dist/training/prepareData.js +0 -51
  394. package/dist/training/sparseCrossEntropy.js +0 -53
  395. package/dist/training/tasks/TokenStore.js +0 -217
  396. package/dist/training/tasks/tokenStream.js +0 -45
  397. package/dist/training/types.js +0 -0
  398. package/dist/training/validateOptions.js +0 -18
  399. package/dist/training/validation.js +0 -30
  400. package/dist/transpose-BC-M_OoT.js +0 -34
  401. package/dist/unsorted_segment_sum-BelC7R-q.js +0 -408
  402. package/dist/utilities/arrayClose.js +0 -29
  403. package/dist/utilities/arrayShape.js +0 -7
  404. package/dist/utilities/datasetID.js +0 -17
  405. package/dist/utilities/dummy.js +0 -36
  406. package/dist/utilities/float16.js +0 -46
  407. package/dist/utilities/maxHeap.js +0 -54
  408. package/dist/utilities/multinomialCPU.js +0 -7
  409. package/dist/utilities/naming.js +0 -0
  410. package/dist/utilities/packed.js +0 -12
  411. package/dist/utilities/parameters.js +0 -53
  412. package/dist/utilities/performance.js +0 -15
  413. package/dist/utilities/profile.js +0 -32
  414. package/dist/utilities/random.js +0 -18
  415. package/dist/utilities/safetensors.js +0 -63
  416. package/dist/utilities/sentences.js +0 -35
  417. package/dist/utilities/tokenParse.js +0 -16
  418. package/dist/utilities/tokens.js +0 -39
  419. package/dist/utilities/topP.js +0 -25
  420. package/dist/utilities/waitForModel.js +0 -11
  421. package/dist/utilities/weights.js +0 -40
  422. package/dist/utilities/yielder.js +0 -6
  423. package/dist/v4-YCkfo8OR.js +0 -27
  424. package/dist/webgpu-BHX-uBym.js +0 -518
  425. package/dist/webgpu_util-5QTyovaf.js +0 -105
  426. package/dist/zeros-hxKGkRfl.js +0 -12
@@ -1,408 +0,0 @@
1
- import { Ar as e, Br as t, C as n, Dt as r, En as i, Lr as a, N as o, Ni as s, Nr as c, O as l, Pt as u, Q as d, Qt as f, Ur as p, Wr as m, Xt as h, Yn as g, Z as _, an as v, cn as ee, dr as te, in as y, m as b, mi as x, nn as S, oi as C, p as w, qn as ne, rt as T, st as re, vn as ie, yi as E, zt as D } from "./dist-CMMLi-qO.js";
2
- import { g as O, h as k, s as A } from "./step-DA-5DNu9.js";
3
- import { t as j } from "./reshape-DJb1jgMt.js";
4
- import { a as M, i as N, o as P } from "./not_equal-Bu3O8rh_.js";
5
- import { t as F } from "./sum-C8qNbFNp.js";
6
- // node_modules/@tensorflow/tfjs-core/dist/ops/all.js
7
- function I(e, t = null, n = !1) {
8
- let r = { x: d(e, "x", "all", "bool") }, i = {
9
- axis: t,
10
- keepDims: n
11
- };
12
- return T.runKernel("All", r, i);
13
- }
14
- var L = /* @__PURE__ */ _({ all_: I });
15
- // node_modules/@tensorflow/tfjs-core/dist/ops/any.js
16
- function R(e, t = null, n = !1) {
17
- let r = { x: d(e, "x", "any", "bool") }, i = {
18
- axis: t,
19
- keepDims: n
20
- };
21
- return T.runKernel("Any", r, i);
22
- }
23
- var z = /* @__PURE__ */ _({ any_: R });
24
- // node_modules/@tensorflow/tfjs-core/dist/ops/arg_max.js
25
- function B(e, t = 0) {
26
- let n = { x: d(e, "x", "argMax") }, i = { axis: t };
27
- return T.runKernel(r, n, i);
28
- }
29
- var V = /* @__PURE__ */ _({ argMax_: B });
30
- // node_modules/@tensorflow/tfjs-core/dist/ops/avg_pool.js
31
- function H(e, t, n, r, i) {
32
- let a = d(e, "x", "avgPool", "float32");
33
- E(k(n, 1), () => `Error in avgPool: Either strides or dilations must be 1. Got strides ${n} and dilations '1'`);
34
- let s = a, c = !1;
35
- a.rank === 3 && (c = !0, s = j(a, [
36
- 1,
37
- a.shape[0],
38
- a.shape[1],
39
- a.shape[2]
40
- ])), E(s.rank === 4, () => `Error in avgPool: x must be rank 4 but got rank ${s.rank}.`), A("avgPool", r, i);
41
- let l = { x: s }, f = {
42
- filterSize: t,
43
- strides: n,
44
- pad: r,
45
- dimRoundingMode: i
46
- }, p = T.runKernel(u, l, f);
47
- return p = o(p, a.dtype), c ? j(p, [
48
- p.shape[1],
49
- p.shape[2],
50
- p.shape[3]
51
- ]) : p;
52
- }
53
- var U = /* @__PURE__ */ _({ avgPool_: H });
54
- // node_modules/@tensorflow/tfjs-core/dist/ops/tanh.js
55
- function W(e) {
56
- let t = { x: d(e, "x", "tanh", "float32") };
57
- return T.runKernel(C, t);
58
- }
59
- var G = /* @__PURE__ */ _({ tanh_: W });
60
- // node_modules/@tensorflow/tfjs-core/dist/ops/batch_to_space_nd.js
61
- function K(e, t, n) {
62
- let r = d(e, "x", "batchToSpaceND"), i = t.reduce((e, t) => e * t);
63
- E(r.rank >= 1 + t.length, () => `input rank is ${r.rank} but should be > than blockShape.length ${t.length}`), E(n.length === t.length, () => `crops.length is ${n.length} but should be equal to blockShape.length ${t.length}`), E(r.shape[0] % i === 0, () => `input tensor batch is ${r.shape[0]} but is not divisible by the product of the elements of blockShape ${t.join(" * ")} === ${i}`);
64
- let a = { x: r }, o = {
65
- blockShape: t,
66
- crops: n
67
- };
68
- return T.runKernel(D, a, o);
69
- }
70
- var q = /* @__PURE__ */ _({ batchToSpaceND_: K });
71
- // node_modules/@tensorflow/tfjs-core/dist/ops/batchnorm_util.js
72
- function J(e) {
73
- let t;
74
- return t = e.rank === 0 || e.rank === 1 ? j(e, [
75
- 1,
76
- 1,
77
- 1,
78
- e.size
79
- ]) : e.rank === 2 ? j(e, [
80
- 1,
81
- 1,
82
- e.shape[0],
83
- e.shape[1]
84
- ]) : e.rank === 3 ? j(e, [
85
- 1,
86
- e.shape[0],
87
- e.shape[1],
88
- e.shape[2]
89
- ]) : e, t;
90
- }
91
- // node_modules/@tensorflow/tfjs-core/dist/ops/batchnorm.js
92
- function Y(e, t, n, r, a, o) {
93
- o ??= .001;
94
- let s = d(e, "x", "batchNorm"), c = d(t, "mean", "batchNorm"), l = d(n, "variance", "batchNorm"), u;
95
- a != null && (u = d(a, "scale", "batchNorm"));
96
- let f;
97
- r != null && (f = d(r, "offset", "batchNorm")), E(c.rank === l.rank, () => "Batch normalization gradient requires mean and variance to have equal ranks."), E(f == null || c.rank === f.rank, () => "Batch normalization gradient requires mean and offset to have equal ranks."), E(u == null || c.rank === u.rank, () => "Batch normalization gradient requires mean and scale to have equal ranks.");
98
- let p = {
99
- x: J(s),
100
- scale: u,
101
- offset: f,
102
- mean: c,
103
- variance: l
104
- }, m = { varianceEpsilon: o }, h = T.runKernel(i, p, m);
105
- return j(h, s.shape);
106
- }
107
- var ae = /* @__PURE__ */ _({ batchNorm_: Y });
108
- // node_modules/@tensorflow/tfjs-core/dist/ops/conv2d.js
109
- function oe(e, t, n, r, i = "NHWC", a = [1, 1], o) {
110
- let s = d(e, "x", "conv2d", "float32"), c = d(t, "filter", "conv2d", "float32"), l = s, u = !1;
111
- s.rank === 3 && (u = !0, l = j(s, [
112
- 1,
113
- s.shape[0],
114
- s.shape[1],
115
- s.shape[2]
116
- ])), E(l.rank === 4, () => `Error in conv2d: input must be rank 4, but got rank ${l.rank}.`), E(c.rank === 4, () => `Error in conv2d: filter must be rank 4, but got rank ${c.rank}.`), A("conv2d", r, o);
117
- let f = i === "NHWC" ? l.shape[3] : l.shape[1];
118
- E(f === c.shape[2], () => `Error in conv2d: depth of input (${f}) must match input depth for filter ${c.shape[2]}.`), E(k(n, a), () => `Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${a}'`), E(O(a), () => "Error in conv2D: Dilated rates should be larger than 0."), E(O(n), () => "Error in conv2D: Strides should be larger than 0.");
119
- let p = {
120
- x: l,
121
- filter: c
122
- }, m = {
123
- strides: n,
124
- pad: r,
125
- dataFormat: i,
126
- dilations: a,
127
- dimRoundingMode: o
128
- }, g = T.runKernel(h, p, m);
129
- return u ? j(g, [
130
- g.shape[1],
131
- g.shape[2],
132
- g.shape[3]
133
- ]) : g;
134
- }
135
- var X = /* @__PURE__ */ _({ conv2d_: oe });
136
- // node_modules/@tensorflow/tfjs-core/dist/ops/conv1d.js
137
- function se(e, t, n, r, i = "NWC", a = 1, o) {
138
- let s = d(e, "x", "conv1d"), c = d(t, "filter", "conv1d"), l = s, u = !1;
139
- s.rank === 2 && (u = !0, l = j(s, [
140
- 1,
141
- s.shape[0],
142
- s.shape[1]
143
- ])), E(l.rank === 3, () => `Error in conv1d: input must be rank 3, but got rank ${l.rank}.`), E(c.rank === 3, () => `Error in conv1d: filter must be rank 3, but got rank ${c.rank}.`), A("conv1d", r, o), E(l.shape[2] === c.shape[1], () => `Error in conv1d: depth of input (${l.shape[2]}) must match input depth for filter ${c.shape[1]}.`), E(k(n, a), () => `Error in conv1D: Either stride or dilation must be 1. Got stride ${n} and dilation '${a}'`), E(O(a), () => "Error in conv1D: Dilated rates should be larger than 0."), E(O(n), () => "Error in conv1D: Stride should be larger than 0."), E(i === "NWC", () => `Error in conv1d: got dataFormat of ${i} but only NWC is currently supported.`);
144
- let f = j(c, [
145
- 1,
146
- c.shape[0],
147
- c.shape[1],
148
- c.shape[2]
149
- ]), p = X(j(l, [
150
- l.shape[0],
151
- 1,
152
- l.shape[1],
153
- l.shape[2]
154
- ]), f, [1, n], r, "NHWC", [1, a], o);
155
- return u ? j(p, [p.shape[2], p.shape[3]]) : j(p, [
156
- p.shape[0],
157
- p.shape[2],
158
- p.shape[3]
159
- ]);
160
- }
161
- var ce = /* @__PURE__ */ _({ conv1d_: se });
162
- // node_modules/@tensorflow/tfjs-core/dist/ops/conv2d_backprop_input.js
163
- function le(e, t, n, r, i, a = "NHWC", o) {
164
- E(e.length === t.rank, () => `Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`);
165
- let s = e, c = t, l = !1;
166
- t.rank === 3 && (l = !0, c = j(t, [
167
- 1,
168
- t.shape[0],
169
- t.shape[1],
170
- t.shape[2]
171
- ]), s = [
172
- 1,
173
- e[0],
174
- e[1],
175
- e[2]
176
- ]), E(s.length === 4, () => `Error in conv2dDerInput: inShape must be length 4, but got length ${s.length}.`), E(c.rank === 4, () => `Error in conv2dDerInput: dy must be rank 4, but got rank ${c.rank}`), E(n.rank === 4, () => `Error in conv2dDerInput: filter must be rank 4, but got rank ${n.rank}`);
177
- let u = a === "NHWC" ? s[3] : s[1], d = a === "NHWC" ? c.shape[3] : c.shape[1];
178
- E(u === n.shape[2], () => `Error in conv2dDerInput: depth of input (${u}) must match input depth for filter ${n.shape[2]}.`), E(d === n.shape[3], () => `Error in conv2dDerInput: depth of output (${d}) must match output depth for filter ${n.shape[3]}.`), A("conv2dDerInput", i, o);
179
- let p = {
180
- dy: c,
181
- filter: n
182
- }, m = {
183
- strides: r,
184
- pad: i,
185
- dataFormat: a,
186
- dimRoundingMode: o,
187
- inputShape: s
188
- }, h = T.runKernel(f, p, m);
189
- return l ? j(h, [
190
- h.shape[1],
191
- h.shape[2],
192
- h.shape[3]
193
- ]) : h;
194
- }
195
- var Z = /* @__PURE__ */ _({ conv2DBackpropInput_: le });
196
- // node_modules/@tensorflow/tfjs-core/dist/ops/conv2d_transpose.js
197
- function ue(e, t, n, r, i, a) {
198
- return Z(n, d(e, "x", "conv2dTranspose"), d(t, "filter", "conv2dTranspose"), r, i, "NHWC", a);
199
- }
200
- var de = /* @__PURE__ */ _({ conv2dTranspose_: ue });
201
- // node_modules/@tensorflow/tfjs-core/dist/ops/cos.js
202
- function fe(e) {
203
- let t = { x: d(e, "x", "cos", "float32") };
204
- return T.runKernel("Cos", t);
205
- }
206
- var pe = /* @__PURE__ */ _({ cos_: fe });
207
- // node_modules/@tensorflow/tfjs-core/dist/ops/cosh.js
208
- function me(e) {
209
- let t = { x: d(e, "x", "cosh", "float32") };
210
- return T.runKernel(S, t);
211
- }
212
- var he = /* @__PURE__ */ _({ cosh_: me });
213
- // node_modules/@tensorflow/tfjs-core/dist/ops/cumprod.js
214
- function ge(e, t = 0, n = !1, r = !1) {
215
- let i = { x: d(e, "x", "cumprod") }, a = {
216
- axis: t,
217
- exclusive: n,
218
- reverse: r
219
- };
220
- return T.runKernel(y, i, a);
221
- }
222
- var _e = /* @__PURE__ */ _({ cumprod_: ge });
223
- // node_modules/@tensorflow/tfjs-core/dist/ops/cumsum.js
224
- function ve(e, t = 0, n = !1, r = !1) {
225
- let i = { x: d(e, "x", "cumsum") }, a = {
226
- axis: t,
227
- exclusive: n,
228
- reverse: r
229
- };
230
- return T.runKernel(v, i, a);
231
- }
232
- var ye = /* @__PURE__ */ _({ cumsum_: ve });
233
- // node_modules/@tensorflow/tfjs-core/dist/ops/depthwise_conv2d.js
234
- function be(e, t, n, r, i = "NHWC", a = [1, 1], o) {
235
- let s = d(e, "x", "depthwiseConv2d", "float32"), c = d(t, "filter", "depthwiseConv2d", "float32"), l = s, u = !1;
236
- s.rank === 3 && (u = !0, l = j(s, [
237
- 1,
238
- s.shape[0],
239
- s.shape[1],
240
- s.shape[2]
241
- ])), E(l.rank === 4, () => `Error in depthwiseConv2d: input must be rank 4, but got rank ${l.rank}.`), E(c.rank === 4, () => `Error in depthwiseConv2d: filter must be rank 4, but got rank ${c.rank}.`);
242
- let f = i === "NHWC" ? l.shape[3] : l.shape[1];
243
- E(f === c.shape[2], () => `Error in depthwiseConv2d: number of input channels (${f}) must match the inChannels dimension in filter ${c.shape[2]}.`), A("depthwiseConv2d", r, o);
244
- let p = {
245
- x: l,
246
- filter: c
247
- }, m = {
248
- strides: n,
249
- pad: r,
250
- dataFormat: i,
251
- dilations: a,
252
- dimRoundingMode: o
253
- }, h = T.runKernel(ee, p, m);
254
- return u ? j(h, [
255
- h.shape[1],
256
- h.shape[2],
257
- h.shape[3]
258
- ]) : h;
259
- }
260
- var Q = /* @__PURE__ */ _({ depthwiseConv2d_: be });
261
- // node_modules/@tensorflow/tfjs-core/dist/ops/equal.js
262
- function xe(e, t) {
263
- let r = d(e, "a", "equal", "string_or_numeric"), i = d(t, "b", "equal", "string_or_numeric");
264
- [r, i] = re(r, i), n(r.shape, i.shape);
265
- let a = {
266
- a: r,
267
- b: i
268
- };
269
- return T.runKernel(ie, a);
270
- }
271
- var Se = /* @__PURE__ */ _({ equal_: xe });
272
- // node_modules/@tensorflow/tfjs-core/dist/ops/erf.js
273
- function Ce(e) {
274
- let t = d(e, "x", "erf");
275
- E(t.dtype === "int32" || t.dtype === "float32", () => "Input dtype must be `int32` or `float32`."), t.dtype === "int32" && (t = o(t, "float32"));
276
- let n = { x: t };
277
- return T.runKernel("Erf", n);
278
- }
279
- var we = /* @__PURE__ */ _({ erf_: Ce });
280
- // node_modules/@tensorflow/tfjs-core/dist/ops/softplus.js
281
- function Te(e) {
282
- let t = { x: d(e, "x", "softplus") };
283
- return T.runKernel(p, t);
284
- }
285
- var Ee = /* @__PURE__ */ _({ softplus_: Te });
286
- // node_modules/@tensorflow/tfjs-core/dist/ops/log_softmax.js
287
- function De(e, t = -1) {
288
- let n = d(e, "logits", "logSoftmax");
289
- if (t === -1 && (t = n.rank - 1), t !== n.rank - 1) throw Error(`Log Softmax along a non-last dimension is not yet supported. Logits was rank ${n.rank} and axis was ${t}`);
290
- return b((e, n) => {
291
- let r = P(e, t, !0), i = w(e, r), a = w(o(i, "float32"), N(F(M(i), t, !0)));
292
- return n([a]), {
293
- value: a,
294
- gradFunc: (e, n) => {
295
- let [r] = n, i = M(r);
296
- return w(e, l(F(e, t, !0), i));
297
- }
298
- };
299
- })(n);
300
- }
301
- var Oe = /* @__PURE__ */ _({ logSoftmax_: De });
302
- // node_modules/@tensorflow/tfjs-core/dist/ops/logical_not.js
303
- function ke(e) {
304
- let t = { x: d(e, "x", "logicalNot", "bool") };
305
- return T.runKernel(ne, t);
306
- }
307
- var Ae = /* @__PURE__ */ _({ logicalNot_: ke });
308
- // node_modules/@tensorflow/tfjs-core/dist/ops/max_pool.js
309
- function je(e, t, n, r, i) {
310
- let a = d(e, "x", "maxPool"), o = a, s = !1;
311
- a.rank === 3 && (s = !0, o = j(a, [
312
- 1,
313
- a.shape[0],
314
- a.shape[1],
315
- a.shape[2]
316
- ])), E(o.rank === 4, () => `Error in maxPool: input must be rank 4 but got rank ${o.rank}.`), E(k(n, 1), () => `Error in maxPool: Either strides or dilations must be 1. Got strides ${n} and dilations '1'`), A("maxPool", r, i);
317
- let c = { x: o }, l = {
318
- filterSize: t,
319
- strides: n,
320
- pad: r,
321
- dimRoundingMode: i
322
- }, u = T.runKernel(g, c, l);
323
- return s ? j(u, [
324
- u.shape[1],
325
- u.shape[2],
326
- u.shape[3]
327
- ]) : u;
328
- }
329
- var Me = /* @__PURE__ */ _({ maxPool_: je });
330
- // node_modules/@tensorflow/tfjs-core/dist/ops/ones_like.js
331
- function Ne(e) {
332
- let t = { x: d(e, "x", "onesLike") };
333
- return T.runKernel(te, t);
334
- }
335
- var Pe = /* @__PURE__ */ _({ onesLike_: Ne });
336
- // node_modules/@tensorflow/tfjs-core/dist/ops/space_to_batch_nd.js
337
- function Fe(e, t, n) {
338
- let r = d(e, "x", "spaceToBatchND");
339
- E(r.rank >= 1 + t.length, () => `input rank ${r.rank} should be > than [blockShape] ${t.length}`), E(n.length === t.length, () => `paddings.shape[0] ${n.length} must be equal to [blockShape] ${t.length}`), E(r.shape.reduce((e, r, i) => i > 0 && i <= t.length ? e && (r + n[i - 1][0] + n[i - 1][1]) % t[i - 1] === 0 : e, !0), () => `input spatial dimensions ${r.shape.slice(1)} with paddings ${n.toString()} must be divisible by blockShapes ${t.toString()}`);
340
- let i = { x: r }, a = {
341
- blockShape: t,
342
- paddings: n
343
- };
344
- return T.runKernel(m, i, a);
345
- }
346
- var Ie = /* @__PURE__ */ _({ spaceToBatchND_: Fe });
347
- // node_modules/@tensorflow/tfjs-core/dist/ops/reverse.js
348
- function Le(t, n) {
349
- let r = { x: d(t, "x", "reverse") }, i = { dims: n };
350
- return T.runKernel(e, r, i);
351
- }
352
- var Re = /* @__PURE__ */ _({ reverse_: Le });
353
- // node_modules/@tensorflow/tfjs-core/dist/ops/rsqrt.js
354
- function ze(e) {
355
- let t = { x: d(e, "x", "rsqrt", "float32") };
356
- return T.runKernel(c, t);
357
- }
358
- var Be = /* @__PURE__ */ _({ rsqrt_: ze });
359
- // node_modules/@tensorflow/tfjs-core/dist/ops/selu.js
360
- function Ve(e) {
361
- let t = { x: d(e, "x", "selu") };
362
- return T.runKernel(a, t);
363
- }
364
- var $ = /* @__PURE__ */ _({ selu_: Ve });
365
- // node_modules/@tensorflow/tfjs-core/dist/ops/separable_conv2d.js
366
- function He(e, t, n, r, i, a = [1, 1], o = "NHWC") {
367
- let s = d(e, "x", "separableConv2d"), c = d(t, "depthwiseFilter", "separableConv2d"), l = d(n, "pointwiseFilter", "separableConv2d"), u = s, f = !1;
368
- if (s.rank === 3 && (f = !0, u = j(s, [
369
- 1,
370
- s.shape[0],
371
- s.shape[1],
372
- s.shape[2]
373
- ])), o === "NCHW") throw Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");
374
- E(u.rank === 4, () => `Error in separableConv2d: input must be rank 4, but got rank ${u.rank}.`), E(c.rank === 4, () => `Error in separableConv2d: depthwise filter must be rank 4, but got rank ${c.rank}.`), E(l.rank === 4, () => `Error in separableConv2d: pointwise filter must be rank 4, but got rank ${c.rank}.`), E(l.shape[0] === 1, () => `Error in separableConv2d: the first dimension of pointwise filter must be 1, but got ${l.shape[0]}.`), E(l.shape[1] === 1, () => `Error in separableConv2d: the second dimension of pointwise filter must be 1, but got ${l.shape[1]}.`);
375
- let p = c.shape[2], m = c.shape[3];
376
- E(l.shape[2] === p * m, () => `Error in separableConv2d: the third dimension of pointwise filter must be ${p * m}, but got ${l.shape[2]}.`);
377
- let h = X(Q(u, c, r, i, o, a), l, 1, "valid", o);
378
- return f ? j(h, [
379
- h.shape[1],
380
- h.shape[2],
381
- h.shape[3]
382
- ]) : h;
383
- }
384
- var Ue = /* @__PURE__ */ _({ separableConv2d_: He });
385
- // node_modules/@tensorflow/tfjs-core/dist/ops/sin.js
386
- function We(e) {
387
- let t = { x: d(e, "x", "sin", "float32") };
388
- return T.runKernel("Sin", t);
389
- }
390
- var Ge = /* @__PURE__ */ _({ sin_: We });
391
- // node_modules/@tensorflow/tfjs-core/dist/ops/sinh.js
392
- function Ke(e) {
393
- let n = { x: d(e, "x", "sinh") };
394
- return T.runKernel(t, n);
395
- }
396
- var qe = /* @__PURE__ */ _({ sinh_: Ke });
397
- // node_modules/@tensorflow/tfjs-core/dist/ops/unsorted_segment_sum.js
398
- function Je(e, t, n) {
399
- let r = d(e, "x", "unsortedSegmentSum"), i = d(t, "segmentIds", "unsortedSegmentSum", "int32");
400
- E(s(n), () => "numSegments must be of dtype int");
401
- let a = {
402
- x: r,
403
- segmentIds: i
404
- }, o = { numSegments: n };
405
- return T.runKernel(x, a, o);
406
- }
407
- var Ye = /* @__PURE__ */ _({ unsortedSegmentSum_: Je });
408
- export { z as A, ce as C, G as D, q as E, U as O, Z as S, ae as T, ye as _, $ as a, pe as b, Ie as c, Ae as d, Oe as f, Q as g, Se as h, Ue as i, L as j, V as k, Pe as l, we as m, qe as n, Be as o, Ee as p, Ge as r, Re as s, Ye as t, Me as u, _e as v, X as w, de as x, he as y };
@@ -1,29 +0,0 @@
1
- // lib/utilities/arrayClose.ts
2
- function e(t, n) {
3
- let r = 0;
4
- if ((Array.isArray(t) || t instanceof Float32Array) && (Array.isArray(n) || n instanceof Float32Array)) {
5
- if (t.length !== n.length) return Infinity;
6
- for (let i = 0; i < t.length; ++i) r = Math.max(r, e(t[i], n[i]));
7
- return r;
8
- }
9
- if (typeof t == "number" && typeof n == "number") {
10
- if (isNaN(t) && isNaN(n)) return 0;
11
- if (!isFinite(t) || !isFinite(n)) return t === n ? 0 : Infinity;
12
- let e = Math.abs(t - n);
13
- return r = Math.max(r, e), r;
14
- }
15
- return Infinity;
16
- }
17
- function t(e, t, n = .99) {
18
- let r = [];
19
- function i(e, t) {
20
- if ((Array.isArray(e) || e instanceof Float32Array) && (Array.isArray(t) || t instanceof Float32Array)) {
21
- if (e.length !== t.length) return !1;
22
- for (let n = 0; n < e.length; n++) if (!i(e[n], t[n])) return !1;
23
- return !0;
24
- }
25
- 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;
26
- }
27
- 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))]);
28
- }
29
- export { e as arraysClose, t as arraysClosePercentile };
@@ -1,7 +0,0 @@
1
- // lib/utilities/arrayShape.ts
2
- function e(e) {
3
- let t = [], n = e;
4
- for (; Array.isArray(n);) t.push(n.length), n = n[n.length - 1];
5
- return t;
6
- }
7
- export { e as default };
@@ -1,17 +0,0 @@
1
- // lib/utilities/datasetID.ts
2
- function e(e) {
3
- let t = e.map((e) => String(e.id)).sort(), n = 2166136261, r = 2654435769, i = (e) => {
4
- n ^= e & 255, n = Math.imul(n, 16777619), r ^= e & 255, r = Math.imul(r, 2246822507);
5
- }, a = (e) => {
6
- let t = e.length >>> 0;
7
- i(t & 255), i(t >>> 8 & 255), i(t >>> 16 & 255), i(t >>> 24 & 255);
8
- for (let t = 0; t < e.length; t++) {
9
- let n = e.charCodeAt(t);
10
- i(n & 255), i(n >>> 8 & 255);
11
- }
12
- }, o = t.length >>> 0;
13
- i(o & 255), i(o >>> 8 & 255), i(o >>> 16 & 255), i(o >>> 24 & 255);
14
- for (let e of t) a(e);
15
- return "dataset__" + (n >>> 0).toString(36) + "_" + (r >>> 0).toString(36);
16
- }
17
- export { e as default };
@@ -1,36 +0,0 @@
1
- import { G as e, H as t, _ as n } from "../dist-CMMLi-qO.js";
2
- import { t as r } from "../zeros-hxKGkRfl.js";
3
- // lib/utilities/dummy.ts
4
- async function i(e) {
5
- let t = r([1, e.config.blockSize], "int32"), n = e.forward({ training: !1 }, t);
6
- await n.data(), n.dispose(), t.dispose();
7
- }
8
- async function a(a) {
9
- let o = e(), s = o.numBytesInGPUAllocated ?? o.numBytesAllocatedInGPU ?? o.numBytes;
10
- await i(a);
11
- let c = r([1, a.config.blockSize], "int32"), l = {
12
- perBatch: 0,
13
- tapeSize: 0,
14
- gradients: a.getNumParams() * 4
15
- };
16
- try {
17
- let { value: r, grads: i } = n(() => {
18
- let e = a.forward({ training: !0 }, c), n = t().state.activeTape, r = 0;
19
- if (n) for (let e of n) r += e.saved?.reduce((e, t) => e + t.size * 4, 0) || 0;
20
- l.tapeSize = r;
21
- let i = e.mean();
22
- return e.dispose(), i;
23
- }), o = e();
24
- l.perBatch = (o.numBytesInGPUAllocated ?? o.numBytesAllocatedInGPU ?? o.numBytes) - s - l.gradients, await r.data(), r.dispose();
25
- for (let e in i) i[e].dispose();
26
- c.dispose();
27
- } catch (e) {
28
- console.error("Error during dummy training pass:", e), c.dispose();
29
- }
30
- return l;
31
- }
32
- function o(e) {
33
- let t = r([1, e.config.blockSize], "int32");
34
- e.forward({ training: !1 }, t).dispose(), t.dispose();
35
- }
36
- export { o as dummyPass, i as dummyPassAsync, a as dummyPassTrainAsync };
@@ -1,46 +0,0 @@
1
- // lib/utilities/float16.ts
2
- function e(e) {
3
- if (typeof Float16Array < "u") {
4
- let t = new Float16Array(e);
5
- return new Uint16Array(t.buffer);
6
- }
7
- return i(e);
8
- }
9
- function t(e, t, r) {
10
- if (typeof Float16Array < "u") {
11
- let n = new Float16Array(e, t, r);
12
- return new Float32Array(n);
13
- }
14
- return n(e, t, r);
15
- }
16
- function n(e, t, n) {
17
- let i = new Uint16Array(e, t, n), a = new Float32Array(n);
18
- for (let e = 0; e < n; e++) a[e] = r(i[e]);
19
- return a;
20
- }
21
- function r(e) {
22
- let t = e & 32768 ? -1 : 1, n = e >>> 10 & 31, r = e & 1023;
23
- return n === 0 ? t * r * 2 ** -24 : n === 31 ? r ? NaN : t * Infinity : t * (1 + r / 1024) * 2 ** (n - 15);
24
- }
25
- function i(e) {
26
- let t = new Uint16Array(e.length), n = /* @__PURE__ */ new Float32Array(1), r = new Uint32Array(n.buffer);
27
- for (let i = 0; i < e.length; i++) {
28
- n[0] = e[i];
29
- let a = r[0], o = a >>> 16 & 32768, s = (a >>> 23 & 255) - 127 + 15, c = a & 8388607;
30
- if ((a >>> 23 & 255) == 255) t[i] = o | 31744 | (c ? 512 : 0);
31
- else if (s >= 31) t[i] = o | 31744;
32
- else if (s <= 0) {
33
- if (s < -10) t[i] = o;
34
- else {
35
- c |= 8388608;
36
- let e = 14 - s, n = c >>> e;
37
- c >>> e - 1 & 1 && (c & (1 << e - 1) - 1 || n & 1) && n++, t[i] = o | n;
38
- }
39
- } else {
40
- let e = s << 10 | c >>> 13;
41
- c & 4096 && (c & 4095 || e & 1) && (e++, (e & 31744) == 31744 && (e = o | 31744)), t[i] = o | e;
42
- }
43
- }
44
- return t;
45
- }
46
- export { t as loadFloat16FromBuffer, i as manualFloat16Array, e as toFloat16Array };
@@ -1,54 +0,0 @@
1
- // lib/utilities/maxHeap.ts
2
- var e = class {
3
- fn;
4
- heap = [];
5
- constructor(e) {
6
- this.fn = e;
7
- }
8
- get length() {
9
- return this.heap.length;
10
- }
11
- get size() {
12
- return this.heap.length;
13
- }
14
- get values() {
15
- return [...this.heap];
16
- }
17
- isEmpty() {
18
- return this.heap.length === 0;
19
- }
20
- peek() {
21
- return this.heap[0];
22
- }
23
- push(e) {
24
- this.heap.push(e), this.siftUp(this.heap.length - 1);
25
- }
26
- pop() {
27
- if (this.heap.length === 0) return;
28
- let e = this.heap[0], t = this.heap.pop();
29
- return this.heap.length > 0 && t !== void 0 && (this.heap[0] = t, this.siftDown(0)), e;
30
- }
31
- clear() {
32
- this.heap.length = 0;
33
- }
34
- toArray() {
35
- return [...this.heap];
36
- }
37
- siftUp(e) {
38
- let t = e;
39
- for (; t > 0;) {
40
- let e = Math.floor((t - 1) / 2);
41
- if (this.fn(this.heap[t]) <= this.fn(this.heap[e])) break;
42
- [this.heap[t], this.heap[e]] = [this.heap[e], this.heap[t]], t = e;
43
- }
44
- }
45
- siftDown(e) {
46
- let t = e;
47
- for (;;) {
48
- let e = t * 2 + 1, n = t * 2 + 2, r = t;
49
- if (e < this.heap.length && this.fn(this.heap[e]) > this.fn(this.heap[r]) && (r = e), n < this.heap.length && this.fn(this.heap[n]) > this.fn(this.heap[r]) && (r = n), r === t) break;
50
- [this.heap[t], this.heap[r]] = [this.heap[r], this.heap[t]], t = r;
51
- }
52
- }
53
- };
54
- export { e as default };
@@ -1,7 +0,0 @@
1
- // lib/utilities/multinomialCPU.ts
2
- function e(e, t) {
3
- let n = 0, r = t ?? Math.random();
4
- for (let t = 0; t < e.length; t++) if (n += e[t], r < n) return t;
5
- return e.length - 1;
6
- }
7
- export { e as default };
File without changes
@@ -1,12 +0,0 @@
1
- import { H as e } from "../dist-CMMLi-qO.js";
2
- // lib/utilities/packed.ts
3
- function t() {
4
- return e().backendName === "webgpu";
5
- }
6
- function n(e) {
7
- return e.dtype === "packedF16";
8
- }
9
- function r(e) {
10
- return n(e);
11
- }
12
- export { n as isPackableTensor, r as isPackedTensor, t as packingSupported };
@@ -1,53 +0,0 @@
1
- import { swigluHidden as e } from "../layers/MLP.js";
2
- // lib/utilities/parameters.ts
3
- var t = 4;
4
- function n(t) {
5
- let n;
6
- switch (t.modelType) {
7
- case "GenAI_NanoGPT_v1":
8
- case "GenAI_NanoGPT_v2":
9
- n = e(t.nEmbed, t.mlpFactor) * t.nEmbed * 2;
10
- break;
11
- case "llama":
12
- case "qwen3":
13
- n = Math.max(256, Math.ceil(t.nEmbed * (8 / 3) / 256) * 256) * t.nEmbed * 3;
14
- break;
15
- default: n = 0;
16
- }
17
- return n;
18
- }
19
- function r(e) {
20
- return 4 * e.nEmbed * e.nEmbed + n(e);
21
- }
22
- function i(e) {
23
- let t = e.modelType === "llama" ? e.vocabSize * e.nEmbed * 2 : e.vocabSize * e.nEmbed, r = e.nLayer * (4 * e.nEmbed * e.nEmbed), i = n(e) * e.nLayer;
24
- return t + r + i;
25
- }
26
- function a(e) {
27
- return i(e) * t;
28
- }
29
- function o(e, n) {
30
- let r = a(e), i = r * 2, o = r * 2, s = n * e.blockSize * e.nEmbed * t;
31
- return r + i + o + s;
32
- }
33
- function s(e, t) {
34
- return {
35
- numParams: i(e),
36
- modelMemoryMB: a(e) / 1048576,
37
- trainingMemoryMB: o(e, t) / 1048576
38
- };
39
- }
40
- function c(e) {
41
- if (e.nEmbed % e.nHead !== 0) throw Error("nEmbed_divisible_nHead");
42
- if (e.blockSize <= 0) throw Error("blockSize_positive");
43
- if (e.vocabSize <= 0) throw Error("vocabSize_positive");
44
- if (e.nLayer <= 0) throw Error("nLayer_positive");
45
- if (e.mlpFactor <= 0) throw Error("mlpFactor_positive");
46
- if (e.nEmbed / e.nHead % 2 != 0) throw Error("headDim_even");
47
- if (!Number.isInteger(e.nEmbed)) throw Error("nEmbed_integer");
48
- if (!Number.isInteger(e.nHead)) throw Error("nHead_integer");
49
- if (!Number.isInteger(e.nLayer)) throw Error("nLayer_integer");
50
- if (!Number.isInteger(e.blockSize)) throw Error("blockSize_integer");
51
- if (!Number.isInteger(e.vocabSize)) throw Error("vocabSize_integer");
52
- }
53
- export { r as estimateLayerParameters, a as estimateMemoryUsage, i as estimateParameterCount, s as estimateResources, o as estimateTrainingMemoryUsage, c as validateConfig };