@tryhamster/gerbil 1.6.0 → 1.6.1

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 (49) hide show
  1. package/dist/{architectures-Ol7yUmKf.mjs → architectures-CpmH4Gha.mjs} +86 -82
  2. package/dist/architectures-CpmH4Gha.mjs.map +1 -0
  3. package/dist/browser/index.js.map +1 -1
  4. package/dist/cli.mjs +8 -8
  5. package/dist/cli.mjs.map +1 -1
  6. package/dist/frameworks/express.mjs +1 -1
  7. package/dist/frameworks/fastify.mjs +1 -1
  8. package/dist/frameworks/hono.mjs +1 -1
  9. package/dist/frameworks/next.d.mts +2 -2
  10. package/dist/frameworks/next.mjs +1 -1
  11. package/dist/frameworks/trpc.mjs +1 -1
  12. package/dist/{gerbil-_68_JSGV.d.mts → gerbil--YDNklsY.d.mts} +2 -2
  13. package/dist/{gerbil-_68_JSGV.d.mts.map → gerbil--YDNklsY.d.mts.map} +1 -1
  14. package/dist/gerbil-BPpEvMYU.mjs +4 -0
  15. package/dist/{gerbil-DsgYlkgf.mjs → gerbil-D13QAlk2.mjs} +2 -2
  16. package/dist/{gerbil-DsgYlkgf.mjs.map → gerbil-D13QAlk2.mjs.map} +1 -1
  17. package/dist/gpu/hooks.d.mts +1 -1
  18. package/dist/gpu/index.d.mts +1 -1
  19. package/dist/gpu/index.mjs +3 -3
  20. package/dist/{gpu-DfUBMUGe.mjs → gpu-DtA28rES.mjs} +12 -8
  21. package/dist/{gpu-DfUBMUGe.mjs.map → gpu-DtA28rES.mjs.map} +1 -1
  22. package/dist/{index-BdbeBDTz.d.mts → index-CZVIHkaH.d.mts} +23 -2
  23. package/dist/index-CZVIHkaH.d.mts.map +1 -0
  24. package/dist/index.d.mts +2 -2
  25. package/dist/index.mjs +5 -5
  26. package/dist/integrations/ai-sdk.mjs +1 -1
  27. package/dist/integrations/langchain.mjs +1 -1
  28. package/dist/integrations/llamaindex.mjs +1 -1
  29. package/dist/integrations/mcp.d.mts +2 -2
  30. package/dist/integrations/mcp.mjs +4 -4
  31. package/dist/{mcp-D3XRaVAc.mjs → mcp-DuaxaIwt.mjs} +3 -3
  32. package/dist/{mcp-D3XRaVAc.mjs.map → mcp-DuaxaIwt.mjs.map} +1 -1
  33. package/dist/moonshine-stt-BkU9cx2d.mjs +4 -0
  34. package/dist/{moonshine-stt-bExSnd2o.mjs → moonshine-stt-BwX7NQ0O.mjs} +749 -2
  35. package/dist/moonshine-stt-BwX7NQ0O.mjs.map +1 -0
  36. package/dist/{one-liner-UvMt5g0G.mjs → one-liner-CMk_GZgS.mjs} +2 -2
  37. package/dist/{one-liner-UvMt5g0G.mjs.map → one-liner-CMk_GZgS.mjs.map} +1 -1
  38. package/dist/repl-CD4NDrku.mjs +9 -0
  39. package/dist/skills/index.d.mts +4 -4
  40. package/dist/skills/index.mjs +3 -3
  41. package/dist/{skills-BJUofoaY.mjs → skills-CJHhljKM.mjs} +2 -2
  42. package/dist/{skills-BJUofoaY.mjs.map → skills-CJHhljKM.mjs.map} +1 -1
  43. package/package.json +1 -1
  44. package/dist/architectures-Ol7yUmKf.mjs.map +0 -1
  45. package/dist/gerbil-CNyb67ca.mjs +0 -4
  46. package/dist/index-BdbeBDTz.d.mts.map +0 -1
  47. package/dist/moonshine-stt-B0dwDCgT.mjs +0 -4
  48. package/dist/moonshine-stt-bExSnd2o.mjs.map +0 -1
  49. package/dist/repl-B5xHAr9n.mjs +0 -9
@@ -3066,34 +3066,39 @@ function generateLfm2Graph(rawConfig, dtype, groupSizeOverride, kvDtype) {
3066
3066
  });
3067
3067
  }
3068
3068
  let prevOutput = "embed_out";
