@qvac/inference 0.21.1 → 0.22.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/NOTICE +30 -1
- package/README.md +44 -1
- package/dist/api/assess-model-fit.d.ts +4 -4
- package/dist/api/assess-model-fit.js +4 -4
- package/dist/api/audio-gen.d.ts +4 -1
- package/dist/api/audio-gen.js +4 -1
- package/dist/api/batch-completion.js +1 -1
- package/dist/api/completion-stream.js +1 -1
- package/dist/api/decide.d.ts +26 -0
- package/dist/api/decide.js +26 -0
- package/dist/api/get-model-info.d.ts +1 -1
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/api/text-to-speech.d.ts +1 -0
- package/dist/api/text-to-speech.js +15 -19
- package/dist/api/transcribe.js +5 -2
- package/dist/api/video-request.d.ts +5 -5
- package/dist/api/video.d.ts +5 -4
- package/dist/api/video.js +5 -4
- package/dist/errors/index.d.ts +3 -0
- package/dist/errors/index.js +5 -0
- package/dist/handlers/assess-model-fit.d.ts +5 -3
- package/dist/handlers/assess-model-fit.js +80 -28
- package/dist/handlers/get-loaded-model-info.js +1 -2
- package/dist/handlers/load-model/safe-fetch.js +5 -6
- package/dist/handlers/registry.d.ts +3 -1
- package/dist/handlers/registry.js +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/logging/logger.js +1 -1
- package/dist/logging/utils.js +1 -1
- package/dist/models/registry/models.d.ts +563 -816
- package/dist/models/registry/models.js +2873 -3110
- package/dist/models/registry/resource-profiles.d.ts +1 -2
- package/dist/models/registry/resource-profiles.js +203 -2
- package/dist/plugins/builtin/asr-ggml/config.d.ts +7 -1
- package/dist/plugins/builtin/asr-ggml/config.js +6 -0
- package/dist/plugins/builtin/asr-ggml/logging.d.ts +1 -1
- package/dist/plugins/builtin/audiogen-ggml/config.d.ts +1 -0
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-edit-stream.js +28 -10
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-gen-input.d.ts +27 -0
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-gen-input.js +23 -0
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-gen-stream.js +6 -27
- package/dist/plugins/builtin/audiogen-ggml/plugin.d.ts +147 -60
- package/dist/plugins/builtin/audiogen-ggml/plugin.js +1 -0
- package/dist/plugins/builtin/bci-whispercpp-transcription/plugin.d.ts +40 -24
- package/dist/plugins/builtin/bci-whispercpp-transcription/plugin.js +1 -1
- package/dist/plugins/builtin/ggml-classification/plugin.d.ts +4 -4
- package/dist/plugins/builtin/ggml-ocr/params.d.ts +18 -0
- package/dist/plugins/builtin/ggml-ocr/params.js +37 -0
- package/dist/plugins/builtin/ggml-ocr/plugin.d.ts +18 -10
- package/dist/plugins/builtin/ggml-ocr/plugin.js +16 -38
- package/dist/plugins/builtin/ggml-vla/plugin.d.ts +21 -14
- package/dist/plugins/builtin/ggml-vla/plugin.js +1 -1
- package/dist/plugins/builtin/index.d.ts +2 -0
- package/dist/plugins/builtin/index.js +2 -0
- package/dist/plugins/builtin/llamacpp-completion/ops/completion-stream.d.ts +9 -7
- package/dist/plugins/builtin/llamacpp-completion/ops/completion-stream.js +109 -189
- package/dist/plugins/builtin/llamacpp-completion/ops/kv-cache-session.d.ts +32 -90
- package/dist/plugins/builtin/llamacpp-completion/ops/kv-cache-session.js +60 -211
- package/dist/plugins/builtin/llamacpp-completion/ops/kv-cache-state.d.ts +2 -49
- package/dist/plugins/builtin/llamacpp-completion/ops/kv-cache-state.js +2 -46
- package/dist/plugins/builtin/llamacpp-completion/plugin.d.ts +185 -87
- package/dist/plugins/builtin/llamacpp-completion/plugin.js +4 -5
- package/dist/plugins/builtin/llamacpp-completion/transform.js +1 -1
- package/dist/plugins/builtin/llamacpp-decision/helpers.d.ts +6 -0
- package/dist/plugins/builtin/llamacpp-decision/helpers.js +97 -0
- package/dist/plugins/builtin/llamacpp-decision/ops/decide.d.ts +91 -0
- package/dist/plugins/builtin/llamacpp-decision/ops/decide.js +129 -0
- package/dist/plugins/builtin/llamacpp-decision/plugin.d.ts +216 -0
- package/dist/plugins/builtin/llamacpp-decision/plugin.js +43 -0
- package/dist/plugins/builtin/llamacpp-embedding/plugin.d.ts +12 -5
- package/dist/plugins/builtin/llamacpp-embedding/plugin.js +1 -1
- package/dist/plugins/builtin/llamacpp-embedding/transform.js +3 -0
- package/dist/plugins/builtin/moss-transcribe/plugin.d.ts +143 -0
- package/dist/plugins/builtin/moss-transcribe/plugin.js +96 -0
- package/dist/plugins/builtin/nmtcpp-translation/load-files.d.ts +6 -0
- package/dist/plugins/builtin/nmtcpp-translation/load-files.js +70 -0
- package/dist/plugins/builtin/nmtcpp-translation/plugin.d.ts +25 -13
- package/dist/plugins/builtin/nmtcpp-translation/plugin.js +9 -73
- package/dist/plugins/builtin/parakeet-transcription/plugin.d.ts +52 -31
- package/dist/plugins/builtin/parakeet-transcription/plugin.js +18 -3
- package/dist/plugins/builtin/sdcpp-generation/ops/video.js +10 -6
- package/dist/plugins/builtin/sdcpp-generation/ops/world.d.ts +2 -2
- package/dist/plugins/builtin/sdcpp-generation/ops/world.js +1 -1
- package/dist/plugins/builtin/sdcpp-generation/plugin.d.ts +59 -33
- package/dist/plugins/builtin/sdcpp-generation/plugin.js +12 -9
- package/dist/plugins/builtin/tts-ggml/ops/moss-options.d.ts +22 -0
- package/dist/plugins/builtin/tts-ggml/ops/moss-options.js +79 -0
- package/dist/plugins/builtin/tts-ggml/ops/text-to-speech-stream.js +4 -1
- package/dist/plugins/builtin/tts-ggml/ops/text-to-speech.js +17 -5
- package/dist/plugins/builtin/tts-ggml/plugin.d.ts +164 -29
- package/dist/plugins/builtin/tts-ggml/plugin.js +38 -1
- package/dist/plugins/builtin/whispercpp-transcription/plugin.d.ts +58 -35
- package/dist/plugins/builtin/whispercpp-transcription/plugin.js +6 -2
- package/dist/plugins/ops/kv-cache-utils.d.ts +1 -1
- package/dist/plugins/ops/kv-cache-utils.js +10 -25
- package/dist/plugins/ops/load-model.js +21 -16
- package/dist/plugins/ops/transcribe.js +17 -1
- package/dist/registry.js +1 -0
- package/dist/resources/model-fit/assess.d.ts +15 -23
- package/dist/resources/model-fit/assess.js +207 -271
- package/dist/resources/model-fit/fit-stub/fetch-fit-stub.d.ts +3 -1
- package/dist/resources/model-fit/fit-stub/fetch-fit-stub.js +6 -1
- package/dist/resources/model-fit/fit-stub/project-fit-from-load.js +2 -0
- package/dist/resources/model-fit/fit-stub/resolve-load-from-stubs.d.ts +5 -3
- package/dist/resources/model-fit/fit-stub/resolve-load-from-stubs.js +9 -1
- package/dist/resources/model-fit/floor.d.ts +10 -10
- package/dist/resources/model-fit/floor.js +13 -13
- package/dist/resources/model-fit/kv-cache.d.ts +23 -0
- package/dist/resources/model-fit/kv-cache.js +85 -0
- package/dist/resources/model-fit/native-probe/advisory-fit.d.ts +11 -6
- package/dist/resources/model-fit/native-probe/advisory-fit.js +12 -27
- package/dist/resources/model-fit/native-probe/child-engine-fit.js +8 -0
- package/dist/resources/model-fit/native-probe/classify-fit.js +32 -1
- package/dist/resources/model-fit/native-probe/create-fit-request.d.ts +4 -1
- package/dist/resources/model-fit/native-probe/create-fit-request.js +24 -14
- package/dist/resources/model-fit/native-probe/engine-fit.d.ts +14 -0
- package/dist/resources/model-fit/native-probe/engine-fit.js +1 -1
- package/dist/resources/model-fit/native-probe/engines/asr.d.ts +4 -0
- package/dist/resources/model-fit/native-probe/engines/asr.js +23 -0
- package/dist/resources/model-fit/native-probe/engines/audiogen.js +29 -1
- package/dist/resources/model-fit/native-probe/engines/diffusion.js +16 -6
- package/dist/resources/model-fit/native-probe/engines/llama.d.ts +0 -1
- package/dist/resources/model-fit/native-probe/engines/llama.js +19 -123
- package/dist/resources/model-fit/native-probe/engines/nmt.d.ts +8 -0
- package/dist/resources/model-fit/native-probe/engines/nmt.js +11 -0
- package/dist/resources/model-fit/native-probe/engines/ocr.d.ts +9 -0
- package/dist/resources/model-fit/native-probe/engines/ocr.js +13 -0
- package/dist/resources/model-fit/native-probe/engines/tts.d.ts +2 -0
- package/dist/resources/model-fit/native-probe/engines/tts.js +49 -3
- package/dist/resources/model-fit/native-probe/run-in-process-fit.d.ts +5 -3
- package/dist/resources/model-fit/native-probe/run-in-process-fit.js +38 -23
- package/dist/resources/model-fit/platform.d.ts +4 -4
- package/dist/resources/model-fit/platform.js +6 -8
- package/dist/resources/model-fit/types.d.ts +3 -117
- package/dist/rpc/inventory.js +5 -7
- package/dist/runtime/env.d.ts +0 -2
- package/dist/runtime/env.js +2 -9
- package/dist/runtime/model-config-utils.js +6 -1
- package/dist/runtime/request-context.d.ts +1 -1
- package/dist/runtime/request-context.js +8 -0
- package/dist/runtime/state.js +5 -0
- package/dist/schemas/assess-model-fit.d.ts +100 -43
- package/dist/schemas/assess-model-fit.js +66 -29
- package/dist/schemas/audio-gen.d.ts +186 -18
- package/dist/schemas/audio-gen.js +180 -48
- package/dist/schemas/batch-completion-stream.d.ts +202 -34
- package/dist/schemas/bci-config.d.ts +2 -0
- package/dist/schemas/bci.d.ts +23 -2
- package/dist/schemas/cancel.d.ts +5 -0
- package/dist/schemas/cancel.js +1 -0
- package/dist/schemas/common.d.ts +1083 -158
- package/dist/schemas/common.js +5 -2
- package/dist/schemas/completion-stream.d.ts +232 -37
- package/dist/schemas/completion-stream.js +64 -20
- package/dist/schemas/config.d.ts +477 -12
- package/dist/schemas/config.js +21 -1
- package/dist/schemas/decision.d.ts +602 -0
- package/dist/schemas/decision.js +205 -0
- package/dist/schemas/download-asset.d.ts +7 -3
- package/dist/schemas/engine-addon-map.d.ts +7 -0
- package/dist/schemas/engine-addon-map.js +23 -3
- package/dist/schemas/errors.d.ts +1 -0
- package/dist/schemas/errors.js +5 -0
- package/dist/schemas/index.d.ts +2 -0
- package/dist/schemas/index.js +2 -0
- package/dist/schemas/llamacpp-config.d.ts +42 -2
- package/dist/schemas/llamacpp-config.js +27 -0
- package/dist/schemas/load-model.d.ts +5247 -1309
- package/dist/schemas/load-model.js +88 -9
- package/dist/schemas/model-config-schemas.d.ts +233 -8
- package/dist/schemas/model-config-schemas.js +4 -1
- package/dist/schemas/model-fit-policy.d.ts +17 -0
- package/dist/schemas/model-fit-policy.js +17 -0
- package/dist/schemas/model-info.d.ts +20 -2
- package/dist/schemas/model-info.js +2 -1
- package/dist/schemas/model-resource-profile.d.ts +3 -4
- package/dist/schemas/model-resource-profile.js +1 -4
- package/dist/schemas/model-src-utils.d.ts +10 -2
- package/dist/schemas/model-types.d.ts +10 -1
- package/dist/schemas/model-types.js +3 -0
- package/dist/schemas/ocr.d.ts +74 -0
- package/dist/schemas/ocr.js +42 -0
- package/dist/schemas/plugin.d.ts +8 -2
- package/dist/schemas/plugin.js +6 -0
- package/dist/schemas/profiling.d.ts +4 -4
- package/dist/schemas/registry.d.ts +26 -0
- package/dist/schemas/registry.js +3 -0
- package/dist/schemas/reload-config.d.ts +10 -2
- package/dist/schemas/rpc-server.js +3 -3
- package/dist/schemas/sdcpp-config.d.ts +26 -0
- package/dist/schemas/sdcpp-config.js +8 -7
- package/dist/schemas/system-resources.d.ts +4 -4
- package/dist/schemas/text-to-speech.d.ts +402 -3
- package/dist/schemas/text-to-speech.js +129 -11
- package/dist/schemas/tools.d.ts +13 -4
- package/dist/schemas/tools.js +18 -6
- package/dist/schemas/transcription-config.d.ts +15 -0
- package/dist/schemas/transcription-config.js +38 -3
- package/dist/schemas/transcription.d.ts +46 -4
- package/dist/schemas/transcription.js +51 -4
- package/dist/schemas/translation-config.d.ts +30 -10
- package/dist/schemas/vla.d.ts +9 -2
- package/dist/schemas/vla.js +9 -5
- package/dist/surface.d.ts +1 -1
- package/dist/surface.js +1 -1
- package/dist/utils/addon-responses.d.ts +1 -0
- package/dist/utils/asr-events.d.ts +1 -0
- package/dist/utils/asr-events.js +2 -1
- package/dist/utils/cache/types.d.ts +7 -0
- package/dist/utils/mcp-adapter.js +12 -8
- package/dist/utils/tool-helpers.d.ts +1 -1
- package/dist/utils/tool-helpers.js +20 -52
- package/dist/utils/tools/parsers/dsml.js +8 -5
- package/dist/utils/tools/parsers/qwen35.js +7 -4
- package/dist/utils/tools/shared.d.ts +3 -0
- package/dist/utils/tools/shared.js +62 -0
- package/dist/utils/transcribe-metadata.d.ts +8 -1
- package/dist/utils/transcribe-metadata.js +13 -3
- package/dist/utils/tts-stats.d.ts +1 -0
- package/package.json +41 -32
- package/dist/resources/model-fit/calibration/darwin-arm64.d.ts +0 -8
- package/dist/resources/model-fit/calibration/darwin-arm64.js +0 -36
- package/dist/resources/model-fit/calibration/darwin-x64.d.ts +0 -8
- package/dist/resources/model-fit/calibration/darwin-x64.js +0 -38
- package/dist/resources/model-fit/calibration/fit.d.ts +0 -73
- package/dist/resources/model-fit/calibration/fit.js +0 -152
- package/dist/resources/model-fit/calibration/index.d.ts +0 -37
- package/dist/resources/model-fit/calibration/index.js +0 -75
- package/dist/resources/model-fit/calibration/linux-arm64.d.ts +0 -8
- package/dist/resources/model-fit/calibration/linux-arm64.js +0 -38
- package/dist/resources/model-fit/calibration/linux-x64-vulkan.d.ts +0 -8
- package/dist/resources/model-fit/calibration/linux-x64-vulkan.js +0 -39
- package/dist/resources/model-fit/calibration/linux-x64.d.ts +0 -8
- package/dist/resources/model-fit/calibration/linux-x64.js +0 -38
- package/dist/resources/model-fit/calibration/win32-x64-vulkan-shared.d.ts +0 -8
- package/dist/resources/model-fit/calibration/win32-x64-vulkan-shared.js +0 -39
- package/dist/resources/model-fit/calibration/win32-x64-vulkan.d.ts +0 -8
- package/dist/resources/model-fit/calibration/win32-x64-vulkan.js +0 -36
- package/dist/resources/model-fit/calibration/win32-x64.d.ts +0 -8
- package/dist/resources/model-fit/calibration/win32-x64.js +0 -38
- package/dist/resources/model-fit/estimators/llm.d.ts +0 -46
- package/dist/resources/model-fit/estimators/llm.js +0 -222
- package/dist/resources/model-fit/estimators/whisper.d.ts +0 -10
- package/dist/resources/model-fit/estimators/whisper.js +0 -76
|
@@ -30,7 +30,9 @@ export type FitStubUnavailableReason =
|
|
|
30
30
|
/** The entry predates fit blobs, or its description could not be built. */
|
|
31
31
|
| 'no-fit-blob' | 'download-failed'
|
|
32
32
|
/** The lookup and the fetch together did not finish within the budget. */
|
|
33
|
-
| 'timed-out'
|
|
33
|
+
| 'timed-out'
|
|
34
|
+
/** The engine's fitter reads the files themselves and no registry description. */
|
|
35
|
+
| 'files-only-engine';
|
|
34
36
|
export type FitStubOutcome =
|
|
35
37
|
/** `path` is the caller's to remove once the fitter has read it. */
|
|
36
38
|
{
|
|
@@ -94,7 +94,12 @@ function withinBudget(name, options, work) {
|
|
|
94
94
|
async function makeStagingDir(options) {
|
|
95
95
|
const root = options.cacheDir ?? getCacheDir('fit-stubs');
|
|
96
96
|
await fsPromises.mkdir(root, { recursive: true });
|
|
97
|
-
|
|
97
|
+
// On Windows `mkdtemp` returns the `\\?\` namespaced form of the path, and
|
|
98
|
+
// an engine that derives a companion's path by appending `/<name>` to it
|
|
99
|
+
// (bci's colocated embedder) then names a file that does not resolve.
|
|
100
|
+
// Keep the root as given and take only the generated directory name.
|
|
101
|
+
const created = await fsPromises.mkdtemp(path.join(root, 'stub-'));
|
|
102
|
+
return path.join(root, path.basename(created));
|
|
98
103
|
}
|
|
99
104
|
async function bindingFor(ref, options) {
|
|
100
105
|
const { registryPath, registrySource } = ref;
|
|
@@ -18,6 +18,8 @@ export async function projectFitFromLoad(load, modelId, options = {}) {
|
|
|
18
18
|
modelType: load.modelType,
|
|
19
19
|
modelPath: resolved.modelPath,
|
|
20
20
|
modelConfig: resolved.modelConfig,
|
|
21
|
+
transcriptionWorkload: load.transcriptionWorkload,
|
|
22
|
+
ttsWorkload: load.ttsWorkload,
|
|
21
23
|
artifacts: resolved.artifacts,
|
|
22
24
|
// Nothing here assembles a shard set, so no load may claim the fitter
|
|
23
25
|
// is looking at a split model.
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type
|
|
1
|
+
import type { TtsFitWorkload } from '../../../schemas/assess-model-fit.js';
|
|
2
|
+
import { type CanonicalModelType, type ModelSrcInput, type TranscriptionFitWorkload } from '../../../schemas/index.js';
|
|
3
3
|
import { type FitStubOptions, type FitStubUnavailableReason } from './fetch-fit-stub.js';
|
|
4
4
|
export interface LoadDescription {
|
|
5
|
+
transcriptionWorkload?: TranscriptionFitWorkload | undefined;
|
|
6
|
+
ttsWorkload?: TtsFitWorkload | undefined;
|
|
5
7
|
/** Absent for the loads `loadModel` also takes without one. */
|
|
6
8
|
modelSrc?: ModelSrcInput | undefined;
|
|
7
9
|
modelType: CanonicalModelType;
|
|
@@ -33,6 +35,6 @@ export type LoadResolution = ResolvedLoad | {
|
|
|
33
35
|
* keys are the real load's.
|
|
34
36
|
*
|
|
35
37
|
* A source already on disk is read directly, since it describes the load more
|
|
36
|
-
* exactly than a stub does.
|
|
38
|
+
* exactly than a stub does. A files-only engine reads only sources on disk.
|
|
37
39
|
*/
|
|
38
40
|
export declare function resolveLoadFromStubs(load: LoadDescription, options?: FitStubOptions): Promise<LoadResolution>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import fs from 'bare-fs';
|
|
2
|
+
import { ModelType } from '../../../schemas/index.js';
|
|
2
3
|
import { getPlugin } from '../../../plugins/registry.js';
|
|
3
4
|
import { getRuntimeContext } from '../../../runtime/state.js';
|
|
4
5
|
import { formatZodError } from '../../../utils/zod-error.js';
|
|
@@ -46,6 +47,11 @@ function stubSetFor(registryPath) {
|
|
|
46
47
|
}
|
|
47
48
|
return primary === undefined ? undefined : { primary, others };
|
|
48
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Engines whose fitter sizes the files on disk and reads no registry
|
|
52
|
+
* description, so a stub would be answered for as if it were the model.
|
|
53
|
+
*/
|
|
54
|
+
const FILES_ONLY_ENGINES = new Set([ModelType.nmtcppTranslation]);
|
|
49
55
|
class NoStubError extends Error {
|
|
50
56
|
reason;
|
|
51
57
|
constructor(reason, message) {
|
|
@@ -63,7 +69,7 @@ class NoStubError extends Error {
|
|
|
63
69
|
* keys are the real load's.
|
|
64
70
|
*
|
|
65
71
|
* A source already on disk is read directly, since it describes the load more
|
|
66
|
-
* exactly than a stub does.
|
|
72
|
+
* exactly than a stub does. A files-only engine reads only sources on disk.
|
|
67
73
|
*/
|
|
68
74
|
export async function resolveLoadFromStubs(load, options = {}) {
|
|
69
75
|
const plugin = getPlugin(load.modelType);
|
|
@@ -84,6 +90,8 @@ export async function resolveLoadFromStubs(load, options = {}) {
|
|
|
84
90
|
const location = srcString(src);
|
|
85
91
|
if (location !== '' && fs.existsSync(location))
|
|
86
92
|
return location;
|
|
93
|
+
if (FILES_ONLY_ENGINES.has(load.modelType))
|
|
94
|
+
throw new NoStubError('files-only-engine');
|
|
87
95
|
const ref = stubRefFor(src);
|
|
88
96
|
if (ref === undefined)
|
|
89
97
|
throw new NoStubError('unresolvable-ref', location);
|
|
@@ -14,18 +14,18 @@ export interface FloorResult {
|
|
|
14
14
|
assumptions: readonly string[];
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
* The smallest resident footprint the catalog facts prove
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* The smallest resident footprint the catalog facts prove: artifact bytes, plus
|
|
18
|
+
* the KV cache for a llama.cpp model at the cheapest element width the engine
|
|
19
|
+
* can default to.
|
|
20
20
|
*
|
|
21
|
-
* Every term
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
21
|
+
* Every term the real load adds on top — weight slack, engine overhead, compute
|
|
22
|
+
* buffers, a completion's working peak — is non-negative, so a floor with all of
|
|
23
|
+
* them at zero is unconditionally valid on any platform and any backend. It can
|
|
24
|
+
* therefore refuse a model (`likely-too-large` when even the floor is over
|
|
25
|
+
* budget) but never confirm one, since how far above the floor the real load
|
|
26
|
+
* lands is unmeasured here.
|
|
27
27
|
*
|
|
28
28
|
* This is the zero-fetch gate. It reads nothing but the catalog and stays the
|
|
29
|
-
* fallback wherever no
|
|
29
|
+
* fallback wherever no engine measurement is available.
|
|
30
30
|
*/
|
|
31
31
|
export declare function computeFloor(input: FloorInput): FloorResult;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LLAMA_WEIGHTS_ASSUMPTION,
|
|
1
|
+
import { LLAMA_WEIGHTS_ASSUMPTION, kvCacheFloorBytes, narrowestKvElementBytes } from './kv-cache.js';
|
|
2
2
|
export const FLOOR_VERSION = 'floor-v1';
|
|
3
3
|
/**
|
|
4
4
|
* Engines whose load builds a KV cache the file sizes exactly, so the floor can
|
|
@@ -7,19 +7,19 @@ export const FLOOR_VERSION = 'floor-v1';
|
|
|
7
7
|
*/
|
|
8
8
|
const KV_CACHE_ENGINES = new Set(['llamacpp-completion', 'llamacpp-embedding']);
|
|
9
9
|
/**
|
|
10
|
-
* The smallest resident footprint the catalog facts prove
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* The smallest resident footprint the catalog facts prove: artifact bytes, plus
|
|
11
|
+
* the KV cache for a llama.cpp model at the cheapest element width the engine
|
|
12
|
+
* can default to.
|
|
13
13
|
*
|
|
14
|
-
* Every term
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
14
|
+
* Every term the real load adds on top — weight slack, engine overhead, compute
|
|
15
|
+
* buffers, a completion's working peak — is non-negative, so a floor with all of
|
|
16
|
+
* them at zero is unconditionally valid on any platform and any backend. It can
|
|
17
|
+
* therefore refuse a model (`likely-too-large` when even the floor is over
|
|
18
|
+
* budget) but never confirm one, since how far above the floor the real load
|
|
19
|
+
* lands is unmeasured here.
|
|
20
20
|
*
|
|
21
21
|
* This is the zero-fetch gate. It reads nothing but the catalog and stays the
|
|
22
|
-
* fallback wherever no
|
|
22
|
+
* fallback wherever no engine measurement is available.
|
|
23
23
|
*/
|
|
24
24
|
export function computeFloor(input) {
|
|
25
25
|
const { profile, workload, extraArtifactBytes } = input;
|
|
@@ -55,8 +55,8 @@ export function computeFloor(input) {
|
|
|
55
55
|
// The narrowest default the engine can pick on any backend, so the floor
|
|
56
56
|
// holds whether the model lands on a GPU (q8_0 with flash attention) or on
|
|
57
57
|
// the CPU (f16). Architectures that disable flash attention stay f16 anyway.
|
|
58
|
-
const element =
|
|
59
|
-
const kv =
|
|
58
|
+
const element = narrowestKvElementBytes(facts);
|
|
59
|
+
const kv = kvCacheFloorBytes(facts, contextTokens, element);
|
|
60
60
|
assumptions.push(element < 2
|
|
61
61
|
? 'the KV cache is floored at the q8_0 element width, the narrowest default the engine picks on any backend; a CPU load allocates an f16 cache above it'
|
|
62
62
|
: `${facts.architecture} loads with flash attention off, so the KV cache is floored at f16 on every backend`, 'default KV-cache types are assumed; an explicit `cache-type-k`/`cache-type-v` in `modelConfig` is not read here and would change these numbers');
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { GgufFacts } from '../../schemas/model-resource-profile.js';
|
|
2
|
+
export declare const LLAMA_WEIGHTS_ASSUMPTION = "weights are counted at full artifact size; llama.cpp maps them by default, so those pages are file-backed and evictable rather than anonymous RAM";
|
|
3
|
+
/**
|
|
4
|
+
* The narrowest KV-cache element width the engine can default to for this
|
|
5
|
+
* model, in bytes: q8_0 where flash attention allows it, f16 otherwise.
|
|
6
|
+
*/
|
|
7
|
+
export declare function narrowestKvElementBytes(facts: GgufFacts): number;
|
|
8
|
+
/**
|
|
9
|
+
* The smallest KV cache the requested context can need, at a fixed element
|
|
10
|
+
* width and clamped to the trained context.
|
|
11
|
+
*
|
|
12
|
+
* Three cases, in order of how much the file actually tells us:
|
|
13
|
+
*
|
|
14
|
+
* 1. **Per-layer classes** — the file describes attention per block, so the
|
|
15
|
+
* cache is summed exactly, with sliding-window blocks capped at their window.
|
|
16
|
+
* 2. **Hybrid attention/recurrent** — `full_attention_interval` says how many
|
|
17
|
+
* blocks hold a cache at all; the rest hold a fixed-size SSM state. Which
|
|
18
|
+
* blocks are which is engine-owned, so the fewest full blocks are counted.
|
|
19
|
+
* 3. **Flat** — every block holds the same cache. A declared sliding window
|
|
20
|
+
* with no per-layer pattern is engine-owned, so every block is counted
|
|
21
|
+
* windowed.
|
|
22
|
+
*/
|
|
23
|
+
export declare function kvCacheFloorBytes(facts: GgufFacts, contextTokens: number, elementBytes: number): number;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KV-cache element widths, in bytes per element.
|
|
3
|
+
*
|
|
4
|
+
* `f16` is the CPU default. On a Metal/Vulkan GPU backend with flash attention
|
|
5
|
+
* on — the SDK's own defaults — `llm-llamacpp` defaults the cache to `q8_0`
|
|
6
|
+
* instead (`addon/src/model-interface/LoadFitNormalization.cpp`, QVAC-21318).
|
|
7
|
+
* `q8_0` packs 32 elements into a 34-byte block.
|
|
8
|
+
*/
|
|
9
|
+
const F16_BYTES_PER_ELEMENT = 2;
|
|
10
|
+
const Q8_0_BYTES_PER_ELEMENT = 34 / 32;
|
|
11
|
+
/** Recurrent/SSM state is kept in f32. */
|
|
12
|
+
const SSM_STATE_BYTES_PER_ELEMENT = 4;
|
|
13
|
+
/**
|
|
14
|
+
* Architectures that disable flash attention, so the GPU `q8_0` KV default
|
|
15
|
+
* never applies and the cache stays `f16` on every backend.
|
|
16
|
+
*/
|
|
17
|
+
function disablesFlashAttention(architecture) {
|
|
18
|
+
return architecture.startsWith('bitnet');
|
|
19
|
+
}
|
|
20
|
+
// Shared with the computed floor so a mixed set carries one weights assumption, not two.
|
|
21
|
+
export const LLAMA_WEIGHTS_ASSUMPTION = 'weights are counted at full artifact size; llama.cpp maps them by default, so those pages are file-backed and evictable rather than anonymous RAM';
|
|
22
|
+
/**
|
|
23
|
+
* The narrowest KV-cache element width the engine can default to for this
|
|
24
|
+
* model, in bytes: q8_0 where flash attention allows it, f16 otherwise.
|
|
25
|
+
*/
|
|
26
|
+
export function narrowestKvElementBytes(facts) {
|
|
27
|
+
return disablesFlashAttention(facts.architecture) ? F16_BYTES_PER_ELEMENT : Q8_0_BYTES_PER_ELEMENT;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The smallest KV cache the requested context can need, at a fixed element
|
|
31
|
+
* width and clamped to the trained context.
|
|
32
|
+
*
|
|
33
|
+
* Three cases, in order of how much the file actually tells us:
|
|
34
|
+
*
|
|
35
|
+
* 1. **Per-layer classes** — the file describes attention per block, so the
|
|
36
|
+
* cache is summed exactly, with sliding-window blocks capped at their window.
|
|
37
|
+
* 2. **Hybrid attention/recurrent** — `full_attention_interval` says how many
|
|
38
|
+
* blocks hold a cache at all; the rest hold a fixed-size SSM state. Which
|
|
39
|
+
* blocks are which is engine-owned, so the fewest full blocks are counted.
|
|
40
|
+
* 3. **Flat** — every block holds the same cache. A declared sliding window
|
|
41
|
+
* with no per-layer pattern is engine-owned, so every block is counted
|
|
42
|
+
* windowed.
|
|
43
|
+
*/
|
|
44
|
+
export function kvCacheFloorBytes(facts, contextTokens, elementBytes) {
|
|
45
|
+
const tokens = Math.min(contextTokens, facts.contextLength);
|
|
46
|
+
if (facts.kvLayerClasses && facts.kvLayerClasses.length > 0) {
|
|
47
|
+
return layerClassBytes(facts.kvLayerClasses, facts, tokens, elementBytes);
|
|
48
|
+
}
|
|
49
|
+
const perBlockPerToken = facts.headCountKv * (facts.keyLength + facts.valueLength);
|
|
50
|
+
if (facts.fullAttentionInterval && facts.fullAttentionInterval > 1) {
|
|
51
|
+
const fullBlocks = Math.floor(facts.blockCount / facts.fullAttentionInterval);
|
|
52
|
+
const ssm = ssmStateBytes(facts, facts.blockCount - fullBlocks);
|
|
53
|
+
return fullBlocks * perBlockPerToken * tokens * elementBytes + ssm;
|
|
54
|
+
}
|
|
55
|
+
if (facts.slidingWindow) {
|
|
56
|
+
const windowedTokens = Math.min(tokens, facts.slidingWindow);
|
|
57
|
+
return facts.blockCount * perBlockPerToken * windowedTokens * elementBytes;
|
|
58
|
+
}
|
|
59
|
+
return facts.blockCount * perBlockPerToken * tokens * elementBytes;
|
|
60
|
+
}
|
|
61
|
+
function layerClassBytes(classes, facts, contextTokens, elementBytes) {
|
|
62
|
+
let total = 0;
|
|
63
|
+
for (const layerClass of classes) {
|
|
64
|
+
const tokens = layerClass.windowed && facts.slidingWindow
|
|
65
|
+
? Math.min(contextTokens, facts.slidingWindow)
|
|
66
|
+
: contextTokens;
|
|
67
|
+
total +=
|
|
68
|
+
layerClass.count *
|
|
69
|
+
layerClass.headCountKv *
|
|
70
|
+
(layerClass.keyLength + layerClass.valueLength) *
|
|
71
|
+
tokens *
|
|
72
|
+
elementBytes;
|
|
73
|
+
}
|
|
74
|
+
return total;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Fixed recurrent state for the blocks of a hybrid model that hold no KV cache:
|
|
78
|
+
* the SSM state plus its convolution window, per block.
|
|
79
|
+
*/
|
|
80
|
+
function ssmStateBytes(facts, recurrentBlocks) {
|
|
81
|
+
if (!facts.ssmInnerSize || !facts.ssmStateSize || recurrentBlocks <= 0)
|
|
82
|
+
return 0;
|
|
83
|
+
const perBlock = facts.ssmInnerSize * facts.ssmStateSize + facts.ssmInnerSize * (facts.ssmConvKernel ?? 0);
|
|
84
|
+
return recurrentBlocks * perBlock * SSM_STATE_BYTES_PER_ELEMENT;
|
|
85
|
+
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import type { AbortSignal } from 'bare-abort-controller';
|
|
2
2
|
import type { Logger } from '../../../logging/types.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { TtsFitWorkload } from '../../../schemas/assess-model-fit.js';
|
|
4
|
+
import type { CanonicalModelType, NativeProbeFit, NativeProbeVerdict, TranscriptionFitWorkload } from '../../../schemas/index.js';
|
|
4
5
|
import { runFit as runFitDefault } from './run-fit.js';
|
|
5
6
|
/**
|
|
6
|
-
* `fit` and `does-not-fit` are projections of the load the SDK is about to run
|
|
7
|
-
*
|
|
8
|
-
* fitted plan, so neither verdict is denial-grade and no verdict changes the
|
|
9
|
-
* load.
|
|
7
|
+
* `fit` and `does-not-fit` are projections of the load the SDK is about to run.
|
|
8
|
+
* The real loader neither consumes nor verifies the fitted plan.
|
|
10
9
|
*
|
|
11
10
|
* The outcome is the wire shape: `loadModel` hands it to the model registry and
|
|
12
11
|
* `getLoadedModelInfo` returns it, so no caller has to read a verdict out of a
|
|
@@ -15,6 +14,8 @@ import { runFit as runFitDefault } from './run-fit.js';
|
|
|
15
14
|
export type AdvisoryFitVerdict = NativeProbeVerdict;
|
|
16
15
|
export type AdvisoryFitOutcome = NativeProbeFit;
|
|
17
16
|
export interface AdvisoryFitInput {
|
|
17
|
+
transcriptionWorkload?: TranscriptionFitWorkload | undefined;
|
|
18
|
+
ttsWorkload?: TtsFitWorkload | undefined;
|
|
18
19
|
modelId: string;
|
|
19
20
|
modelType: CanonicalModelType;
|
|
20
21
|
modelPath: string;
|
|
@@ -28,7 +29,6 @@ export interface AdvisoryFitInput {
|
|
|
28
29
|
*/
|
|
29
30
|
export interface AdvisoryFitOptions {
|
|
30
31
|
signal?: AbortSignal;
|
|
31
|
-
enabled?: boolean;
|
|
32
32
|
mobile?: boolean;
|
|
33
33
|
timeoutMs?: number;
|
|
34
34
|
runFit?: typeof runFitDefault;
|
|
@@ -36,6 +36,11 @@ export interface AdvisoryFitOptions {
|
|
|
36
36
|
availableSystemBytes?: () => Promise<number | undefined>;
|
|
37
37
|
countsDeviceRows?: () => Promise<boolean>;
|
|
38
38
|
residentModelBytes?: () => Promise<number>;
|
|
39
|
+
/**
|
|
40
|
+
* Bytes to hold back beyond what is resident, for models the caller counts
|
|
41
|
+
* as loaded alongside this one but that this worker does not yet hold.
|
|
42
|
+
*/
|
|
43
|
+
extraResidentBytes?: number;
|
|
39
44
|
}
|
|
40
45
|
/**
|
|
41
46
|
* Runs the advisory fit check for a load that is about to start, against the
|
|
@@ -24,24 +24,11 @@ const ADVISORY_FIT_BASE_MARGIN_MIB = 1024;
|
|
|
24
24
|
*/
|
|
25
25
|
const NATIVE_PROBE_ESTIMATOR_VERSION = 'native-probe-v2';
|
|
26
26
|
const BYTES_PER_MIB = 1024 * 1024;
|
|
27
|
-
const DISABLED_VALUES = new Set(['0', 'false', 'off', 'no']);
|
|
28
27
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* unset, leaves the check on.
|
|
33
|
-
*
|
|
34
|
-
* The worker environment and the mobile runtime flag are imported lazily. Both
|
|
35
|
-
* modules reach Bare-only bindings, and resolving them eagerly would make this
|
|
36
|
-
* orchestration untestable outside a Bare runtime.
|
|
28
|
+
* The mobile runtime flag is imported lazily: that module reaches Bare-only
|
|
29
|
+
* bindings, and resolving it eagerly would make this orchestration untestable
|
|
30
|
+
* outside a Bare runtime.
|
|
37
31
|
*/
|
|
38
|
-
async function resolveEnabled(explicit) {
|
|
39
|
-
if (explicit !== undefined)
|
|
40
|
-
return explicit;
|
|
41
|
-
const { getValidatedEnv } = await import('../../../runtime/env.js');
|
|
42
|
-
const value = getValidatedEnv().QVAC_ADVISORY_MODEL_FIT;
|
|
43
|
-
return value === undefined || !DISABLED_VALUES.has(value.toLowerCase());
|
|
44
|
-
}
|
|
45
32
|
async function resolveMobile(explicit) {
|
|
46
33
|
if (explicit !== undefined)
|
|
47
34
|
return explicit;
|
|
@@ -123,9 +110,7 @@ async function deviceBytesCountAgainstSystem() {
|
|
|
123
110
|
import('../platform.js')
|
|
124
111
|
]);
|
|
125
112
|
const collector = getResourceCollector();
|
|
126
|
-
// Unknown counts them
|
|
127
|
-
// this check exists to stop, and refusing one that would have fitted is
|
|
128
|
-
// advisory only.
|
|
113
|
+
// Unknown counts them, which errs toward refusing.
|
|
129
114
|
if (!collector)
|
|
130
115
|
return true;
|
|
131
116
|
const resources = { capabilities: collector.getCapabilities(), sample: collector.sample() };
|
|
@@ -182,13 +167,13 @@ function report(logger, input, outcome) {
|
|
|
182
167
|
const prefix = `[advisory-fit:${input.modelType}:${input.modelId}]`;
|
|
183
168
|
if (outcome.verdict === 'fit') {
|
|
184
169
|
const plan = outcome.plan;
|
|
185
|
-
logger.info(`${prefix} projected to fit
|
|
170
|
+
logger.info(`${prefix} projected to fit${plan === undefined
|
|
186
171
|
? footprint(outcome)
|
|
187
172
|
: ` — nCtx ${plan.nCtx}, nGpuLayers ${plan.nGpuLayers} across ${plan.nGpuDevices} GPU device(s)`}`);
|
|
188
173
|
return;
|
|
189
174
|
}
|
|
190
175
|
if (outcome.verdict === 'does-not-fit') {
|
|
191
|
-
logger.warn(`${prefix} projected not to fit
|
|
176
|
+
logger.warn(`${prefix} projected not to fit${footprint(outcome)}: ${outcome.reason}${outcome.message === undefined ? '' : ` (${outcome.message})`}`);
|
|
192
177
|
return;
|
|
193
178
|
}
|
|
194
179
|
// `unsupported-load` covers every load this check refuses up front — a model
|
|
@@ -216,19 +201,19 @@ export async function runAdvisoryFitCheck(input, options = {}) {
|
|
|
216
201
|
let logger = options.logger;
|
|
217
202
|
try {
|
|
218
203
|
logger ??= getEngineLogger();
|
|
219
|
-
if (!(await resolveEnabled(options.enabled)))
|
|
220
|
-
return unknown('disabled');
|
|
221
204
|
const mobile = await resolveMobile(options.mobile);
|
|
222
205
|
const availableBytes = await (options.availableSystemBytes ?? defaultAvailableSystemBytes)();
|
|
223
|
-
const residentBytes = await (options.residentModelBytes ?? defaultResidentModelBytes)()
|
|
206
|
+
const residentBytes = (await (options.residentModelBytes ?? defaultResidentModelBytes)()) +
|
|
207
|
+
(options.extraResidentBytes ?? 0);
|
|
224
208
|
const residentReserveMiB = Math.ceil(residentBytes / BYTES_PER_MIB);
|
|
225
|
-
// Always sent, even with a zero reserve
|
|
226
|
-
//
|
|
227
|
-
// diverge silently if an engine default moves.
|
|
209
|
+
// Always sent, even with a zero reserve, so the base margin has one source
|
|
210
|
+
// and an engine default never decides it.
|
|
228
211
|
const plan = createFitRequest({
|
|
229
212
|
modelType: input.modelType,
|
|
230
213
|
modelPath: input.modelPath,
|
|
231
214
|
modelConfig: input.modelConfig,
|
|
215
|
+
transcriptionWorkload: input.transcriptionWorkload,
|
|
216
|
+
ttsWorkload: input.ttsWorkload,
|
|
232
217
|
artifacts: input.artifacts,
|
|
233
218
|
isShardedModel: input.isShardedModel,
|
|
234
219
|
marginBytes: (ADVISORY_FIT_BASE_MARGIN_MIB + residentReserveMiB) * BYTES_PER_MIB
|
|
@@ -34,6 +34,14 @@ async function assessFitOf(probe) {
|
|
|
34
34
|
const { assessFit } = await import('@qvac/diffusion-cpp');
|
|
35
35
|
return assessFit(probe.request);
|
|
36
36
|
}
|
|
37
|
+
case 'ocr-ggml': {
|
|
38
|
+
const { assessFit } = await import('@qvac/ocr-ggml');
|
|
39
|
+
return assessFit(probe.request);
|
|
40
|
+
}
|
|
41
|
+
case 'translation-nmtcpp': {
|
|
42
|
+
const { default: TranslationNmtcpp } = await import('@qvac/translation-nmtcpp');
|
|
43
|
+
return TranslationNmtcpp.assessFit(probe.request);
|
|
44
|
+
}
|
|
37
45
|
}
|
|
38
46
|
}
|
|
39
47
|
export async function callChildEngineFit(probe) {
|
|
@@ -45,7 +45,8 @@ function breakdown(weights, context, compute) {
|
|
|
45
45
|
/**
|
|
46
46
|
* The parts of `deviceBytes` the engine separates. Audiogen reports a peak
|
|
47
47
|
* across pipeline phases and diffusion a per-module table, neither of which
|
|
48
|
-
* divides into these three, so both come back empty.
|
|
48
|
+
* divides into these three, so both come back empty. OCR sizes its weights
|
|
49
|
+
* alone and leaves the image-dependent memory uncounted.
|
|
49
50
|
*
|
|
50
51
|
* The llama rows are summed over the same devices the engine's own
|
|
51
52
|
* `deviceBytes` covers, which is every row but `host`.
|
|
@@ -71,14 +72,28 @@ function breakdownFor(probe) {
|
|
|
71
72
|
const result = probe.result;
|
|
72
73
|
return breakdown(result.weightsBytes, result.stateBytes, sumOf(result.lmComputeBytes, result.codecComputeBytes));
|
|
73
74
|
}
|
|
75
|
+
if (probe.engine === 'ocr-ggml') {
|
|
76
|
+
return breakdown(probe.result.weightsBytes, undefined, undefined);
|
|
77
|
+
}
|
|
74
78
|
return {};
|
|
75
79
|
}
|
|
76
80
|
function llamaProjection(probe) {
|
|
77
81
|
const first = probe.result.devices.find((device) => device.name !== HOST_ROW && device.name !== CPU_DEVICE);
|
|
82
|
+
const devices = probe.result.devices
|
|
83
|
+
.filter((device) => device.name !== HOST_ROW)
|
|
84
|
+
.map((device) => ({
|
|
85
|
+
name: device.name,
|
|
86
|
+
totalBytes: device.totalBytes,
|
|
87
|
+
freeBytes: device.freeBytes,
|
|
88
|
+
weightsBytes: device.modelBytes,
|
|
89
|
+
contextBytes: device.contextBytes,
|
|
90
|
+
computeBytes: device.computeBytes
|
|
91
|
+
}));
|
|
78
92
|
return {
|
|
79
93
|
deviceBytes: probe.result.deviceBytes,
|
|
80
94
|
hostBytes: probe.result.hostBytes,
|
|
81
95
|
...breakdownFor(probe),
|
|
96
|
+
...(devices.length > 0 && { devices }),
|
|
82
97
|
...(first !== undefined && {
|
|
83
98
|
deviceName: first.name,
|
|
84
99
|
deviceFreeBytes: first.freeBytes,
|
|
@@ -86,10 +101,26 @@ function llamaProjection(probe) {
|
|
|
86
101
|
})
|
|
87
102
|
};
|
|
88
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* The translation fitter reports one allowance against the free memory of the
|
|
106
|
+
* device it ran on. Only the file bytes inside it are weights; the rest does
|
|
107
|
+
* not divide into context and compute.
|
|
108
|
+
*/
|
|
109
|
+
function nmtProjection(result) {
|
|
110
|
+
return {
|
|
111
|
+
deviceName: result.backend,
|
|
112
|
+
deviceBytes: result.requiredBytes,
|
|
113
|
+
deviceFreeBytes: result.freeBytes,
|
|
114
|
+
weightsBytes: result.modelBytes,
|
|
115
|
+
report: result.report
|
|
116
|
+
};
|
|
117
|
+
}
|
|
89
118
|
function projectionFor(probe) {
|
|
90
119
|
if (probe.engine === 'diffusion-cpp') {
|
|
91
120
|
return { deviceName: probe.result.backend, report: probe.result.report };
|
|
92
121
|
}
|
|
122
|
+
if (probe.engine === 'translation-nmtcpp')
|
|
123
|
+
return nmtProjection(probe.result);
|
|
93
124
|
if (isLlama(probe))
|
|
94
125
|
return llamaProjection(probe);
|
|
95
126
|
const result = probe.result;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { TtsFitWorkload } from '../../../schemas/assess-model-fit.js';
|
|
2
|
+
import { type CanonicalModelType, type TranscriptionFitWorkload } from '../../../schemas/index.js';
|
|
2
3
|
import type { FitProbeRequest } from './engine-fit.js';
|
|
3
4
|
export type FitRequestPlan = {
|
|
4
5
|
supported: true;
|
|
@@ -8,9 +9,11 @@ export type FitRequestPlan = {
|
|
|
8
9
|
detail: string;
|
|
9
10
|
};
|
|
10
11
|
export interface CreateFitRequestParams {
|
|
12
|
+
ttsWorkload?: TtsFitWorkload | undefined;
|
|
11
13
|
modelType: CanonicalModelType;
|
|
12
14
|
modelPath: string;
|
|
13
15
|
modelConfig: unknown;
|
|
16
|
+
transcriptionWorkload?: TranscriptionFitWorkload | undefined;
|
|
14
17
|
artifacts?: Record<string, string> | undefined;
|
|
15
18
|
isShardedModel: boolean;
|
|
16
19
|
/** Free memory that must remain for the projection to count as fitting. */
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { ModelType } from '../../../schemas/index.js';
|
|
2
|
-
import { createBciFitRequest, createParakeetFitRequest, createWhisperFitRequest } from './engines/asr.js';
|
|
2
|
+
import { createBciFitRequest, createMossTranscribeFitRequest, createParakeetFitRequest, createWhisperFitRequest } from './engines/asr.js';
|
|
3
3
|
import { createAudiogenFitRequest } from './engines/audiogen.js';
|
|
4
4
|
import { createDiffusionFitRequest } from './engines/diffusion.js';
|
|
5
5
|
import { createLlamaFitRequest, llamaLoadKindFor } from './engines/llama.js';
|
|
6
|
+
import { createNmtFitRequest } from './engines/nmt.js';
|
|
7
|
+
import { createOcrFitRequest } from './engines/ocr.js';
|
|
6
8
|
import { createTtsFitRequest } from './engines/tts.js';
|
|
7
9
|
/**
|
|
8
10
|
* Builds a fit request from the same resolved config and artifacts the real
|
|
@@ -15,24 +17,28 @@ import { createTtsFitRequest } from './engines/tts.js';
|
|
|
15
17
|
*/
|
|
16
18
|
export function createFitRequest(params) {
|
|
17
19
|
const { modelType, modelPath, modelConfig, artifacts, marginBytes } = params;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
modelConfig,
|
|
24
|
-
artifacts,
|
|
25
|
-
isShardedModel: params.isShardedModel,
|
|
26
|
-
marginBytes
|
|
27
|
-
});
|
|
20
|
+
if (params.transcriptionWorkload !== undefined && modelType !== ModelType.mossTranscribe) {
|
|
21
|
+
return {
|
|
22
|
+
supported: false,
|
|
23
|
+
detail: 'transcriptionWorkload is supported only for MOSS transcription'
|
|
24
|
+
};
|
|
28
25
|
}
|
|
29
|
-
// Every engine
|
|
30
|
-
//
|
|
26
|
+
// Every engine reads whole files rather than a shard set, so a split model is
|
|
27
|
+
// not a shape any of them can be pointed at.
|
|
31
28
|
if (params.isShardedModel) {
|
|
32
29
|
return { supported: false, detail: 'sharded models are not representable' };
|
|
33
30
|
}
|
|
31
|
+
const loadKind = llamaLoadKindFor(modelType);
|
|
32
|
+
if (loadKind !== undefined) {
|
|
33
|
+
return createLlamaFitRequest({ loadKind, modelPath, modelConfig, artifacts, marginBytes });
|
|
34
|
+
}
|
|
34
35
|
const common = { modelPath, modelConfig, artifacts, marginBytes };
|
|
35
36
|
switch (modelType) {
|
|
37
|
+
case ModelType.mossTranscribe:
|
|
38
|
+
return createMossTranscribeFitRequest({
|
|
39
|
+
...common,
|
|
40
|
+
transcriptionWorkload: params.transcriptionWorkload
|
|
41
|
+
});
|
|
36
42
|
case ModelType.whispercppTranscription:
|
|
37
43
|
return createWhisperFitRequest(common);
|
|
38
44
|
case ModelType.parakeetTranscription:
|
|
@@ -40,11 +46,15 @@ export function createFitRequest(params) {
|
|
|
40
46
|
case ModelType.bciWhispercppTranscription:
|
|
41
47
|
return createBciFitRequest(common);
|
|
42
48
|
case ModelType.ttsGgml:
|
|
43
|
-
return createTtsFitRequest(common);
|
|
49
|
+
return createTtsFitRequest({ ...common, ttsWorkload: params.ttsWorkload });
|
|
44
50
|
case ModelType.audiogenGgml:
|
|
45
51
|
return createAudiogenFitRequest(common);
|
|
46
52
|
case ModelType.sdcppGeneration:
|
|
47
53
|
return createDiffusionFitRequest({ modelPath, modelConfig, artifacts });
|
|
54
|
+
case ModelType.ggmlOcr:
|
|
55
|
+
return createOcrFitRequest(common);
|
|
56
|
+
case ModelType.nmtcppTranslation:
|
|
57
|
+
return createNmtFitRequest(common);
|
|
48
58
|
default:
|
|
49
59
|
return { supported: false, detail: `no fitter for model type: ${modelType}` };
|
|
50
60
|
}
|
|
@@ -4,6 +4,8 @@ import type { BciFitRequest, BciFitResult } from '@qvac/bci-whispercpp';
|
|
|
4
4
|
import type { DiffusionFitRequest, DiffusionFitResult } from '@qvac/diffusion-cpp';
|
|
5
5
|
import type { EmbedFitRequest, EmbedFitResult } from '@qvac/embed-llamacpp';
|
|
6
6
|
import type LlmLlamacpp from '@qvac/llm-llamacpp';
|
|
7
|
+
import type { OcrFitRequest, OcrFitResult } from '@qvac/ocr-ggml';
|
|
8
|
+
import type TranslationNmtcpp from '@qvac/translation-nmtcpp';
|
|
7
9
|
import type { TtsFitRequest, TtsFitResult } from '@qvac/tts-ggml';
|
|
8
10
|
/**
|
|
9
11
|
* The engine packages each expose their own `assessFit`, taking the same fields
|
|
@@ -31,6 +33,12 @@ export type FitProbeRequest = {
|
|
|
31
33
|
} | {
|
|
32
34
|
engine: 'diffusion-cpp';
|
|
33
35
|
request: DiffusionFitRequest;
|
|
36
|
+
} | {
|
|
37
|
+
engine: 'ocr-ggml';
|
|
38
|
+
request: OcrFitRequest;
|
|
39
|
+
} | {
|
|
40
|
+
engine: 'translation-nmtcpp';
|
|
41
|
+
request: TranslationNmtcpp.FitRequest;
|
|
34
42
|
};
|
|
35
43
|
export type FitProbeEngine = FitProbeRequest['engine'];
|
|
36
44
|
export type FitProbeResult = {
|
|
@@ -54,6 +62,12 @@ export type FitProbeResult = {
|
|
|
54
62
|
} | {
|
|
55
63
|
engine: 'diffusion-cpp';
|
|
56
64
|
result: DiffusionFitResult;
|
|
65
|
+
} | {
|
|
66
|
+
engine: 'ocr-ggml';
|
|
67
|
+
result: OcrFitResult;
|
|
68
|
+
} | {
|
|
69
|
+
engine: 'translation-nmtcpp';
|
|
70
|
+
result: TranslationNmtcpp.FitResult;
|
|
57
71
|
};
|
|
58
72
|
/** Calls one engine's fitter, taken from the plugin that owns its addon. */
|
|
59
73
|
export declare function callEngineFit(probe: FitProbeRequest): Promise<FitProbeResult>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TranscriptionFitWorkload } from '../../../../schemas/index.js';
|
|
1
2
|
import type { FitRequestPlan } from '../create-fit-request.js';
|
|
2
3
|
export interface AsrFitRequestParams {
|
|
3
4
|
modelPath: string;
|
|
@@ -5,6 +6,9 @@ export interface AsrFitRequestParams {
|
|
|
5
6
|
artifacts?: Record<string, string> | undefined;
|
|
6
7
|
marginBytes?: number | undefined;
|
|
7
8
|
}
|
|
9
|
+
export declare function createMossTranscribeFitRequest(params: AsrFitRequestParams & {
|
|
10
|
+
transcriptionWorkload?: TranscriptionFitWorkload | undefined;
|
|
11
|
+
}): FitRequestPlan;
|
|
8
12
|
export declare function createWhisperFitRequest(params: AsrFitRequestParams): FitRequestPlan;
|
|
9
13
|
export declare function createParakeetFitRequest(params: AsrFitRequestParams): FitRequestPlan;
|
|
10
14
|
export declare function createBciFitRequest(params: AsrFitRequestParams): FitRequestPlan;
|