prefer-inference-core 0.0.0-g0be6ef9
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/LICENSE +21 -0
- package/README.md +166 -0
- package/dist/catalog.d.ts +27 -0
- package/dist/catalog.d.ts.map +1 -0
- package/dist/catalog.js +547 -0
- package/dist/catalog.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +412 -0
- package/dist/cli.js.map +1 -0
- package/dist/huggingface.d.ts +18 -0
- package/dist/huggingface.d.ts.map +1 -0
- package/dist/huggingface.js +296 -0
- package/dist/huggingface.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/planning.d.ts +11 -0
- package/dist/planning.d.ts.map +1 -0
- package/dist/planning.js +610 -0
- package/dist/planning.js.map +1 -0
- package/dist/prefer.mjs +9493 -0
- package/dist/prefer.mjs.map +7 -0
- package/dist/releases.d.ts +33 -0
- package/dist/releases.d.ts.map +1 -0
- package/dist/releases.js +288 -0
- package/dist/releases.js.map +1 -0
- package/dist/resources.d.ts +10 -0
- package/dist/resources.d.ts.map +1 -0
- package/dist/resources.js +250 -0
- package/dist/resources.js.map +1 -0
- package/dist/types.d.ts +409 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +20 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +112 -0
- package/dist/utils.js.map +1 -0
- package/package.json +58 -0
- package/schemas/prefer-model-catalog-extension.schema.json +25 -0
- package/schemas/prefer-model-catalog.schema.json +54 -0
- package/schemas/prefer-model-plan.schema.json +115 -0
- package/schemas/prefer-resource-profile.schema.json +70 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Clint Valusek
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# `prefer-inference-core`
|
|
2
|
+
|
|
3
|
+
Shared model-catalog, Hugging Face metadata, configuration-resolution, and
|
|
4
|
+
immutable-release tooling for PreFer controllers.
|
|
5
|
+
|
|
6
|
+
The package is data-driven. PreFer's authored YAML and the materialized catalog
|
|
7
|
+
shipped with a grouped release define supported models; the library does not
|
|
8
|
+
hard-code a second model list. Model weights are never packaged here.
|
|
9
|
+
|
|
10
|
+
## Supported catalog
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { readModelCatalog, resolveModelVariant } from "prefer-inference-core";
|
|
14
|
+
|
|
15
|
+
const catalog = await readModelCatalog("prefer-model-catalog.json");
|
|
16
|
+
const qwen = resolveModelVariant(catalog, "qwen-3.8-27b", {
|
|
17
|
+
engine: "sglang",
|
|
18
|
+
useNvfp4: true,
|
|
19
|
+
modelRoot: "/models"
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Settings merge from broadest to narrowest: global, engine, inferred
|
|
24
|
+
artifact/quant behavior, model, model+engine, repository, quant, exact
|
|
25
|
+
repository/quant+engine, then caller overrides. Arrays and scalar values
|
|
26
|
+
replace earlier values; objects merge recursively.
|
|
27
|
+
|
|
28
|
+
Resolved variants include a repository storage root and an exact local path for
|
|
29
|
+
each artifact. Engine artifact-role defaults supply repeated component bindings
|
|
30
|
+
such as image target, VAE, and text-encoder arguments; authored artifact
|
|
31
|
+
settings are only needed for a real exception.
|
|
32
|
+
|
|
33
|
+
The release catalog currently covers every logical model in PreFer's five
|
|
34
|
+
engine catalogs. Each model exposes a consistent prompt-ready profile and each
|
|
35
|
+
resolved variant returns the exact selected artifact bundle, including
|
|
36
|
+
cross-repository companions such as projectors, draft models, encoders, VAEs,
|
|
37
|
+
and runtime metadata. Hugging Face supplies the resolved file facts; authored
|
|
38
|
+
YAML carries only PreFer's choices and overrides.
|
|
39
|
+
|
|
40
|
+
Dedicated GGUF repositories opt into metadata-only quant discovery, so their
|
|
41
|
+
full published quant selection is available without copying Hugging Face's file
|
|
42
|
+
catalog into YAML. All llama.cpp text artifacts are selectable for SGLang and
|
|
43
|
+
vLLM as well as llama.cpp. Discoverability is not a claim that an
|
|
44
|
+
engine/model/quant/hardware tuple has been validated; deployment inventories
|
|
45
|
+
carry that state.
|
|
46
|
+
|
|
47
|
+
## Resource-aware planning
|
|
48
|
+
|
|
49
|
+
The package normalizes every engine's deployment inventory into the same
|
|
50
|
+
`prefer.resources.v1` shape. GPU identity, count, usable memory, architecture,
|
|
51
|
+
compute capability, and format capabilities are primary. Host RAM, CPU, and
|
|
52
|
+
storage remain independent resources and only participate when a route uses
|
|
53
|
+
them. Unified-memory systems use one shared pool; the planner never adds the
|
|
54
|
+
same bytes once as VRAM and again as host RAM.
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
import { normalizeDeploymentResources, planModelSet } from "prefer-inference-core";
|
|
58
|
+
|
|
59
|
+
const resources = normalizeDeploymentResources(deployment, runtimeObservation);
|
|
60
|
+
const plan = planModelSet(catalog, {
|
|
61
|
+
engine: "llama.cpp",
|
|
62
|
+
resources,
|
|
63
|
+
models: [
|
|
64
|
+
{ model_id: "qwen-3.8-27b", required: true },
|
|
65
|
+
{ model_id: "gemma-4-12b", priority: 10, speed_score: 74, quality_score: 88 }
|
|
66
|
+
],
|
|
67
|
+
hints: {
|
|
68
|
+
required_capabilities: ["tool-calling"],
|
|
69
|
+
preferred_roles: ["repository-coding"],
|
|
70
|
+
speed_importance: 0.8,
|
|
71
|
+
quality_importance: 1,
|
|
72
|
+
quant_bias: "balanced"
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Planning starts with each model's normal quant and walks downward through
|
|
78
|
+
quality-credible published variants only when the preferred artifact does not
|
|
79
|
+
fit. NVFP4 and FP8 selections require matching hardware capabilities. Optional
|
|
80
|
+
bundle members may be omitted for memory, model-count, or staged-storage
|
|
81
|
+
limits; required omissions make the plan incomplete and remain explicit.
|
|
82
|
+
Required capabilities are hard gates. Preferred capabilities and roles only
|
|
83
|
+
rank optional bundle members. `speed_importance` weights a caller-supplied
|
|
84
|
+
route speed score when available; otherwise active parameter count is used as
|
|
85
|
+
a low-confidence ordering hint. Quality importance uses only a caller-supplied
|
|
86
|
+
workload score; PreFer does not invent or embed a cross-model leaderboard. The
|
|
87
|
+
default curated order is preserved when no hints are supplied. `quant_bias`
|
|
88
|
+
can explicitly favor quality or capacity, while `balanced` retains the normal
|
|
89
|
+
quant and falls back only when needed.
|
|
90
|
+
|
|
91
|
+
The default estimate uses exact selected artifact bytes, a small runtime
|
|
92
|
+
allowance, and a device reserve equal to 4% of capacity with a 1.5 GiB floor
|
|
93
|
+
and 4 GiB cap. `--headroom-gib` fixes that reserve directly and
|
|
94
|
+
`--headroom-percent` changes the scaling factor. Its result is labelled
|
|
95
|
+
`artifact-only`, not presented as a measured peak. A caller can add
|
|
96
|
+
architecture-derived or measured fixed memory and bytes-per-token, exact free
|
|
97
|
+
device memory, and host-memory availability. `tuneWorkloadToFit` can then trade
|
|
98
|
+
context and concurrency while respecting the caller's minimums and stated
|
|
99
|
+
priority. Existing deployments that explicitly configure CPU expert/component
|
|
100
|
+
offload remain conditional rather than being rejected when static local
|
|
101
|
+
inventory omits private host RAM; runtime discovery must supply that capacity
|
|
102
|
+
before launch. This lets NeurOn replace a static launch estimate with runtime
|
|
103
|
+
measurements without forking PreFer's selection rules.
|
|
104
|
+
|
|
105
|
+
The standalone CLI exposes the same boundary:
|
|
106
|
+
|
|
107
|
+
```text
|
|
108
|
+
prefer hardware normalize --input prefer-llama-deployment-inventory.json --deployment aws/g6/xlarge/general
|
|
109
|
+
prefer hardware detect --base prefer-vllm-deployment-inventory.json --deployment local/gb10/1x/performance
|
|
110
|
+
prefer model plan --resources resources.json --engine llama.cpp --models qwen-3.8-27b,gemma-4-12b --preferred-role repository-coding --speed-importance 0.8 --headroom-gib 2
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Qwen3.8 27B defaults to Unsloth UD-Q6_K_XL on every engine. Setting
|
|
114
|
+
`USE_NVFP4=true` in the CLI environment (or passing `useNvfp4` to the library)
|
|
115
|
+
selects the engine-specific NVFP4 source. Explicit repository and quant choices
|
|
116
|
+
still win. The CLI resolves storage from `--model-root`, then
|
|
117
|
+
`PREFER_MODELS_DIR`, then `/models`.
|
|
118
|
+
|
|
119
|
+
## NeurOn-owned runtime extensions
|
|
120
|
+
|
|
121
|
+
NeurOn can request any additional Hugging Face repositories without editing or
|
|
122
|
+
rebuilding PreFer:
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
import {
|
|
126
|
+
createCatalogExtension,
|
|
127
|
+
createRuntimeModelCatalog
|
|
128
|
+
} from "prefer-inference-core";
|
|
129
|
+
|
|
130
|
+
const extension = await createCatalogExtension([
|
|
131
|
+
{ repository: "org/another-model", revision: "main" },
|
|
132
|
+
{
|
|
133
|
+
model_id: "neuron-private-choice",
|
|
134
|
+
repository: "org/private-model",
|
|
135
|
+
revision: "0123456789abcdef0123456789abcdef01234567"
|
|
136
|
+
}
|
|
137
|
+
], { token: process.env.HF_TOKEN, cacheDir: ".cache/huggingface" });
|
|
138
|
+
|
|
139
|
+
const runtime = createRuntimeModelCatalog(supportedCatalog, [extension]);
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
A repository-only selection adds metadata without inventing a canonical model
|
|
143
|
+
ID. A named selection adds a NeurOn-owned ID. PreFer IDs win by default:
|
|
144
|
+
collisions throw unless the caller explicitly chooses `keep` or `replace`.
|
|
145
|
+
Resolved revisions, file paths, byte sizes, LFS hashes, base-model declarations,
|
|
146
|
+
license, library/pipeline identity, and tags reported by Hugging Face are retained in the
|
|
147
|
+
extension. Repository results also say whether the returned file tree is
|
|
148
|
+
complete or was narrowed by the caller's `include` patterns. Controllers decide when to refresh and can supply their own `fetch`
|
|
149
|
+
implementation, token, cache, timeout, and bounded concurrency.
|
|
150
|
+
|
|
151
|
+
The standalone bundled CLI exposes the same operations:
|
|
152
|
+
|
|
153
|
+
```text
|
|
154
|
+
prefer catalog extend \
|
|
155
|
+
--repo org/another-model@main \
|
|
156
|
+
--model neuron-private-choice=org/private-model@0123456789abcdef0123456789abcdef01234567 \
|
|
157
|
+
--output neuron-extension.json
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Immutable PreFer releases
|
|
161
|
+
|
|
162
|
+
`listPreferReleases`, `resolvePreferRelease`, and `downloadPreferTooling` cover
|
|
163
|
+
stable/preview release selection, full-SHA identity checks, asset checksum
|
|
164
|
+
verification, and local caching. NeurOn may keep its existing scheduling and
|
|
165
|
+
rate-limit policy while replacing duplicate parsing and integrity logic with
|
|
166
|
+
these functions.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { EngineId, HuggingFaceSelection, JsonObject, LoadedCatalogSources, ModelCatalogSnapshot, ResolvedModelVariant } from "./types.js";
|
|
2
|
+
import { type HuggingFaceResolveOptions } from "./huggingface.js";
|
|
3
|
+
export interface RefreshCatalogOptions extends HuggingFaceResolveOptions {
|
|
4
|
+
previous?: ModelCatalogSnapshot | undefined;
|
|
5
|
+
now?: (() => Date) | undefined;
|
|
6
|
+
}
|
|
7
|
+
export interface ResolveVariantOptions {
|
|
8
|
+
engine: EngineId;
|
|
9
|
+
repository?: string | undefined;
|
|
10
|
+
quant?: string | undefined;
|
|
11
|
+
modelRoot?: string | undefined;
|
|
12
|
+
useNvfp4?: boolean | undefined;
|
|
13
|
+
overrides?: JsonObject | undefined;
|
|
14
|
+
}
|
|
15
|
+
export declare function loadCatalogSources(root: string): Promise<LoadedCatalogSources>;
|
|
16
|
+
export declare function listHuggingFaceSelections(sources: LoadedCatalogSources): HuggingFaceSelection[];
|
|
17
|
+
export declare function refreshModelCatalog(root: string, options?: RefreshCatalogOptions): Promise<{
|
|
18
|
+
catalog: ModelCatalogSnapshot;
|
|
19
|
+
reused_previous: boolean;
|
|
20
|
+
}>;
|
|
21
|
+
export declare function resolveModelVariant(catalog: ModelCatalogSnapshot, modelId: string, options: ResolveVariantOptions): ResolvedModelVariant;
|
|
22
|
+
/** Resolve either a canonical PreFer model id or one unique authored alias. */
|
|
23
|
+
export declare function resolveCatalogModelId(catalog: ModelCatalogSnapshot, modelId: string): string;
|
|
24
|
+
export declare function listModelVariants(catalog: ModelCatalogSnapshot, modelId: string, engine?: EngineId): ResolvedModelVariant[];
|
|
25
|
+
export declare function validateModelCatalog(value: unknown): asserts value is ModelCatalogSnapshot;
|
|
26
|
+
export declare function readModelCatalog(path: string): Promise<ModelCatalogSnapshot>;
|
|
27
|
+
//# sourceMappingURL=catalog.d.ts.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