@qvac/translation-nmtcpp 0.17.1 → 0.18.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 +15 -4
- package/index.d.ts +2 -2
- package/index.js +14 -17
- package/package.json +4 -2
- package/prebuilds/android-arm64/qvac__translation-nmtcpp.bare +0 -0
- package/prebuilds/darwin-arm64/qvac__translation-nmtcpp.bare +0 -0
- package/prebuilds/darwin-arm64/qvac__translation-nmtcpp.bare.exports +1 -1
- package/prebuilds/darwin-x64/qvac__translation-nmtcpp.bare +0 -0
- package/prebuilds/darwin-x64/qvac__translation-nmtcpp.bare.exports +1 -1
- package/prebuilds/ios-arm64/qvac__translation-nmtcpp.bare +0 -0
- package/prebuilds/ios-arm64/qvac__translation-nmtcpp.bare.exports +1 -1
- package/prebuilds/ios-arm64-simulator/qvac__translation-nmtcpp.bare +0 -0
- package/prebuilds/ios-arm64-simulator/qvac__translation-nmtcpp.bare.exports +1 -1
- package/prebuilds/ios-x64-simulator/qvac__translation-nmtcpp.bare +0 -0
- package/prebuilds/ios-x64-simulator/qvac__translation-nmtcpp.bare.exports +1 -1
- package/prebuilds/linux-arm64/qvac__translation-nmtcpp.bare +0 -0
- package/prebuilds/linux-x64/qvac__translation-nmtcpp.bare +0 -0
- package/prebuilds/win32-x64/qvac__translation-nmtcpp.bare +0 -0
package/README.md
CHANGED
|
@@ -288,7 +288,7 @@ const backendSettings = {
|
|
|
288
288
|
use_gpu: true, // Enable GPU inference (default: false → CPU-only)
|
|
289
289
|
gpu_backend: 'vulkan', // Optional: pick a specific backend by name substring
|
|
290
290
|
gpu_device: 0, // Optional: ordinal within matching devices (default: 0)
|
|
291
|
-
backendsDir: './prebuilds', // Optional
|
|
291
|
+
backendsDir: './prebuilds', // Optional override of the fabric backends root
|
|
292
292
|
openclCacheDir: '/path/ok' // Optional (Android only): OpenCL kernel-cache dir
|
|
293
293
|
}
|
|
294
294
|
```
|
|
@@ -300,7 +300,7 @@ The three GPU control keys each accept a camelCase alias alongside the snake_cas
|
|
|
300
300
|
| `use_gpu` | `useGPU` | boolean | Enable GPU inference. When `false` (default), only the CPU backend is used. Bergamot is CPU-only by design — this flag is effectively a no-op for Bergamot. |
|
|
301
301
|
| `gpu_backend` | `gpuBackend` | string | Case-insensitive **substring** match against eligible Vulkan, Metal, OpenCL, or CUDA device names (e.g. `"vulkan"`, `"vulkan0"`, `"opencl"`, `"metal"`). When unset, the default gated selection runs (see [Backends](#backends)). Any explicit selector that resolves to OpenCL bypasses the build-time `USE_OPENCL` guard — an informed opt-in. |
|
|
302
302
|
| `gpu_device` | `gpuDevice` | int | Ordinal within the matching devices. Defaults to `0` (first match). Example: `{gpu_backend: "vulkan", gpu_device: 1}` picks the second Vulkan adapter. |
|
|
303
|
-
| `backendsDir` | — | string | Path to the directory containing the runtime backend shared libraries (`libqvac-ggml-vulkan.so`, etc.). Defaults to
|
|
303
|
+
| `backendsDir` | — | string | Path to the directory containing the runtime backend shared libraries (`libqvac-ggml-vulkan.so`, etc.). Defaults to the root `@qvac/fabric/backends` resolves on desktop, falling back to this package's `prebuilds/` on mobile, where the package tree isn't resolvable from the packed worklet. Must be an absolute path when set; paths with `..` segments or unresolvable symlinks are rejected with a warning and fall back to that default. |
|
|
304
304
|
| `openclCacheDir` | — | string | **Android only.** Writable directory the OpenCL backend uses for its JIT kernel cache (forwarded via `GGML_OPENCL_CACHE_DIR`). Must be an absolute path; paths with `..` segments are rejected. The OpenCL backend falls back to a non-writable relative path if this is unset, which `ggml_abort()`s during init inside the app sandbox — always provide an app-writable path when exercising OpenCL on Android. |
|
|
305
305
|
|
|
306
306
|
GPU execution is limited to Vulkan, Metal/MTL, OpenCL, and CUDA devices reported as GPU or integrated GPU. RPC, ROCm/HIP, SYCL, MUSA, and unknown backend families fall back to CPU — RPC because translation has no split-mode support and cannot execute over it. CUDA is admitted ahead of its planned Fabric build so that build does not require another selector change. An explicit selector only narrows this eligible set; it cannot enable an unsupported family.
|
|
@@ -389,9 +389,11 @@ try {
|
|
|
389
389
|
})
|
|
390
390
|
.await() // Wait for translation to complete
|
|
391
391
|
|
|
392
|
-
// Access performance statistics (if enabled with opts.stats)
|
|
392
|
+
// Access performance statistics (if enabled with opts.stats). The counters
|
|
393
|
+
// accumulate over the life of the loaded model; difference consecutive
|
|
394
|
+
// readings for per-run figures.
|
|
393
395
|
if (response.stats) {
|
|
394
|
-
console.log('
|
|
396
|
+
console.log('Total translation time so far:', response.stats.totalTime, 's')
|
|
395
397
|
}
|
|
396
398
|
} catch (error) {
|
|
397
399
|
console.error('Translation failed:', error)
|
|
@@ -601,6 +603,15 @@ Populated on `response.stats` when the model was constructed with
|
|
|
601
603
|
> Pivot translations may emit keys prefixed with the model name
|
|
602
604
|
> (e.g. `"BERGAMOT : ->TPS"`); the table above models the non-pivot shape.
|
|
603
605
|
|
|
606
|
+
`totalTime`, `decodeTime`, `encodeTime` and `TTFT` accumulate over the life
|
|
607
|
+
of the loaded model rather than describing the run that returned them.
|
|
608
|
+
`totalTokens` accumulates on Bergamot and on GGML greedy decoding
|
|
609
|
+
(`beamsize: 1`), but GGML beam search reports the run's own count. `TPS`
|
|
610
|
+
divides these readings as they stand. The counters restart at zero on
|
|
611
|
+
`unload()`/`load()` and on `cancel()`. For per-run figures, difference
|
|
612
|
+
consecutive readings — jobs are serialized, so nothing lands between them —
|
|
613
|
+
and read a reading lower than the last as that run's own figure.
|
|
614
|
+
|
|
604
615
|
### Errors
|
|
605
616
|
|
|
606
617
|
Native-facing failures reject with a structured `QvacErrorAddonMarian`
|
package/index.d.ts
CHANGED
|
@@ -147,8 +147,8 @@ declare namespace TranslationNmtcpp {
|
|
|
147
147
|
gpuDevice?: number;
|
|
148
148
|
/**
|
|
149
149
|
* Path to the directory containing backend shared libraries
|
|
150
|
-
* (libqvac-ggml-vulkan.so, etc.). Defaults to `@qvac/fabric`
|
|
151
|
-
* on desktop, falling back to this package's `prebuilds/` on mobile where
|
|
150
|
+
* (libqvac-ggml-vulkan.so, etc.). Defaults to the root `@qvac/fabric/backends`
|
|
151
|
+
* resolves on desktop, falling back to this package's `prebuilds/` on mobile where
|
|
152
152
|
* the package tree isn't resolvable from the packed worklet.
|
|
153
153
|
*/
|
|
154
154
|
backendsDir?: string;
|
package/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-require-imports -- Bare modules and @qvac/logging expose CommonJS export shapes. */
|
|
3
|
-
const path = require("bare-path");
|
|
4
3
|
const fs = require("bare-fs");
|
|
4
|
+
const path = require("bare-path");
|
|
5
5
|
const QvacLogger = require("@qvac/logging");
|
|
6
|
+
const fabricBackends = require("@qvac/fabric/backends");
|
|
6
7
|
/* eslint-enable @typescript-eslint/no-require-imports */
|
|
7
8
|
const infer_base_1 = require("@qvac/infer-base");
|
|
8
9
|
const marian_1 = require("./marian");
|
|
@@ -18,24 +19,20 @@ const indic_processor_1 = require("./third-party/indic-processor");
|
|
|
18
19
|
const BERGAMOT_TARGET_TOKEN_BY_PAIR = {
|
|
19
20
|
"en:pt": ">>por<<",
|
|
20
21
|
};
|
|
21
|
-
// The ggml compute backends (GGML_BACKEND_DL modules) ship exactly once,
|
|
22
|
-
// @qvac/fabric
|
|
23
|
-
//
|
|
24
|
-
// consumer. On desktop,
|
|
25
|
-
//
|
|
26
|
-
// (the worklet runs from a packed bundle), so fall back to this addon's
|
|
27
|
-
// prebuilds, where the mobile packaging stages the backends. The native side
|
|
22
|
+
// The ggml compute backends (GGML_BACKEND_DL modules) ship exactly once, next to
|
|
23
|
+
// the @qvac/fabric runtime (<root>/<host>/qvac__fabric). We deliberately do not
|
|
24
|
+
// copy them into this addon to avoid duplicating tens of MB per fabric
|
|
25
|
+
// consumer. On desktop, @qvac/fabric/backends resolves that root in whichever
|
|
26
|
+
// package holds the runtime. On mobile the package tree isn't resolvable at
|
|
27
|
+
// runtime (the worklet runs from a packed bundle), so fall back to this addon's
|
|
28
|
+
// own prebuilds, where the mobile packaging stages the backends. The native side
|
|
28
29
|
// appends BACKENDS_SUBDIR ("<host>/qvac__fabric") to whichever root we return.
|
|
29
30
|
function resolveBackendsDir() {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
catch {
|
|
37
|
-
// Mobile worklets cannot resolve the @qvac/fabric package tree.
|
|
38
|
-
}
|
|
31
|
+
// fabric's resolver only checks that the platform package resolves, not that
|
|
32
|
+
// its prebuilds are on disk.
|
|
33
|
+
const fabricRoot = fabricBackends.resolveBackendsDir();
|
|
34
|
+
if (fabricRoot !== null && fs.existsSync(fabricRoot))
|
|
35
|
+
return fabricRoot;
|
|
39
36
|
return path.join(__dirname, "prebuilds");
|
|
40
37
|
}
|
|
41
38
|
class QvacIndicTransResponse extends infer_base_1.QvacResponse {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qvac/translation-nmtcpp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.1",
|
|
4
4
|
"description": "translation addon for qvac",
|
|
5
5
|
"addon": true,
|
|
6
6
|
"engines": {
|
|
@@ -78,6 +78,8 @@
|
|
|
78
78
|
"bugs": "https://github.com/tetherto/qvac/issues",
|
|
79
79
|
"homepage": "https://qvac.tether.io",
|
|
80
80
|
"devDependencies": {
|
|
81
|
+
"@qvac/fabric-android-arm64": "^0.19.0",
|
|
82
|
+
"@qvac/fabric-ios": "^0.19.0",
|
|
81
83
|
"@qvac/registry-client": "^0.6.1",
|
|
82
84
|
"@types/node": "^24.2.1",
|
|
83
85
|
"bare-fetch": "^3.0.1",
|
|
@@ -96,7 +98,7 @@
|
|
|
96
98
|
},
|
|
97
99
|
"dependencies": {
|
|
98
100
|
"@qvac/error": "^0.1.0",
|
|
99
|
-
"@qvac/fabric": "^0.
|
|
101
|
+
"@qvac/fabric": "^0.19.0",
|
|
100
102
|
"@qvac/infer-base": "^0.6.2",
|
|
101
103
|
"@qvac/logging": "^0.1.0",
|
|
102
104
|
"bare-fs": "^4.5.1",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|