webslm 0.3.1 → 0.4.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/README.md +62 -12
- package/dist/ai-sdk/index.d.ts +1 -1
- package/dist/ai-sdk/index.js +1 -1
- package/dist/cache/models.d.ts +6 -0
- package/dist/cache/models.js +11 -0
- package/dist/curated.d.ts +31 -1
- package/dist/curated.js +49 -5
- package/dist/engine.d.ts +33 -4
- package/dist/engine.js +451 -44
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/models.d.ts +23 -4
- package/dist/models.js +60 -5
- package/dist/native.d.ts +165 -0
- package/dist/native.js +243 -0
- package/dist/protocol.d.ts +12 -2
- package/dist/recommended-sampling.d.ts +54 -0
- package/dist/recommended-sampling.js +73 -0
- package/dist/simple.d.ts +20 -6
- package/dist/simple.js +33 -7
- package/dist/types.d.ts +81 -15
- package/native-manifest.json +47 -0
- package/package.json +2 -1
- package/wasm/relaxed/webslm_wasm.d.ts +26 -4
- package/wasm/relaxed/webslm_wasm.js +70 -17
- package/wasm/relaxed/webslm_wasm_bg.wasm +0 -0
- package/wasm/relaxed/webslm_wasm_bg.wasm.d.ts +5 -3
- package/wasm/simd/webslm_wasm.d.ts +26 -4
- package/wasm/simd/webslm_wasm.js +70 -17
- package/wasm/simd/webslm_wasm_bg.wasm +0 -0
- package/wasm/simd/webslm_wasm_bg.wasm.d.ts +5 -3
- package/wasm/threads/webslm_wasm.d.ts +26 -4
- package/wasm/threads/webslm_wasm.js +75 -22
- package/wasm/threads/webslm_wasm_bg.wasm +0 -0
- package/wasm/threads/webslm_wasm_bg.wasm.d.ts +5 -3
|
@@ -34,6 +34,41 @@ export class JsSource {
|
|
|
34
34
|
}
|
|
35
35
|
if (Symbol.dispose) JsSource.prototype[Symbol.dispose] = JsSource.prototype.free;
|
|
36
36
|
|
|
37
|
+
/**
|
|
38
|
+
* The converted-weight file of one model load (see the module docs).
|
|
39
|
+
*/
|
|
40
|
+
export class JsWeightCache {
|
|
41
|
+
__destroy_into_raw() {
|
|
42
|
+
const ptr = this.__wbg_ptr;
|
|
43
|
+
this.__wbg_ptr = 0;
|
|
44
|
+
JsWeightCacheFinalization.unregister(this);
|
|
45
|
+
return ptr;
|
|
46
|
+
}
|
|
47
|
+
free() {
|
|
48
|
+
const ptr = this.__destroy_into_raw();
|
|
49
|
+
wasm.__wbg_jsweightcache_free(ptr, 0);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* `key` names the converted checkpoint (`"org/name@sha"`; the load
|
|
53
|
+
* format is appended). `read(start, end)` resolves to bytes
|
|
54
|
+
* `[start, end)` of the stored file of `size` bytes (`0`: none);
|
|
55
|
+
* `write(chunk)` appends to the new file and may return a promise.
|
|
56
|
+
* @param {string} key
|
|
57
|
+
* @param {number} size
|
|
58
|
+
* @param {Function} read
|
|
59
|
+
* @param {Function} write
|
|
60
|
+
*/
|
|
61
|
+
constructor(key, size, read, write) {
|
|
62
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
63
|
+
const len0 = WASM_VECTOR_LEN;
|
|
64
|
+
const ret = wasm.jsweightcache_new(ptr0, len0, size, read, write);
|
|
65
|
+
this.__wbg_ptr = ret;
|
|
66
|
+
JsWeightCacheFinalization.register(this, this.__wbg_ptr, this);
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (Symbol.dispose) JsWeightCache.prototype[Symbol.dispose] = JsWeightCache.prototype.free;
|
|
71
|
+
|
|
37
72
|
/**
|
|
38
73
|
* Incremental SHA-256.
|
|
39
74
|
*/
|
|
@@ -223,12 +258,18 @@ export class WasmModel {
|
|
|
223
258
|
* (default 1), in `adapterMode` (default `"unmerged"`: its delta is
|
|
224
259
|
* added in f32 beside the weights; `"merged"` merges it into the
|
|
225
260
|
* weights as they load).
|
|
261
|
+
*
|
|
262
|
+
* `weightCache`, when given, keeps the converted (block-quantized)
|
|
263
|
+
* weights: a valid stored file serves them instead of converting the
|
|
264
|
+
* checkpoint, else they are written to it as they are converted;
|
|
265
|
+
* `info().weightCache` says which (see [`WeightCacheOutcome`]).
|
|
226
266
|
* @param {JsSource} source
|
|
227
267
|
* @param {string} options_json
|
|
228
268
|
* @param {JsSource | null} [lora]
|
|
269
|
+
* @param {JsWeightCache | null} [weight_cache]
|
|
229
270
|
* @returns {Promise<WasmModel>}
|
|
230
271
|
*/
|
|
231
|
-
static load(source, options_json, lora) {
|
|
272
|
+
static load(source, options_json, lora, weight_cache) {
|
|
232
273
|
_assertClass(source, JsSource);
|
|
233
274
|
var ptr0 = source.__destroy_into_raw();
|
|
234
275
|
const ptr1 = passStringToWasm0(options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -238,7 +279,12 @@ export class WasmModel {
|
|
|
238
279
|
_assertClass(lora, JsSource);
|
|
239
280
|
ptr2 = lora.__destroy_into_raw();
|
|
240
281
|
}
|
|
241
|
-
|
|
282
|
+
let ptr3 = 0;
|
|
283
|
+
if (!isLikeNone(weight_cache)) {
|
|
284
|
+
_assertClass(weight_cache, JsWeightCache);
|
|
285
|
+
ptr3 = weight_cache.__destroy_into_raw();
|
|
286
|
+
}
|
|
287
|
+
const ret = wasm.wasmmodel_load(ptr0, ptr1, len1, ptr2, ptr3);
|
|
242
288
|
return ret;
|
|
243
289
|
}
|
|
244
290
|
/**
|
|
@@ -1038,6 +1084,10 @@ function __wbg_get_imports() {
|
|
|
1038
1084
|
const ret = new Float32Array(getArrayF32FromWasm0(arg0, arg1));
|
|
1039
1085
|
return ret;
|
|
1040
1086
|
},
|
|
1087
|
+
__wbg_new_from_slice_4ee02165f9de919e: function(arg0, arg1) {
|
|
1088
|
+
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
1089
|
+
return ret;
|
|
1090
|
+
},
|
|
1041
1091
|
__wbg_new_typed_6f8b0d724fe26c07: function(arg0, arg1) {
|
|
1042
1092
|
try {
|
|
1043
1093
|
var state0 = {a: arg0, b: arg1};
|
|
@@ -1374,33 +1424,33 @@ function __wbg_get_imports() {
|
|
|
1374
1424
|
arg0.writeBuffer(arg1, arg2, getArrayU8FromWasm0(arg3, arg4), arg5, arg6);
|
|
1375
1425
|
}, arguments); },
|
|
1376
1426
|
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
1377
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
1427
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 312, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1378
1428
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___JsValue__core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_);
|
|
1379
1429
|
return ret;
|
|
1380
1430
|
},
|
|
1381
1431
|
__wbindgen_generic_0000000000000002: function(arg0, arg1) {
|
|
1382
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDevice")], shim_idx:
|
|
1432
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDevice")], shim_idx: 245, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1383
1433
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_);
|
|
1384
1434
|
return ret;
|
|
1385
1435
|
},
|
|
1386
1436
|
__wbindgen_generic_0000000000000003: function(arg0, arg1) {
|
|
1387
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDeviceLostInfo")], shim_idx:
|
|
1437
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDeviceLostInfo")], shim_idx: 249, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1388
1438
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true_);
|
|
1389
1439
|
return ret;
|
|
1390
1440
|
},
|
|
1391
1441
|
__wbindgen_generic_0000000000000004: function(arg0, arg1) {
|
|
1392
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUUncapturedErrorEvent")], shim_idx:
|
|
1393
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1442
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUUncapturedErrorEvent")], shim_idx: 249, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1443
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true__37);
|
|
1394
1444
|
return ret;
|
|
1395
1445
|
},
|
|
1396
1446
|
__wbindgen_generic_0000000000000005: function(arg0, arg1) {
|
|
1397
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("any")], shim_idx:
|
|
1398
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1447
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("any")], shim_idx: 245, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1448
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__38);
|
|
1399
1449
|
return ret;
|
|
1400
1450
|
},
|
|
1401
1451
|
__wbindgen_generic_0000000000000006: function(arg0, arg1) {
|
|
1402
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("undefined")], shim_idx:
|
|
1403
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1452
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("undefined")], shim_idx: 245, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1453
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__39);
|
|
1404
1454
|
return ret;
|
|
1405
1455
|
},
|
|
1406
1456
|
__wbindgen_generic_0000000000000007: function(arg0) {
|
|
@@ -1443,8 +1493,8 @@ function wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_549
|
|
|
1443
1493
|
wasm.wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true_(arg0, arg1, arg2);
|
|
1444
1494
|
}
|
|
1445
1495
|
|
|
1446
|
-
function
|
|
1447
|
-
wasm.
|
|
1496
|
+
function wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true__37(arg0, arg1, arg2) {
|
|
1497
|
+
wasm.wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true__37(arg0, arg1, arg2);
|
|
1448
1498
|
}
|
|
1449
1499
|
|
|
1450
1500
|
function wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___JsValue__core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_(arg0, arg1, arg2) {
|
|
@@ -1461,15 +1511,15 @@ function wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bin
|
|
|
1461
1511
|
}
|
|
1462
1512
|
}
|
|
1463
1513
|
|
|
1464
|
-
function
|
|
1465
|
-
const ret = wasm.
|
|
1514
|
+
function wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__38(arg0, arg1, arg2) {
|
|
1515
|
+
const ret = wasm.wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__38(arg0, arg1, arg2);
|
|
1466
1516
|
if (ret[1]) {
|
|
1467
1517
|
throw takeFromExternrefTable0(ret[0]);
|
|
1468
1518
|
}
|
|
1469
1519
|
}
|
|
1470
1520
|
|
|
1471
|
-
function
|
|
1472
|
-
const ret = wasm.
|
|
1521
|
+
function wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__39(arg0, arg1, arg2) {
|
|
1522
|
+
const ret = wasm.wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__39(arg0, arg1, arg2);
|
|
1473
1523
|
if (ret[1]) {
|
|
1474
1524
|
throw takeFromExternrefTable0(ret[0]);
|
|
1475
1525
|
}
|
|
@@ -1511,6 +1561,9 @@ const __wbindgen_enum_GpuTextureViewDimension = ["1d", "2d", "2d-array", "cube",
|
|
|
1511
1561
|
const JsSourceFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1512
1562
|
? { register: () => {}, unregister: () => {} }
|
|
1513
1563
|
: new FinalizationRegistry(ptr => wasm.__wbg_jssource_free(ptr, 1));
|
|
1564
|
+
const JsWeightCacheFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1565
|
+
? { register: () => {}, unregister: () => {} }
|
|
1566
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_jsweightcache_free(ptr, 1));
|
|
1514
1567
|
const Sha256HasherFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1515
1568
|
? { register: () => {}, unregister: () => {} }
|
|
1516
1569
|
: new FinalizationRegistry(ptr => wasm.__wbg_sha256hasher_free(ptr, 1));
|
|
Binary file
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export const __wbg_jssource_free: (a: number, b: number) => void;
|
|
5
|
+
export const __wbg_jsweightcache_free: (a: number, b: number) => void;
|
|
5
6
|
export const __wbg_sha256hasher_free: (a: number, b: number) => void;
|
|
6
7
|
export const __wbg_wasmmodel_free: (a: number, b: number) => void;
|
|
7
8
|
export const __wbg_wasmsession_free: (a: number, b: number) => void;
|
|
8
9
|
export const buildInfo: () => [number, number, number];
|
|
9
10
|
export const jssource_new: (a: any, b: number) => number;
|
|
11
|
+
export const jsweightcache_new: (a: number, b: number, c: number, d: any, e: any) => number;
|
|
10
12
|
export const parseSafetensorsHeader: (a: number, b: number) => [number, number, number];
|
|
11
13
|
export const sha256hasher_finish: (a: number) => [number, number];
|
|
12
14
|
export const sha256hasher_new: () => number;
|
|
@@ -19,7 +21,7 @@ export const wasmmodel_createSession: (a: number) => [number, number, number];
|
|
|
19
21
|
export const wasmmodel_detokenize: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
20
22
|
export const wasmmodel_generate: (a: number, b: number, c: number, d: number, e: number, f: any, g: number) => any;
|
|
21
23
|
export const wasmmodel_info: (a: number) => [number, number, number];
|
|
22
|
-
export const wasmmodel_load: (a: number, b: number, c: number, d: number) => any;
|
|
24
|
+
export const wasmmodel_load: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
23
25
|
export const wasmmodel_removeAdapter: (a: number) => any;
|
|
24
26
|
export const wasmmodel_renderChat: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
25
27
|
export const wasmmodel_reset: (a: number) => [number, number];
|
|
@@ -40,10 +42,10 @@ export const wasmsession_truncate: (a: number, b: number) => [number, number];
|
|
|
40
42
|
export const wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___js_sys_56365fc49d784db6___Function_fn_wasm_bindgen_8cf186fa7724d16d___JsValue_____wasm_bindgen_8cf186fa7724d16d___sys__Undefined___js_sys_56365fc49d784db6___Function_fn_wasm_bindgen_8cf186fa7724d16d___JsValue_____wasm_bindgen_8cf186fa7724d16d___sys__Undefined_______true_: (a: number, b: number, c: any, d: any) => void;
|
|
41
43
|
export const wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___JsValue__core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_: (a: number, b: number, c: any) => [number, number];
|
|
42
44
|
export const wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_: (a: number, b: number, c: any) => [number, number];
|
|
43
|
-
export const wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__37: (a: number, b: number, c: any) => [number, number];
|
|
44
45
|
export const wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__38: (a: number, b: number, c: any) => [number, number];
|
|
46
|
+
export const wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__39: (a: number, b: number, c: any) => [number, number];
|
|
45
47
|
export const wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true_: (a: number, b: number, c: any) => void;
|
|
46
|
-
export const
|
|
48
|
+
export const wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true__37: (a: number, b: number, c: any) => void;
|
|
47
49
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
48
50
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
49
51
|
export const __wbindgen_exn_store: (a: number) => void;
|
|
@@ -17,6 +17,21 @@ export class JsSource {
|
|
|
17
17
|
constructor(read: Function, list?: Function | null);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* The converted-weight file of one model load (see the module docs).
|
|
22
|
+
*/
|
|
23
|
+
export class JsWeightCache {
|
|
24
|
+
free(): void;
|
|
25
|
+
[Symbol.dispose](): void;
|
|
26
|
+
/**
|
|
27
|
+
* `key` names the converted checkpoint (`"org/name@sha"`; the load
|
|
28
|
+
* format is appended). `read(start, end)` resolves to bytes
|
|
29
|
+
* `[start, end)` of the stored file of `size` bytes (`0`: none);
|
|
30
|
+
* `write(chunk)` appends to the new file and may return a promise.
|
|
31
|
+
*/
|
|
32
|
+
constructor(key: string, size: number, read: Function, write: Function);
|
|
33
|
+
}
|
|
34
|
+
|
|
20
35
|
/**
|
|
21
36
|
* Incremental SHA-256.
|
|
22
37
|
*/
|
|
@@ -92,8 +107,13 @@ export class WasmModel {
|
|
|
92
107
|
* (default 1), in `adapterMode` (default `"unmerged"`: its delta is
|
|
93
108
|
* added in f32 beside the weights; `"merged"` merges it into the
|
|
94
109
|
* weights as they load).
|
|
110
|
+
*
|
|
111
|
+
* `weightCache`, when given, keeps the converted (block-quantized)
|
|
112
|
+
* weights: a valid stored file serves them instead of converting the
|
|
113
|
+
* checkpoint, else they are written to it as they are converted;
|
|
114
|
+
* `info().weightCache` says which (see [`WeightCacheOutcome`]).
|
|
95
115
|
*/
|
|
96
|
-
static load(source: JsSource, options_json: string, lora?: JsSource | null): Promise<WasmModel>;
|
|
116
|
+
static load(source: JsSource, options_json: string, lora?: JsSource | null, weight_cache?: JsWeightCache | null): Promise<WasmModel>;
|
|
97
117
|
/**
|
|
98
118
|
* Removes the adapter, restoring the base weights exactly. Resolves to
|
|
99
119
|
* the description of the adapter removed, or `null` when there was
|
|
@@ -251,11 +271,13 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
251
271
|
export interface InitOutput {
|
|
252
272
|
readonly memory: WebAssembly.Memory;
|
|
253
273
|
readonly __wbg_jssource_free: (a: number, b: number) => void;
|
|
274
|
+
readonly __wbg_jsweightcache_free: (a: number, b: number) => void;
|
|
254
275
|
readonly __wbg_sha256hasher_free: (a: number, b: number) => void;
|
|
255
276
|
readonly __wbg_wasmmodel_free: (a: number, b: number) => void;
|
|
256
277
|
readonly __wbg_wasmsession_free: (a: number, b: number) => void;
|
|
257
278
|
readonly buildInfo: () => [number, number, number];
|
|
258
279
|
readonly jssource_new: (a: any, b: number) => number;
|
|
280
|
+
readonly jsweightcache_new: (a: number, b: number, c: number, d: any, e: any) => number;
|
|
259
281
|
readonly parseSafetensorsHeader: (a: number, b: number) => [number, number, number];
|
|
260
282
|
readonly sha256hasher_finish: (a: number) => [number, number];
|
|
261
283
|
readonly sha256hasher_new: () => number;
|
|
@@ -268,7 +290,7 @@ export interface InitOutput {
|
|
|
268
290
|
readonly wasmmodel_detokenize: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
269
291
|
readonly wasmmodel_generate: (a: number, b: number, c: number, d: number, e: number, f: any, g: number) => any;
|
|
270
292
|
readonly wasmmodel_info: (a: number) => [number, number, number];
|
|
271
|
-
readonly wasmmodel_load: (a: number, b: number, c: number, d: number) => any;
|
|
293
|
+
readonly wasmmodel_load: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
272
294
|
readonly wasmmodel_removeAdapter: (a: number) => any;
|
|
273
295
|
readonly wasmmodel_renderChat: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
274
296
|
readonly wasmmodel_reset: (a: number) => [number, number];
|
|
@@ -289,10 +311,10 @@ export interface InitOutput {
|
|
|
289
311
|
readonly wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___js_sys_56365fc49d784db6___Function_fn_wasm_bindgen_8cf186fa7724d16d___JsValue_____wasm_bindgen_8cf186fa7724d16d___sys__Undefined___js_sys_56365fc49d784db6___Function_fn_wasm_bindgen_8cf186fa7724d16d___JsValue_____wasm_bindgen_8cf186fa7724d16d___sys__Undefined_______true_: (a: number, b: number, c: any, d: any) => void;
|
|
290
312
|
readonly wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___JsValue__core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_: (a: number, b: number, c: any) => [number, number];
|
|
291
313
|
readonly wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_: (a: number, b: number, c: any) => [number, number];
|
|
292
|
-
readonly wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__37: (a: number, b: number, c: any) => [number, number];
|
|
293
314
|
readonly wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__38: (a: number, b: number, c: any) => [number, number];
|
|
315
|
+
readonly wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__39: (a: number, b: number, c: any) => [number, number];
|
|
294
316
|
readonly wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true_: (a: number, b: number, c: any) => void;
|
|
295
|
-
readonly
|
|
317
|
+
readonly wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true__37: (a: number, b: number, c: any) => void;
|
|
296
318
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
297
319
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
298
320
|
readonly __wbindgen_exn_store: (a: number) => void;
|
package/wasm/simd/webslm_wasm.js
CHANGED
|
@@ -34,6 +34,41 @@ export class JsSource {
|
|
|
34
34
|
}
|
|
35
35
|
if (Symbol.dispose) JsSource.prototype[Symbol.dispose] = JsSource.prototype.free;
|
|
36
36
|
|
|
37
|
+
/**
|
|
38
|
+
* The converted-weight file of one model load (see the module docs).
|
|
39
|
+
*/
|
|
40
|
+
export class JsWeightCache {
|
|
41
|
+
__destroy_into_raw() {
|
|
42
|
+
const ptr = this.__wbg_ptr;
|
|
43
|
+
this.__wbg_ptr = 0;
|
|
44
|
+
JsWeightCacheFinalization.unregister(this);
|
|
45
|
+
return ptr;
|
|
46
|
+
}
|
|
47
|
+
free() {
|
|
48
|
+
const ptr = this.__destroy_into_raw();
|
|
49
|
+
wasm.__wbg_jsweightcache_free(ptr, 0);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* `key` names the converted checkpoint (`"org/name@sha"`; the load
|
|
53
|
+
* format is appended). `read(start, end)` resolves to bytes
|
|
54
|
+
* `[start, end)` of the stored file of `size` bytes (`0`: none);
|
|
55
|
+
* `write(chunk)` appends to the new file and may return a promise.
|
|
56
|
+
* @param {string} key
|
|
57
|
+
* @param {number} size
|
|
58
|
+
* @param {Function} read
|
|
59
|
+
* @param {Function} write
|
|
60
|
+
*/
|
|
61
|
+
constructor(key, size, read, write) {
|
|
62
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
63
|
+
const len0 = WASM_VECTOR_LEN;
|
|
64
|
+
const ret = wasm.jsweightcache_new(ptr0, len0, size, read, write);
|
|
65
|
+
this.__wbg_ptr = ret;
|
|
66
|
+
JsWeightCacheFinalization.register(this, this.__wbg_ptr, this);
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (Symbol.dispose) JsWeightCache.prototype[Symbol.dispose] = JsWeightCache.prototype.free;
|
|
71
|
+
|
|
37
72
|
/**
|
|
38
73
|
* Incremental SHA-256.
|
|
39
74
|
*/
|
|
@@ -223,12 +258,18 @@ export class WasmModel {
|
|
|
223
258
|
* (default 1), in `adapterMode` (default `"unmerged"`: its delta is
|
|
224
259
|
* added in f32 beside the weights; `"merged"` merges it into the
|
|
225
260
|
* weights as they load).
|
|
261
|
+
*
|
|
262
|
+
* `weightCache`, when given, keeps the converted (block-quantized)
|
|
263
|
+
* weights: a valid stored file serves them instead of converting the
|
|
264
|
+
* checkpoint, else they are written to it as they are converted;
|
|
265
|
+
* `info().weightCache` says which (see [`WeightCacheOutcome`]).
|
|
226
266
|
* @param {JsSource} source
|
|
227
267
|
* @param {string} options_json
|
|
228
268
|
* @param {JsSource | null} [lora]
|
|
269
|
+
* @param {JsWeightCache | null} [weight_cache]
|
|
229
270
|
* @returns {Promise<WasmModel>}
|
|
230
271
|
*/
|
|
231
|
-
static load(source, options_json, lora) {
|
|
272
|
+
static load(source, options_json, lora, weight_cache) {
|
|
232
273
|
_assertClass(source, JsSource);
|
|
233
274
|
var ptr0 = source.__destroy_into_raw();
|
|
234
275
|
const ptr1 = passStringToWasm0(options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -238,7 +279,12 @@ export class WasmModel {
|
|
|
238
279
|
_assertClass(lora, JsSource);
|
|
239
280
|
ptr2 = lora.__destroy_into_raw();
|
|
240
281
|
}
|
|
241
|
-
|
|
282
|
+
let ptr3 = 0;
|
|
283
|
+
if (!isLikeNone(weight_cache)) {
|
|
284
|
+
_assertClass(weight_cache, JsWeightCache);
|
|
285
|
+
ptr3 = weight_cache.__destroy_into_raw();
|
|
286
|
+
}
|
|
287
|
+
const ret = wasm.wasmmodel_load(ptr0, ptr1, len1, ptr2, ptr3);
|
|
242
288
|
return ret;
|
|
243
289
|
}
|
|
244
290
|
/**
|
|
@@ -1038,6 +1084,10 @@ function __wbg_get_imports() {
|
|
|
1038
1084
|
const ret = new Float32Array(getArrayF32FromWasm0(arg0, arg1));
|
|
1039
1085
|
return ret;
|
|
1040
1086
|
},
|
|
1087
|
+
__wbg_new_from_slice_4ee02165f9de919e: function(arg0, arg1) {
|
|
1088
|
+
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
1089
|
+
return ret;
|
|
1090
|
+
},
|
|
1041
1091
|
__wbg_new_typed_6f8b0d724fe26c07: function(arg0, arg1) {
|
|
1042
1092
|
try {
|
|
1043
1093
|
var state0 = {a: arg0, b: arg1};
|
|
@@ -1374,33 +1424,33 @@ function __wbg_get_imports() {
|
|
|
1374
1424
|
arg0.writeBuffer(arg1, arg2, getArrayU8FromWasm0(arg3, arg4), arg5, arg6);
|
|
1375
1425
|
}, arguments); },
|
|
1376
1426
|
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
1377
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
1427
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 303, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1378
1428
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___JsValue__core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_);
|
|
1379
1429
|
return ret;
|
|
1380
1430
|
},
|
|
1381
1431
|
__wbindgen_generic_0000000000000002: function(arg0, arg1) {
|
|
1382
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDevice")], shim_idx:
|
|
1432
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDevice")], shim_idx: 236, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1383
1433
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_);
|
|
1384
1434
|
return ret;
|
|
1385
1435
|
},
|
|
1386
1436
|
__wbindgen_generic_0000000000000003: function(arg0, arg1) {
|
|
1387
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDeviceLostInfo")], shim_idx:
|
|
1437
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUDeviceLostInfo")], shim_idx: 240, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1388
1438
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true_);
|
|
1389
1439
|
return ret;
|
|
1390
1440
|
},
|
|
1391
1441
|
__wbindgen_generic_0000000000000004: function(arg0, arg1) {
|
|
1392
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUUncapturedErrorEvent")], shim_idx:
|
|
1393
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1442
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUUncapturedErrorEvent")], shim_idx: 240, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1443
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true__37);
|
|
1394
1444
|
return ret;
|
|
1395
1445
|
},
|
|
1396
1446
|
__wbindgen_generic_0000000000000005: function(arg0, arg1) {
|
|
1397
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("any")], shim_idx:
|
|
1398
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1447
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("any")], shim_idx: 236, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1448
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__38);
|
|
1399
1449
|
return ret;
|
|
1400
1450
|
},
|
|
1401
1451
|
__wbindgen_generic_0000000000000006: function(arg0, arg1) {
|
|
1402
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("undefined")], shim_idx:
|
|
1403
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1452
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("undefined")], shim_idx: 236, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1453
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__39);
|
|
1404
1454
|
return ret;
|
|
1405
1455
|
},
|
|
1406
1456
|
__wbindgen_generic_0000000000000007: function(arg0) {
|
|
@@ -1443,8 +1493,8 @@ function wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_549
|
|
|
1443
1493
|
wasm.wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true_(arg0, arg1, arg2);
|
|
1444
1494
|
}
|
|
1445
1495
|
|
|
1446
|
-
function
|
|
1447
|
-
wasm.
|
|
1496
|
+
function wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true__37(arg0, arg1, arg2) {
|
|
1497
|
+
wasm.wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true__37(arg0, arg1, arg2);
|
|
1448
1498
|
}
|
|
1449
1499
|
|
|
1450
1500
|
function wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___JsValue__core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_(arg0, arg1, arg2) {
|
|
@@ -1461,15 +1511,15 @@ function wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bin
|
|
|
1461
1511
|
}
|
|
1462
1512
|
}
|
|
1463
1513
|
|
|
1464
|
-
function
|
|
1465
|
-
const ret = wasm.
|
|
1514
|
+
function wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__38(arg0, arg1, arg2) {
|
|
1515
|
+
const ret = wasm.wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__38(arg0, arg1, arg2);
|
|
1466
1516
|
if (ret[1]) {
|
|
1467
1517
|
throw takeFromExternrefTable0(ret[0]);
|
|
1468
1518
|
}
|
|
1469
1519
|
}
|
|
1470
1520
|
|
|
1471
|
-
function
|
|
1472
|
-
const ret = wasm.
|
|
1521
|
+
function wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__39(arg0, arg1, arg2) {
|
|
1522
|
+
const ret = wasm.wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__39(arg0, arg1, arg2);
|
|
1473
1523
|
if (ret[1]) {
|
|
1474
1524
|
throw takeFromExternrefTable0(ret[0]);
|
|
1475
1525
|
}
|
|
@@ -1511,6 +1561,9 @@ const __wbindgen_enum_GpuTextureViewDimension = ["1d", "2d", "2d-array", "cube",
|
|
|
1511
1561
|
const JsSourceFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1512
1562
|
? { register: () => {}, unregister: () => {} }
|
|
1513
1563
|
: new FinalizationRegistry(ptr => wasm.__wbg_jssource_free(ptr, 1));
|
|
1564
|
+
const JsWeightCacheFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1565
|
+
? { register: () => {}, unregister: () => {} }
|
|
1566
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_jsweightcache_free(ptr, 1));
|
|
1514
1567
|
const Sha256HasherFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1515
1568
|
? { register: () => {}, unregister: () => {} }
|
|
1516
1569
|
: new FinalizationRegistry(ptr => wasm.__wbg_sha256hasher_free(ptr, 1));
|
|
Binary file
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export const __wbg_jssource_free: (a: number, b: number) => void;
|
|
5
|
+
export const __wbg_jsweightcache_free: (a: number, b: number) => void;
|
|
5
6
|
export const __wbg_sha256hasher_free: (a: number, b: number) => void;
|
|
6
7
|
export const __wbg_wasmmodel_free: (a: number, b: number) => void;
|
|
7
8
|
export const __wbg_wasmsession_free: (a: number, b: number) => void;
|
|
8
9
|
export const buildInfo: () => [number, number, number];
|
|
9
10
|
export const jssource_new: (a: any, b: number) => number;
|
|
11
|
+
export const jsweightcache_new: (a: number, b: number, c: number, d: any, e: any) => number;
|
|
10
12
|
export const parseSafetensorsHeader: (a: number, b: number) => [number, number, number];
|
|
11
13
|
export const sha256hasher_finish: (a: number) => [number, number];
|
|
12
14
|
export const sha256hasher_new: () => number;
|
|
@@ -19,7 +21,7 @@ export const wasmmodel_createSession: (a: number) => [number, number, number];
|
|
|
19
21
|
export const wasmmodel_detokenize: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
20
22
|
export const wasmmodel_generate: (a: number, b: number, c: number, d: number, e: number, f: any, g: number) => any;
|
|
21
23
|
export const wasmmodel_info: (a: number) => [number, number, number];
|
|
22
|
-
export const wasmmodel_load: (a: number, b: number, c: number, d: number) => any;
|
|
24
|
+
export const wasmmodel_load: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
23
25
|
export const wasmmodel_removeAdapter: (a: number) => any;
|
|
24
26
|
export const wasmmodel_renderChat: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
25
27
|
export const wasmmodel_reset: (a: number) => [number, number];
|
|
@@ -40,10 +42,10 @@ export const wasmsession_truncate: (a: number, b: number) => [number, number];
|
|
|
40
42
|
export const wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___js_sys_56365fc49d784db6___Function_fn_wasm_bindgen_8cf186fa7724d16d___JsValue_____wasm_bindgen_8cf186fa7724d16d___sys__Undefined___js_sys_56365fc49d784db6___Function_fn_wasm_bindgen_8cf186fa7724d16d___JsValue_____wasm_bindgen_8cf186fa7724d16d___sys__Undefined_______true_: (a: number, b: number, c: any, d: any) => void;
|
|
41
43
|
export const wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___JsValue__core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_: (a: number, b: number, c: any) => [number, number];
|
|
42
44
|
export const wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_: (a: number, b: number, c: any) => [number, number];
|
|
43
|
-
export const wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__37: (a: number, b: number, c: any) => [number, number];
|
|
44
45
|
export const wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__38: (a: number, b: number, c: any) => [number, number];
|
|
46
|
+
export const wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___sys__JsNullable_wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true__39: (a: number, b: number, c: any) => [number, number];
|
|
45
47
|
export const wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true_: (a: number, b: number, c: any) => void;
|
|
46
|
-
export const
|
|
48
|
+
export const wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true__37: (a: number, b: number, c: any) => void;
|
|
47
49
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
48
50
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
49
51
|
export const __wbindgen_exn_store: (a: number) => void;
|
|
@@ -17,6 +17,21 @@ export class JsSource {
|
|
|
17
17
|
constructor(read: Function, list?: Function | null);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* The converted-weight file of one model load (see the module docs).
|
|
22
|
+
*/
|
|
23
|
+
export class JsWeightCache {
|
|
24
|
+
free(): void;
|
|
25
|
+
[Symbol.dispose](): void;
|
|
26
|
+
/**
|
|
27
|
+
* `key` names the converted checkpoint (`"org/name@sha"`; the load
|
|
28
|
+
* format is appended). `read(start, end)` resolves to bytes
|
|
29
|
+
* `[start, end)` of the stored file of `size` bytes (`0`: none);
|
|
30
|
+
* `write(chunk)` appends to the new file and may return a promise.
|
|
31
|
+
*/
|
|
32
|
+
constructor(key: string, size: number, read: Function, write: Function);
|
|
33
|
+
}
|
|
34
|
+
|
|
20
35
|
/**
|
|
21
36
|
* Incremental SHA-256.
|
|
22
37
|
*/
|
|
@@ -92,8 +107,13 @@ export class WasmModel {
|
|
|
92
107
|
* (default 1), in `adapterMode` (default `"unmerged"`: its delta is
|
|
93
108
|
* added in f32 beside the weights; `"merged"` merges it into the
|
|
94
109
|
* weights as they load).
|
|
110
|
+
*
|
|
111
|
+
* `weightCache`, when given, keeps the converted (block-quantized)
|
|
112
|
+
* weights: a valid stored file serves them instead of converting the
|
|
113
|
+
* checkpoint, else they are written to it as they are converted;
|
|
114
|
+
* `info().weightCache` says which (see [`WeightCacheOutcome`]).
|
|
95
115
|
*/
|
|
96
|
-
static load(source: JsSource, options_json: string, lora?: JsSource | null): Promise<WasmModel>;
|
|
116
|
+
static load(source: JsSource, options_json: string, lora?: JsSource | null, weight_cache?: JsWeightCache | null): Promise<WasmModel>;
|
|
97
117
|
/**
|
|
98
118
|
* Removes the adapter, restoring the base weights exactly. Resolves to
|
|
99
119
|
* the description of the adapter removed, or `null` when there was
|
|
@@ -270,6 +290,7 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
270
290
|
|
|
271
291
|
export interface InitOutput {
|
|
272
292
|
readonly __wbg_jssource_free: (a: number, b: number) => void;
|
|
293
|
+
readonly __wbg_jsweightcache_free: (a: number, b: number) => void;
|
|
273
294
|
readonly __wbg_sha256hasher_free: (a: number, b: number) => void;
|
|
274
295
|
readonly __wbg_wasmmodel_free: (a: number, b: number) => void;
|
|
275
296
|
readonly __wbg_wasmsession_free: (a: number, b: number) => void;
|
|
@@ -277,6 +298,7 @@ export interface InitOutput {
|
|
|
277
298
|
readonly buildInfo: () => [number, number, number];
|
|
278
299
|
readonly initThreadPool: (a: number) => any;
|
|
279
300
|
readonly jssource_new: (a: any, b: number) => number;
|
|
301
|
+
readonly jsweightcache_new: (a: number, b: number, c: number, d: any, e: any) => number;
|
|
280
302
|
readonly parseSafetensorsHeader: (a: number, b: number) => [number, number, number];
|
|
281
303
|
readonly sha256hasher_finish: (a: number) => [number, number];
|
|
282
304
|
readonly sha256hasher_new: () => number;
|
|
@@ -290,7 +312,7 @@ export interface InitOutput {
|
|
|
290
312
|
readonly wasmmodel_detokenize: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
291
313
|
readonly wasmmodel_generate: (a: number, b: number, c: number, d: number, e: number, f: any, g: number) => any;
|
|
292
314
|
readonly wasmmodel_info: (a: number) => [number, number, number];
|
|
293
|
-
readonly wasmmodel_load: (a: number, b: number, c: number, d: number) => any;
|
|
315
|
+
readonly wasmmodel_load: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
294
316
|
readonly wasmmodel_removeAdapter: (a: number) => any;
|
|
295
317
|
readonly wasmmodel_renderChat: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
296
318
|
readonly wasmmodel_reset: (a: number) => [number, number];
|
|
@@ -315,12 +337,12 @@ export interface InitOutput {
|
|
|
315
337
|
readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___js_sys_b608be85a12bc1d0___Function_fn_wasm_bindgen_3c612a990bfab728___JsValue_____wasm_bindgen_3c612a990bfab728___sys__Undefined___js_sys_b608be85a12bc1d0___Function_fn_wasm_bindgen_3c612a990bfab728___JsValue_____wasm_bindgen_3c612a990bfab728___sys__Undefined_______true_: (a: number, b: number, c: any, d: any) => void;
|
|
316
338
|
readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue__core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true_: (a: number, b: number, c: any) => [number, number];
|
|
317
339
|
readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___sys__JsNullable_wgpu_4ecf802b864e9046___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true_: (a: number, b: number, c: any) => [number, number];
|
|
318
|
-
readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___sys__JsNullable_wgpu_4ecf802b864e9046___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true__45: (a: number, b: number, c: any) => [number, number];
|
|
319
340
|
readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___sys__JsNullable_wgpu_4ecf802b864e9046___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true__46: (a: number, b: number, c: any) => [number, number];
|
|
341
|
+
readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___sys__JsNullable_wgpu_4ecf802b864e9046___backend__webgpu__webgpu_sys__gen_GpuError__GpuError___core_2b10d7c4e784534e___result__Result_____wasm_bindgen_3c612a990bfab728___JsError___true__47: (a: number, b: number, c: any) => [number, number];
|
|
320
342
|
readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___js_sys_b608be85a12bc1d0___futures__task__wait_async_polyfill__MessageEvent______true_: (a: number, b: number, c: any) => void;
|
|
321
343
|
readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue______true_: (a: number, b: number, c: any) => void;
|
|
322
|
-
readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue______true__43: (a: number, b: number, c: any) => void;
|
|
323
344
|
readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue______true__44: (a: number, b: number, c: any) => void;
|
|
345
|
+
readonly wasm_bindgen_3c612a990bfab728___convert__closures_____invoke___wasm_bindgen_3c612a990bfab728___JsValue______true__45: (a: number, b: number, c: any) => void;
|
|
324
346
|
readonly memory: WebAssembly.Memory;
|
|
325
347
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
326
348
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|