@tryhamster/gerbil 1.9.0 → 1.10.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 (51) hide show
  1. package/dist/cli.mjs +7 -7
  2. package/dist/cli.mjs.map +1 -1
  3. package/dist/frameworks/express.mjs +1 -1
  4. package/dist/frameworks/fastify.mjs +1 -1
  5. package/dist/frameworks/hono.mjs +1 -1
  6. package/dist/frameworks/next.d.mts +2 -2
  7. package/dist/frameworks/next.mjs +1 -1
  8. package/dist/frameworks/trpc.mjs +1 -1
  9. package/dist/gerbil-IqsK32DM.mjs +4 -0
  10. package/dist/{gerbil-Bc6-CoH7.d.mts → gerbil-PEAdJdsH.d.mts} +10 -9
  11. package/dist/{gerbil-Bc6-CoH7.d.mts.map → gerbil-PEAdJdsH.d.mts.map} +1 -1
  12. package/dist/{gerbil-Cj2Yllj9.mjs → gerbil-sQ7eqzn3.mjs} +22 -10
  13. package/dist/gerbil-sQ7eqzn3.mjs.map +1 -0
  14. package/dist/gpu/hooks.d.mts +9 -1
  15. package/dist/gpu/hooks.d.mts.map +1 -1
  16. package/dist/gpu/hooks.mjs +24 -1
  17. package/dist/gpu/hooks.mjs.map +1 -1
  18. package/dist/gpu/index.d.mts +1 -1
  19. package/dist/gpu/index.mjs +2 -2
  20. package/dist/{gpu-C5Ez0lSl.mjs → gpu-B1xk3xOJ.mjs} +98 -2
  21. package/dist/gpu-B1xk3xOJ.mjs.map +1 -0
  22. package/dist/{index-BBAaLqdK.d.mts → index-CJux7zbV.d.mts} +95 -1
  23. package/dist/index-CJux7zbV.d.mts.map +1 -0
  24. package/dist/index.d.mts +2 -2
  25. package/dist/index.mjs +4 -4
  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-IK-hR3S8.mjs → mcp-BX-ryGGJ.mjs} +3 -3
  32. package/dist/{mcp-IK-hR3S8.mjs.map → mcp-BX-ryGGJ.mjs.map} +1 -1
  33. package/dist/{moonshine-stt-9wc6t11v.mjs → moonshine-stt-BKeD6OYF.mjs} +358 -18
  34. package/dist/moonshine-stt-BKeD6OYF.mjs.map +1 -0
  35. package/dist/moonshine-stt-DKC0PHF_.mjs +4 -0
  36. package/dist/{one-liner-CdA1YTku.mjs → one-liner-m6NjYWMg.mjs} +2 -2
  37. package/dist/{one-liner-CdA1YTku.mjs.map → one-liner-m6NjYWMg.mjs.map} +1 -1
  38. package/dist/{repl-Dk9UxWyt.mjs → repl-hN4jSHrb.mjs} +3 -3
  39. package/dist/skills/index.d.mts +4 -4
  40. package/dist/skills/index.mjs +3 -3
  41. package/dist/{skills-Dl7Yl7ui.mjs → skills-DZ5OITy0.mjs} +2 -2
  42. package/dist/{skills-Dl7Yl7ui.mjs.map → skills-DZ5OITy0.mjs.map} +1 -1
  43. package/dist/tune/index.d.mts.map +1 -1
  44. package/dist/tune/index.mjs +1 -1
  45. package/package.json +1 -1
  46. package/dist/gerbil-CJci0igh.mjs +0 -4
  47. package/dist/gerbil-Cj2Yllj9.mjs.map +0 -1
  48. package/dist/gpu-C5Ez0lSl.mjs.map +0 -1
  49. package/dist/index-BBAaLqdK.d.mts.map +0 -1
  50. package/dist/moonshine-stt-9wc6t11v.mjs.map +0 -1
  51. package/dist/moonshine-stt-B7rDn6Q9.mjs +0 -4
@@ -8673,6 +8673,120 @@ const convTranspose1dDepthwiseSpec = {
8673
8673
  ]);
8674
8674
  }
8675
8675
  };