3069
+ let pendingNorm1Out = null;
3069
3070
  for (let i = 0; i < num_layers; i++) {
3070
3071
  const prefix = `layer${i}`;
3071
- const operatorNormW = CANONICAL_KEYS.lfm2OperatorNorm(i);
3072
- addTensor({
3073
- name: operatorNormW,
3074
- shape: [hidden_size],
3075
- dtype: "f32",
3076
- storage: "constant",
3077
- safetensorsKey: operatorNormW
3078
- });
3079
- const norm1Out = `${prefix}_norm1_out`;
3080
- addTensor({
3081
- name: norm1Out,
3082
- shape: ["T", hidden_size],
3083
- dtype: "f32",
3084
- storage: "activation"
3085
- });
3086
- addNode({
3087
- id: `${prefix}_norm1`,
3088
- opType: "RMSNorm",
3089
- inputs: [prevOutput, operatorNormW],
3090
- outputs: [norm1Out],
3091
- attributes: {
3092
- hidden_size,
3093
- eps: rms_norm_eps,
3094
- seq_len_tensor: prevOutput
3095
- }
3096
- });
3072
+ let norm1Out;
3073
+ if (pendingNorm1Out) norm1Out = pendingNorm1Out;
3074
+ else {
3075
+ const operatorNormW = CANONICAL_KEYS.lfm2OperatorNorm(i);
3076
+ addTensor({
3077
+ name: operatorNormW,
3078
+ shape: [hidden_size],
3079
+ dtype: "f32",
3080
+ storage: "constant",
3081
+ safetensorsKey: operatorNormW
3082
+ });
3083
+ norm1Out = `${prefix}_norm1_out`;
3084
+ addTensor({
3085
+ name: norm1Out,
3086
+ shape: ["T", hidden_size],
3087
+ dtype: "f32",
3088
+ storage: "activation"
3089
+ });
3090
+ addNode({
3091
+ id: `${prefix}_norm1`,
3092
+ opType: "RMSNorm",
3093
+ inputs: [prevOutput, operatorNormW],
3094
+ outputs: [norm1Out],
3095
+ attributes: {
3096
+ hidden_size,
3097
+ eps: rms_norm_eps,
3098
+ seq_len_tensor: prevOutput
3099
+ }
3100
+ });
3101
+ }
3097
3102
  const mixerOut = isAttentionLayer(i) ? buildAttentionBlock(i, prefix, norm1Out) : buildShortConvBlock(i, prefix, norm1Out);
3098
3103
  const resid1Out = `${prefix}_resid1`;
3099
3104
  const ffnNormW = CANONICAL_KEYS.lfm2FfnNorm(i);
@@ -3180,16 +3185,51 @@ function generateLfm2Graph(rawConfig, dtype, groupSizeOverride, kvDtype) {
3180
3185
  dtype: "f32",
3181
3186
  storage: "activation"
3182
3187
  });
3183
- addNode({
3184
- id: `${prefix}_resid2`,
3185
- opType: "Add",
3186
- inputs: [resid1Out, mlpOut],
3187
- outputs: [resid2Out],
3188
- attributes: {
3189
- count_tensor: resid1Out,
3190
- hidden_size
3191
- }
3192
- });
3188
+ if (i + 1 < num_layers) {
3189
+ const nextNormW = CANONICAL_KEYS.lfm2OperatorNorm(i + 1);
3190
+ addTensor({
3191
+ name: nextNormW,
3192
+ shape: [hidden_size],
3193
+ dtype: "f32",
3194
+ storage: "constant",
3195
+ safetensorsKey: nextNormW
3196
+ });
3197
+ const nextNorm1Out = `layer${i + 1}_norm1_out`;
3198
+ addTensor({
3199
+ name: nextNorm1Out,
3200
+ shape: ["T", hidden_size],
3201
+ dtype: "f32",
3202
+ storage: "activation"
3203
+ });
3204
+ addNode({
3205
+ id: `${prefix}_resid2_norm1`,
3206
+ opType: "ResidualRMSNorm",
3207
+ inputs: [
3208
+ resid1Out,
3209
+ mlpOut,
3210
+ nextNormW
3211
+ ],
3212
+ outputs: [resid2Out, nextNorm1Out],
3213
+ attributes: {
3214
+ hidden_size,
3215
+ eps: rms_norm_eps,
3216
+ seq_len_tensor: resid1Out
3217
+ }
3218
+ });
3219
+ pendingNorm1Out = nextNorm1Out;
3220
+ } else {
3221
+ addNode({
3222
+ id: `${prefix}_resid2`,
3223
+ opType: "Add",
3224
+ inputs: [resid1Out, mlpOut],
3225
+ outputs: [resid2Out],
3226
+ attributes: {
3227
+ count_tensor: resid1Out,
3228
+ hidden_size
3229
+ }
3230
+ });
3231
+ pendingNorm1Out = null;
3232
+ }
3193
3233
  prevOutput = resid2Out;
3194
3234
  }
