@basecompute/basert 0.5.3 → 0.5.4
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/dist/index.d.ts +2 -0
- package/dist/index.js +62 -9
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -208,5 +208,7 @@ export declare const __internal: {
|
|
|
208
208
|
TranscribeSegmentC: koffi.IKoffiCType;
|
|
209
209
|
toSamplingC: typeof toSamplingC;
|
|
210
210
|
toModelConfig: typeof toModelConfig;
|
|
211
|
+
/** Drop the cached library so the next model load resolves BASERT_LIB_PATH again. */
|
|
212
|
+
resetLib(): void;
|
|
211
213
|
};
|
|
212
214
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -275,6 +275,26 @@ const ModelConfigC = koffi_1.default.struct("BaseRTModelConfig", {
|
|
|
275
275
|
attention_bias: "uint8",
|
|
276
276
|
rope_yarn_truncate: "uint8",
|
|
277
277
|
_gptoss_pad: "uint8",
|
|
278
|
+
// Qwen3.8-Flash-Next (qwen4_exp; 0 / empty = not applicable)
|
|
279
|
+
hc_count: "uint32",
|
|
280
|
+
hc_lowrank: "uint32",
|
|
281
|
+
gdn_gate_sigmoid: "uint32",
|
|
282
|
+
ple_layer: "uint32",
|
|
283
|
+
ple_embed_dim: "uint32",
|
|
284
|
+
ple_conv_kernel: "uint32",
|
|
285
|
+
ngram_size: "uint32",
|
|
286
|
+
heads_per_ngram: "uint32",
|
|
287
|
+
ple_eos_token: "uint32",
|
|
288
|
+
ngram_padded_vocab: "uint32",
|
|
289
|
+
ngram_head_vocab: koffi_1.default.array("uint32", 32),
|
|
290
|
+
ngram_head_off: koffi_1.default.array("uint32", 32),
|
|
291
|
+
indexer_n_heads: "uint32",
|
|
292
|
+
indexer_head_dim: "uint32",
|
|
293
|
+
indexer_budget: "uint32",
|
|
294
|
+
indexer_compress: "uint32",
|
|
295
|
+
_q4_pad: "uint32",
|
|
296
|
+
// uint64_t: the struct is 8-byte aligned from here on (2144 bytes).
|
|
297
|
+
ngram_mult: koffi_1.default.array("uint64", 4),
|
|
278
298
|
});
|
|
279
299
|
const SamplingConfigC = koffi_1.default.struct("BaseRTSamplingConfig", {
|
|
280
300
|
temperature: "float",
|
|
@@ -324,7 +344,9 @@ function lib() {
|
|
|
324
344
|
const k = koffi_1.default.load(resolveLibPath());
|
|
325
345
|
const out = "_Out_";
|
|
326
346
|
void out;
|
|
327
|
-
_lib
|
|
347
|
+
// Built into a local and published to _lib only once every check below has
|
|
348
|
+
// passed: a refused library must not stay cached as a half-checked table.
|
|
349
|
+
const l = {
|
|
328
350
|
baseRT_version_string: k.func("const char *baseRT_version_string()"),
|
|
329
351
|
baseRT_load_model: k.func("void *baseRT_load_model(const char *, const char *, int)"),
|
|
330
352
|
baseRT_free_model: k.func("void baseRT_free_model(void *)"),
|
|
@@ -374,17 +396,33 @@ function lib() {
|
|
|
374
396
|
baseRT_transcribe_stream: k.func("const char *baseRT_transcribe_stream(void *, const char *, const char *, _Out_ BaseRTTranscribeStats *, SegmentCallback *, void *)"),
|
|
375
397
|
baseRT_transcribe_pcm_stream: k.func("const char *baseRT_transcribe_pcm_stream(void *, float *, int, const char *, _Out_ BaseRTTranscribeStats *, SegmentCallback *, void *)"),
|
|
376
398
|
};
|
|
377
|
-
//
|
|
378
|
-
//
|
|
379
|
-
//
|
|
380
|
-
//
|
|
399
|
+
// Preferred config getter (since 0.4.0): the library copies exactly
|
|
400
|
+
// sizeof(ModelConfigC) bytes into our buffer (zeros past its own struct), so
|
|
401
|
+
// the by-value baseRT_get_config above — whose return slot koffi sizes from
|
|
402
|
+
// OUR mirror — is only used when the symbol is missing.
|
|
403
|
+
try {
|
|
404
|
+
l.baseRT_get_config_into = k.func("size_t baseRT_get_config_into(void *, _Out_ BaseRTModelConfig *, size_t)");
|
|
405
|
+
}
|
|
406
|
+
catch {
|
|
407
|
+
// Symbol missing in an older library — fall back to the by-value getter.
|
|
408
|
+
}
|
|
409
|
+
// ModelConfigC is mirrored by hand above. The struct only ever grows by
|
|
410
|
+
// appended fields, so with the sized getter a library of another size is the
|
|
411
|
+
// supported mixed-version case (an engine still on the previous layout under
|
|
412
|
+
// a newer binding, or the reverse): we read the fields we share and see
|
|
413
|
+
// zeros for the rest, which every field treats as "not applicable". Only the
|
|
414
|
+
// by-value fallback needs the exact size — koffi sizes its return slot from
|
|
415
|
+
// our mirror, so a different library size would decode garbage past the
|
|
416
|
+
// divergence point there. Fail at load, not at use. (Older libraries predate
|
|
417
|
+
// the symbol; skip the check there.)
|
|
381
418
|
try {
|
|
382
419
|
const configSizeof = k.func("size_t baseRT_model_config_sizeof()");
|
|
383
420
|
const cSize = Number(configSizeof());
|
|
384
421
|
const jsSize = koffi_1.default.sizeof(ModelConfigC);
|
|
385
|
-
if (cSize !== jsSize) {
|
|
422
|
+
if (cSize !== jsSize && !l.baseRT_get_config_into) {
|
|
386
423
|
throw new Error(`BaseRTModelConfig layout drift: library says ${cSize} bytes, ` +
|
|
387
|
-
`Node mirror is ${jsSize} bytes
|
|
424
|
+
`Node mirror is ${jsSize} bytes, and the library has no ` +
|
|
425
|
+
`baseRT_get_config_into to read it by size. Update ModelConfigC in ` +
|
|
388
426
|
`bindings/node/src/index.ts to match include/baseRT/types.h.`);
|
|
389
427
|
}
|
|
390
428
|
}
|
|
@@ -393,7 +431,8 @@ function lib() {
|
|
|
393
431
|
throw e;
|
|
394
432
|
// Symbol missing in an older library — no check possible.
|
|
395
433
|
}
|
|
396
|
-
|
|
434
|
+
_lib = l;
|
|
435
|
+
return l;
|
|
397
436
|
}
|
|
398
437
|
// ---------------------------------------------------------------------------
|
|
399
438
|
// Helpers
|
|
@@ -570,7 +609,17 @@ class BaseRTModel {
|
|
|
570
609
|
}
|
|
571
610
|
// -- Model info ------------------------------------------------------------
|
|
572
611
|
get config() {
|
|
573
|
-
|
|
612
|
+
const into = this._l.baseRT_get_config_into;
|
|
613
|
+
if (!into)
|
|
614
|
+
return toModelConfig(this._l.baseRT_get_config(this.handle));
|
|
615
|
+
const out = {};
|
|
616
|
+
// Returns the library's sizeof; fields it lacks read as zero, which every
|
|
617
|
+
// field treats as "not applicable". 0 never happens for a live handle.
|
|
618
|
+
const libSize = Number(into(this.handle, out, koffi_1.default.sizeof(ModelConfigC)));
|
|
619
|
+
if (libSize === 0) {
|
|
620
|
+
throw new Error("baseRT_get_config_into returned no configuration");
|
|
621
|
+
}
|
|
622
|
+
return toModelConfig(out);
|
|
574
623
|
}
|
|
575
624
|
get memoryUsage() {
|
|
576
625
|
return this._l.baseRT_model_memory(this.handle);
|
|
@@ -825,5 +874,9 @@ exports.__internal = {
|
|
|
825
874
|
TranscribeSegmentC,
|
|
826
875
|
toSamplingC,
|
|
827
876
|
toModelConfig,
|
|
877
|
+
/** Drop the cached library so the next model load resolves BASERT_LIB_PATH again. */
|
|
878
|
+
resetLib() {
|
|
879
|
+
_lib = null;
|
|
880
|
+
},
|
|
828
881
|
};
|
|
829
882
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basecompute/basert",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"description": "Fast local LLM inference on Apple Silicon, NVIDIA GB10 and AMD Strix: the basert CLI and Node.js bindings",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"koffi": "^2.9.0"
|
|
40
40
|
},
|
|
41
41
|
"optionalDependencies": {
|
|
42
|
-
"@basecompute/basert-darwin-arm64": "0.5.
|
|
43
|
-
"@basecompute/basert-linux-arm64-cuda": "0.5.
|
|
44
|
-
"@basecompute/basert-linux-x64-rocm": "0.5.
|
|
42
|
+
"@basecompute/basert-darwin-arm64": "0.5.4",
|
|
43
|
+
"@basecompute/basert-linux-arm64-cuda": "0.5.4",
|
|
44
|
+
"@basecompute/basert-linux-x64-rocm": "0.5.4"
|
|
45
45
|
},
|
|
46
46
|
"files": [
|
|
47
47
|
"dist/**/*.js",
|