8676
+ const LORA_WG = 64;
8677
+ const WGSL_LORA_DOWN = `\
8678
+ struct Params { M: u32, IN: u32, R: u32, pad: u32 };
8679
+ @group(0) @binding(0) var<storage, read> X: array<f32>;
8680
+ @group(0) @binding(1) var<storage, read> A: array<f32>;
8681
+ @group(0) @binding(2) var<storage, read_write> T: array<f32>;
8682
+ @group(0) @binding(3) var<storage, read> params: Params;
8683
+
8684
+ @compute @workgroup_size(64)
8685
+ fn main(
8686
+ @builtin(global_invocation_id) gid: vec3u,
8687
+ @builtin(num_workgroups) nwg: vec3u,
8688
+ ) {
8689
+ let idx = gid.y * (nwg.x * 64u) + gid.x;
8690
+ let total = params.M * params.R;
8691
+ if (idx >= total) { return; }
8692
+ let m = idx / params.R;
8693
+ let k = idx % params.R;
8694
+ let xBase = m * params.IN;
8695
+ let aBase = k * params.IN;
8696
+ var sum: f32 = 0.0;
8697
+ for (var i: u32 = 0u; i < params.IN; i = i + 1u) {
8698
+ sum = sum + X[xBase + i] * A[aBase + i];
8699
+ }
8700
+ T[idx] = sum;
8701
+ }
8702
+ `;
8703
+ const WGSL_LORA_UP = `\
8704
+ struct Params { M: u32, R: u32, OUT: u32, scaling: f32 };
8705
+ @group(0) @binding(0) var<storage, read> T: array<f32>;
8706
+ @group(0) @binding(1) var<storage, read> B: array<f32>;
8707
+ @group(0) @binding(2) var<storage, read_write> Y: array<f32>;
8708
+ @group(0) @binding(3) var<storage, read> params: Params;
8709
+
8710
+ @compute @workgroup_size(64)
8711
+ fn main(
8712
+ @builtin(global_invocation_id) gid: vec3u,
8713
+ @builtin(num_workgroups) nwg: vec3u,
8714
+ ) {
8715
+ let idx = gid.y * (nwg.x * 64u) + gid.x;
8716
+ let total = params.M * params.OUT;
8717
+ if (idx >= total) { return; }
8718
+ let m = idx / params.OUT;
8719
+ let o = idx % params.OUT;
8720
+ let tBase = m * params.R;
8721
+ let bBase = o * params.R;
8722
+ var sum: f32 = 0.0;
8723
+ for (var k: u32 = 0u; k < params.R; k = k + 1u) {
8724
+ sum = sum + T[tBase + k] * B[bBase + k];
8725
+ }
8726
+ Y[idx] = Y[idx] + params.scaling * sum;
8727
+ }
8728
+ `;
8729
+ /** M (row count) for a LoRA dispatch = first dim of the shape-source activation. */
8730
+ function loraRows(op, resolvedShapes) {
8731
+ return resolvedShapes[op.inputs[0]]?.[0] ?? 1;
8732
+ }
8733
+ /**
8734
+ * LoRA down-projection: tmp[M,R] = X · Aᵀ. `op.inputs[0]` names the input
8735
+ * activation (the shape source); attributes carry IN and R.
8736
+ */
8737
+ const LORA_DOWN_SPEC = {
8738
+ shaderCode: WGSL_LORA_DOWN,
8739
+ entryPoint: "main",
8740
+ bindings: [
8741
+ { type: "storage-read" },
8742
+ { type: "storage-read" },
8743
+ { type: "storage-read-write" },
8744
+ { type: "uniform" }
8745
+ ],
8746
+ getDispatchSize(op, resolvedShapes) {
8747
+ const m = loraRows(op, resolvedShapes);
8748
+ const r = op.attributes.R;
8749
+ return dispatch2D(cdiv(m * r, LORA_WG));
8750
+ },
8751
+ buildParams(op, resolvedShapes) {
8752
+ return buildUniformBuffer([
8753
+ loraRows(op, resolvedShapes),
8754
+ op.attributes.IN,
8755
+ op.attributes.R,
8756
+ 0
8757
+ ]);
8758
+ }
8759
+ };
8760
+ /**
8761
+ * LoRA up-projection + accumulate: Y[M,OUT] += scaling · (tmp · Bᵀ).
8762
+ * `op.inputs[0]` names the shape-source activation; attributes carry R, OUT and
8763
+ * the f32 scaling (alpha/r, or alpha/√r for rslora).
8764
+ */
8765
+ const LORA_UP_SPEC = {
8766
+ shaderCode: WGSL_LORA_UP,
8767
+ entryPoint: "main",
8768
+ bindings: [
8769
+ { type: "storage-read" },
8770
+ { type: "storage-read" },
8771
+ { type: "storage-read-write" },
8772
+ { type: "uniform" }
8773
+ ],
8774
+ getDispatchSize(op, resolvedShapes) {
8775
+ const m = loraRows(op, resolvedShapes);
8776
+ const out = op.attributes.OUT;
8777
+ return dispatch2D(cdiv(m * out, LORA_WG));
8778
+ },
8779
+ buildParams(op, resolvedShapes) {
8780
+ const m = loraRows(op, resolvedShapes);
8781
+ const buf = /* @__PURE__ */ new ArrayBuffer(16);
8782
+ const view = new DataView(buf);
8783
+ view.setUint32(0, m, true);
8784
+ view.setUint32(4, op.attributes.R, true);
8785
+ view.setUint32(8, op.attributes.OUT, true);
8786
+ view.setFloat32(12, op.attributes.scaling, true);
8787
+ return buf;
8788
+ }
8789
+ };
8676
8790
  const KERNEL_REGISTRY = {
8677
8791
  Embedding: embeddingSpec,
8678
8792
  EmbeddingInt4: embeddingInt4Spec,
@@ -8787,6 +8901,16 @@ var Executor = class Executor {
8787
8901
  dispatchEntries = [];
8788
8902
  /** Dispatch entries for decode (M=1): uses K-parallel matvec kernels. */
8789
8903
  decodeEntries = [];
8904
+ /** Per-node decode entries captured BEFORE fusion (the overlay base). */
8905
+ decodeEntriesUnfused = [];
8906
+ /** True while a runtime adapter is applied. */
8907
+ loraActive = false;
8908
+ /** Decode entries (unfused base + spliced LoRA dispatches). */
8909
+ decodeEntriesLoRA = [];
8910
+ /** Prefill entries (base + spliced LoRA dispatches). */
8911
+ prefillEntriesLoRA = [];
8912
+ /** GPU buffers owned by the current adapter (A/B factors + tmp); freed on swap. */
8913
+ loraBuffers = [];
8790
8914
  /** Argmax dispatch entry (created in initBindGroups). */
8791
8915
  argmaxEntry = null;
8792
8916
  /** True when running on Safari/WebKit (needs multi-encoder submit). */
@@ -8985,6 +9109,7 @@ var Executor = class Executor {
8985
9109
  });
8986
9110
  } else this.decodeEntries.push(prefillEntry);
