@tryhamster/gerbil 1.10.1 → 1.10.2
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/cli.mjs +1 -1
- package/dist/cli.mjs.map +1 -1
- package/dist/gpu/index.mjs +1 -1
- package/dist/{gpu-B1xk3xOJ.mjs → gpu-Ps1eQaXG.mjs} +86 -15
- package/dist/gpu-Ps1eQaXG.mjs.map +1 -0
- package/dist/index.mjs +1 -1
- package/dist/outetts-CAL3_K3j.d.mts.map +1 -1
- package/dist/skills/index.d.mts +11 -11
- package/dist/skills/index.d.mts.map +1 -1
- package/package.json +1 -1
- package/dist/gpu-B1xk3xOJ.mjs.map +0 -1
package/dist/gpu/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as resolveDefaultRepo, n as OUTETTS_ASSETS, r as OUTETTS_PRESET_VOICES, t as DEFAULT_MODELS } from "../defaults-C_bJK9zs.mjs";
|
|
2
2
|
import { D as createDefaultHFKeyMapper, a as generateMoonshineEncoderGraph, h as generateNanoCodecDecoderGraph, i as generateMoonshineDecoderGraph, m as generateKaniTtsGraph, o as moonshineEncoderFrames, r as MOONSHINE_REMAINING_WORK, s as parseMoonshineConfig, u as audioTokensToCodes, x as parseKaniConfig } from "../architectures-BHkqQ9xp.mjs";
|
|
3
|
-
import { A as dequantizeGemma4VisionProjection, C as audioTokensToDacCodes, D as parseOuteTtsConfig, E as generateOuteTtsBackboneGraph, M as generateGemma4VisionGraph, N as patchGemma4VisionClips, O as KaniTTS, P as resolveGemma4VisionInfo, S as loadOuteSpeaker, T as generateDacSpeechDecoderGraph, _ as smartResize, a as buildGemma4PosEmbeds, b as OuteTTS, c as buildMRoPECosSin, d as buildPositionIds, f as buildRotaryCosSin, g as preprocessImageGemma4, h as preprocessImage, i as buildGemma4PoolMatrix, j as dequantizeMLXProjection, k as generateQwen3_5VisionGraph, l as buildMRoPEPositionIds, m as mropeFreqDims, n as GEMMA4_IMAGE_PROCESSOR, o as buildGemma4RotaryCosSin, p as buildVisionPositionTensors, r as QWEN3_5_IMAGE_PROCESSOR, s as buildGemma4VisionPositionTensors, t as WebGPUEngine, u as buildPosEmbeds, v as VisionExecutor, w as dacOutputLength, x as buildOutePromptString, y as ParlerTTS } from "../gpu-
|
|
3
|
+
import { A as dequantizeGemma4VisionProjection, C as audioTokensToDacCodes, D as parseOuteTtsConfig, E as generateOuteTtsBackboneGraph, M as generateGemma4VisionGraph, N as patchGemma4VisionClips, O as KaniTTS, P as resolveGemma4VisionInfo, S as loadOuteSpeaker, T as generateDacSpeechDecoderGraph, _ as smartResize, a as buildGemma4PosEmbeds, b as OuteTTS, c as buildMRoPECosSin, d as buildPositionIds, f as buildRotaryCosSin, g as preprocessImageGemma4, h as preprocessImage, i as buildGemma4PoolMatrix, j as dequantizeMLXProjection, k as generateQwen3_5VisionGraph, l as buildMRoPEPositionIds, m as mropeFreqDims, n as GEMMA4_IMAGE_PROCESSOR, o as buildGemma4RotaryCosSin, p as buildVisionPositionTensors, r as QWEN3_5_IMAGE_PROCESSOR, s as buildGemma4VisionPositionTensors, t as WebGPUEngine, u as buildPosEmbeds, v as VisionExecutor, w as dacOutputLength, x as buildOutePromptString, y as ParlerTTS } from "../gpu-Ps1eQaXG.mjs";
|
|
4
4
|
import { T as initGPU, a as loadModel, f as Tokenizer, g as Executor, h as fetchAdapter, i as loadKaniTTS, m as buildLoRADeltas, n as MoonshineEncoderExecutor, o as loadMoonshine, p as applyLoRAToStore, t as MoonshineSTT, u as quantizeKaniBackbone } from "../moonshine-stt-BKeD6OYF.mjs";
|
|
5
5
|
|
|
6
6
|
export { DEFAULT_MODELS, Executor, GEMMA4_IMAGE_PROCESSOR, KaniTTS, MOONSHINE_REMAINING_WORK, MoonshineEncoderExecutor, MoonshineSTT, OUTETTS_ASSETS, OUTETTS_PRESET_VOICES, OuteTTS, ParlerTTS, QWEN3_5_IMAGE_PROCESSOR, Tokenizer, VisionExecutor, WebGPUEngine, applyLoRAToStore, audioTokensToCodes, audioTokensToDacCodes, buildGemma4PoolMatrix, buildGemma4PosEmbeds, buildGemma4RotaryCosSin, buildGemma4VisionPositionTensors, buildLoRADeltas, buildMRoPECosSin, buildMRoPEPositionIds, buildOutePromptString, buildPosEmbeds, buildPositionIds, buildRotaryCosSin, buildVisionPositionTensors, createDefaultHFKeyMapper, dacOutputLength, dequantizeGemma4VisionProjection, dequantizeMLXProjection, fetchAdapter, generateDacSpeechDecoderGraph, generateGemma4VisionGraph, generateKaniTtsGraph, generateMoonshineDecoderGraph, generateMoonshineEncoderGraph, generateNanoCodecDecoderGraph, generateOuteTtsBackboneGraph, generateQwen3_5VisionGraph, initGPU, loadKaniTTS, loadModel, loadMoonshine, loadOuteSpeaker, moonshineEncoderFrames, mropeFreqDims, parseKaniConfig, parseMoonshineConfig, parseOuteTtsConfig, patchGemma4VisionClips, preprocessImage, preprocessImageGemma4, quantizeKaniBackbone, resolveDefaultRepo, resolveGemma4VisionInfo, smartResize };
|
|
@@ -806,7 +806,7 @@ function nucleusSample$1(probs, ids, topP) {
|
|
|
806
806
|
* In-place top-k filter over a probability array: keep only the `k` highest, zero
|
|
807
807
|
* the rest, and renormalize. No-op when k <= 0 or k >= length (keep everything).
|
|
808
808
|
*/
|
|
809
|
-
function applyTopK
|
|
809
|
+
function applyTopK(scores, k) {
|
|
810
810
|
const n = scores.length;
|
|
811
811
|
if (k <= 0 || k >= n) return;
|
|
812
812
|
const order = Array.from({ length: n }, (_, i) => i).sort((a, b) => scores[b] - scores[a]);
|
|
@@ -1065,7 +1065,7 @@ var KaniTTS = class KaniTTS {
|
|
|
1065
1065
|
scores[i] = s / p.temperature;
|
|
1066
1066
|
}
|
|
1067
1067
|
softmaxInPlace$1(scores);
|
|
1068
|
-
applyTopK
|
|
1068
|
+
applyTopK(scores, p.topK);
|
|
1069
1069
|
return nucleusSample$1(scores, ids, p.topP);
|
|
1070
1070
|
}
|
|
1071
1071
|
/**
|
|
@@ -2880,16 +2880,6 @@ function softmaxInPlace(scores) {
|
|
|
2880
2880
|
}
|
|
2881
2881
|
for (let i = 0; i < scores.length; i++) scores[i] /= sum;
|
|
2882
2882
|
}
|
|
2883
|
-
/** In-place top-k filter: keep the k highest, zero the rest, renormalize. */
|
|
2884
|
-
function applyTopK(scores, k) {
|
|
2885
|
-
const n = scores.length;
|
|
2886
|
-
if (k <= 0 || k >= n) return;
|
|
2887
|
-
const order = Array.from({ length: n }, (_, i) => i).sort((a, b) => scores[b] - scores[a]);
|
|
2888
|
-
let keepSum = 0;
|
|
2889
|
-
for (let r = 0; r < k; r++) keepSum += scores[order[r]];
|
|
2890
|
-
for (let r = k; r < n; r++) scores[order[r]] = 0;
|
|
2891
|
-
if (keepSum > 0) for (let i = 0; i < n; i++) scores[i] /= keepSum;
|
|
2892
|
-
}
|
|
2893
2883
|
/** Top-p nucleus sample from a softmaxed prob array over `ids`. */
|
|
2894
2884
|
function nucleusSample(probs, ids, topP) {
|
|
2895
2885
|
const n = probs.length;
|
|
@@ -2913,6 +2903,81 @@ function nucleusSample(probs, ids, topP) {
|
|
|
2913
2903
|
return ids[order[0]];
|
|
2914
2904
|
}
|
|
2915
2905
|
/**
|
|
2906
|
+
* Select the `k` highest-scoring token ids in a single O(n·logk) pass (bounded
|
|
2907
|
+
* min-heap), applying the repetition penalty to `previous` tokens inline so a
|
|
2908
|
+
* penalized token can drop out of the shortlist. Returns the kept ids and their
|
|
2909
|
+
* (penalized, pre-temperature) logits, unsorted.
|
|
2910
|
+
*
|
|
2911
|
+
* This replaces the two full-vocab `Array.from(...).sort(...)` passes the sampler
|
|
2912
|
+
* ran PER TOKEN over OuteTTS's ~157k vocab (the top-k filter + the nucleus sort):
|
|
2913
|
+
* a codec-LM emits hundreds-to-thousands of tokens per utterance, so those two
|
|
2914
|
+
* O(n·logn) sorts — plus their two fresh 157k-element allocations every step —
|
|
2915
|
+
* dominated host-side decode and made the browser SPEECH tab look stalled
|
|
2916
|
+
* ("SYNTHESIZING…" for minutes). Restricting the softmax + nucleus to the kept
|
|
2917
|
+
* top-k is distribution-identical to the old full-vocab path (softmax is
|
|
2918
|
+
* monotonic and the discarded tail is renormalized away either way).
|
|
2919
|
+
*/
|
|
2920
|
+
function selectTopKPenalized(logits, k, penalized, penalty) {
|
|
2921
|
+
const n = logits.length;
|
|
2922
|
+
const cap = Math.min(k, n);
|
|
2923
|
+
const heapVal = new Float32Array(cap);
|
|
2924
|
+
const heapId = new Int32Array(cap);
|
|
2925
|
+
let size = 0;
|
|
2926
|
+
const penalize = (i, v) => {
|
|
2927
|
+
if (penalized?.has(i)) return v > 0 ? v / penalty : v * penalty;
|
|
2928
|
+
return v;
|
|
2929
|
+
};
|
|
2930
|
+
const siftDown$1 = () => {
|
|
2931
|
+
let root = 0;
|
|
2932
|
+
for (;;) {
|
|
2933
|
+
let smallest = root;
|
|
2934
|
+
const l = 2 * root + 1;
|
|
2935
|
+
const r = 2 * root + 2;
|
|
2936
|
+
if (l < size && heapVal[l] < heapVal[smallest]) smallest = l;
|
|
2937
|
+
if (r < size && heapVal[r] < heapVal[smallest]) smallest = r;
|
|
2938
|
+
if (smallest === root) break;
|
|
2939
|
+
const tv = heapVal[root];
|
|
2940
|
+
const ti = heapId[root];
|
|
2941
|
+
heapVal[root] = heapVal[smallest];
|
|
2942
|
+
heapId[root] = heapId[smallest];
|
|
2943
|
+
heapVal[smallest] = tv;
|
|
2944
|
+
heapId[smallest] = ti;
|
|
2945
|
+
root = smallest;
|
|
2946
|
+
}
|
|
2947
|
+
};
|
|
2948
|
+
const siftUp = (node0) => {
|
|
2949
|
+
let node = node0;
|
|
2950
|
+
while (node > 0) {
|
|
2951
|
+
const parent = node - 1 >> 1;
|
|
2952
|
+
if (heapVal[parent] <= heapVal[node]) break;
|
|
2953
|
+
const tv = heapVal[node];
|
|
2954
|
+
const ti = heapId[node];
|
|
2955
|
+
heapVal[node] = heapVal[parent];
|
|
2956
|
+
heapId[node] = heapId[parent];
|
|
2957
|
+
heapVal[parent] = tv;
|
|
2958
|
+
heapId[parent] = ti;
|
|
2959
|
+
node = parent;
|
|
2960
|
+
}
|
|
2961
|
+
};
|
|
2962
|
+
for (let i = 0; i < n; i++) {
|
|
2963
|
+
const v = penalize(i, logits[i]);
|
|
2964
|
+
if (size < cap) {
|
|
2965
|
+
heapVal[size] = v;
|
|
2966
|
+
heapId[size] = i;
|
|
2967
|
+
size++;
|
|
2968
|
+
siftUp(size - 1);
|
|
2969
|
+
} else if (v > heapVal[0]) {
|
|
2970
|
+
heapVal[0] = v;
|
|
2971
|
+
heapId[0] = i;
|
|
2972
|
+
siftDown$1();
|
|
2973
|
+
}
|
|
2974
|
+
}
|
|
2975
|
+
return {
|
|
2976
|
+
ids: heapId.subarray(0, size),
|
|
2977
|
+
vals: heapVal.subarray(0, size)
|
|
2978
|
+
};
|
|
2979
|
+
}
|
|
2980
|
+
/**
|
|
2916
2981
|
* Resample interleaved-or-mono PCM to mono at `targetRate` via linear interpolation.
|
|
2917
2982
|
* Audio is assumed already mono (Float32 [-1,1]); if `srcRate === targetRate` the
|
|
2918
2983
|
* input is returned as-is. Linear resampling is sufficient for codec conditioning
|
|
@@ -3145,9 +3210,16 @@ var OuteTTS = class OuteTTS {
|
|
|
3145
3210
|
*/
|
|
3146
3211
|
sampleToken(logits, p) {
|
|
3147
3212
|
const n = logits.length;
|
|
3213
|
+
const prev = p.repetitionPenalty !== 1 ? new Set(p.previous) : null;
|
|
3214
|
+
if (p.topK > 0 && p.topK < n) {
|
|
3215
|
+
const { ids: kIds, vals: kVals } = selectTopKPenalized(logits, p.topK, prev, p.repetitionPenalty);
|
|
3216
|
+
const scores$1 = new Float32Array(kVals.length);
|
|
3217
|
+
for (let i = 0; i < kVals.length; i++) scores$1[i] = kVals[i] / p.temperature;
|
|
3218
|
+
softmaxInPlace(scores$1);
|
|
3219
|
+
return nucleusSample(scores$1, Int32Array.from(kIds), p.topP);
|
|
3220
|
+
}
|
|
3148
3221
|
const ids = new Int32Array(n);
|
|
3149
3222
|
const scores = new Float32Array(n);
|
|
3150
|
-
const prev = p.repetitionPenalty !== 1 ? new Set(p.previous) : null;
|
|
3151
3223
|
for (let i = 0; i < n; i++) {
|
|
3152
3224
|
ids[i] = i;
|
|
3153
3225
|
let s = logits[i];
|
|
@@ -3155,7 +3227,6 @@ var OuteTTS = class OuteTTS {
|
|
|
3155
3227
|
scores[i] = s / p.temperature;
|
|
3156
3228
|
}
|
|
3157
3229
|
softmaxInPlace(scores);
|
|
3158
|
-
applyTopK(scores, p.topK);
|
|
3159
3230
|
return nucleusSample(scores, ids, p.topP);
|
|
3160
3231
|
}
|
|
3161
3232
|
/**
|
|
@@ -7272,4 +7343,4 @@ var WebGPUEngine = class WebGPUEngine {
|
|
|
7272
7343
|
|
|
7273
7344
|
//#endregion
|
|
7274
7345
|
export { dequantizeGemma4VisionProjection as A, audioTokensToDacCodes as C, parseOuteTtsConfig as D, generateOuteTtsBackboneGraph as E, generateGemma4VisionGraph as M, patchGemma4VisionClips as N, KaniTTS as O, resolveGemma4VisionInfo as P, loadOuteSpeaker as S, generateDacSpeechDecoderGraph as T, smartResize as _, buildGemma4PosEmbeds as a, OuteTTS as b, buildMRoPECosSin as c, buildPositionIds as d, buildRotaryCosSin as f, preprocessImageGemma4 as g, preprocessImage as h, buildGemma4PoolMatrix as i, dequantizeMLXProjection as j, generateQwen3_5VisionGraph as k, buildMRoPEPositionIds as l, mropeFreqDims as m, GEMMA4_IMAGE_PROCESSOR as n, buildGemma4RotaryCosSin as o, buildVisionPositionTensors as p, QWEN3_5_IMAGE_PROCESSOR as r, buildGemma4VisionPositionTensors as s, WebGPUEngine as t, buildPosEmbeds as u, VisionExecutor as v, dacOutputLength as w, buildOutePromptString as x, ParlerTTS as y };
|
|
7275
|
-
//# sourceMappingURL=gpu-
|
|
7346
|
+
//# sourceMappingURL=gpu-Ps1eQaXG.mjs.map
|