bitgpu 0.10.0 → 0.12.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 +90 -34
- package/dist/chat.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +293 -55
- package/dist/index.js.map +1 -1
- package/dist/{types-CcgsXirU.d.ts → types-Bl0FS_nX.d.ts} +31 -6
- package/package.json +1 -1
|
@@ -43,7 +43,9 @@ interface EngineOptions {
|
|
|
43
43
|
/** Prefill GEMM tiling: `'auto'` tiles once a prompt fills the 64-row tiles, `'always'`/`'never'` force it. Default `'auto'`. */
|
|
44
44
|
prefillTiling?: 'auto' | 'always' | 'never';
|
|
45
45
|
/** 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`.
|
|
46
|
+
* half that with `kvCache: 'f16'`, ~a quarter with `'q8'`). Default `2048`. Capped by the
|
|
47
|
+
* model's RoPE range: the baked cache length for ONNX-derived manifests, `max_positions`
|
|
48
|
+
* (the GGUF context length) for GGUF-derived ones - exceeding it fails loudly at load. */
|
|
47
49
|
maxSeqLen?: number;
|
|
48
50
|
/** KV-cache STORAGE precision. `'f16'` halves KV memory (all arithmetic stays f32; each cached
|
|
49
51
|
* K/V value is rounded once at cache-write); it falls back to `'f32'` silently when the
|
|
@@ -57,6 +59,20 @@ interface EngineOptions {
|
|
|
57
59
|
* seed -> same tokens; cache reuse == full prefill). See `capabilities.kvCache` for what's
|
|
58
60
|
* active. Default `'f32'`. */
|
|
59
61
|
kvCache?: 'f32' | 'f16' | 'q8';
|
|
62
|
+
/** What happens when a conversation outgrows `maxSeqLen`. `'error'` (default): generate
|
|
63
|
+
* throws, exactly as before. `'sinks'`: StreamingLLM-style rolling window - the first
|
|
64
|
+
* `sinkTokens` positions (attention sinks) plus the most recent window are kept and the
|
|
65
|
+
* middle is evicted in batches, so generation and multi-turn chat continue indefinitely in
|
|
66
|
+
* fixed memory. Keys are cached UNROPED and rotated at read by cache-relative position, so
|
|
67
|
+
* eviction never rewrites or (under q8) requantizes cache bytes. Sink mode is its own
|
|
68
|
+
* measured mode like f16/q8: within-mode decoding stays exact and deterministic, and before
|
|
69
|
+
* the first eviction f32+sinks matches default f32 (gated); after eviction the model
|
|
70
|
+
* genuinely forgets evicted middle context - that is the trade. Prompts longer than the
|
|
71
|
+
* window still throw (trim prompt-side, e.g. chat onOverflow). */
|
|
72
|
+
overflow?: 'error' | 'sinks';
|
|
73
|
+
/** Number of initial attention-sink positions kept forever under `overflow: 'sinks'`.
|
|
74
|
+
* Default `4` (the StreamingLLM setting). */
|
|
75
|
+
sinkTokens?: number;
|
|
60
76
|
/** Called as the model loads. */
|
|
61
77
|
onProgress?: (progress: LoadProgress) => void;
|
|
62
78
|
/** Called if the GPU device is lost after creation (driver reset, OS reclaim, tab backgrounding
|
|
@@ -197,8 +213,11 @@ interface EngineCapabilities {
|
|
|
197
213
|
/** Active KV-cache storage precision ('f16' only when requested AND the adapter has shader-f16;
|
|
198
214
|
* 'q8' whenever requested - it needs no adapter feature). */
|
|
199
215
|
kvCache: 'f32' | 'f16' | 'q8';
|
|
200
|
-
/**
|
|
201
|
-
|
|
216
|
+
/** Active overflow policy ('sinks' = rolling window with attention sinks). */
|
|
217
|
+
overflow: 'error' | 'sinks';
|
|
218
|
+
/** The engine's KV window in positions (the resolved maxSeqLen option). Under
|
|
219
|
+
* `overflow: 'error'` prompt + generated tokens must fit inside it; under `'sinks'` it is
|
|
220
|
+
* the rolling window size. */
|
|
202
221
|
maxSeqLen: number;
|
|
203
222
|
/** Adapter identification, when the browser exposes it. */
|
|
204
223
|
adapter: {
|
|
@@ -219,10 +238,16 @@ interface EngineCapabilities {
|
|
|
219
238
|
* Restore requires the SAME model architecture and the SAME `kvCache` mode; snapshots never
|
|
220
239
|
* convert across modes. Treat the fields as opaque. */
|
|
221
240
|
interface KvSnapshot {
|
|
222
|
-
/** Snapshot format version
|
|
223
|
-
|
|
241
|
+
/** Snapshot format version: `1` = default mode, `2` = saved under `overflow: 'sinks'`
|
|
242
|
+
* (the cache holds unroped keys and a rolled window; restore requires sink mode). */
|
|
243
|
+
version: 1 | 2;
|
|
224
244
|
/** KV storage mode the snapshot was taken under. */
|
|
225
245
|
kvCache: 'f32' | 'f16' | 'q8';
|
|
246
|
+
/** Version 2 only: rolling-window state (sink count and filled cache slots). */
|
|
247
|
+
roll?: {
|
|
248
|
+
sinkTokens: number;
|
|
249
|
+
cacheLen: number;
|
|
250
|
+
};
|
|
226
251
|
/** Architecture stamp; restore rejects a snapshot from a different model shape. */
|
|
227
252
|
model: {
|
|
228
253
|
layers: number;
|
|
@@ -274,4 +299,4 @@ interface Engine {
|
|
|
274
299
|
}
|
|
275
300
|
//#endregion
|
|
276
301
|
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, TokenLogprobs as u };
|
|
277
|
-
//# sourceMappingURL=types-
|
|
302
|
+
//# sourceMappingURL=types-Bl0FS_nX.d.ts.map
|