8987
9111
  }
9112
+ this.decodeEntriesUnfused = this.decodeEntries.slice();
8988
9113
  this.fuseSwiGLUDecodeEntries();
8989
9114
  this.fuseDualMatVecDecodeEntries();
8990
9115
  this.fuseDualKVCacheAppendEntries();
@@ -9023,6 +9148,198 @@ var Executor = class Executor {
9023
9148
  usage: 12
9024
9149
  });
9025
9150
  }
9151
+ /** True while a runtime LoRA overlay is applied. */
9152
+ get hasRuntimeAdapter() {
9153
+ return this.loraActive;
9154
+ }
9155
+ /** Decode entries in effect for the current adapter state. */
9156
+ get activeDecodeEntries() {
9157
+ return this.loraActive ? this.decodeEntriesLoRA : this.decodeEntries;
9158
+ }
9159
+ /**
9160
+ * Apply a runtime LoRA overlay on the STATIC base. For each delta whose target
9161
+ * maps to a base linear (MatMulInt4 / MatMul) with matching dims, uploads the
9162
+ * f32 A/B factors and splices two low-rank dispatches — `tmp = A·x`, then
9163
+ * `y += scaling·B·tmp` — right after that node in both the decode and prefill
9164
+ * paths, so the corrected output is live before any consumer reads it.
9165
+ *
9166
+ * Rebuilds the overlay from scratch each call (this is how adapters hot-swap);
9167
+ * the base weight buffers and bind groups are never touched or re-uploaded.
9168
+ * Pass an empty list (or call {@link clearRuntimeLoRA}) to drop the overlay.
9169
+ */
9170
+ applyRuntimeLoRA(deltas) {
9171
+ this.clearRuntimeLoRA();
9172
+ const overlay = /* @__PURE__ */ new Map();
9173
+ let applied = 0;
9174
+ let skipped = 0;
9175
+ for (const d of deltas) {
9176
+ if (d.fanInFanOut) {
9177
+ console.warn(`[executor] runtime LoRA: fan_in_fan_out target ${d.key} unsupported; skipping.`);
9178
+ skipped++;
9179
+ continue;
9180
+ }
9181
+ const node = this.graph.nodes.find((n) => {
9182
+ if (n.opType !== "MatMulInt4" && n.opType !== "MatMul") return false;
9183
+ const w = n.inputs[1];
9184
+ if (!w) return false;
9185
+ return (w.endsWith(".q") ? w.slice(0, -2) : w) === d.key;
9186
+ });
9187
+ if (!node) {
9188
+ skipped++;
9189
+ continue;
9190
+ }
9191
+ const K = node.attributes.K;
9192
+ const N = node.attributes.N;
9193
+ if (K !== d.inFeatures || N !== d.outFeatures) {
9194
+ console.warn(`[executor] runtime LoRA: dim mismatch on ${d.key} (base ${N}×${K}, delta ${d.outFeatures}×${d.inFeatures}); skipping.`);
9195
+ skipped++;
9196
+ continue;
9197
+ }
9198
+ const xName = node.inputs[0];
9199
+ const yName = node.outputs[0];
9200
+ const xBuf = this.getBuffer(xName);
9201
+ const yBuf = this.getBuffer(yName);
9202
+ if (!xBuf || !yBuf) {
9203
+ skipped++;
9204
+ continue;
9205
+ }
9206
+ const aBuf = createStorageBuffer(this.ctx, `lora_A_${node.id}`, d.A.byteLength, d.A);
9207
+ const bBuf = createStorageBuffer(this.ctx, `lora_B_${node.id}`, d.B.byteLength, d.B);
9208
+ const tmpBuf = createStorageBuffer(this.ctx, `lora_tmp_${node.id}`, this.maxSeqLen * d.r * 4);
9209
+ this.loraBuffers.push(aBuf, bBuf, tmpBuf);
9210
+ overlay.set(node.id, this.buildLoraPair(node.id, xName, xBuf, yBuf, aBuf, bBuf, tmpBuf, d));
9211
+ applied++;
9212
+ }
9213
+ if (applied === 0) {
9214
+ this.loraActive = false;
9215
+ return {
9216
+ applied,
9217
+ skipped
9218
+ };
9219
+ }
9220
+ this.decodeEntriesLoRA = this.buildSelectiveLoraDecode(overlay);
9221
+ this.prefillEntriesLoRA = this.spliceLoraOverlay(this.dispatchEntries, overlay);
9222
+ this.loraActive = true;
9223
+ return {
9224
+ applied,
9225
+ skipped
9226
+ };
9227
+ }
9228
+ /** Drop the runtime LoRA overlay and free its GPU buffers. Base is untouched. */
9229
+ clearRuntimeLoRA() {
9230
+ this.loraActive = false;
9231
+ this.decodeEntriesLoRA = [];
9232
+ this.prefillEntriesLoRA = [];
9233
+ for (const b of this.loraBuffers) try {
9234
+ b.destroy();
9235
+ } catch {}
9236
+ this.loraBuffers = [];
9237
+ }
9238
+ /** Build the [down, up] low-rank dispatch pair for one adapted node. */
9239
+ buildLoraPair(nodeId, xName, xBuf, yBuf, aBuf, bBuf, tmpBuf, d) {
9240
+ const shapes = this.resolveShapes(1);
9241
+ const downNode = {
9242
+ id: `lora_down_${nodeId}`,
9243
+ opType: "MatMul",
9244
+ inputs: [xName],
9245
+ outputs: [],
9246
+ attributes: {
9247
+ IN: d.inFeatures,
9248
+ R: d.r
9249
+ }
9250
+ };
9251
+ const downPipeline = getOrCreatePipeline(this.ctx, `lora_down_${nodeId}`, LORA_DOWN_SPEC.shaderCode, LORA_DOWN_SPEC.entryPoint);
9252
+ const downUniform = createUniformBuffer(this.ctx, `lora_down_u_${nodeId}`, LORA_DOWN_SPEC.buildParams(downNode, shapes));
9253
+ const downBind = createBindGroup(this.ctx, downPipeline, [
9254
+ { buffer: xBuf },
9255
+ { buffer: aBuf },
9256
+ { buffer: tmpBuf },
9257
+ { buffer: downUniform }
9258
+ ], `lora_down_bg_${nodeId}`);
9259
+ const upNode = {
9260
+ id: `lora_up_${nodeId}`,
9261
+ opType: "MatMul",
9262
+ inputs: [xName],
9263
+ outputs: [],
9264
+ attributes: {
9265
+ R: d.r,
9266
+ OUT: d.outFeatures,
9267
+ scaling: d.scaling
9268
+ }
9269
+ };
9270
+ const upPipeline = getOrCreatePipeline(this.ctx, `lora_up_${nodeId}`, LORA_UP_SPEC.shaderCode, LORA_UP_SPEC.entryPoint);
9271
+ const upUniform = createUniformBuffer(this.ctx, `lora_up_u_${nodeId}`, LORA_UP_SPEC.buildParams(upNode, shapes));
9272
+ const upBind = createBindGroup(this.ctx, upPipeline, [
9273
+ { buffer: tmpBuf },
9274
+ { buffer: bBuf },
9275
+ { buffer: yBuf },
9276
+ { buffer: upUniform }
9277
+ ], `lora_up_bg_${nodeId}`);
9278
+ this.loraBuffers.push(downUniform, upUniform);
9279
+ return [{
9280
+ nodeId: downNode.id,
9281
+ node: downNode,
9282
+ spec: LORA_DOWN_SPEC,
9283
+ pipeline: downPipeline,
9284
+ bindGroup: downBind,
9285
+ uniformBuffer: downUniform,
9286
+ lastParamsBytes: null,
9287
+ lastDispatchSize: null
9288
+ }, {
9289
+ nodeId: upNode.id,
9290
+ node: upNode,
9291
+ spec: LORA_UP_SPEC,
9292
+ pipeline: upPipeline,
9293
+ bindGroup: upBind,
9294
+ uniformBuffer: upUniform,
9295
+ lastParamsBytes: null,
9296
+ lastDispatchSize: null
9297
+ }];
9298
+ }
9299
+ /** Copy a base entry list, splicing each node's LoRA pair in right after it. */
9300
+ spliceLoraOverlay(base, overlay) {
9301
+ const out = [];
9302
+ for (const entry of base) {
9303
+ out.push(entry);
9304
+ const pair = overlay.get(entry.nodeId);
9305
+ if (pair) out.push(...pair);
9306
+ }
9307
+ return out;
9308
+ }
9309
+ /** Original constituent node ids a (possibly fused) decode entry covers. */
9310
+ coveredNodeIds(entry) {
9311
+ return entry.fusedNodeIds ?? [entry.nodeId];
9312
+ }
9313
+ /**
9314
+ * Build the decode entry list for an active adapter with SELECTIVE unfusing.
9315
+ * Every fused group that covers no adapted linear is kept exactly as the
9316
+ * no-adapter fast path runs it (full SwiGLU/dual/gated fusion, no numerics
9317
+ * change). Only the groups that cover an adapted node fall back to their
9318
+ * pre-fusion per-node dispatches (pulled from {@link decodeEntriesUnfused}),
9319
+ * with the low-rank `[down, up]` pair spliced right after each adapted node so
9320
+ * its corrected output is live before any consumer reads it. Replaying the
9321
+ * exact pre-fusion entries reproduces the validated unfused numerics for the
9322
+ * adapted groups while leaving all other groups on the fused path.
9323
+ */
9324
+ buildSelectiveLoraDecode(overlay) {
9325
+ const unfusedById = /* @__PURE__ */ new Map();
9326
+ for (const e of this.decodeEntriesUnfused) unfusedById.set(e.nodeId, e);
9327
+ const out = [];
9328
+ for (const entry of this.decodeEntries) {
9329
+ const covered = this.coveredNodeIds(entry);
9330
+ const bases = covered.map((id) => unfusedById.get(id));
9331
+ if (!covered.some((id) => overlay.has(id)) || bases.some((b) => b === void 0)) {
9332
+ out.push(entry);
9333
+ continue;
9334
+ }
9335
+ for (let k = 0; k < covered.length; k++) {
9336
+ out.push(bases[k]);
9337
+ const pair = overlay.get(covered[k]);
9338
+ if (pair) out.push(...pair);
9339
+ }
9340
+ }
9341
+ return out;
9342
+ }
9026
9343
  /**
9027
9344
  * Run a forward pass. Uses matvec kernels for M=1 (decode), tiled for M>1 (prefill).
9028
9345
  */
