bitgpu 0.12.0 → 0.13.1

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 CHANGED
@@ -34,7 +34,7 @@ weights stream straight from the Hugging Face Hub. This runs as-is:
34
34
  import { createEngine } from 'bitgpu'
35
35
  import { createChat } from 'bitgpu/chat'
36
36
 
37
- const REPO = 'https://cdn.jsdelivr.net/gh/stfurkan/bitgpu@v0.12.0/models/bonsai-1.7b-gguf'
37
+ const REPO = 'https://cdn.jsdelivr.net/gh/stfurkan/bitgpu@v0.13.1/models/bonsai-1.7b-gguf'
38
38
  const TOK = 'https://huggingface.co/onnx-community/Bonsai-1.7B-ONNX/resolve/main'
39
39
  const engine = await createEngine({
40
40
  manifestUrl: `${REPO}/manifest.json`,
@@ -226,10 +226,15 @@ feasibility, so the model can never be trapped mid-number), and `oneOf` as a **d
226
226
  union** - object branches sharing one required property whose single-value `enum` differs per
227
227
  branch, e.g. a slide that is either `{type: 'bullets', ...}` or `{type: 'quote', ...}`; the
228
228
  machine tracks the live branches until the discriminator commits. All nested to any depth.
229
- Anything else (`pattern`, float ranges, general `oneOf`, `$ref`, ...) **throws up front** -
230
- never silently ignored. The guarantee is structural, not semantic: a schema makes the output
231
- parse into the right shape, not be true. Built on the engine's generic `candidateFilter` hook
232
- (see `GenerateOptions`), which is open for custom grammars.
229
+ Annotation-only keywords - `description`, `title`, `default`, `examples`, `$schema`, `$id`,
230
+ `deprecated`, `readOnly`, `writeOnly`, `$comment` - are **accepted and ignored** (they carry no
231
+ constraint), so a real MCP / OpenAI tool schema passes through unmodified and a property's
232
+ `description` still reaches the model via the chat template. Genuinely-constraining keywords the
233
+ enforcer does not implement (`pattern`, `format`, float ranges, general `oneOf`, `$ref`, ...)
234
+ **throw up front** - never silently ignored, because those would *look* enforced. The guarantee
235
+ is structural, not semantic: a schema makes the output parse into the right shape, not be true.
236
+ Built on the engine's generic `candidateFilter` hook (see `GenerateOptions`), which is open for
237
+ custom grammars.
233
238
 
234
239
  ### Confidence (`logprobs`)
235
240
 
@@ -318,9 +323,32 @@ GPU gate proves the reuse paths bit-exact on real hardware. Prefer your own toke
318
323
 
319
324
  ## Bring your own model
320
325
 
321
- bitgpu loads its own small format instead of parsing ONNX or GGUF at runtime: a
326
+ ### Any 1-bit GGUF, zero steps: `bitgpu/gguf`
327
+
328
+ For GGUF models there is no conversion step at all - `fromGguf` fetches ONLY the header
329
+ (HTTP ranges, a few MB, never the weights), builds the manifest in memory, and derives the
330
+ lookup tables, so one URL is the whole setup:
331
+
332
+ ```ts
333
+ import { createEngine } from 'bitgpu'
334
+ import { fromGguf } from 'bitgpu/gguf'
335
+
336
+ const engine = await createEngine({
337
+ ...(await fromGguf('https://huggingface.co/prism-ml/Bonsai-1.7B-gguf/resolve/main/Bonsai-1.7B-Q1_0.gguf')),
338
+ kvCache: 'q8',
339
+ })
340
+ ```
341
+
342
+ The in-browser parse is gated: it must deep-equal the offline converter's manifest AND an
343
+ engine built from it must reproduce the known-good greedy ids bit-exactly on GPU. Prefer the
344
+ committed [`models/`](models/) manifests when one exists (a `manifest.json` is smaller than a
345
+ GGUF header and caches better); `fromGguf` is for models nobody has converted yet.
346
+
347
+ ### Offline converters
348
+
349
+ bitgpu loads its own small format instead of parsing ONNX (or re-parsing GGUF) at runtime: a
322
350
  `manifest.json` (the architecture contract + every tensor mapped to a byte range) and a small
323
- aux file, both produced ONCE, offline, from a standard export - while the big weights file is
351
+ aux file, both produced ONCE from a standard export - while the big weights file is
324
352
  used byte-for-byte unchanged, so it can keep streaming from wherever it already lives (e.g.
325
353
  the Hugging Face Hub). Same one-time-conversion model as llama.cpp or MLX. Two converters:
326
354
 
package/dist/chat.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { c as KvSnapshot, n as Engine, o as GenerateOptions, u as TokenLogprobs } from "./types-Bl0FS_nX.js";
1
+ import { c as KvSnapshot, m as TokenLogprobs, n as Engine, o as GenerateOptions } from "./types-ByYx15Yw.js";
2
2
 
3
3
  //#region src/chat/tokenizer.d.ts
4
4
  interface ChatMessage {
@@ -76,6 +76,19 @@ interface JsonSchema {
76
76
  * combinable with enum (the literals already fix the length). */
77
77
  minLength?: number;
78
78
  maxLength?: number;
79
+ /** Human-readable docs. Ignored by the enforcer, but the chat template renders the tools list
80
+ * (parameters included) into the model's prompt, so a property `description` DOES reach the
81
+ * model - the reason MCP/OpenAI tool schemas pass through unmodified. */
82
+ description?: string;
83
+ title?: string;
84
+ default?: unknown;
85
+ examples?: unknown[];
86
+ deprecated?: boolean;
87
+ readOnly?: boolean;
88
+ writeOnly?: boolean;
89
+ $comment?: string;
90
+ $schema?: string;
91
+ $id?: string;
79
92
  }
80
93
  /** Validate a schema against the enforceable subset; throws listing anything unsupported. */
81
94
  declare function validateJsonSchema(schema: JsonSchema, path?: string, isRoot?: boolean): void;
package/dist/chat.js CHANGED
@@ -4415,6 +4415,18 @@ const SUPPORTED = /* @__PURE__ */ new Set([
4415
4415
  "minLength",
4416
4416
  "maxLength"
4417
4417
  ]);
4418
+ const ANNOTATIONS = /* @__PURE__ */ new Set([
4419
+ "description",
4420
+ "title",
4421
+ "default",
4422
+ "examples",
4423
+ "deprecated",
4424
+ "readOnly",
4425
+ "writeOnly",
4426
+ "$comment",
4427
+ "$schema",
4428
+ "$id"
4429
+ ]);
4418
4430
  const TYPES = /* @__PURE__ */ new Set([
4419
4431
  "object",
4420
4432
  "array",
@@ -4435,10 +4447,10 @@ function findDiscriminator(branches) {
4435
4447
  }
4436
4448
  /** Validate a schema against the enforceable subset; throws listing anything unsupported. */
4437
4449
  function validateJsonSchema(schema, path = "schema", isRoot = true) {
4438
- const unknown = Object.keys(schema).filter((k) => !SUPPORTED.has(k));
4439
- if (unknown.length) throw new Error(`bitgpu/chat: unsupported JSON Schema keyword(s) at ${path}: ${unknown.join(", ")} (enforceable subset: ${[...SUPPORTED].join(", ")})`);
4450
+ const unknown = Object.keys(schema).filter((k) => !SUPPORTED.has(k) && !ANNOTATIONS.has(k));
4451
+ if (unknown.length) throw new Error(`bitgpu/chat: unsupported JSON Schema keyword(s) at ${path}: ${unknown.join(", ")} (enforceable subset: ${[...SUPPORTED].join(", ")}; annotations accepted-and-ignored: ${[...ANNOTATIONS].join(", ")})`);
4440
4452
  if (schema.oneOf !== void 0) {
4441
- const extra = Object.keys(schema).filter((k) => k !== "oneOf");
4453
+ const extra = Object.keys(schema).filter((k) => k !== "oneOf" && !ANNOTATIONS.has(k));
4442
4454
  if (extra.length) throw new Error(`bitgpu/chat: oneOf at ${path} cannot combine with other keywords (got ${extra.join(", ")})`);
4443
4455
  if (!Array.isArray(schema.oneOf) || schema.oneOf.length < 2) throw new Error(`bitgpu/chat: oneOf at ${path} needs at least 2 branches`);
4444
4456
  schema.oneOf.forEach((b, i) => {