@tryhamster/gerbil 1.8.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +10 -0
- package/dist/browser/index.js.map +1 -1
- package/dist/cli.mjs +7 -7
- package/dist/cli.mjs.map +1 -1
- package/dist/frameworks/express.mjs +1 -1
- package/dist/frameworks/fastify.mjs +1 -1
- package/dist/frameworks/hono.mjs +1 -1
- package/dist/frameworks/next.d.mts +2 -2
- package/dist/frameworks/next.mjs +1 -1
- package/dist/frameworks/trpc.mjs +1 -1
- package/dist/{gerbil-DU1aRO6v.d.mts → gerbil-CSk3AHNN.d.mts} +10 -9
- package/dist/{gerbil-DU1aRO6v.d.mts.map → gerbil-CSk3AHNN.d.mts.map} +1 -1
- package/dist/gerbil-DrV6iNcD.mjs +4 -0
- package/dist/{gerbil-Cgmb4Dit.mjs → gerbil-DtREprR_.mjs} +32 -10
- package/dist/gerbil-DtREprR_.mjs.map +1 -0
- package/dist/gpu/hooks.d.mts +16 -1
- package/dist/gpu/hooks.d.mts.map +1 -1
- package/dist/gpu/hooks.mjs +29 -4
- package/dist/gpu/hooks.mjs.map +1 -1
- package/dist/gpu/index.d.mts +1 -1
- package/dist/gpu/index.mjs +2 -2
- package/dist/{gpu-kQVLpV3n.mjs → gpu-NPdk7pmr.mjs} +221 -25
- package/dist/gpu-NPdk7pmr.mjs.map +1 -0
- package/dist/{index-ElJKy9i9.d.mts → index-B56xBiR2.d.mts} +96 -4
- package/dist/index-B56xBiR2.d.mts.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/integrations/ai-sdk.mjs +1 -1
- package/dist/integrations/langchain.mjs +1 -1
- package/dist/integrations/llamaindex.mjs +1 -1
- package/dist/integrations/mcp.d.mts +2 -2
- package/dist/integrations/mcp.mjs +4 -4
- package/dist/{mcp-DTusP2m5.mjs → mcp-XU4quJ9w.mjs} +3 -3
- package/dist/{mcp-DTusP2m5.mjs.map → mcp-XU4quJ9w.mjs.map} +1 -1
- package/dist/moonshine-stt-BRTnAoQ8.mjs +4 -0
- package/dist/{moonshine-stt-9wc6t11v.mjs → moonshine-stt-BYbYwSz2.mjs} +301 -13
- package/dist/moonshine-stt-BYbYwSz2.mjs.map +1 -0
- package/dist/{one-liner-Bk5x7gYH.mjs → one-liner-1WoJGLlZ.mjs} +2 -2
- package/dist/{one-liner-Bk5x7gYH.mjs.map → one-liner-1WoJGLlZ.mjs.map} +1 -1
- package/dist/{repl-DV6l-jT8.mjs → repl-B41yROa-.mjs} +3 -3
- package/dist/skills/index.d.mts +4 -4
- package/dist/skills/index.mjs +3 -3
- package/dist/{skills-BhcwnL2l.mjs → skills-C9RgR8qU.mjs} +2 -2
- package/dist/{skills-BhcwnL2l.mjs.map → skills-C9RgR8qU.mjs.map} +1 -1
- package/dist/tune/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/gerbil-BFk5jV0h.mjs +0 -4
- package/dist/gerbil-Cgmb4Dit.mjs.map +0 -1
- package/dist/gpu-kQVLpV3n.mjs.map +0 -1
- package/dist/index-ElJKy9i9.d.mts.map +0 -1
- package/dist/moonshine-stt-9wc6t11v.mjs.map +0 -1
- 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,164 @@ 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.spliceLoraOverlay(this.decodeEntriesUnfused, 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
|
+
}
|
|
9026
9309
|
/**
|
|
9027
9310
|
* Run a forward pass. Uses matvec kernels for M=1 (decode), tiled for M>1 (prefill).
|
|
9028
9311
|
*/
|
|
@@ -9030,7 +9313,7 @@ var Executor = class Executor {
|
|
|
9030
9313
|
const T = inputIds.length;
|
|
9031
9314
|
const resolvedShapes = this.resolveShapes(T);
|
|
9032
9315
|
const runtimeContext = { seqPos: this.seqPos };
|
|
9033
|
-
const entries = T === 1 ? this.decodeEntries : this.dispatchEntries;
|
|
9316
|
+
const entries = T === 1 ? this.loraActive ? this.decodeEntriesLoRA : this.decodeEntries : this.loraActive ? this.prefillEntriesLoRA : this.dispatchEntries;
|
|
9034
9317
|
this.ctx.device.queue.writeBuffer(this.inputIdsBuffer, 0, inputIds);
|
|
9035
9318
|
await this.streamPleRows(inputIds);
|
|
9036
9319
|
const dispatchSizes = new Array(entries.length);
|
|
@@ -9434,10 +9717,11 @@ var Executor = class Executor {
|
|
|
9434
9717
|
};
|
|
9435
9718
|
const resolvedShapes = this.resolveShapes(T);
|
|
9436
9719
|
const runtimeContext = { seqPos: this.seqPos };
|
|
9720
|
+
const decodeEntries = this.activeDecodeEntries;
|
|
9437
9721
|
this.ctx.device.queue.writeBuffer(this.inputIdsBuffer, 0, inputIds);
|
|
9438
|
-
const argmaxDispatchSizes = new Array(
|
|
9439
|
-
for (let i = 0; i <
|
|
9440
|
-
const entry =
|
|
9722
|
+
const argmaxDispatchSizes = new Array(decodeEntries.length);
|
|
9723
|
+
for (let i = 0; i < decodeEntries.length; i++) {
|
|
9724
|
+
const entry = decodeEntries[i];
|
|
9441
9725
|
const paramsData = entry.spec.buildParams(entry.node, resolvedShapes, runtimeContext);
|
|
9442
9726
|
const paramsView = new Uint8Array(paramsData);
|
|
9443
9727
|
let changed = !entry.lastParamsBytes || entry.lastParamsBytes.length !== paramsView.length;
|
|
@@ -9468,13 +9752,13 @@ var Executor = class Executor {
|
|
|
9468
9752
|
mark("uniformMs");
|
|
9469
9753
|
const group = this.webkitGroupSize;
|
|
9470
9754
|
const perOp = budget && group === 1 ? globalThis.__webkitBudgetByOp ??= {} : null;
|
|
9471
|
-
for (let start = 0; start <
|
|
9755
|
+
for (let start = 0; start < decodeEntries.length; start += group) {
|
|
9472
9756
|
const enc = this.ctx.device.createCommandEncoder();
|
|
9473
|
-
const end = Math.min(start + group,
|
|
9757
|
+
const end = Math.min(start + group, decodeEntries.length);
|
|
9474
9758
|
for (let i = start; i < end; i++) {
|
|
9475
9759
|
const p = enc.beginComputePass();
|
|
9476
|
-
p.setPipeline(
|
|
9477
|
-
p.setBindGroup(0,
|
|
9760
|
+
p.setPipeline(decodeEntries[i].pipeline);
|
|
9761
|
+
p.setBindGroup(0, decodeEntries[i].bindGroup);
|
|
9478
9762
|
p.dispatchWorkgroups(...argmaxDispatchSizes[i]);
|
|
9479
9763
|
p.end();
|
|
9480
9764
|
}
|
|
@@ -9484,7 +9768,7 @@ var Executor = class Executor {
|
|
|
9484
9768
|
const t0 = perOp ? performance.now() : 0;
|
|
9485
9769
|
await this.ctx.device.queue.onSubmittedWorkDone();
|
|
9486
9770
|
if (perOp) {
|
|
9487
|
-
const op =
|
|
9771
|
+
const op = decodeEntries[start].node.opType;
|
|
9488
9772
|
const cell = perOp[op] ??= {
|
|
9489
9773
|
ms: 0,
|
|
9490
9774
|
n: 0
|
|
@@ -9510,8 +9794,8 @@ var Executor = class Executor {
|
|
|
9510
9794
|
} else {
|
|
9511
9795
|
const encoder = this.ctx.device.createCommandEncoder({ label: "argmax" });
|
|
9512
9796
|
const pass = encoder.beginComputePass({ label: "am_pass" });
|
|
9513
|
-
for (let i = 0; i <
|
|
9514
|
-
const entry =
|
|
9797
|
+
for (let i = 0; i < decodeEntries.length; i++) {
|
|
9798
|
+
const entry = decodeEntries[i];
|
|
9515
9799
|
pass.setPipeline(entry.pipeline);
|
|
9516
9800
|
pass.setBindGroup(0, entry.bindGroup);
|
|
9517
9801
|
pass.dispatchWorkgroups(...argmaxDispatchSizes[i]);
|
|
@@ -9683,6 +9967,10 @@ var Executor = class Executor {
|
|
|
9683
9967
|
entry.lastParamsBytes = null;
|
|
9684
9968
|
entry.lastDispatchSize = null;
|
|
9685
9969
|
}
|
|
9970
|
+
for (const entry of [...this.decodeEntriesLoRA, ...this.prefillEntriesLoRA]) {
|
|
9971
|
+
entry.lastParamsBytes = null;
|
|
9972
|
+
entry.lastDispatchSize = null;
|
|
9973
|
+
}
|
|
9686
9974
|
}
|
|
9687
9975
|
/**
|
|
9688
9976
|
* Diagnostic: dispatch ONLY the first kernel (EmbeddingInt4) using the
|
|
@@ -14496,5 +14784,5 @@ function selectGraphWeights(graph, weights) {
|
|
|
14496
14784
|
}
|
|
14497
14785
|
|
|
14498
14786
|
//#endregion
|
|
14499
|
-
export {
|
|
14500
|
-
//# sourceMappingURL=moonshine-stt-
|
|
14787
|
+
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 };
|
|
14788
|
+
//# sourceMappingURL=moonshine-stt-BYbYwSz2.mjs.map
|