@@ -9030,7 +9347,7 @@ var Executor = class Executor {
9030
9347
  const T = inputIds.length;
9031
9348
  const resolvedShapes = this.resolveShapes(T);
9032
9349
  const runtimeContext = { seqPos: this.seqPos };
9033
- const entries = T === 1 ? this.decodeEntries : this.dispatchEntries;
9350
+ const entries = T === 1 ? this.loraActive ? this.decodeEntriesLoRA : this.decodeEntries : this.loraActive ? this.prefillEntriesLoRA : this.dispatchEntries;
9034
9351
  this.ctx.device.queue.writeBuffer(this.inputIdsBuffer, 0, inputIds);
9035
9352
  await this.streamPleRows(inputIds);
9036
9353
  const dispatchSizes = new Array(entries.length);
@@ -9434,10 +9751,11 @@ var Executor = class Executor {
9434
9751
  };
9435
9752
  const resolvedShapes = this.resolveShapes(T);
9436
9753
  const runtimeContext = { seqPos: this.seqPos };
9754
+ const decodeEntries = this.activeDecodeEntries;
9437
9755
  this.ctx.device.queue.writeBuffer(this.inputIdsBuffer, 0, inputIds);
9438
- const argmaxDispatchSizes = new Array(this.decodeEntries.length);
9439
- for (let i = 0; i < this.decodeEntries.length; i++) {
9440
- const entry = this.decodeEntries[i];
9756
+ const argmaxDispatchSizes = new Array(decodeEntries.length);
9757
+ for (let i = 0; i < decodeEntries.length; i++) {
9758
+ const entry = decodeEntries[i];
9441
9759
  const paramsData = entry.spec.buildParams(entry.node, resolvedShapes, runtimeContext);
9442
9760
  const paramsView = new Uint8Array(paramsData);
9443
9761
  let changed = !entry.lastParamsBytes || entry.lastParamsBytes.length !== paramsView.length;
@@ -9468,13 +9786,13 @@ var Executor = class Executor {
9468
9786
  mark("uniformMs");
9469
9787
  const group = this.webkitGroupSize;
9470
9788
  const perOp = budget && group === 1 ? globalThis.__webkitBudgetByOp ??= {} : null;
9471
- for (let start = 0; start < this.decodeEntries.length; start += group) {
9789
+ for (let start = 0; start < decodeEntries.length; start += group) {
9472
9790
  const enc = this.ctx.device.createCommandEncoder();
9473
- const end = Math.min(start + group, this.decodeEntries.length);
9791
+ const end = Math.min(start + group, decodeEntries.length);
9474
9792
  for (let i = start; i < end; i++) {
9475
9793
  const p = enc.beginComputePass();
9476
- p.setPipeline(this.decodeEntries[i].pipeline);
9477
- p.setBindGroup(0, this.decodeEntries[i].bindGroup);
9794
+ p.setPipeline(decodeEntries[i].pipeline);
9795
+ p.setBindGroup(0, decodeEntries[i].bindGroup);
9478
9796
  p.dispatchWorkgroups(...argmaxDispatchSizes[i]);
9479
9797
  p.end();
9480
9798
  }
@@ -9484,7 +9802,7 @@ var Executor = class Executor {
9484
9802
  const t0 = perOp ? performance.now() : 0;
9485
9803
  await this.ctx.device.queue.onSubmittedWorkDone();
9486
9804
  if (perOp) {
9487
- const op = this.decodeEntries[start].node.opType;
9805
+ const op = decodeEntries[start].node.opType;
9488
9806
  const cell = perOp[op] ??= {
9489
9807
  ms: 0,
9490
9808
  n: 0
@@ -9510,8 +9828,8 @@ var Executor = class Executor {
9510
9828
  } else {
9511
9829
  const encoder = this.ctx.device.createCommandEncoder({ label: "argmax" });
9512
9830
  const pass = encoder.beginComputePass({ label: "am_pass" });
9513
- for (let i = 0; i < this.decodeEntries.length; i++) {
9514
- const entry = this.decodeEntries[i];
9831
+ for (let i = 0; i < decodeEntries.length; i++) {
9832
+ const entry = decodeEntries[i];
9515
9833
  pass.setPipeline(entry.pipeline);
9516
9834
  pass.setBindGroup(0, entry.bindGroup);
9517
9835
  pass.dispatchWorkgroups(...argmaxDispatchSizes[i]);
@@ -9573,9 +9891,10 @@ var Executor = class Executor {
9573
9891
  this.ctx.device.queue.writeBuffer(this.argmaxEntry.uniformBuffer, 0, argmaxParams);
9574
9892
  }
9575
9893
  }
9576
- const dispatchSizes = new Array(this.decodeEntries.length);
9577
- for (let i = 0; i < this.decodeEntries.length; i++) {
9578
- const entry = this.decodeEntries[i];
9894
+ const decodeEntries = this.activeDecodeEntries;
9895
+ const dispatchSizes = new Array(decodeEntries.length);
9896
+ for (let i = 0; i < decodeEntries.length; i++) {
9897
+ const entry = decodeEntries[i];
9579
9898
  const paramsData = entry.spec.buildParams(entry.node, resolvedShapes, runtimeContext);
9580
9899
  const paramsView = new Uint8Array(paramsData);
9581
9900
  let changed = !entry.lastParamsBytes || entry.lastParamsBytes.length !== paramsView.length;
@@ -9627,8 +9946,8 @@ var Executor = class Executor {
9627
9946
  endOfPassWriteIndex: 1
9628
9947
  }
9629
9948
  } : { label: "decode_pass" });
9630
- for (let i = 0; i < this.decodeEntries.length; i++) {
9631
- const entry = this.decodeEntries[i];
9949
+ for (let i = 0; i < decodeEntries.length; i++) {
9950
+ const entry = decodeEntries[i];
9632
9951
  pass.setPipeline(entry.pipeline);
9633
9952
  pass.setBindGroup(0, entry.bindGroup);
9634
9953
  pass.dispatchWorkgroups(...dispatchSizes[i]);
@@ -9683,6 +10002,10 @@ var Executor = class Executor {
9683
10002
  entry.lastParamsBytes = null;
9684
10003
  entry.lastDispatchSize = null;
9685
10004
  }
10005
+ for (const entry of [...this.decodeEntriesLoRA, ...this.prefillEntriesLoRA]) {
10006
+ entry.lastParamsBytes = null;
10007
+ entry.lastDispatchSize = null;
10008
+ }
9686
10009
  }
9687
10010
  /**
9688
10011
  * Diagnostic: dispatch ONLY the first kernel (EmbeddingInt4) using the
@@ -10094,6 +10417,11 @@ var Executor = class Executor {
10094
10417
  const fusedBindGroup = createBindGroup(this.ctx, fusedPipeline, bufferEntries, `bg_swiglu_mv_${e1.nodeId}`);
10095
10418
  const fusedEntry = {
10096
10419
  nodeId: `fused_swiglu_${e1.nodeId}`,
10420
+ fusedNodeIds: [
10421
+ ...this.coveredNodeIds(e1),
10422
+ ...this.coveredNodeIds(e2),
10423
+ ...this.coveredNodeIds(e3)
10424
+ ],
10097
10425
  node: e1.node,
10098
10426
  spec: fusedSpec,
10099
10427
  pipeline: fusedPipeline,
@@ -10164,6 +10492,7 @@ var Executor = class Executor {
10164
10492
  const fusedBindGroup = createBindGroup(this.ctx, fusedPipeline, bufferEntries, `bg_dual_mv_${e0.nodeId}`);
10165
10493
  const fusedEntry = {
10166
10494
  nodeId: `fused_dual_${e0.nodeId}`,
10495
+ fusedNodeIds: [...this.coveredNodeIds(e0), ...this.coveredNodeIds(e1)],
10167
10496
  node: e0.node,
10168
10497
  spec: fusedSpec,
10169
10498
  pipeline: fusedPipeline,
@@ -10223,6 +10552,7 @@ var Executor = class Executor {
10223
10552
  const fusedBindGroup = createBindGroup(this.ctx, fusedPipeline, bufferEntries, `bg_dual_kv_${e0.nodeId}`);
10224
10553
  const fusedEntry = {
10225
10554
  nodeId: `fused_kv_${e0.nodeId}`,
10555
+ fusedNodeIds: [...this.coveredNodeIds(e0), ...this.coveredNodeIds(e1)],
10226
10556
  node: e0.node,
10227
10557
  spec: fusedSpec,
10228
10558
  pipeline: fusedPipeline,
@@ -10286,6 +10616,7 @@ var Executor = class Executor {
10286
10616
  const fusedBindGroup = createBindGroup(this.ctx, fusedPipeline, bufferEntries, `bg_gated_o_${eo.nodeId}`);
10287
10617
  const fusedEntry = {
10288
10618
  nodeId: `fused_gated_o_${eo.nodeId}`,
10619
+ fusedNodeIds: [...this.coveredNodeIds(eg), ...this.coveredNodeIds(eo)],
10289
10620
  node: eo.node,
10290
10621
  spec: fusedSpec,
10291
10622
  pipeline: fusedPipeline,
@@ -10346,6 +10677,7 @@ var Executor = class Executor {
10346
10677
  const fusedBindGroup = createBindGroup(this.ctx, fusedPipeline, bufferEntries, `bg_swiglu_gated_${ep.nodeId}`);
10347
10678
  const fusedEntry = {
10348
10679
  nodeId: `fused_swiglu_gated_${ep.nodeId}`,
10680
+ fusedNodeIds: [...this.coveredNodeIds(es), ...this.coveredNodeIds(ep)],
10349
10681
  node: ep.node,
10350
10682
  spec: fusedSpec,
10351
10683
  pipeline: fusedPipeline,
@@ -10423,6 +10755,7 @@ var Executor = class Executor {
10423
10755
  const fusedBindGroup = createBindGroup(this.ctx, fusedPipeline, bufferList, `bg_conv_update_${e1.nodeId}`);
10424
10756
  const fusedEntry = {
10425
10757
  nodeId: `fused_conv_update_${e1.nodeId}`,
10758
+ fusedNodeIds: [...this.coveredNodeIds(e1), ...this.coveredNodeIds(e2)],
10426
10759
  node: e1.node,
10427
10760
  spec: fusedSpec,
10428
10761
  pipeline: fusedPipeline,
@@ -10507,6 +10840,7 @@ var Executor = class Executor {
10507
10840
  const fusedBindGroup = createBindGroup(this.ctx, fusedPipeline, bufferEntries, `bg_add_norm_${e0.nodeId}`);
10508
10841
  this.decodeEntries.splice(i, 2, {
10509
10842
  nodeId: fusedNode.id,
10843
+ fusedNodeIds: [...this.coveredNodeIds(e0), ...this.coveredNodeIds(e1)],
10510
10844
  node: fusedNode,
10511
10845
  spec: fusedSpec,
10512
10846
  pipeline: fusedPipeline,
@@ -10592,6 +10926,11 @@ var Executor = class Executor {
10592
10926
  const fusedBindGroup = createBindGroup(this.ctx, fusedPipeline, bufferEntries, `bg_dual_norm_rope_${e0.nodeId}`);
10593
10927
  const fusedEntry = {
10594
10928
  nodeId: fusedNode.id,
10929
+ fusedNodeIds: [
10930
+ ...this.coveredNodeIds(e0),
10931
+ ...this.coveredNodeIds(e1),
10932
+ ...this.coveredNodeIds(e2)
10933
+ ],
10595
10934
  node: fusedNode,
10596
10935
  spec: fusedSpec,
10597
10936
  pipeline: fusedPipeline,
@@ -10665,6 +11004,7 @@ var Executor = class Executor {
10665
11004
  const fusedBindGroup = createBindGroup(this.ctx, fusedPipeline, bufferEntries, `bg_dual_norm_${e0.nodeId}`);
10666
11005
  const fusedEntry = {
10667
11006
  nodeId: fusedNode.id,
11007
+ fusedNodeIds: [...this.coveredNodeIds(e0), ...this.coveredNodeIds(e1)],
10668
11008
  node: fusedNode,
10669
11009
  spec: fusedSpec,
10670
11010
  pipeline: fusedPipeline,
@@ -14496,5 +14836,5 @@ function selectGraphWeights(graph, weights) {
14496
14836
  }
14497
14837
 
14498
14838
  //#endregion
14499
- export { getOrCreatePipeline as C, destroyBuffers as S, verifyGPU as T, MATMUL_BIAS_F16C_SPEC as _, loadMoonshine as a, createStorageBuffer as b, quantizeBackboneInt4 as c, Tokenizer as d, applyLoRAToStore as f, KERNEL_REGISTRY as g, Executor as h, loadModel as i, quantizeKaniBackbone as l, fetchAdapter as m, MoonshineEncoderExecutor as n, loadOuteTTS as o, buildLoRADeltas as p, loadKaniTTS as r, loadParlerTTS as s, MoonshineSTT as t, remapPrunedToken as u, clearPipelineCache as v, initGPU as w, createUniformBuffer as x, createBindGroup as y };
14500
- //# sourceMappingURL=moonshine-stt-9wc6t11v.mjs.map
14839
+ export { destroyBuffers as C, verifyGPU as E, createUniformBuffer as S, initGPU as T, KERNEL_REGISTRY as _, loadModel as a, createBindGroup as b, loadParlerTTS as c, remapPrunedToken as d, Tokenizer as f, Executor as g, fetchAdapter as h, loadKaniTTS as i, quantizeBackboneInt4 as l, buildLoRADeltas as m, MoonshineEncoderExecutor as n, loadMoonshine as o, applyLoRAToStore as p, createKeyMapperForArch as r, loadOuteTTS as s, MoonshineSTT as t, quantizeKaniBackbone as u, MATMUL_BIAS_F16C_SPEC as v, getOrCreatePipeline as w, createStorageBuffer as x, clearPipelineCache as y };
14840
+ //# sourceMappingURL=moonshine-stt-BKeD6OYF.mjs.map