bitgpu 0.13.1 → 0.14.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 +17 -1
- package/dist/chat.d.ts +11 -3
- package/dist/chat.js +9 -3
- package/dist/chat.js.map +1 -1
- package/dist/gguf.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +134 -40
- package/dist/index.js.map +1 -1
- package/dist/{types-ByYx15Yw.d.ts → types-iFADjEuf.d.ts} +34 -4
- package/package.json +4 -2
|
@@ -131,6 +131,15 @@ interface EngineOptions {
|
|
|
131
131
|
* seed -> same tokens; cache reuse == full prefill). See `capabilities.kvCache` for what's
|
|
132
132
|
* active. Default `'f32'`. */
|
|
133
133
|
kvCache?: 'f32' | 'f16' | 'q8';
|
|
134
|
+
/** Activation-compute precision for the decode matmuls (the 1-bit GEMVs that dominate decode).
|
|
135
|
+
* `'f16'` reads activations as f16 and runs the per-block dot in f16 (2x ALU rate on
|
|
136
|
+
* Apple/AMD/recent NVIDIA) with f32 accumulation; the residual stream and weights stay f32.
|
|
137
|
+
* Like `kvCache: 'f16'` it needs the `shader-f16` adapter feature and the subgroup path, and
|
|
138
|
+
* SILENTLY FALLS BACK to f32 without them, so it is safe to request unconditionally. Outputs
|
|
139
|
+
* are not bit-identical to f32 (measured near-lossless by the GPU gate, q8-KV tier) but WITHIN
|
|
140
|
+
* the mode decoding is exact and deterministic. Applies to decode only (prefill stays f32).
|
|
141
|
+
* See `capabilities.activation` for what is active. Default `'f32'`. */
|
|
142
|
+
activation?: 'f32' | 'f16';
|
|
134
143
|
/** What happens when a conversation outgrows `maxSeqLen`. `'error'` (default): generate
|
|
135
144
|
* throws, exactly as before. `'sinks'`: StreamingLLM-style rolling window - the first
|
|
136
145
|
* `sinkTokens` positions (attention sinks) plus the most recent window are kept and the
|
|
@@ -285,6 +294,9 @@ interface EngineCapabilities {
|
|
|
285
294
|
/** Active KV-cache storage precision ('f16' only when requested AND the adapter has shader-f16;
|
|
286
295
|
* 'q8' whenever requested - it needs no adapter feature). */
|
|
287
296
|
kvCache: 'f32' | 'f16' | 'q8';
|
|
297
|
+
/** Active activation-compute precision ('f16' only when requested AND the adapter has shader-f16
|
|
298
|
+
* AND the subgroup path is in use; else 'f32'). */
|
|
299
|
+
activation: 'f32' | 'f16';
|
|
288
300
|
/** Active overflow policy ('sinks' = rolling window with attention sinks). */
|
|
289
301
|
overflow: 'error' | 'sinks';
|
|
290
302
|
/** The engine's KV window in positions (the resolved maxSeqLen option). Under
|
|
@@ -303,6 +315,9 @@ interface EngineCapabilities {
|
|
|
303
315
|
maxStorageBufferBindingSize: number;
|
|
304
316
|
maxComputeWorkgroupStorageSize: number;
|
|
305
317
|
};
|
|
318
|
+
/** Whether the device has the `timestamp-query` feature (true GPU-side kernel timing is
|
|
319
|
+
* available to the dev profiler; see the profileDecode diagnostics). */
|
|
320
|
+
timestampQuery: boolean;
|
|
306
321
|
}
|
|
307
322
|
/** A saved KV cache + conversation token history, from {@link Engine.saveCache}. A plain object
|
|
308
323
|
* holding one `ArrayBuffer`, so it is structured-cloneable: store it in IndexedDB / OPFS or send
|
|
@@ -330,7 +345,13 @@ interface KvSnapshot {
|
|
|
330
345
|
};
|
|
331
346
|
/** The full conversation token sequence at save time. */
|
|
332
347
|
ids: number[];
|
|
333
|
-
/**
|
|
348
|
+
/** DELTA snapshot: `data` holds only cache positions `[base, len)` - the leading `base` positions
|
|
349
|
+
* (e.g. a shared prewarmed system prompt) are NOT stored and must already be present in the
|
|
350
|
+
* restore target (restore into an engine freshly prewarmed with the same prefix). Absent/0 = a
|
|
351
|
+
* full snapshot (all positions in `data`). Restore validates the target is exactly at the base
|
|
352
|
+
* boundary with a matching token prefix. */
|
|
353
|
+
base?: number;
|
|
354
|
+
/** Packed per-layer cached K/V bytes (and q8 block scales) for the stored positions. */
|
|
334
355
|
data: ArrayBuffer;
|
|
335
356
|
}
|
|
336
357
|
/** A loaded model ready to generate. Create one with {@link createEngine}. */
|
|
@@ -354,8 +375,17 @@ interface Engine {
|
|
|
354
375
|
* the conversation alive, so conversations survive engine disposal and page reloads (persist
|
|
355
376
|
* the snapshot in IndexedDB / OPFS). Size ~ tokens x layers x kvHeads x headDim x 2 x
|
|
356
377
|
* bytes-per-value (~224 KB/token at f32 on Bonsai-1.7B, ~63 KB/token at q8). Returns `null`
|
|
357
|
-
* when the cache is empty. Serialized with generate/prefill/forward like every engine op.
|
|
358
|
-
|
|
378
|
+
* when the cache is empty. Serialized with generate/prefill/forward like every engine op.
|
|
379
|
+
*
|
|
380
|
+
* `from` makes a DELTA snapshot that excludes the first `from` cache positions (a shared
|
|
381
|
+
* prewarmed prefix), so per-conversation snapshots drop the redundant system-prompt KV (tens of
|
|
382
|
+
* MB at chat scale). Restore it into an engine freshly prewarmed with the SAME prefix - see the
|
|
383
|
+
* `base` field on {@link KvSnapshot}. `from` counts cache positions: for a prewarm of P tokens
|
|
384
|
+
* pass `from = P - 1` (a fresh prewarm caches P-1 positions; the last prewarm token's K/V is part
|
|
385
|
+
* of the delta). `bitgpu/chat`'s `save({ delta: true })` computes this for you. */
|
|
386
|
+
saveCache(opts?: {
|
|
387
|
+
from?: number;
|
|
388
|
+
}): Promise<KvSnapshot | null>;
|
|
359
389
|
/** Replace the current conversation with a {@link KvSnapshot} (CPU -> GPU upload). The next
|
|
360
390
|
* `generate(delta, { reuseCache: true })` continues the saved conversation exactly. Throws if
|
|
361
391
|
* the snapshot's model architecture or `kvCache` mode does not match this engine, or if it
|
|
@@ -371,4 +401,4 @@ interface Engine {
|
|
|
371
401
|
}
|
|
372
402
|
//#endregion
|
|
373
403
|
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-
|
|
404
|
+
//# sourceMappingURL=types-iFADjEuf.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bitgpu",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.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",
|
|
@@ -55,7 +55,9 @@
|
|
|
55
55
|
"check:publish": "publint --strict && attw --pack . --profile esm-only",
|
|
56
56
|
"prepare": "npm run build",
|
|
57
57
|
"prepublishOnly": "npm run build && npm run check:publish",
|
|
58
|
-
"test:gguf": "tsx scripts/verify-gguf.ts"
|
|
58
|
+
"test:gguf": "tsx scripts/verify-gguf.ts",
|
|
59
|
+
"profile": "node scripts/profile.mjs",
|
|
60
|
+
"bench": "node scripts/benchmark.mjs"
|
|
59
61
|
},
|
|
60
62
|
"devDependencies": {
|
|
61
63
|
"@arethetypeswrong/cli": "0.18.4",
|