gpu-engine 0.0.0-stage → 0.0.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/LICENSE +21 -0
- package/README.md +96 -2
- package/SPEC.md +988 -0
- package/THIRD_PARTY_NOTICES.md +29 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +4 -0
- package/dist/harness.d.mts +132 -0
- package/dist/harness.mjs +1 -0
- package/dist/index.d.mts +98 -0
- package/dist/index.mjs +1 -0
- package/dist/load-o_thEAKC.mjs +258 -0
- package/dist/scaffold-CY5xhy-V.mjs +106 -0
- package/dist/types-BwigqFwr.d.mts +868 -0
- package/docs/apps.md +108 -0
- package/docs/cli.md +126 -0
- package/docs/data.md +101 -0
- package/docs/diagnostics.md +509 -0
- package/docs/harness.md +191 -0
- package/docs/layers.md +249 -0
- package/docs/measurements/auto-threshold.json +335 -0
- package/docs/measurements/auto-threshold.md +56 -0
- package/docs/measurements/real-gpu-2026-11-22.json +4718 -0
- package/docs/measurements/real-gpu-2026-11-22.md +75 -0
- package/docs/runtime.md +112 -0
- package/docs/sealed-test-set.md +107 -0
- package/docs/weights-format.md +138 -0
- package/llms.txt +24 -0
- package/package.json +73 -3
- package/skills/gpu-engine/SKILL.md +117 -0
- package/templates/common/AGENTS.md +27 -0
- package/templates/common/github/workflows/ci.yml +35 -0
- package/templates/common/gitignore +3 -0
- package/templates/common/package.template.json +27 -0
- package/templates/common/tsconfig.template.json +17 -0
- package/templates/pooled/NEW_MODEL_NAME.eval.ts +93 -0
- package/templates/pooled/NEW_MODEL_NAME.model.ts +11 -0
- package/templates/pooled/SPEC.md +31 -0
- package/templates/pooled/src/decode.ts +10 -0
- package/templates/pooled/src/index.ts +44 -0
- package/templates/pooled/src/weights.ts +4 -0
- package/templates/retrieve/NEW_MODEL_NAME.eval.ts +149 -0
- package/templates/retrieve/NEW_MODEL_NAME.model.ts +12 -0
- package/templates/retrieve/SPEC.md +33 -0
- package/templates/retrieve/data/table.jsonl +16 -0
- package/templates/retrieve/src/decode.ts +9 -0
- package/templates/retrieve/src/index.ts +45 -0
- package/templates/retrieve/src/table.ts +21 -0
- package/templates/retrieve/src/weights.ts +4 -0
- package/templates/tag/NEW_MODEL_NAME.eval.ts +114 -0
- package/templates/tag/NEW_MODEL_NAME.model.ts +11 -0
- package/templates/tag/SPEC.md +31 -0
- package/templates/tag/src/decode.ts +25 -0
- package/templates/tag/src/index.ts +44 -0
- package/templates/tag/src/weights.ts +4 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
Code copied or closely adapted from other projects is listed here with its project, author, licence, the file it went into and what was taken. Ideas taken without code are credited in SPEC.md section 13 and need no entry.
|
|
4
|
+
|
|
5
|
+
Both projects below are under the MIT License. Its permission notice, which applies to each copyright line below:
|
|
6
|
+
|
|
7
|
+
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
8
|
+
>
|
|
9
|
+
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
10
|
+
>
|
|
11
|
+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
12
|
+
|
|
13
|
+
## gpu-utils
|
|
14
|
+
|
|
15
|
+
- Project: https://github.com/AnandChowdhary/gpu-utils
|
|
16
|
+
- Author: Anand Chowdhary
|
|
17
|
+
- Licence: MIT, Copyright (c) 2026 Anand Chowdhary
|
|
18
|
+
- Into: `src/runtime/program.ts`
|
|
19
|
+
- Taken from `packages/runtime/src/program.ts`: compiling each pass into a compute pipeline inside a validation error scope, uploading buffers padded to a multiple of 16 bytes (at least 16), encoding every dispatch into one compute pass of one command encoder, and reading the result back through a `MAP_READ` staging buffer.
|
|
20
|
+
- Taken from `packages/runtime/src/gpu.ts`: the buffer usage flags inlined as numbers, so the module touches no WebGPU global at import time.
|
|
21
|
+
- Changed here: one explicit bind group layout for the fixed bindings instead of `auto` layouts, and ping-pong activation buffers between ops.
|
|
22
|
+
|
|
23
|
+
## gpu-icons-search
|
|
24
|
+
|
|
25
|
+
- Project: https://github.com/antfu/gpu-icons-search
|
|
26
|
+
- Author: Anthony Fu
|
|
27
|
+
- Licence: MIT, Copyright (c) 2025-PRESENT Anthony Fu <https://github.com/antfu>
|
|
28
|
+
- Into: `test/helpers/gpu-rig.ts`, `src/harness/parity.ts`, `src/runtime/webgpu.ts`
|
|
29
|
+
- Taken from `training/src/gpu.ts`: opening a Dawn device in Node with `create([])` from the `webgpu` package while keeping that instance referenced, so garbage collection cannot crash the process (`gpu-rig.ts` keeps it at module level, `parity.ts` one per `webgpu` package, and `webgpu.ts` asks the caller to keep it), and naming the adapter by joining its vendor, architecture and description.
|
package/dist/cli.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{H as e}from"./load-o_thEAKC.mjs";import{a as t,g as n,h as r,i,n as a,o,r as s,s as c,t as l,u}from"./scaffold-CY5xhy-V.mjs";import{resolve as d}from"node:path";const f={value:`path`,help:`model package folder (default: the working directory)`},p={new:{run:a,usage:`new <name> --head tag|pooled|retrieve [--dir <path>]`,summary:`scaffold a model package: model and eval files, decode, shipped entry, AGENTS.md, SPEC.md, skill, CI`,positionals:[`name`],flags:{head:{value:`kind`,values:[`tag`,`pooled`,`retrieve`],required:!0,help:`head kind of the model`},dir:{value:`path`,help:`folder to create the package in (default: the working directory)`}}},loop:{run:c,usage:`loop [--log "<idea>"] [--status kept|dropped] [--regenerate train|dev|train,dev] [--fail [--set <name>]] [--mark kept|dropped] [--dir <path>]`,summary:`data, checks, train, dev table with baselines and oracle, gate; appends a try`,positionals:[],flags:{log:{value:`idea`,help:`what this try changes, written to tries.jsonl`},status:{value:`status`,values:[`kept`,`dropped`],help:`mark the try as kept or dropped`},regenerate:{value:`sets`,help:`rewrite train and/or dev from their generators and lock entries, never test`},fail:{excludes:[`log`,`status`,`regenerate`],help:`list dev misses only`},set:{value:`name`,needs:`fail`,help:`with --fail, one dev set`},mark:{value:`status`,values:[`kept`,`dropped`],help:`train nothing; mark the last try kept or dropped`},dir:f}},promote:{run:o,usage:`promote [--verify] [--seal [--key-out <path>]] [--scan] [--dir <path>]`,summary:`the only command that reads the test set: scores, gates and writes the promoted model`,positionals:[],flags:{verify:{excludes:[`seal`,`key-out`],help:`check the committed promotion without reading test data (the CI gate)`},seal:{help:`encrypt the test set so only CI can read it (level 3)`},"key-out":{value:`path`,needs:`seal`,help:`with --seal, where to write the key (default: outside the working tree)`},scan:{excludes:[`verify`,`seal`,`key-out`],help:`scan the files the promote workflow commits for test inputs and repair them`},dir:f}},parity:{run:s,usage:`parity [--dir <path>]`,summary:`trainer = CPU = WGSL on dev and edge fixtures; writes parity.json`,positionals:[],flags:{dir:f}},inspect:{run:i,usage:`inspect "<text>" [--dir <path>]`,summary:`tokens, feature rows, raw output, decoded result, backend and reason`,positionals:[`text`],flags:{dir:f}},doctor:{run:t,usage:`doctor [--dir <path>]`,summary:`every static check, each finding with its code, why and fix`,positionals:[],flags:{dir:f}},build:{run:u,usage:`build [--dir <path>]`,summary:`dist/index.mjs, one module that imports nothing, and its types in dist/index.d.mts`,positionals:[],flags:{dir:f}}},m=[`new`,`loop`,`promote`,`parity`,`inspect`,`doctor`,`build`];function h(e){return Object.hasOwn(p,e)}function g(){let e=Math.max(...m.map(e=>e.length));return[`Usage: gpu-engine <command> [arguments]`,``,`Commands:`,...m.map(t=>` ${t.padEnd(e)} ${p[t].summary}`),``,"Run `gpu-engine <command> --help` for its flags, and `gpu-engine --version` for the version.","After a lone `--`, every argument is text, even one starting with `--`."].join(`
|
|
3
|
+
`)}function _(e){let t=p[e],n=Object.entries(t.flags).map(([e,{value:t,help:n}])=>` ${(t===void 0?`--${e}`:`--${e} <${t}>`).padEnd(22)} ${n}`);return[`Usage: gpu-engine ${t.usage}`,``,t.summary,``,`Flags:`,...n].join(`
|
|
4
|
+
`)}function v(e){return e.startsWith(`--`)||e===`-h`}function y(e,t){let n=p[e],i=[],a={},o=!1,s=!1;for(let c=0;c<t.length;c++){let l=t[c]??``;if(s){i.push(l);continue}if(l===`--`){s=!0;continue}if(l===`--help`||l===`-h`){o=!0;continue}if(!l.startsWith(`--`)){i.push(l);continue}let u=l.indexOf(`=`),d=u===-1?l.slice(2):l.slice(2,u),f=Object.hasOwn(n.flags,d)?n.flags[d]:void 0;if(f===void 0)throw r(`CLI_FLAG_INVALID`,`\`${e}\` has no flag --${d}`);if(Object.hasOwn(a,d))throw r(`CLI_FLAG_INVALID`,`--${d} is given twice`);if(f.value===void 0){if(u!==-1)throw r(`CLI_FLAG_INVALID`,`--${d} takes no value`);a[d]=!0;continue}let p;if(u===-1){if(c++,p=t[c],p!==void 0&&v(p))throw r(`CLI_FLAG_INVALID`,`--${d} needs a value <${f.value}>, got the flag ${p}; write --${d}=${p} for that text`)}else p=l.slice(u+1);if(p===void 0)throw r(`CLI_FLAG_INVALID`,`--${d} needs a value <${f.value}>`);if(f.values!==void 0&&!f.values.includes(p))throw r(`CLI_FLAG_INVALID`,`--${d} must be one of ${f.values.join(`, `)}`);a[d]=p}if(o)return{positionals:i,flags:a,help:o};for(let[t,i]of Object.entries(n.flags)){let n=Object.hasOwn(a,t);if(i.required===!0&&!n)throw r(`CLI_FLAG_INVALID`,`\`${e}\` needs --${t} <${i.value??`value`}>`);if(!n)continue;if(i.needs!==void 0&&!Object.hasOwn(a,i.needs))throw r(`CLI_FLAG_INVALID`,`--${t} needs --${i.needs}`);let o=i.excludes?.find(e=>Object.hasOwn(a,e));if(o!==void 0)throw r(`CLI_FLAG_INVALID`,`--${t} cannot be combined with --${o}`)}if(i.length<n.positionals.length)throw r(`CLI_FLAG_INVALID`,`\`${e}\` needs <${n.positionals[i.length]??`argument`}>`);if(i.length>n.positionals.length)throw r(`CLI_FLAG_INVALID`,`\`${e}\` takes ${n.positionals.length} argument(s), got ${i.length}`);return{positionals:i,flags:a,help:o}}const b={cwd:process.cwd(),print:e=>process.stdout.write(`${e}\n`),printError:e=>process.stderr.write(`${e}\n`)};async function x(t,i=b){let[a,...o]=t;if(a===void 0)return i.printError(g()),1;if(a===`--help`||a===`-h`)return i.print(g()),0;if(a===`--version`||a===`-v`)return i.print(await l()),0;try{if(!h(a))throw r(`CLI_COMMAND_UNKNOWN`,`unknown command \`${a}\``);let e=y(a,o);if(e.help)return i.print(_(a)),0;let t=typeof e.flags.dir==`string`?e.flags.dir:`.`,n={command:a,dir:d(i.cwd,t),positionals:e.positionals,flags:e.flags,print:i.print,printError:i.printError,ownsProcess:i===b};return await p[a].run(n)}catch(t){return t instanceof e?i.printError(n(t.diagnostic)):i.printError(t instanceof Error?t.message:String(t)),1}}process.exitCode=await x(process.argv.slice(2));export{};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { $ as PooledClassHead, A as GateFile, At as TriesRow, B as Layer, C as EvalSets, Ct as TensorShape, D as FeatureRows, Dt as TrainCheckpoint, E as FeatureRow, Et as TokensInput, F as Head, Ft as engineError, G as ModelInput, H as LoadOptions, I as HeadKind, It as formatDiagnostic, J as OpKind, K as ModelOutput, L as HeadOutput, Lt as GpuEngineError, M as Gold, Mt as DiagnosticCode, N as GpuEntryPoint, Nt as diagnostic, O as FlagNames, Ot as TrainOptions, P as HashRow, Pt as diagnostics, Q as ParityOptions, R as Inspection, Rt as RunCode, S as EvalInput, St as TagHead, T as FeatureBlock, Tt as Token, U as Model, V as LayerKind, W as ModelDefinition, X as OpSpec, Y as OpPlan, Z as ParityFile, _ as Diagnostic, _t as SetKind, a as BackendRequest, at as Report, b as EvalDefinition, bt as ShipOptions, c as CanonicalDefinition, ct as RowLayout, d as CommandName, dt as ScoreTable, et as PooledValuesHead, f as ConvLayer, ft as ScoredModel, g as DevScorer, gt as SetData, h as DenseLayer, ht as SeedRun, i as Backend, it as ReadsRow, j as GateLine, jt as WeightsFile, k as FlagRow, kt as TrainResult, l as Command, lt as RunError, m as DatasetGenerator, mt as SealedSet, n as Availability, nt as PromotedEntry, o as BiScanLayer, ot as RetrieveHead, p as DatasetDefinition, pt as SealLevel, q as ModelPlan, r as AvailabilityOptions, rt as Random, s as Budgets, st as RetrieveMatch, t as Activation, tt as Project, u as CommandContext, ut as RunResult, v as EmbedLayer, vt as SetScores, w as Example, wt as TensorSpec, x as EvalGate, xt as TableRow, y as EncodedTensor, yt as ShapeRow, z as Int6Quantization } from "./types-BwigqFwr.mjs";
|
|
2
|
+
import "valibot";
|
|
3
|
+
/** Values an op's forward pass keeps for its backward pass, by name. */
|
|
4
|
+
type OpCache = Map<string, Float32Array | Int32Array>;
|
|
5
|
+
/** `Int32Array` feature rows for `embed`, `Float32Array` activations for every other op. */
|
|
6
|
+
type OpInput = Float32Array | Int32Array;
|
|
7
|
+
/** Shapes the WGSL template inlines as `const`. Only the token count arrives at run time. */
|
|
8
|
+
interface WgslIo {
|
|
9
|
+
readonly maxTokens: number;
|
|
10
|
+
/** The widest activation in the model: scratch and `temp` buffers hold `maxTokens * maxWidth` floats. */
|
|
11
|
+
readonly maxWidth: number;
|
|
12
|
+
}
|
|
13
|
+
/** One compute pass: a complete WGSL module with entry `main` and the fixed bindings above. */
|
|
14
|
+
interface WgslPass {
|
|
15
|
+
readonly label: string;
|
|
16
|
+
readonly code: string;
|
|
17
|
+
/** Workgroup counts for `n` tokens. */
|
|
18
|
+
dispatch(n: number): readonly [x: number, y: number, z: number];
|
|
19
|
+
}
|
|
20
|
+
interface ForwardOp<S extends OpSpec = OpSpec> {
|
|
21
|
+
/** Runs `n` tokens. Fills `cache` for the backward pass when given. */
|
|
22
|
+
forward(op: OpPlan<S>, w: Float32Array, x: OpInput, n: number, cache?: OpCache): Float32Array;
|
|
23
|
+
wgsl(op: OpPlan<S>, io: WgslIo): readonly WgslPass[];
|
|
24
|
+
}
|
|
25
|
+
interface HeadForwardOp<H extends Head = Head> extends ForwardOp<H> {
|
|
26
|
+
/** Turns logits for `n` tokens into the raw head output. A retrieve head's logits are one score per id in `ids`. */
|
|
27
|
+
decode(head: H, logits: Float32Array, n: number, ids?: readonly string[]): HeadOutput<H>;
|
|
28
|
+
}
|
|
29
|
+
type LayerOf<K extends Layer['kind']> = Extract<Layer, {
|
|
30
|
+
kind: K;
|
|
31
|
+
}>;
|
|
32
|
+
type ForwardRegistry = { readonly [K in Layer['kind']]: ForwardOp<LayerOf<K>>; };
|
|
33
|
+
type HeadOf<K extends Head['kind']> = Extract<Head, {
|
|
34
|
+
kind: K;
|
|
35
|
+
}>;
|
|
36
|
+
type HeadForwardRegistry = { readonly [K in Head['kind']]: HeadForwardOp<HeadOf<K>>; };
|
|
37
|
+
/** Examples per split for one training run, and the table a retrieve head scores against. */
|
|
38
|
+
interface TrainData {
|
|
39
|
+
readonly train: readonly Example[];
|
|
40
|
+
readonly dev: readonly Example[];
|
|
41
|
+
/** Required for a retrieve head (`RUN_TABLE_MISSING`), ignored by other heads. */
|
|
42
|
+
readonly table?: readonly TableRow[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Trains every seed in turn inside the wall-clock budget and returns the best dev checkpoint of the best seed,
|
|
46
|
+
* quantized when the definition has `quant`. `score` judges weights on dev, higher is better; it defaults to minus the
|
|
47
|
+
* mean quantized dev loss. A retrieve head needs `data.table` and `options.negatives`. `onSeed` is called with each
|
|
48
|
+
* seed's run as it finishes, its index in `options.seeds` and the seed count.
|
|
49
|
+
*/
|
|
50
|
+
export declare function train(definition: ModelDefinition, data: TrainData, options: TrainOptions, score?: DevScorer, onSeed?: (run: SeedRun, index: number, count: number) => void): Promise<TrainResult>;
|
|
51
|
+
/** Hashes, counts and fingerprints of the test set. Never text. */
|
|
52
|
+
interface SealedDigest {
|
|
53
|
+
/** SHA-256 per test file, keyed by its path relative to the package. A sealed file is hashed as it is stored. */
|
|
54
|
+
readonly files: Readonly<Record<string, string>>;
|
|
55
|
+
/** The sealed (`.enc`) files among `files`. Their rows are not counted and not fingerprinted. */
|
|
56
|
+
readonly sealed: readonly string[];
|
|
57
|
+
/** Non-empty rows per plaintext file. */
|
|
58
|
+
readonly examples: Readonly<Record<string, number>>;
|
|
59
|
+
/** Rows per file that are not JSON or not `{ input, gold }`. */
|
|
60
|
+
readonly invalid: Readonly<Record<string, number>>;
|
|
61
|
+
/** Sorted, distinct fingerprints of every input text, group name and `vocab` word. */
|
|
62
|
+
readonly fingerprints: {
|
|
63
|
+
readonly inputs: readonly string[];
|
|
64
|
+
readonly groups: readonly string[];
|
|
65
|
+
readonly vocabulary: readonly string[];
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/** The ops a forward pass runs. Tests pass fake ops; everything else uses `defaultOps`. */
|
|
69
|
+
interface OpRegistry {
|
|
70
|
+
readonly layers: ForwardRegistry;
|
|
71
|
+
readonly heads: HeadForwardRegistry;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Walks the plan over `n` tokens of feature rows (`rows[t * plan.slots + s]`) and returns the logits: `n * outWidth`
|
|
75
|
+
* values for a tag head, `outWidth` for a pooled or retrieve head. Fills `caches[i]` for op `i` when given.
|
|
76
|
+
*/
|
|
77
|
+
export declare function forward(modelPlan: ModelPlan, weights: Float32Array, rows: Int32Array, n: number, caches?: OpCache[], ops?: OpRegistry): Float32Array;
|
|
78
|
+
/** The plan of a definition: ops, tensor offsets, parameter count, multiply-adds and hash. Checks the definition first. */
|
|
79
|
+
export declare function plan(definition: CanonicalDefinition): ModelPlan;
|
|
80
|
+
/** Quantizes a weights array into the tensors of a weights file: int6 when the definition has `quant`, else float32. */
|
|
81
|
+
export declare function toWeightsFile(modelPlan: ModelPlan, weights: Float32Array): WeightsFile;
|
|
82
|
+
/** The float32 weights array the forward pass reads. Throws `WEIGHTS_DEFINITION_MISMATCH` when the file does not fit the plan. */
|
|
83
|
+
export declare function dequantize(file: WeightsFile, modelPlan: ModelPlan): Float32Array;
|
|
84
|
+
/** Writes a weights file. `encode(decode(bytes))` is byte-identical. */
|
|
85
|
+
export declare function encode(file: WeightsFile): Uint8Array;
|
|
86
|
+
/**
|
|
87
|
+
* Reads a weights file and checks it against the plan of the definition it carries.
|
|
88
|
+
* Throws `WEIGHTS_FORMAT_INVALID`, `WEIGHTS_VERSION_UNSUPPORTED` or `WEIGHTS_DEFINITION_MISMATCH`.
|
|
89
|
+
*/
|
|
90
|
+
export declare function decode(bytes: Uint8Array): WeightsFile;
|
|
91
|
+
/** `gpu-engine build`: prints each file it wrote with its bytes and Brotli bytes. */
|
|
92
|
+
export declare function runBuild(ctx: CommandContext): Promise<number>;
|
|
93
|
+
/** Runs every static check and prints each finding with its code, why and fix. Exits 1 on any finding. */
|
|
94
|
+
export declare function runDoctor(ctx: CommandContext): Promise<number>;
|
|
95
|
+
/** Shows what the model does with one input. Never reads the test set. */
|
|
96
|
+
export declare function runInspect(ctx: CommandContext): Promise<number>;
|
|
97
|
+
/** Runs one try, with `--fail` lists the candidate's dev misses, or with `--mark` marks the last try. */
|
|
98
|
+
export declare function runLoop(ctx: CommandContext): Promise<number>;
|
|
99
|
+
/** A WebGPU entry point and the name of the adapter it found. Keep `gpu` referenced while models run on it. */
|
|
100
|
+
interface WebGpuEntry {
|
|
101
|
+
readonly gpu: GPU;
|
|
102
|
+
readonly adapter: string;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Compares backends on the promoted weights and writes `parity.json` and `MODEL_CARD.md`. Exit 1 on any difference.
|
|
106
|
+
* On an adapter that `softwareAdapter` does not name, the CPU and WGSL result is also the real GPU result. Tests
|
|
107
|
+
* inject `open` to name the adapter.
|
|
108
|
+
*/
|
|
109
|
+
export declare function runParity(ctx: CommandContext, open?: (dir: string) => Promise<WebGpuEntry>): Promise<number>;
|
|
110
|
+
/**
|
|
111
|
+
* Loads the one `*.model.ts` and one `*.eval.ts` in `dir`. Throws `PROJECT_FILE_MISSING`, `PROJECT_FILE_AMBIGUOUS`,
|
|
112
|
+
* `PROJECT_IMPORT_FAILED`, `PROJECT_EXPORT_INVALID`, or a `DEFINE_*` code when an export skipped `defineModel` or `defineEval`, or when a
|
|
113
|
+
* retrieve head's eval has no `train.negatives`. A retrieve head
|
|
114
|
+
* also gets the rows of its `eval.table` that parse (RH1); the data step reports a missing or broken table.
|
|
115
|
+
*/
|
|
116
|
+
export declare function loadProject(dir: string): Promise<Project>;
|
|
117
|
+
/**
|
|
118
|
+
* Promotes the candidate under the output mute (SPEC.md section 6, Output mute), installed before the package's code
|
|
119
|
+
* loads. With `--verify` checks the committed promotion without reading test data; with `--seal` seals the test set;
|
|
120
|
+
* with `--scan` scans the files the promote workflow commits.
|
|
121
|
+
*/
|
|
122
|
+
export declare function runPromote(ctx: CommandContext): Promise<number>;
|
|
123
|
+
/**
|
|
124
|
+
* The generated model card. Pure: the same report, parity file and definition give the same bytes. The definition's
|
|
125
|
+
* `quant` names the weights the scores come from.
|
|
126
|
+
*/
|
|
127
|
+
export declare function renderModelCard(report: Report, parity: ParityFile | null, definition: Pick<ModelDefinition, 'quant'>): string;
|
|
128
|
+
/** The generated results page: the score tables and the gate. Pure. */
|
|
129
|
+
export declare function renderResults(report: Report): string;
|
|
130
|
+
/** Scaffolds a new model package in `<--dir or the working directory>/<name>`. */
|
|
131
|
+
export declare function runNew(ctx: CommandContext): Promise<number>;
|
|
132
|
+
export { type Activation, type Availability, type AvailabilityOptions, type Backend, type BackendRequest, type BiScanLayer, type Budgets, type CanonicalDefinition, type Command, type CommandContext, type CommandName, type ConvLayer, type DatasetDefinition, type DatasetGenerator, type DenseLayer, type DevScorer, type Diagnostic, type DiagnosticCode, type EmbedLayer, type EncodedTensor, type EvalDefinition, type EvalGate, type EvalInput, type EvalSets, type Example, type FeatureBlock, type FeatureRow, type FeatureRows, type FlagNames, type FlagRow, type GateFile, type GateLine, type Gold, GpuEngineError, type GpuEntryPoint, type HashRow, type Head, type HeadKind, type HeadOutput, type Inspection, type Int6Quantization, type Layer, type LayerKind, type LoadOptions, type Model, type ModelDefinition, type ModelInput, type ModelOutput, type ModelPlan, type OpKind, type OpPlan, type OpSpec, type ParityFile, type ParityOptions, type PooledClassHead, type PooledValuesHead, type Project, type PromotedEntry, type Random, type ReadsRow, type Report, type RetrieveHead, type RetrieveMatch, type RowLayout, type RunCode, type RunError, type RunResult, type ScoreTable, type ScoredModel, type SealLevel, type SealedDigest, type SealedSet, type SeedRun, type SetData, type SetKind, type SetScores, type ShapeRow, type ShipOptions, type TableRow, type TagHead, type TensorShape, type TensorSpec, type Token, type TokensInput, type TrainCheckpoint, type TrainData, type TrainOptions, type TrainResult, type TriesRow, type WeightsFile, diagnostic, diagnostics, engineError, formatDiagnostic };
|
package/dist/harness.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,c as t,d as n,f as r,g as i,h as a,i as o,l as s,m as c,n as l,o as u,p as d,r as f,s as p,u as m}from"./scaffold-CY5xhy-V.mjs";import{H as h,L as g,f as _,h as v,m as y,o as b,p as x}from"./load-o_thEAKC.mjs";export{h as GpuEngineError,_ as decode,x as dequantize,d as diagnostic,c as diagnostics,y as encode,a as engineError,i as formatDiagnostic,b as forward,n as loadProject,g as plan,t as renderModelCard,s as renderResults,m as runBuild,e as runDoctor,o as runInspect,p as runLoop,l as runNew,f as runParity,u as runPromote,v as toWeightsFile,r as train};
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { $ as PooledClassHead, B as Layer, C as EvalSets, E as FeatureRow, Et as TokensInput, F as Head, G as ModelInput, H as LoadOptions, I as HeadKind, K as ModelOutput, L as HeadOutput, Lt as GpuEngineError, M as Gold, Mt as DiagnosticCode, N as GpuEntryPoint, Ot as TrainOptions, P as HashRow, Q as ParityOptions, R as Inspection, Rt as RunCode, S as EvalInput, St as TagHead, Tt as Token, U as Model, V as LayerKind, W as ModelDefinition, _ as Diagnostic, _t as SetKind, a as BackendRequest, b as EvalDefinition, bt as ShipOptions, et as PooledValuesHead, f as ConvLayer, h as DenseLayer, i as Backend, k as FlagRow, lt as RunError, m as DatasetGenerator, mt as SealedSet, n as Availability, o as BiScanLayer, ot as RetrieveHead, p as DatasetDefinition, r as AvailabilityOptions, rt as Random, s as Budgets, st as RetrieveMatch, t as Activation, ut as RunResult, v as EmbedLayer, w as Example, x as EvalGate, xt as TableRow, yt as ShapeRow, z as Int6Quantization } from "./types-BwigqFwr.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Types a model definition and checks it. Returns its argument unchanged. Throws `DEFINE_NET_ORDER`,
|
|
4
|
+
* `DEFINE_LAYER_SHAPE`, `DEFINE_HEAD_LABELS` or `DEFINE_BUDGET_EXCEEDED` with a fix.
|
|
5
|
+
*/
|
|
6
|
+
export declare function defineModel<const D extends ModelDefinition>(definition: D): D;
|
|
7
|
+
/**
|
|
8
|
+
* Types an evaluation definition from its model and checks it with `checkEval`. `model` is the model file's default
|
|
9
|
+
* export: it types `decode`'s head output and the input of `decode` and the baselines. With `decode`, its return type
|
|
10
|
+
* types `metric`, the baselines and the generators; without it, or with one that returns the head output, the head
|
|
11
|
+
* output does. Returns `definition` unchanged.
|
|
12
|
+
*/
|
|
13
|
+
export declare function defineEval<const D extends ModelDefinition, Output>(model: D, definition: EvalDefinition<Output, EvalInput<D>, ModelOutput<D>> & {
|
|
14
|
+
readonly decode: (raw: ModelOutput<D>, input: EvalInput<D>) => Output;
|
|
15
|
+
}): EvalDefinition<Output, EvalInput<D>, ModelOutput<D>>;
|
|
16
|
+
export declare function defineEval<const D extends ModelDefinition>(model: D, definition: EvalDefinition<ModelOutput<D>, EvalInput<D>, ModelOutput<D>>): EvalDefinition<ModelOutput<D>, EvalInput<D>, ModelOutput<D>>;
|
|
17
|
+
/** Types a dataset definition. Returns its argument unchanged. */
|
|
18
|
+
export declare function defineDataset<Output>(definition: DatasetDefinition<Output>): DatasetDefinition<Output>;
|
|
19
|
+
/** Feature row builders. `rowLayout` checks what they return (`DEFINE_FEATURE_ROW`). */
|
|
20
|
+
export declare const features: {
|
|
21
|
+
/** Token input: at most `max` tokens, each with the given feature rows. Keeps the rows' types, flag names included. */
|
|
22
|
+
tokens<const Rows extends readonly FeatureRow[]>(options: {
|
|
23
|
+
readonly max: number;
|
|
24
|
+
readonly rows: Rows;
|
|
25
|
+
}): TokensInput<Rows>;
|
|
26
|
+
/** Character class and length bucket: 2 slots over 13 embedding rows. */
|
|
27
|
+
shape(): ShapeRow;
|
|
28
|
+
/** `k` distinct FNV-1a rows of the lowercased token among `buckets` embedding rows. */
|
|
29
|
+
hash(options: {
|
|
30
|
+
readonly buckets: number;
|
|
31
|
+
readonly k: number;
|
|
32
|
+
}): HashRow;
|
|
33
|
+
/** One embedding row, on for a token when the caller's flag `name` is true for it. */
|
|
34
|
+
flag<const Name extends string>(options: {
|
|
35
|
+
readonly name: Name;
|
|
36
|
+
}): FlagRow<Name>;
|
|
37
|
+
};
|
|
38
|
+
/** Layer builders for the closed catalog. */
|
|
39
|
+
export declare const layers: {
|
|
40
|
+
/** Sums each token's feature rows into `size` values. The first layer, once. */
|
|
41
|
+
embed(options: {
|
|
42
|
+
readonly size: number;
|
|
43
|
+
}): EmbedLayer;
|
|
44
|
+
/** Mixes each token with its neighbours over `taps` (odd) positions, one kernel per channel. */
|
|
45
|
+
conv(options: {
|
|
46
|
+
readonly taps: number;
|
|
47
|
+
}): ConvLayer;
|
|
48
|
+
/** A gated scan of `size` channels in each direction; writes `2 * size` values per token. */
|
|
49
|
+
biScan(options: {
|
|
50
|
+
readonly size: number;
|
|
51
|
+
}): BiScanLayer;
|
|
52
|
+
/** A fully connected layer of `size` values with an activation. */
|
|
53
|
+
dense(options: {
|
|
54
|
+
readonly size: number;
|
|
55
|
+
readonly activation: Activation;
|
|
56
|
+
}): DenseLayer;
|
|
57
|
+
};
|
|
58
|
+
declare function pooled<const Labels extends readonly string[]>(options: {
|
|
59
|
+
readonly labels: Labels;
|
|
60
|
+
readonly outputs?: never;
|
|
61
|
+
}): PooledClassHead<Labels>;
|
|
62
|
+
declare function pooled(options: {
|
|
63
|
+
readonly outputs: number;
|
|
64
|
+
readonly labels?: never;
|
|
65
|
+
}): PooledValuesHead;
|
|
66
|
+
/** Head builders, one per head kind. Labels keep their literal types, so they type the result. */
|
|
67
|
+
export declare const heads: {
|
|
68
|
+
/** A label for every token. */
|
|
69
|
+
tag<const Labels extends readonly string[]>(options: {
|
|
70
|
+
readonly labels: Labels;
|
|
71
|
+
}): TagHead<Labels>;
|
|
72
|
+
/** One answer for the whole input: one of `labels`, or `outputs` numbers. */
|
|
73
|
+
pooled: typeof pooled;
|
|
74
|
+
/** Scores the input against each table row through one shared tower of `size` values. */
|
|
75
|
+
retrieve(options: {
|
|
76
|
+
readonly size: number;
|
|
77
|
+
}): RetrieveHead;
|
|
78
|
+
};
|
|
79
|
+
/** int6 quantization-aware training from `qatFrom` (a share of the run) on. */
|
|
80
|
+
export declare function int6(options: {
|
|
81
|
+
readonly qatFrom: number;
|
|
82
|
+
}): Int6Quantization;
|
|
83
|
+
/** Marks the test set. Only `promote` reads it. */
|
|
84
|
+
export declare function sealed(path: string): SealedSet;
|
|
85
|
+
/** Splits text into runs of letters and marks, runs of digits, and each other non-space character. */
|
|
86
|
+
export declare function tokenize(text: string): Token[];
|
|
87
|
+
/**
|
|
88
|
+
* Loads a weights file. Never rejects: a model that failed to load returns its load error from every `run`, and
|
|
89
|
+
* `inspect()` names it. The file carries its definition; `options.definition` types the result and must hash the same.
|
|
90
|
+
* A retrieve model needs `options.table`, whose ids type the ranking.
|
|
91
|
+
*/
|
|
92
|
+
export declare function loadModel<D extends ModelDefinition = ModelDefinition, Id extends string = string>(weights: Uint8Array | ArrayBuffer, options: LoadOptions<D, Id>): Promise<Model<D, Id>>;
|
|
93
|
+
/**
|
|
94
|
+
* Which backend `auto` would run a model of `options.definition` on, and the rule that chose it, without loading
|
|
95
|
+
* weights or opening a device. Never rejects.
|
|
96
|
+
*/
|
|
97
|
+
export declare function availability(options: AvailabilityOptions): Promise<Availability>;
|
|
98
|
+
export { type Activation, type Availability, type AvailabilityOptions, type Backend, type BackendRequest, type BiScanLayer, type Budgets, type ConvLayer, type DatasetDefinition, type DatasetGenerator, type DenseLayer, type Diagnostic, type DiagnosticCode, type EmbedLayer, type EvalDefinition, type EvalGate, type EvalInput, type EvalSets, type Example, type FeatureRow, type FlagRow, type Gold, GpuEngineError, type GpuEntryPoint, type HashRow, type Head, type HeadKind, type HeadOutput, type Inspection, type Int6Quantization, type Layer, type LayerKind, type LoadOptions, type Model, type ModelDefinition, type ModelInput, type ModelOutput, type ParityOptions, type PooledClassHead, type PooledValuesHead, type Random, type RetrieveHead, type RetrieveMatch, type RunCode, type RunError, type RunResult, type SealedSet, type SetKind, type ShapeRow, type ShipOptions, type TableRow, type TagHead, type Token, type TokensInput, type TrainOptions };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{H as GpuEngineError,t as availability,E as defineDataset,D as defineEval,O as defineModel,k as features,A as heads,j as int6,M as layers,n as loadModel,N as sealed,V as tokenize}from"./load-o_thEAKC.mjs";
|