bitgpu 0.11.0 → 0.13.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 +61 -29
- package/dist/chat.d.ts +1 -1
- package/dist/gguf.d.ts +33 -0
- package/dist/gguf.js +394 -0
- package/dist/gguf.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +166 -31
- package/dist/index.js.map +1 -1
- package/dist/{types-DJ61q1gX.d.ts → types-ByYx15Yw.d.ts} +77 -3
- package/package.json +7 -2
|
@@ -1,4 +1,70 @@
|
|
|
1
1
|
//#region src/types.d.ts
|
|
2
|
+
/** A byte range inside the data or aux file. */
|
|
3
|
+
interface ManifestRef {
|
|
4
|
+
src?: string;
|
|
5
|
+
dtype: string;
|
|
6
|
+
shape?: number[];
|
|
7
|
+
off: number;
|
|
8
|
+
len: number;
|
|
9
|
+
}
|
|
10
|
+
/** One tensor entry in a manifest. */
|
|
11
|
+
interface ManifestTensor {
|
|
12
|
+
kind?: string;
|
|
13
|
+
N?: number;
|
|
14
|
+
K?: number;
|
|
15
|
+
rows?: number;
|
|
16
|
+
cols?: number;
|
|
17
|
+
block?: number;
|
|
18
|
+
bits?: number;
|
|
19
|
+
lut?: string;
|
|
20
|
+
/** v2 manifests: 'q1_0' marks a tensor whose weight ref covers an interleaved GGUF
|
|
21
|
+
* Q1_0 region ([f16 scale][16 sign bytes] per 128-weight block); the loader demuxes
|
|
22
|
+
* it in-flight into the planar sign/scale buffers the kernels consume. */
|
|
23
|
+
container?: string;
|
|
24
|
+
/** normalized at load: the raw interleaved region of a container tensor */
|
|
25
|
+
q1_0?: ManifestRef;
|
|
26
|
+
weight?: ManifestRef;
|
|
27
|
+
scales?: ManifestRef;
|
|
28
|
+
zp?: ManifestRef;
|
|
29
|
+
src?: string;
|
|
30
|
+
dtype?: string;
|
|
31
|
+
off?: number;
|
|
32
|
+
len?: number;
|
|
33
|
+
}
|
|
34
|
+
/** The architecture contract of a manifest. */
|
|
35
|
+
interface ManifestArch {
|
|
36
|
+
model_type?: string;
|
|
37
|
+
layers: number;
|
|
38
|
+
hidden: number;
|
|
39
|
+
intermediate: number;
|
|
40
|
+
heads: number;
|
|
41
|
+
kv_heads: number;
|
|
42
|
+
head_dim: number;
|
|
43
|
+
rms_eps: number;
|
|
44
|
+
vocab: number;
|
|
45
|
+
eos: number;
|
|
46
|
+
act: string;
|
|
47
|
+
tie_word_embeddings?: boolean;
|
|
48
|
+
/** rope parameters for manifests without baked cos/sin caches (v2/GGUF) */
|
|
49
|
+
rope?: {
|
|
50
|
+
rope_theta: number;
|
|
51
|
+
rope_type?: string;
|
|
52
|
+
factor?: number;
|
|
53
|
+
original_max_position_embeddings?: number;
|
|
54
|
+
};
|
|
55
|
+
/** position cap for synthesized rope (GGUF context_length) */
|
|
56
|
+
max_positions?: number;
|
|
57
|
+
}
|
|
58
|
+
/** The small model-description file bitgpu loads (see docs/FORMAT.md). Usually fetched as
|
|
59
|
+
* `manifest.json`; `bitgpu/gguf` builds one in memory straight from a GGUF header. */
|
|
60
|
+
interface Manifest {
|
|
61
|
+
version?: number;
|
|
62
|
+
data_file: string;
|
|
63
|
+
aux_file: string;
|
|
64
|
+
arch: ManifestArch;
|
|
65
|
+
luts: Record<string, ManifestRef>;
|
|
66
|
+
tensors: Record<string, ManifestTensor>;
|
|
67
|
+
}
|
|
2
68
|
/** Progress event emitted while a model loads. */
|
|
3
69
|
interface LoadProgress {
|
|
4
70
|
phase: 'manifest' | 'weights' | 'pipelines';
|
|
@@ -20,6 +86,12 @@ interface EngineOptions {
|
|
|
20
86
|
dataUrl?: string;
|
|
21
87
|
/** Explicit URL for the aux file (overrides `${modelUrl}/<aux_file>`). */
|
|
22
88
|
auxUrl?: string;
|
|
89
|
+
/** An in-memory manifest (skips the manifest fetch). `bitgpu/gguf`'s `fromGguf` returns one
|
|
90
|
+
* parsed straight from a GGUF header. Requires `dataUrl` (or `modelUrl`) for the weights. */
|
|
91
|
+
manifest?: Manifest;
|
|
92
|
+
/** In-memory aux bytes (skips the aux fetch). `fromGguf` computes them (the LUTs are derived,
|
|
93
|
+
* not stored, for GGUF models). */
|
|
94
|
+
aux?: ArrayBuffer | Uint8Array;
|
|
23
95
|
/** Fetch JSON (manifest). Override to add caching. Default: `fetch(url).json()`. */
|
|
24
96
|
fetchJson?: (url: string) => Promise<unknown>;
|
|
25
97
|
/** Fetch binary (data/aux). Override to add caching (e.g. OPFS) for the ~290MB data file. Default: `fetch(url).arrayBuffer()`. */
|
|
@@ -43,7 +115,9 @@ interface EngineOptions {
|
|
|
43
115
|
/** Prefill GEMM tiling: `'auto'` tiles once a prompt fills the 64-row tiles, `'always'`/`'never'` force it. Default `'auto'`. */
|
|
44
116
|
prefillTiling?: 'auto' | 'always' | 'never';
|
|
45
117
|
/** Max KV-cache length (prompt + generated positions). Caps VRAM (~`maxSeqLen` x 224 KB at f32,
|
|
46
|
-
* half that with `kvCache: 'f16'`, ~a quarter with `'q8'`). Default `2048`.
|
|
118
|
+
* half that with `kvCache: 'f16'`, ~a quarter with `'q8'`). Default `2048`. Capped by the
|
|
119
|
+
* model's RoPE range: the baked cache length for ONNX-derived manifests, `max_positions`
|
|
120
|
+
* (the GGUF context length) for GGUF-derived ones - exceeding it fails loudly at load. */
|
|
47
121
|
maxSeqLen?: number;
|
|
48
122
|
/** KV-cache STORAGE precision. `'f16'` halves KV memory (all arithmetic stays f32; each cached
|
|
49
123
|
* K/V value is rounded once at cache-write); it falls back to `'f32'` silently when the
|
|
@@ -296,5 +370,5 @@ interface Engine {
|
|
|
296
370
|
dispose(): void;
|
|
297
371
|
}
|
|
298
372
|
//#endregion
|
|
299
|
-
export { ForwardResult as a, KvSnapshot as c, EngineOptions as i, LoadProgress as l, Engine as n, GenerateOptions as o, EngineCapabilities as r, GenerateResult as s, DeviceLostInfo as t,
|
|
300
|
-
//# sourceMappingURL=types-
|
|
373
|
+
export { ForwardResult as a, KvSnapshot as c, ManifestArch as d, ManifestRef as f, EngineOptions as i, LoadProgress as l, TokenLogprobs as m, Engine as n, GenerateOptions as o, ManifestTensor as p, EngineCapabilities as r, GenerateResult as s, DeviceLostInfo as t, Manifest as u };
|
|
374
|
+
//# sourceMappingURL=types-ByYx15Yw.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bitgpu",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Fast WebGPU runtime for 1-bit (binary-weight) LLMs in the browser. Bit-exact, zero runtime dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,6 +37,10 @@
|
|
|
37
37
|
"./chat": {
|
|
38
38
|
"types": "./dist/chat.d.ts",
|
|
39
39
|
"default": "./dist/chat.js"
|
|
40
|
+
},
|
|
41
|
+
"./gguf": {
|
|
42
|
+
"types": "./dist/gguf.d.ts",
|
|
43
|
+
"default": "./dist/gguf.js"
|
|
40
44
|
}
|
|
41
45
|
},
|
|
42
46
|
"scripts": {
|
|
@@ -50,7 +54,8 @@
|
|
|
50
54
|
"verify:headless": "node scripts/headless-verify.mjs",
|
|
51
55
|
"check:publish": "publint --strict && attw --pack . --profile esm-only",
|
|
52
56
|
"prepare": "npm run build",
|
|
53
|
-
"prepublishOnly": "npm run build && npm run check:publish"
|
|
57
|
+
"prepublishOnly": "npm run build && npm run check:publish",
|
|
58
|
+
"test:gguf": "tsx scripts/verify-gguf.ts"
|
|
54
59
|
},
|
|
55
60
|
"devDependencies": {
|
|
56
61
|
"@arethetypeswrong/cli": "0.18.4",
|