3195
3235
  function buildShortConvBlock(i, prefix, norm1Out) {
@@ -3203,43 +3243,6 @@ function generateLfm2Graph(rawConfig, dtype, groupSizeOverride, kvDtype) {
3203
3243
  storage: "activation"
3204
3244
  });
3205
3245
  addLinearOp(`${prefix}_conv_in_proj`, norm1Out, inProjW, [bcxDim, hidden_size], bcxOut, hidden_size, bcxDim);
3206
- const cOut = `${prefix}_conv_C`;
3207
- addTensor({
3208
- name: cOut,
3209
- shape: ["T", conv_dim],
3210
- dtype: "f32",
3211
- storage: "activation"
3212
- });
3213
- addNode({
3214
- id: `${prefix}_conv_split_C`,
3215
- opType: "SliceCols",
3216
- inputs: [bcxOut],
3217
- outputs: [cOut],
3218
- attributes: {
3219
- in_width: bcxDim,
3220
- out_width: conv_dim,
3221
- col_offset: conv_dim
3222
- }
3223
- });
3224
- const bxOut = `${prefix}_conv_Bx`;
3225
- addTensor({
3226
- name: bxOut,
3227
- shape: ["T", conv_dim],
3228
- dtype: "f32",
3229
- storage: "activation"
3230
- });
3231
- addNode({
3232
- id: `${prefix}_conv_gate_in`,
3233
- opType: "MulCols",
3234
- inputs: [bcxOut],
3235
- outputs: [bxOut],
3236
- attributes: {
3237
- in_width: bcxDim,
3238
- out_width: conv_dim,
3239
- off_a: 0,
3240
- off_b: 2 * conv_dim
3241
- }
3242
- });
3243
3246
  const convW = CANONICAL_KEYS.lfm2ConvWeight(i);
3244
3247
  addTensor({
3245
3248
  name: convW,
@@ -3264,29 +3267,30 @@ function generateLfm2Graph(rawConfig, dtype, groupSizeOverride, kvDtype) {
3264
3267
  });
3265
3268
  addNode({
3266
3269
  id: `${prefix}_conv1d`,
3267
- opType: "CausalConv1dGated",
3270
+ opType: "CausalConv1dGatedBcx",
3268
3271
  inputs: [
3269
- bxOut,
3272
+ bcxOut,
3270
3273
  convW,
3271
- convState,
3272
- cOut
3274
+ convState
3273
3275
  ],
3274
3276
  outputs: [yOut],
3275
3277
  attributes: {
3276
3278
  channels: conv_dim,
3277
3279
  kernel_size: conv_kernel,
3278
- seq_len_tensor: bxOut
3280
+ in_width: bcxDim,
3281
+ seq_len_tensor: bcxOut
3279
3282
  }
3280
3283
  });
3281
3284
  addNode({
3282
3285
  id: `${prefix}_conv_state_update`,
3283
- opType: "ConvStateUpdate",
3284
- inputs: [bxOut],
3286
+ opType: "ConvStateUpdateBcx",
3287
+ inputs: [bcxOut],
3285
3288
  outputs: [convState],
3286
3289
  attributes: {
3287
3290
  channels: conv_dim,
3288
3291
  state_size: conv_kernel - 1,
3289
- T_tensor: bxOut
3292
+ in_width: bcxDim,
3293
+ T_tensor: bcxOut
3290
3294
  }
3291
3295
  });
3292
3296
  const outProjW = CANONICAL_KEYS.lfm2ConvOutProj(i);
@@ -6120,4 +6124,4 @@ function isArchitectureSupported(name) {
6120
6124
 
6121
6125
  //#endregion
6122
6126
  export { quantizeInt4 as C, createDefaultHFKeyMapper as D, GEMMA4_VIS_KEYS as E, DEFAULT_GROUP_SIZE as S, DTYPE_BYTES as T, kaniCosTensor as _, generateMoonshineEncoderGraph as a, nanoCodecWeightMap as b, KANI_END_OF_HUMAN as c, buildKaniLayerCosSin as d, computeKaniPositions as f, kaniAttentionLayerIndices as g, generateNanoCodecDecoderGraph as h, generateMoonshineDecoderGraph as i, KANI_START_OF_HUMAN as l, generateKaniTtsGraph as m, isArchitectureSupported as n, moonshineEncoderFrames as o, foldNanoCodecWeightNorm as p, MOONSHINE_REMAINING_WORK as r, parseMoonshineConfig as s, generateGraph as t, audioTokensToCodes as u, kaniLayerAlpha as v, CANONICAL_KEYS as w, parseKaniConfig as x, kaniSinTensor as y };
6123
- //# sourceMappingURL=architectures-Ol7yUmKf.mjs.map
6127
+ //# sourceMappingURL=architectures-CpmH4Gha.mjs.map