webslm 0.3.0 → 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 +71 -15
- 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 -43
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/models.d.ts +30 -9
- package/dist/models.js +72 -10
- package/dist/native.d.ts +165 -0
- package/dist/native.js +243 -0
- package/dist/protocol.d.ts +14 -3
- 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 +106 -20
- package/native-manifest.json +47 -0
- package/package.json +2 -1
- package/wasm/relaxed/webslm_wasm.d.ts +34 -9
- package/wasm/relaxed/webslm_wasm.js +78 -22
- 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 +34 -9
- package/wasm/simd/webslm_wasm.js +78 -22
- 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 +34 -9
- package/wasm/threads/webslm_wasm.js +83 -27
- package/wasm/threads/webslm_wasm_bg.wasm +0 -0
- package/wasm/threads/webslm_wasm_bg.wasm.d.ts +5 -3
package/dist/types.d.ts
CHANGED
|
@@ -2,10 +2,25 @@
|
|
|
2
2
|
import type { EngineHandle } from "./models.js";
|
|
3
3
|
import type { WasmFlavour } from "./wasm-flavour.js";
|
|
4
4
|
/**
|
|
5
|
-
* Where the model runs. `"auto"` (the default) picks
|
|
6
|
-
* ~100M parameters when an adapter is available, the CPU otherwise.
|
|
5
|
+
* Where the model runs. `"auto"` (the default) picks the GPU for models above
|
|
6
|
+
* ~100M parameters when an adapter is available, the CPU otherwise. `"gpu"`
|
|
7
|
+
* is the GPU of the engine that runs: WebGPU in browsers, Metal, Vulkan or
|
|
8
|
+
* DX12 with the native engine in Node; `"webgpu"` is a synonym kept for
|
|
9
|
+
* existing code. A loaded model reports `"webgpu"` (WebAssembly engine),
|
|
10
|
+
* `"gpu"` (native engine) or `"cpu"`.
|
|
7
11
|
*/
|
|
8
|
-
export type Device = "auto" | "cpu" | "webgpu";
|
|
12
|
+
export type Device = "auto" | "cpu" | "gpu" | "webgpu";
|
|
13
|
+
/**
|
|
14
|
+
* Which build of the engine runs a model in Node (see
|
|
15
|
+
* {@link LoadModelOptions.backend}): `"native"` is the Node-API addon of the
|
|
16
|
+
* engine (native SIMD kernels on every core, the GPU through Metal, Vulkan or
|
|
17
|
+
* DX12), downloaded on first use from the GitHub Release of this version and
|
|
18
|
+
* checked against the SHA-256 the package carries; `"wasm"` the WebAssembly
|
|
19
|
+
* build (the only one in browsers). `"auto"` (the default) picks `"native"`
|
|
20
|
+
* when the addon is available (cached, or downloaded and verified) and the
|
|
21
|
+
* source is a hub model, else `"wasm"`.
|
|
22
|
+
*/
|
|
23
|
+
export type Backend = "auto" | "native" | "wasm";
|
|
9
24
|
/** How weight matrices are stored once loaded. */
|
|
10
25
|
export type Quant = "q8" | "q4" | "f32";
|
|
11
26
|
/**
|
|
@@ -15,6 +30,19 @@ export type Quant = "q8" | "q4" | "f32";
|
|
|
15
30
|
* dequantizes the weights instead. WebGPU always uses f32 activations.
|
|
16
31
|
*/
|
|
17
32
|
export type Activations = "quantized" | "f32";
|
|
33
|
+
/**
|
|
34
|
+
* How LoRA adapters run on a model. `"unmerged"` (the default) keeps the
|
|
35
|
+
* adapter beside the weights and adds its delta in f32 (`y = W·x + s·B(A·x)`,
|
|
36
|
+
* PEFT's definition): the weights and the adapter each keep their precision,
|
|
37
|
+
* so `quant: "q8"` with `activations: "f32"` on Q8_0-exact weights gives the
|
|
38
|
+
* logits of `quant: "f32"` with the same adapter bit for bit on the CPU, and
|
|
39
|
+
* applying, swapping or removing an adapter reads no base weights. It costs
|
|
40
|
+
* two small matmuls per adapted layer (a few percent of decode speed on
|
|
41
|
+
* quantized weights). `"merged"` merges the adapter into the weights before
|
|
42
|
+
* they are quantized: no decode cost, but `W + s·B·A` is quantized again,
|
|
43
|
+
* which loses part of the adapter.
|
|
44
|
+
*/
|
|
45
|
+
export type AdapterMode = "unmerged" | "merged";
|
|
18
46
|
/** Checkpoint files held by the page: bytes from OPFS, IndexedDB, an upload, a training job... */
|
|
19
47
|
export type FileData = Blob | ArrayBuffer | Uint8Array;
|
|
20
48
|
/**
|
|
@@ -58,15 +86,17 @@ export interface ApplyAdapterOptions {
|
|
|
58
86
|
readonly onProgress?: (progress: LoadProgress) => void;
|
|
59
87
|
readonly signal?: AbortSignal;
|
|
60
88
|
}
|
|
61
|
-
/** A LoRA adapter
|
|
89
|
+
/** A LoRA adapter applied to a model. */
|
|
62
90
|
export interface LoraInfo {
|
|
63
|
-
/**
|
|
91
|
+
/** Adapted modules, e.g. `"model.layers.0.self_attn.q_proj"`. */
|
|
64
92
|
readonly modules: readonly string[];
|
|
65
93
|
readonly scale: number;
|
|
66
94
|
/** Largest rank over the modules. */
|
|
67
95
|
readonly rank: number;
|
|
68
96
|
/** `base_model_name_or_path` from `adapter_config.json`. */
|
|
69
97
|
readonly baseModel?: string;
|
|
98
|
+
/** How the adapter runs (see {@link AdapterMode}). */
|
|
99
|
+
readonly mode: AdapterMode;
|
|
70
100
|
/** Hub repository id, when the adapter came from the hub. */
|
|
71
101
|
readonly repo?: string;
|
|
72
102
|
/** Commit sha of the hub revision, when the adapter came from the hub. */
|
|
@@ -94,11 +124,23 @@ export interface LoadProgress {
|
|
|
94
124
|
}
|
|
95
125
|
export interface LoadModelOptions {
|
|
96
126
|
/**
|
|
97
|
-
* Defaults to `"auto"`:
|
|
98
|
-
* adapter is available
|
|
99
|
-
*
|
|
127
|
+
* Defaults to `"auto"`: the GPU for models above ~100M parameters when an
|
|
128
|
+
* adapter is available (a hardware one with the native engine, which skips
|
|
129
|
+
* software rasterizers and checks the model fits the GPU's memory first),
|
|
130
|
+
* the CPU otherwise. With the WebAssembly engine, `"gpu"` (or `"webgpu"`)
|
|
131
|
+
* falls back to the CPU when no GPU device can be created; with the native
|
|
132
|
+
* engine it fails with `UNSUPPORTED_DEVICE` instead, as `webslm run --device
|
|
133
|
+
* gpu` does. {@link ModelInfo.deviceNote} says why a device was not used.
|
|
100
134
|
*/
|
|
101
135
|
readonly device?: Device;
|
|
136
|
+
/**
|
|
137
|
+
* The engine build in Node (see {@link Backend}). `"native"` fails with
|
|
138
|
+
* `UNSUPPORTED_DEVICE` when the addon is not available (no build for this
|
|
139
|
+
* platform, offline without it in the cache, a failed download or checksum,
|
|
140
|
+
* or a browser); `"wasm"` keeps the WebAssembly build. {@link
|
|
141
|
+
* ModelInfo.runtime} reports which one runs.
|
|
142
|
+
*/
|
|
143
|
+
readonly backend?: Backend;
|
|
102
144
|
/**
|
|
103
145
|
* Weight format. Defaults to `"q8"`; `"q4"` (4-bit, 16-value blocks) is
|
|
104
146
|
* smaller and less accurate. `"auto"` estimates the memory of the model
|
|
@@ -124,13 +166,18 @@ export interface LoadModelOptions {
|
|
|
124
166
|
/** Largest number of positions a session holds. Defaults to min(4096, model maximum). */
|
|
125
167
|
readonly contextLength?: number;
|
|
126
168
|
/**
|
|
127
|
-
* A PEFT LoRA adapter
|
|
128
|
-
*
|
|
129
|
-
* {@link Model.
|
|
169
|
+
* A PEFT LoRA adapter applied at load, in {@link LoadModelOptions.adapterMode}.
|
|
170
|
+
* It can be swapped or removed later with {@link Model.applyAdapter} and
|
|
171
|
+
* {@link Model.removeAdapter}.
|
|
130
172
|
*/
|
|
131
173
|
readonly adapter?: AdapterSource;
|
|
132
174
|
/** Scale of {@link LoadModelOptions.adapter} (default `1`). */
|
|
133
175
|
readonly adapterScale?: number;
|
|
176
|
+
/**
|
|
177
|
+
* How LoRA adapters run on this model, the one given at load and those
|
|
178
|
+
* applied later (default `"unmerged"`; see {@link AdapterMode}).
|
|
179
|
+
*/
|
|
180
|
+
readonly adapterMode?: AdapterMode;
|
|
134
181
|
readonly onProgress?: (progress: LoadProgress) => void;
|
|
135
182
|
readonly signal?: AbortSignal;
|
|
136
183
|
/**
|
|
@@ -149,6 +196,14 @@ export interface LoadModelOptions {
|
|
|
149
196
|
* `~/.cache/webslm`). Ignored in browsers, which use OPFS.
|
|
150
197
|
*/
|
|
151
198
|
readonly cacheDir?: string;
|
|
199
|
+
/**
|
|
200
|
+
* Keep the converted (Q8_0 or 4-bit) weights of a hub model in the cache
|
|
201
|
+
* (OPFS in browsers, the cache directory in Node), so that the next load
|
|
202
|
+
* reads them instead of converting the checkpoint again; `info().weightCache`
|
|
203
|
+
* reports what the load did. Default `true`; `WEBSLM_QUANT_CACHE=0` turns
|
|
204
|
+
* it off in Node, as for the command-line tool.
|
|
205
|
+
*/
|
|
206
|
+
readonly weightCache?: boolean;
|
|
152
207
|
/**
|
|
153
208
|
* Run on CPU kernels whose results are bit-identical in every WebAssembly
|
|
154
209
|
* build and natively (the `webslm` CLI and the Rust crates), at some cost
|
|
@@ -162,19 +217,22 @@ export interface LoadModelOptions {
|
|
|
162
217
|
* isolated or in Node, `"relaxed"` with relaxed SIMD, else `"simd"`). Each
|
|
163
218
|
* worker instantiates one build: the first model loaded in it decides.
|
|
164
219
|
* A build missing from a package built from source (see the README)
|
|
165
|
-
* fails with `UNSUPPORTED_DEVICE`; the automatic choice skips it.
|
|
220
|
+
* fails with `UNSUPPORTED_DEVICE`; the automatic choice skips it. Under
|
|
221
|
+
* `backend: "auto"`, naming a build runs WebAssembly.
|
|
166
222
|
*/
|
|
167
223
|
readonly wasmFlavour?: WasmFlavour;
|
|
168
224
|
/**
|
|
169
225
|
* Size of the thread pool of the `"threads"` build. Defaults to the number
|
|
170
|
-
* of logical cores, at most 8.
|
|
226
|
+
* of logical cores, at most 8. On the native engine, the size of its CPU
|
|
227
|
+
* thread pool (default: the available cores, capped by the cgroup CPU
|
|
228
|
+
* quota), set by the first native load of the process.
|
|
171
229
|
*/
|
|
172
230
|
readonly threads?: number;
|
|
173
231
|
}
|
|
174
232
|
/** How the CPU backend runs a model. */
|
|
175
233
|
export interface CpuInfo {
|
|
176
|
-
/** The WebAssembly build. */
|
|
177
|
-
readonly flavour: WasmFlavour;
|
|
234
|
+
/** The WebAssembly build, or `"native"` for the native engine. */
|
|
235
|
+
readonly flavour: WasmFlavour | "native";
|
|
178
236
|
/** CPU kernel set, e.g. `"relaxed-simd"`. */
|
|
179
237
|
readonly kernels: string;
|
|
180
238
|
/** Threads the kernels use. */
|
|
@@ -192,11 +250,16 @@ export interface ChatMessage {
|
|
|
192
250
|
readonly role: "system" | "user" | "assistant" | (string & {});
|
|
193
251
|
readonly content: string;
|
|
194
252
|
}
|
|
195
|
-
/**
|
|
253
|
+
/**
|
|
254
|
+
* Options of a generation. Unset sampling options come from the model card's
|
|
255
|
+
* recommendation for the curated models (`CURATED_MODELS`, see
|
|
256
|
+
* `recommendedSampling`), else from the checkpoint's `generation_config.json`
|
|
257
|
+
* (greedy decoding when it does not ask for sampling).
|
|
258
|
+
*/
|
|
196
259
|
export interface GenerateOptions {
|
|
197
260
|
/** Largest number of new tokens (default 512). */
|
|
198
261
|
readonly maxTokens?: number;
|
|
199
|
-
/** `0` is greedy decoding. */
|
|
262
|
+
/** `0` is greedy decoding (and turns the recommended sampling off). */
|
|
200
263
|
readonly temperature?: number;
|
|
201
264
|
readonly topK?: number;
|
|
202
265
|
readonly topP?: number;
|
|
@@ -371,6 +434,19 @@ export interface GenerationConfig {
|
|
|
371
434
|
readonly minP?: number;
|
|
372
435
|
readonly repetitionPenalty?: number;
|
|
373
436
|
}
|
|
437
|
+
/** What a load did with the converted-weight cache. */
|
|
438
|
+
export interface WeightCacheInfo {
|
|
439
|
+
/**
|
|
440
|
+
* `"hit"`: the converted weights were read from the cache instead of
|
|
441
|
+
* converting the checkpoint; `"written"`: they were converted and stored
|
|
442
|
+
* for the next load; `"failed"`: storing them failed (nothing is kept);
|
|
443
|
+
* `"off"`: not used (turned off, a float format such as `"f32"`, a source
|
|
444
|
+
* other than the hub, or storage that cannot hold it).
|
|
445
|
+
*/
|
|
446
|
+
readonly status: "hit" | "written" | "failed" | "off";
|
|
447
|
+
/** Bytes read from the cache, or stored in it. */
|
|
448
|
+
readonly bytes: number;
|
|
449
|
+
}
|
|
374
450
|
/** Description of a loaded model. */
|
|
375
451
|
export interface ModelInfo {
|
|
376
452
|
/** Hub repository id, when loaded from the hub. */
|
|
@@ -379,11 +455,19 @@ export interface ModelInfo {
|
|
|
379
455
|
readonly revision?: string;
|
|
380
456
|
readonly modelType: string;
|
|
381
457
|
readonly architecture: string;
|
|
382
|
-
/**
|
|
458
|
+
/**
|
|
459
|
+
* Device actually used: `"cpu"`, `"webgpu"` (the WebAssembly engine on
|
|
460
|
+
* WebGPU) or `"gpu"` (the native engine on Metal, Vulkan or DX12).
|
|
461
|
+
*/
|
|
383
462
|
readonly device: Exclude<Device, "auto">;
|
|
463
|
+
/** The engine build that runs the model (see {@link LoadModelOptions.backend}). */
|
|
464
|
+
readonly runtime: Exclude<Backend, "auto">;
|
|
465
|
+
/** Why `backend: "auto"` did not pick the native engine, in Node. */
|
|
466
|
+
readonly runtimeNote?: string;
|
|
384
467
|
/**
|
|
385
|
-
* Human-readable backend, e.g. `"CPU (wasm, relaxed SIMD, 8 threads)"
|
|
386
|
-
* `"WebGPU (Apple M3)"
|
|
468
|
+
* Human-readable backend, e.g. `"CPU (wasm, relaxed SIMD, 8 threads)"`,
|
|
469
|
+
* `"WebGPU (Apple M3)"`, `"CPU (native, neon-i8mm, 10 threads)"` or
|
|
470
|
+
* `"GPU (native, Apple M5, Metal)"`.
|
|
387
471
|
*/
|
|
388
472
|
readonly backend: string;
|
|
389
473
|
/** How the CPU backend runs, when the model runs on it. */
|
|
@@ -414,6 +498,8 @@ export interface ModelInfo {
|
|
|
414
498
|
readonly files: readonly LoadedFile[];
|
|
415
499
|
/** Whether every file came from the local cache (no download). */
|
|
416
500
|
readonly fromCache: boolean;
|
|
501
|
+
/** What the load did with the converted-weight cache ({@link LoadModelOptions.weightCache}). */
|
|
502
|
+
readonly weightCache: WeightCacheInfo;
|
|
417
503
|
/** Milliseconds spent downloading and loading. */
|
|
418
504
|
readonly loadTimeMs: number;
|
|
419
505
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.4.0",
|
|
3
|
+
"assets": {
|
|
4
|
+
"darwin-arm64": {
|
|
5
|
+
"file": "webslm-node-0.4.0-darwin-arm64.node.gz",
|
|
6
|
+
"size": 4528545,
|
|
7
|
+
"sha256": "615b47fbe81fd696b2e7fde769248aecd19e3464293ea1e3eee4f09f0280dd3d",
|
|
8
|
+
"nodeSha256": "d38589792edf3ae420185d3d8801465016a086189cfa8448babecb0bee2c20c7"
|
|
9
|
+
},
|
|
10
|
+
"darwin-x64": {
|
|
11
|
+
"file": "webslm-node-0.4.0-darwin-x64.node.gz",
|
|
12
|
+
"size": 4776800,
|
|
13
|
+
"sha256": "96d2d94899c39189b65638be2a93e3aaf354f78bce4b64d70978151a79a2976f",
|
|
14
|
+
"nodeSha256": "ef8edd095b0cd6d0132ca7e014d3419b80ada134abed1c8e573eff46ab7e1bd9"
|
|
15
|
+
},
|
|
16
|
+
"linux-x64-gnu": {
|
|
17
|
+
"file": "webslm-node-0.4.0-linux-x64-gnu.node.gz",
|
|
18
|
+
"size": 4813554,
|
|
19
|
+
"sha256": "b4ed809cff282998a42cb20a54383009fbf251a5eb082bb8b81933c569a9fb30",
|
|
20
|
+
"nodeSha256": "53301dd894229e70c1a30a2d286459dbcb1e0239933e2bae9af3c5e38702fa82"
|
|
21
|
+
},
|
|
22
|
+
"linux-arm64-gnu": {
|
|
23
|
+
"file": "webslm-node-0.4.0-linux-arm64-gnu.node.gz",
|
|
24
|
+
"size": 4534591,
|
|
25
|
+
"sha256": "11f45efbde6cad74b963a967d376b656047ef41089972e7999d37a70065a1b4d",
|
|
26
|
+
"nodeSha256": "3819d06ada9a926ad72ee61c47aed19eafdda89688e324b79af0402f6a085d2d"
|
|
27
|
+
},
|
|
28
|
+
"linux-x64-musl": {
|
|
29
|
+
"file": "webslm-node-0.4.0-linux-x64-musl.node.gz",
|
|
30
|
+
"size": 5175333,
|
|
31
|
+
"sha256": "5939e77ca6cbfa27a97936ec1c5e801bea08d859265cb8fa29fb4633f1da54c1",
|
|
32
|
+
"nodeSha256": "19179c923bffca73df39d8d8866e56584e7cb8cce934d5579e9e416b90311912"
|
|
33
|
+
},
|
|
34
|
+
"linux-arm64-musl": {
|
|
35
|
+
"file": "webslm-node-0.4.0-linux-arm64-musl.node.gz",
|
|
36
|
+
"size": 5008989,
|
|
37
|
+
"sha256": "5729dfb3c257597d9fec34e1894df4ce6e1e93ea8d47ca5970ca763e2bbdc657",
|
|
38
|
+
"nodeSha256": "285f4f9e86fc9b5e558e78135f20a169c55db235a6df460aedb50dd708afdff9"
|
|
39
|
+
},
|
|
40
|
+
"win32-x64-msvc": {
|
|
41
|
+
"file": "webslm-node-0.4.0-win32-x64-msvc.node.gz",
|
|
42
|
+
"size": 5248826,
|
|
43
|
+
"sha256": "dee69d5d9b6d3d51f68238dc3698e42aca1cd5b752b3047d76d426811e6525cf",
|
|
44
|
+
"nodeSha256": "a43e8046bd46189329b45c8ed3837e7a431dd35dcba63f79d5a4da98ed97076f"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webslm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Run small language models in the browser and in Node, straight from their original Hugging Face checkpoints: a Rust engine compiled to WebAssembly, in a worker, with an offline cache.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Maxime Golfier",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
},
|
|
51
51
|
"files": [
|
|
52
52
|
"dist",
|
|
53
|
+
"native-manifest.json",
|
|
53
54
|
"wasm/simd/webslm_wasm.js",
|
|
54
55
|
"wasm/simd/webslm_wasm.d.ts",
|
|
55
56
|
"wasm/simd/webslm_wasm_bg.wasm",
|
|
@@ -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
|
*/
|
|
@@ -43,8 +58,8 @@ export class WasmModel {
|
|
|
43
58
|
free(): void;
|
|
44
59
|
[Symbol.dispose](): void;
|
|
45
60
|
/**
|
|
46
|
-
*
|
|
47
|
-
* replacing the adapter applied before (if any). `options_json`:
|
|
61
|
+
* Applies a PEFT LoRA adapter served by `lora` (in the model's
|
|
62
|
+
* `adapterMode`), replacing the adapter applied before (if any). `options_json`:
|
|
48
63
|
* `{ scale?: number }` (default 1). Resolves to the adapter's
|
|
49
64
|
* description (see [`LoraInfo`]); rejects with `INVALID_ADAPTER`,
|
|
50
65
|
* leaving the model unchanged, when the adapter does not fit the
|
|
@@ -77,7 +92,8 @@ export class WasmModel {
|
|
|
77
92
|
* Loads a checkpoint from `source`. `options_json` is a JSON object:
|
|
78
93
|
* `{ format?: "q8" | "q4" | "q4_0" | "f32" | "f16" | "bf16",
|
|
79
94
|
* contextLength?: number, deterministic?: boolean,
|
|
80
|
-
* activations?: "quantized" | "f32", device?: "cpu" | "webgpu" | "auto"
|
|
95
|
+
* activations?: "quantized" | "f32", device?: "cpu" | "webgpu" | "auto",
|
|
96
|
+
* adapterScale?: number, adapterMode?: "unmerged" | "merged" }`.
|
|
81
97
|
*
|
|
82
98
|
* `device` defaults to `"cpu"`. `"auto"` picks WebGPU when an adapter
|
|
83
99
|
* is available and the model has more than
|
|
@@ -87,10 +103,17 @@ export class WasmModel {
|
|
|
87
103
|
* results depend on the adapter.
|
|
88
104
|
*
|
|
89
105
|
* `lora`, when given, serves a PEFT LoRA adapter (`adapter_config.json`
|
|
90
|
-
* and `adapter_model.safetensors`)
|
|
91
|
-
*
|
|
106
|
+
* and `adapter_model.safetensors`) applied at load, at `adapterScale`
|
|
107
|
+
* (default 1), in `adapterMode` (default `"unmerged"`: its delta is
|
|
108
|
+
* added in f32 beside the weights; `"merged"` merges it into the
|
|
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`]).
|
|
92
115
|
*/
|
|
93
|
-
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>;
|
|
94
117
|
/**
|
|
95
118
|
* Removes the adapter, restoring the base weights exactly. Resolves to
|
|
96
119
|
* the description of the adapter removed, or `null` when there was
|
|
@@ -248,11 +271,13 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
248
271
|
export interface InitOutput {
|
|
249
272
|
readonly memory: WebAssembly.Memory;
|
|
250
273
|
readonly __wbg_jssource_free: (a: number, b: number) => void;
|
|
274
|
+
readonly __wbg_jsweightcache_free: (a: number, b: number) => void;
|
|
251
275
|
readonly __wbg_sha256hasher_free: (a: number, b: number) => void;
|
|
252
276
|
readonly __wbg_wasmmodel_free: (a: number, b: number) => void;
|
|
253
277
|
readonly __wbg_wasmsession_free: (a: number, b: number) => void;
|
|
254
278
|
readonly buildInfo: () => [number, number, number];
|
|
255
279
|
readonly jssource_new: (a: any, b: number) => number;
|
|
280
|
+
readonly jsweightcache_new: (a: number, b: number, c: number, d: any, e: any) => number;
|
|
256
281
|
readonly parseSafetensorsHeader: (a: number, b: number) => [number, number, number];
|
|
257
282
|
readonly sha256hasher_finish: (a: number) => [number, number];
|
|
258
283
|
readonly sha256hasher_new: () => number;
|
|
@@ -265,7 +290,7 @@ export interface InitOutput {
|
|
|
265
290
|
readonly wasmmodel_detokenize: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
266
291
|
readonly wasmmodel_generate: (a: number, b: number, c: number, d: number, e: number, f: any, g: number) => any;
|
|
267
292
|
readonly wasmmodel_info: (a: number) => [number, number, number];
|
|
268
|
-
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;
|
|
269
294
|
readonly wasmmodel_removeAdapter: (a: number) => any;
|
|
270
295
|
readonly wasmmodel_renderChat: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
271
296
|
readonly wasmmodel_reset: (a: number) => [number, number];
|
|
@@ -286,10 +311,10 @@ export interface InitOutput {
|
|
|
286
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;
|
|
287
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];
|
|
288
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];
|
|
289
|
-
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];
|
|
290
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];
|
|
291
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;
|
|
292
|
-
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;
|
|
293
318
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
294
319
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
295
320
|
readonly __wbindgen_exn_store: (a: number) => void;
|
|
@@ -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
|
*/
|
|
@@ -104,8 +139,8 @@ export class WasmModel {
|
|
|
104
139
|
wasm.__wbg_wasmmodel_free(ptr, 0);
|
|
105
140
|
}
|
|
106
141
|
/**
|
|
107
|
-
*
|
|
108
|
-
* replacing the adapter applied before (if any). `options_json`:
|
|
142
|
+
* Applies a PEFT LoRA adapter served by `lora` (in the model's
|
|
143
|
+
* `adapterMode`), replacing the adapter applied before (if any). `options_json`:
|
|
109
144
|
* `{ scale?: number }` (default 1). Resolves to the adapter's
|
|
110
145
|
* description (see [`LoraInfo`]); rejects with `INVALID_ADAPTER`,
|
|
111
146
|
* leaving the model unchanged, when the adapter does not fit the
|
|
@@ -208,7 +243,8 @@ export class WasmModel {
|
|
|
208
243
|
* Loads a checkpoint from `source`. `options_json` is a JSON object:
|
|
209
244
|
* `{ format?: "q8" | "q4" | "q4_0" | "f32" | "f16" | "bf16",
|
|
210
245
|
* contextLength?: number, deterministic?: boolean,
|
|
211
|
-
* activations?: "quantized" | "f32", device?: "cpu" | "webgpu" | "auto"
|
|
246
|
+
* activations?: "quantized" | "f32", device?: "cpu" | "webgpu" | "auto",
|
|
247
|
+
* adapterScale?: number, adapterMode?: "unmerged" | "merged" }`.
|
|
212
248
|
*
|
|
213
249
|
* `device` defaults to `"cpu"`. `"auto"` picks WebGPU when an adapter
|
|
214
250
|
* is available and the model has more than
|
|
@@ -218,14 +254,22 @@ export class WasmModel {
|
|
|
218
254
|
* results depend on the adapter.
|
|
219
255
|
*
|
|
220
256
|
* `lora`, when given, serves a PEFT LoRA adapter (`adapter_config.json`
|
|
221
|
-
* and `adapter_model.safetensors`)
|
|
222
|
-
*
|
|
257
|
+
* and `adapter_model.safetensors`) applied at load, at `adapterScale`
|
|
258
|
+
* (default 1), in `adapterMode` (default `"unmerged"`: its delta is
|
|
259
|
+
* added in f32 beside the weights; `"merged"` merges it into the
|
|
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`]).
|
|
223
266
|
* @param {JsSource} source
|
|
224
267
|
* @param {string} options_json
|
|
225
268
|
* @param {JsSource | null} [lora]
|
|
269
|
+
* @param {JsWeightCache | null} [weight_cache]
|
|
226
270
|
* @returns {Promise<WasmModel>}
|
|
227
271
|
*/
|
|
228
|
-
static load(source, options_json, lora) {
|
|
272
|
+
static load(source, options_json, lora, weight_cache) {
|
|
229
273
|
_assertClass(source, JsSource);
|
|
230
274
|
var ptr0 = source.__destroy_into_raw();
|
|
231
275
|
const ptr1 = passStringToWasm0(options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -235,7 +279,12 @@ export class WasmModel {
|
|
|
235
279
|
_assertClass(lora, JsSource);
|
|
236
280
|
ptr2 = lora.__destroy_into_raw();
|
|
237
281
|
}
|
|
238
|
-
|
|
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);
|
|
239
288
|
return ret;
|
|
240
289
|
}
|
|
241
290
|
/**
|
|
@@ -1035,6 +1084,10 @@ function __wbg_get_imports() {
|
|
|
1035
1084
|
const ret = new Float32Array(getArrayF32FromWasm0(arg0, arg1));
|
|
1036
1085
|
return ret;
|
|
1037
1086
|
},
|
|
1087
|
+
__wbg_new_from_slice_4ee02165f9de919e: function(arg0, arg1) {
|
|
1088
|
+
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
1089
|
+
return ret;
|
|
1090
|
+
},
|
|
1038
1091
|
__wbg_new_typed_6f8b0d724fe26c07: function(arg0, arg1) {
|
|
1039
1092
|
try {
|
|
1040
1093
|
var state0 = {a: arg0, b: arg1};
|
|
@@ -1371,33 +1424,33 @@ function __wbg_get_imports() {
|
|
|
1371
1424
|
arg0.writeBuffer(arg1, arg2, getArrayU8FromWasm0(arg3, arg4), arg5, arg6);
|
|
1372
1425
|
}, arguments); },
|
|
1373
1426
|
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
1374
|
-
// 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`.
|
|
1375
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_);
|
|
1376
1429
|
return ret;
|
|
1377
1430
|
},
|
|
1378
1431
|
__wbindgen_generic_0000000000000002: function(arg0, arg1) {
|
|
1379
|
-
// 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`.
|
|
1380
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_);
|
|
1381
1434
|
return ret;
|
|
1382
1435
|
},
|
|
1383
1436
|
__wbindgen_generic_0000000000000003: function(arg0, arg1) {
|
|
1384
|
-
// 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`.
|
|
1385
1438
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true_);
|
|
1386
1439
|
return ret;
|
|
1387
1440
|
},
|
|
1388
1441
|
__wbindgen_generic_0000000000000004: function(arg0, arg1) {
|
|
1389
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("GPUUncapturedErrorEvent")], shim_idx:
|
|
1390
|
-
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);
|
|
1391
1444
|
return ret;
|
|
1392
1445
|
},
|
|
1393
1446
|
__wbindgen_generic_0000000000000005: function(arg0, arg1) {
|
|
1394
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("any")], shim_idx:
|
|
1395
|
-
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);
|
|
1396
1449
|
return ret;
|
|
1397
1450
|
},
|
|
1398
1451
|
__wbindgen_generic_0000000000000006: function(arg0, arg1) {
|
|
1399
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("undefined")], shim_idx:
|
|
1400
|
-
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);
|
|
1401
1454
|
return ret;
|
|
1402
1455
|
},
|
|
1403
1456
|
__wbindgen_generic_0000000000000007: function(arg0) {
|
|
@@ -1440,8 +1493,8 @@ function wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_549
|
|
|
1440
1493
|
wasm.wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wgpu_54917290532eaf6b___backend__webgpu__webgpu_sys__gen_GpuDeviceLostInfo__GpuDeviceLostInfo______true_(arg0, arg1, arg2);
|
|
1441
1494
|
}
|
|
1442
1495
|
|
|
1443
|
-
function
|
|
1444
|
-
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);
|
|
1445
1498
|
}
|
|
1446
1499
|
|
|
1447
1500
|
function wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bindgen_8cf186fa7724d16d___JsValue__core_608f92abc48d28da___result__Result_____wasm_bindgen_8cf186fa7724d16d___JsError___true_(arg0, arg1, arg2) {
|
|
@@ -1458,15 +1511,15 @@ function wasm_bindgen_8cf186fa7724d16d___convert__closures_____invoke___wasm_bin
|
|
|
1458
1511
|
}
|
|
1459
1512
|
}
|
|
1460
1513
|
|
|
1461
|
-
function
|
|
1462
|
-
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);
|
|
1463
1516
|
if (ret[1]) {
|
|
1464
1517
|
throw takeFromExternrefTable0(ret[0]);
|
|
1465
1518
|
}
|
|
1466
1519
|
}
|
|
1467
1520
|
|
|
1468
|
-
function
|
|
1469
|
-
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);
|
|
1470
1523
|
if (ret[1]) {
|
|
1471
1524
|
throw takeFromExternrefTable0(ret[0]);
|
|
1472
1525
|
}
|
|
@@ -1508,6 +1561,9 @@ const __wbindgen_enum_GpuTextureViewDimension = ["1d", "2d", "2d-array", "cube",
|
|
|
1508
1561
|
const JsSourceFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1509
1562
|
? { register: () => {}, unregister: () => {} }
|
|
1510
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));
|
|
1511
1567
|
const Sha256HasherFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1512
1568
|
? { register: () => {}, unregister: () => {} }
|
|
1513
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;
|