bitgpu 0.10.0 → 0.11.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.
@@ -57,6 +57,20 @@ interface EngineOptions {
57
57
  * seed -> same tokens; cache reuse == full prefill). See `capabilities.kvCache` for what's
58
58
  * active. Default `'f32'`. */
59
59
  kvCache?: 'f32' | 'f16' | 'q8';
60
+ /** What happens when a conversation outgrows `maxSeqLen`. `'error'` (default): generate
61
+ * throws, exactly as before. `'sinks'`: StreamingLLM-style rolling window - the first
62
+ * `sinkTokens` positions (attention sinks) plus the most recent window are kept and the
63
+ * middle is evicted in batches, so generation and multi-turn chat continue indefinitely in
64
+ * fixed memory. Keys are cached UNROPED and rotated at read by cache-relative position, so
65
+ * eviction never rewrites or (under q8) requantizes cache bytes. Sink mode is its own
66
+ * measured mode like f16/q8: within-mode decoding stays exact and deterministic, and before
67
+ * the first eviction f32+sinks matches default f32 (gated); after eviction the model
68
+ * genuinely forgets evicted middle context - that is the trade. Prompts longer than the
69
+ * window still throw (trim prompt-side, e.g. chat onOverflow). */
70
+ overflow?: 'error' | 'sinks';
71
+ /** Number of initial attention-sink positions kept forever under `overflow: 'sinks'`.
72
+ * Default `4` (the StreamingLLM setting). */
73
+ sinkTokens?: number;
60
74
  /** Called as the model loads. */
61
75
  onProgress?: (progress: LoadProgress) => void;
62
76
  /** Called if the GPU device is lost after creation (driver reset, OS reclaim, tab backgrounding
@@ -197,8 +211,11 @@ interface EngineCapabilities {
197
211
  /** Active KV-cache storage precision ('f16' only when requested AND the adapter has shader-f16;
198
212
  * 'q8' whenever requested - it needs no adapter feature). */
199
213
  kvCache: 'f32' | 'f16' | 'q8';
200
- /** The engine's KV window in positions (the resolved maxSeqLen option): prompt + generated
201
- * tokens per conversation must fit inside it. */
214
+ /** Active overflow policy ('sinks' = rolling window with attention sinks). */
215
+ overflow: 'error' | 'sinks';
216
+ /** The engine's KV window in positions (the resolved maxSeqLen option). Under
217
+ * `overflow: 'error'` prompt + generated tokens must fit inside it; under `'sinks'` it is
218
+ * the rolling window size. */
202
219
  maxSeqLen: number;
203
220
  /** Adapter identification, when the browser exposes it. */
204
221
  adapter: {
@@ -219,10 +236,16 @@ interface EngineCapabilities {
219
236
  * Restore requires the SAME model architecture and the SAME `kvCache` mode; snapshots never
220
237
  * convert across modes. Treat the fields as opaque. */
221
238
  interface KvSnapshot {
222
- /** Snapshot format version (currently `1`). */
223
- version: 1;
239
+ /** Snapshot format version: `1` = default mode, `2` = saved under `overflow: 'sinks'`
240
+ * (the cache holds unroped keys and a rolled window; restore requires sink mode). */
241
+ version: 1 | 2;
224
242
  /** KV storage mode the snapshot was taken under. */
225
243
  kvCache: 'f32' | 'f16' | 'q8';
244
+ /** Version 2 only: rolling-window state (sink count and filled cache slots). */
245
+ roll?: {
246
+ sinkTokens: number;
247
+ cacheLen: number;
248
+ };
226
249
  /** Architecture stamp; restore rejects a snapshot from a different model shape. */
227
250
  model: {
228
251
  layers: number;
@@ -274,4 +297,4 @@ interface Engine {
274
297
  }
275
298
  //#endregion
276
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, TokenLogprobs as u };
277
- //# sourceMappingURL=types-CcgsXirU.d.ts.map
300
+ //# sourceMappingURL=types-DJ61q1gX.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bitgpu",
3
- "version": "0.10.0",
3
+ "version": "0.11.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",