gpu-engine 0.0.0 → 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.
Files changed (54) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +96 -2
  3. package/SPEC.md +988 -0
  4. package/THIRD_PARTY_NOTICES.md +29 -0
  5. package/dist/cli.d.mts +1 -0
  6. package/dist/cli.mjs +4 -0
  7. package/dist/harness.d.mts +132 -0
  8. package/dist/harness.mjs +1 -0
  9. package/dist/index.d.mts +98 -0
  10. package/dist/index.mjs +1 -0
  11. package/dist/load-o_thEAKC.mjs +258 -0
  12. package/dist/scaffold-CY5xhy-V.mjs +106 -0
  13. package/dist/types-BwigqFwr.d.mts +868 -0
  14. package/docs/apps.md +108 -0
  15. package/docs/cli.md +126 -0
  16. package/docs/data.md +101 -0
  17. package/docs/diagnostics.md +509 -0
  18. package/docs/harness.md +191 -0
  19. package/docs/layers.md +249 -0
  20. package/docs/measurements/auto-threshold.json +335 -0
  21. package/docs/measurements/auto-threshold.md +56 -0
  22. package/docs/measurements/real-gpu-2026-11-22.json +4718 -0
  23. package/docs/measurements/real-gpu-2026-11-22.md +75 -0
  24. package/docs/runtime.md +112 -0
  25. package/docs/sealed-test-set.md +107 -0
  26. package/docs/weights-format.md +138 -0
  27. package/llms.txt +24 -0
  28. package/package.json +68 -2
  29. package/skills/gpu-engine/SKILL.md +117 -0
  30. package/templates/common/AGENTS.md +27 -0
  31. package/templates/common/github/workflows/ci.yml +35 -0
  32. package/templates/common/gitignore +3 -0
  33. package/templates/common/package.template.json +27 -0
  34. package/templates/common/tsconfig.template.json +17 -0
  35. package/templates/pooled/NEW_MODEL_NAME.eval.ts +93 -0
  36. package/templates/pooled/NEW_MODEL_NAME.model.ts +11 -0
  37. package/templates/pooled/SPEC.md +31 -0
  38. package/templates/pooled/src/decode.ts +10 -0
  39. package/templates/pooled/src/index.ts +44 -0
  40. package/templates/pooled/src/weights.ts +4 -0
  41. package/templates/retrieve/NEW_MODEL_NAME.eval.ts +149 -0
  42. package/templates/retrieve/NEW_MODEL_NAME.model.ts +12 -0
  43. package/templates/retrieve/SPEC.md +33 -0
  44. package/templates/retrieve/data/table.jsonl +16 -0
  45. package/templates/retrieve/src/decode.ts +9 -0
  46. package/templates/retrieve/src/index.ts +45 -0
  47. package/templates/retrieve/src/table.ts +21 -0
  48. package/templates/retrieve/src/weights.ts +4 -0
  49. package/templates/tag/NEW_MODEL_NAME.eval.ts +114 -0
  50. package/templates/tag/NEW_MODEL_NAME.model.ts +11 -0
  51. package/templates/tag/SPEC.md +31 -0
  52. package/templates/tag/src/decode.ts +25 -0
  53. package/templates/tag/src/index.ts +44 -0
  54. package/templates/tag/src/weights.ts +4 -0
@@ -0,0 +1,509 @@
1
+ # Diagnostics
2
+
3
+ Every code gpu-engine reports, with why it happens and how to fix it. Generated from `src/errors.ts`, which adds the harness codes to the run-time codes in `src/runtime-errors.ts`, by `pnpm docs:diagnostics`; do not edit by hand. `gpu-engine doctor` prints the same why and fix under each finding. Messages name files and counts, never examples.
4
+
5
+ ## Definition, thrown by `defineModel` and `defineEval`
6
+
7
+ ### DEFINE_NET_ORDER
8
+
9
+ Why: `net` must start with exactly one `embed` layer, and `embed` may not appear anywhere else.
10
+
11
+ Fix: Put one `layers.embed({ size })` first in `net` and remove any other `embed` layer.
12
+
13
+ ### DEFINE_LAYER_SHAPE
14
+
15
+ Why: A layer has a size, tap count or activation it cannot run with.
16
+
17
+ Fix: Use positive integer sizes, an odd `taps` of at least 1, and an activation from `relu`, `tanh` or `none`.
18
+
19
+ ### DEFINE_FEATURE_ROW
20
+
21
+ Why: The token input cannot be featurized: it is not `features.tokens(...)`, `max` or `buckets` is not a positive integer, `k` is outside 1 to `buckets`, `rows` is empty or has an unknown kind, a flag name is empty, or a shape row or a flag name repeats.
22
+
23
+ Fix: Give `features.tokens` a positive integer `max` and at least one row, keep `k` between 1 and `buckets`, use one `features.shape()` and distinct non-empty flag names.
24
+
25
+ ### DEFINE_HEAD_LABELS
26
+
27
+ Why: The head cannot be built from its labels: fewer than two labels, a duplicate label, or both or neither of `labels` and `outputs`.
28
+
29
+ Fix: Give the head two or more distinct `labels`, or for a pooled values head only `outputs`.
30
+
31
+ ### DEFINE_BUDGET_EXCEEDED
32
+
33
+ Why: The layers already exceed a budget before any training: multiply-adds per token, or a packed int6 size that cannot fit the Brotli budget.
34
+
35
+ Fix: Shrink a layer (embed size, scan size, dense size, hash buckets) or raise the budget in `budgets`.
36
+
37
+ ### DEFINE_QUANT_INVALID
38
+
39
+ Why: `quant` is not int6 quantization with `qatFrom` a finite share of the run from 0 to 1.
40
+
41
+ Fix: Write `quant: int6({ qatFrom })` with `qatFrom` from 0 to 1, such as 0.7, or leave `quant` out for float32 weights.
42
+
43
+ ### DEFINE_BUDGET_INVALID
44
+
45
+ Why: A budget is not a positive integer, so no size or multiply-add count can be compared against it.
46
+
47
+ Fix: Give `budgets.brotliBytes` and `budgets.macsPerToken` positive integers, such as `{ brotliBytes: 5_000, macsPerToken: 3_200 }`.
48
+
49
+ ### DEFINE_NAME_INVALID
50
+
51
+ Why: The model name names the weights file, `weights/<name>.bin`, and the package, so it must be a lowercase name that cannot leave the `weights/` folder.
52
+
53
+ Fix: Use lowercase letters, digits and `-`, starting with a letter, at most 64 characters, such as `unit-phrases`.
54
+
55
+ ### DEFINE_DATA_INVALID
56
+
57
+ Why: `data` cannot generate or check the sets: `seed` is not a safe integer, a `minSize` count is not a positive integer, or a `generate` entry is not a function.
58
+
59
+ Fix: Write `defineDataset({ seed: 1, minSize: { train, dev, test } })` with positive integer counts, and give `generate` only functions `(random) => examples`.
60
+
61
+ ### DEFINE_TRAIN_INVALID
62
+
63
+ Why: `train` cannot run: `seeds` is empty, repeats a seed or holds a non-integer, `epochs` or `batch` is not a positive integer, `learningRate` or `budgetSeconds` is not a finite number above 0, `warmup` is outside 0 up to 1, or `negatives` is not a positive integer (a retrieve head needs it).
64
+
65
+ Fix: Write every option out, such as `{ seeds: [1, 2, 3], epochs: 20, batch: 32, learningRate: 0.01, warmup: 0.1, budgetSeconds: 40 }`, and add `negatives: 8` for a retrieve head.
66
+
67
+ ### DEFINE_GATE_INVALID
68
+
69
+ Why: `gate` cannot compare scores: `floors` is not `promoted`, or `noise` is not a finite number of at least 0.
70
+
71
+ Fix: Write `gate: { floors: 'promoted', noise }` with `noise` at or above the measured seed spread, such as 0.05.
72
+
73
+ ### DEFINE_PARITY_INVALID
74
+
75
+ Why: `parity` is not an object, or its `tolerance` is not a finite number of at least 0, so no logit difference can be compared with it.
76
+
77
+ Fix: Write `parity: { tolerance: 1e-3 }`, and raise it only with a measured reason.
78
+
79
+ ### DEFINE_SHIP_INVALID
80
+
81
+ Why: `ship` is present, and `brotliBytes` is not a positive integer or `files` is not a non-empty list of paths.
82
+
83
+ Fix: Write `ship: { brotliBytes: 40_000, files: ['dist/index.mjs'] }`, or leave `ship` out.
84
+
85
+ ### DEFINE_EVAL_INVALID
86
+
87
+ Why: The eval cannot score: `metric` is not a function, `decode` is not a function, or `baselines` is not an object of functions.
88
+
89
+ Fix: Give `metric: (pred, gold) => number`, an optional `decode: (raw, input) => result`, and `baselines` as named functions `(input) => result` (`{}` for none).
90
+
91
+ ### DEFINE_SET_FOLDER
92
+
93
+ Why: Each set must live in its own folder: train in `data/train/`, dev in `data/dev/`, test in `data/test/`, each path written plainly, without `.` or `..` segments. The retrieve table lives inside the package, outside those folders.
94
+
95
+ Fix: Move the files and point `sets` at `data/train/*.jsonl`, `data/dev/*.jsonl` and `sealed('data/test/*.jsonl')`.
96
+
97
+ ### DEFINE_EVAL_MODEL
98
+
99
+ Why: `defineEval` takes the model definition first, so it can type the decode, the baselines and the metric from the head, and the eval definition second.
100
+
101
+ Fix: Import the model file's default export in the eval file and write `export default defineEval(model, { ... })`.
102
+
103
+ ## Weights file
104
+
105
+ ### WEIGHTS_FORMAT_INVALID
106
+
107
+ Why: The bytes are not a gpu-engine weights file: the magic, a length or a tensor record is wrong.
108
+
109
+ Fix: Load the `weights/<name>.bin` file written by `gpu-engine promote`, or re-export it with the byte layout in SPEC.md section 5.
110
+
111
+ ### WEIGHTS_VERSION_UNSUPPORTED
112
+
113
+ Why: The weights file uses a format version this runtime does not read.
114
+
115
+ Fix: Upgrade gpu-engine, or re-export the weights with the format version this runtime reads.
116
+
117
+ ### WEIGHTS_DEFINITION_MISMATCH
118
+
119
+ Why: The definition hash or a tensor shape in the file does not match the definition the file carries.
120
+
121
+ Fix: Load weights trained from this definition. In a model package a changed model file is expected while tuning: run `gpu-engine loop` to train a candidate from it, and promote once when the tuning is done, not after every try.
122
+
123
+ ## Runtime, returned by `run`
124
+
125
+ ### RUN_BACKEND_UNAVAILABLE
126
+
127
+ Why: The requested backend cannot run here: WebGPU is missing or no adapter was found.
128
+
129
+ Fix: Use `backend: 'auto'` or `'cpu'`, or pass a WebGPU entry point as `gpu` (in Node, the `webgpu` package).
130
+
131
+ ### RUN_GPU_FAILED
132
+
133
+ Why: The GPU device was lost or reported a validation error while running the model.
134
+
135
+ Fix: Retry with `backend: 'cpu'`, and run `gpu-engine parity` to check the WGSL output.
136
+
137
+ ### RUN_INPUT_INVALID
138
+
139
+ Why: The input is not a string or a `{ text, flags }` object, or a flag list does not have one entry per token.
140
+
141
+ Fix: Pass a string, or `{ text, flags }` where each flag array has one boolean per token of `text`.
142
+
143
+ ### RUN_OUTPUT_NONFINITE
144
+
145
+ Why: The model produced a logit or a score that is not a finite number, so decoding it would give a label chosen by accident or `Infinity`.
146
+
147
+ Fix: Check the weights file with `gpu-engine parity`; weights this large overflow float32, so retrain with a lower `train.learningRate`.
148
+
149
+ ### RUN_FAILED
150
+
151
+ Why: The model loaded, but running it failed for a reason no other run code covers, such as an op that throws.
152
+
153
+ Fix: Run `gpu-engine inspect "<text>"` on the same input to see which step fails, and report it with the weights file.
154
+
155
+ ### RUN_MODEL_DESTROYED
156
+
157
+ Why: The model was destroyed with `model.destroy()`, which freed its GPU buffers and device, so it cannot run again.
158
+
159
+ Fix: Call `destroy()` only when the model is no longer needed, or load the weights again with `loadModel`.
160
+
161
+ ### RUN_TABLE_MISSING
162
+
163
+ Why: A retrieve model needs a table of rows to score the input against.
164
+
165
+ Fix: Pass `table` to `loadModel`: the `{ id, text }` rows the model ranks.
166
+
167
+ ## Loading a model package
168
+
169
+ ### PROJECT_FILE_MISSING
170
+
171
+ Why: The folder has no `*.model.ts` or no `*.eval.ts` file.
172
+
173
+ Fix: Run the command in the model package folder, pass `--dir <path>`, or create the file with `gpu-engine new`.
174
+
175
+ ### PROJECT_FILE_AMBIGUOUS
176
+
177
+ Why: The folder has more than one `*.model.ts` or more than one `*.eval.ts` file.
178
+
179
+ Fix: Keep one model file and one eval file per package, or pass `--dir` to the package you mean.
180
+
181
+ ### PROJECT_EXPORT_INVALID
182
+
183
+ Why: The model or eval file does not default-export the result of `defineModel` or `defineEval`.
184
+
185
+ Fix: Write `export default defineModel({ ... })` in the model file and `export default defineEval(model, { ... })` in the eval file.
186
+
187
+ ### PROJECT_IMPORT_FAILED
188
+
189
+ Why: The model or eval file threw while it was imported: a syntax error, a missing import, or code at the top level that fails.
190
+
191
+ Fix: Run `node <file>` to see the full error, fix the file, then run the command again.
192
+
193
+ ### PROJECT_STATE_INVALID
194
+
195
+ Why: A file the harness keeps for itself, `tries.jsonl` or `.gpu-engine/candidate.json`, does not parse or has another shape: a line a killed `loop` left half-written, a hand edit, or a file written by an older version.
196
+
197
+ Fix: For `tries.jsonl`, restore it from git or delete the broken line; the harness only appends to it. For `.gpu-engine/candidate.json`, run `gpu-engine loop` to write a fresh candidate.
198
+
199
+ ## Data and the sealed test set
200
+
201
+ ### DATA_ROW_INVALID
202
+
203
+ Why: A data row is not valid JSON or does not have the `{ input, gold }` shape the head needs.
204
+
205
+ Fix: Write one JSON object per line with `input` (text or `{ text, flags }`) and `gold` in the shape of the head.
206
+
207
+ ### DATA_LABEL_UNKNOWN
208
+
209
+ Why: A gold label is not one of the head labels.
210
+
211
+ Fix: Fix the label in the data, or add it to the head `labels` in the model file.
212
+
213
+ ### DATA_SET_MISSING
214
+
215
+ Why: One of the train, dev or test sets has no files.
216
+
217
+ Fix: Add JSONL files to the set folder, or declare a generator in `defineDataset` and run `gpu-engine loop` to write them.
218
+
219
+ ### DATA_SET_TOO_SMALL
220
+
221
+ Why: A set has fewer examples than `minSize` asks for.
222
+
223
+ Fix: Add examples or raise the generator count. Lower `minSize` only when the smaller set still measures the model.
224
+
225
+ ### DATA_SPLIT_OVERLAP
226
+
227
+ Why: The same example, after normalising case and whitespace, appears in two sets, so a score there measures memory.
228
+
229
+ Fix: Remove the shared examples from one of the sets. Change the test set only by hand, then delete its lock entry and rerun.
230
+
231
+ ### DATA_GROUP_SHARED
232
+
233
+ Why: A declared group appears in more than one set, so the split does not test anything new.
234
+
235
+ Fix: Move every example of the group into one set.
236
+
237
+ ### DATA_VOCAB_SHARED
238
+
239
+ Why: A declared vocabulary word appears in more than one set, so the model can pass by memorising words.
240
+
241
+ Fix: Split the vocabulary so each word belongs to one set, or drop the word from the `vocab` field of those rows when sharing it is intended.
242
+
243
+ ### DATA_HASH_CHANGED
244
+
245
+ Why: A data file no longer matches the hash recorded in `data.lock.json`.
246
+
247
+ Fix: Restore the file. If the change is intended, delete that set from `data.lock.json` by hand and rerun to record the new hash.
248
+
249
+ ### DATA_GENERATOR_CHANGED
250
+
251
+ Why: A train or dev generator no longer writes the file it wrote before. Generators only run into an empty folder, so without this check `loop` would keep training on the old rows and ignore the edit.
252
+
253
+ Fix: Run `gpu-engine loop --regenerate train` (or `dev`, or `train,dev`) to rewrite the file and its lock entry, or undo the generator change. The test set is never regenerated.
254
+
255
+ ### DATA_TEST_READ
256
+
257
+ Why: Something other than `promote` read or referenced the sealed test set.
258
+
259
+ Fix: Remove the reference. Only the `sealed('data/test/...')` call in the eval file may name the test folder, and only `gpu-engine promote` reads it.
260
+
261
+ ### DATA_TEST_PRINTED
262
+
263
+ Why: A test example or a test-only field was about to be printed or written to a file, or the package code wrote one into a file the promote workflow commits.
264
+
265
+ Fix: Report test results as per-set aggregates only. Tries rows hold dev scores only. Never print or write from `metric`, `decode` or a baseline.
266
+
267
+ ## Training, in `gpu-engine loop`
268
+
269
+ ### TRAIN_DIVERGED
270
+
271
+ Why: Every checkpoint of a seed holds a weight that is not finite, or scores a dev loss that is not finite: the loss stopped being finite and training never recovered, so there are no weights to keep.
272
+
273
+ Fix: Lower `train.learningRate` or raise `train.warmup`, then run `gpu-engine loop` again.
274
+
275
+ ## Budgets
276
+
277
+ ### BUDGET_BYTES_EXCEEDED
278
+
279
+ Why: The Brotli-compressed weights are larger than `budgets.brotliBytes`.
280
+
281
+ Fix: Shrink the model (hash buckets, layer sizes) or raise the budget.
282
+
283
+ ## Gate
284
+
285
+ ### GATE_FLOOR_FAILED
286
+
287
+ Why: A set scored below the last promoted score minus the gate noise.
288
+
289
+ Fix: Keep tuning on dev with `gpu-engine loop` until every set is back above its floor.
290
+
291
+ ### GATE_FILE_INVALID
292
+
293
+ Why: `gate.json` is not `{ level, promoted }` with `promoted` null or a promoted entry with dev and test scores.
294
+
295
+ Fix: Restore `gate.json` from history. Only `gpu-engine promote` and `promote --seal` write it.
296
+
297
+ ## Promote
298
+
299
+ ### PROMOTE_CANDIDATE_MISSING
300
+
301
+ Why: There is no candidate to promote.
302
+
303
+ Fix: Run `gpu-engine loop` first. It writes the candidate that `promote` scores.
304
+
305
+ ### PROMOTE_CANDIDATE_STALE
306
+
307
+ Why: The model definition or the data changed after the candidate was trained.
308
+
309
+ Fix: Run `gpu-engine loop` to train a fresh candidate, then promote.
310
+
311
+ ### PROMOTE_SCORE_FAILED
312
+
313
+ Why: `metric`, `decode` or a baseline threw while `promote` scored a test set, or the package code raised an unhandled promise rejection or an uncaught exception after the read. Its message is not shown, since it can quote a test example.
314
+
315
+ Fix: Make `metric`, `decode` and the baselines return a value for every input and gold the head can produce and start no promise they leave unhandled, check them on dev with `gpu-engine loop --fail`, then promote again.
316
+
317
+ ### PROMOTE_OUTSIDE_CI
318
+
319
+ Why: The test set is sealed at level 3, so `promote` only runs in CI.
320
+
321
+ Fix: Run the `promote` workflow in CI. It holds the key in the `GPU_ENGINE_TEST_KEY` secret.
322
+
323
+ ### PROMOTE_SCAN_FAILED
324
+
325
+ Why: `data.lock.json` at git `HEAD` (or in the working tree outside git) names no test file, so `promote --scan` has nothing to scan the committed files with. It changed nothing.
326
+
327
+ Fix: Run `gpu-engine loop` so the data step records the test set in `data.lock.json`, commit the lock, then scan again.
328
+
329
+ ## Level 3 sealing
330
+
331
+ ### SEAL_KEY_MISSING
332
+
333
+ Why: The test set is encrypted and no key was given.
334
+
335
+ Fix: Set `GPU_ENGINE_TEST_KEY` in the CI secret store. The key never goes into the repository.
336
+
337
+ ### SEAL_KEY_INVALID
338
+
339
+ Why: The key is not 64 hex characters, or it does not decrypt the sealed test set.
340
+
341
+ Fix: Set `GPU_ENGINE_TEST_KEY` to the key written by `gpu-engine promote --seal`.
342
+
343
+ ### SEAL_REFUSED
344
+
345
+ Why: `promote --seal` cannot seal this package: it is already at level 3, a sealed file or `.github/workflows/promote.yml` already exists, or the key path is inside the working tree or names a file that exists.
346
+
347
+ Fix: Seal once per package. Pass `--key-out` with a new file outside the repository, and move an existing promote workflow aside first.
348
+
349
+ ### SEAL_PLAINTEXT_FOUND
350
+
351
+ Why: The package is sealed at level 3, but a plaintext test file is in the test folder, where any agent can read it.
352
+
353
+ Fix: Delete the plaintext file. The sealed `.enc` file beside it holds the test set, and only the promote workflow in CI decrypts it.
354
+
355
+ ### SEAL_LOCK_INVALID
356
+
357
+ Why: The test entry of `data.lock.json` does not describe the sealed files: it is missing, names a file that is not sealed, or lacks a `plaintext` hash. A sealed set cannot be fingerprinted again without the key.
358
+
359
+ Fix: Restore `data.lock.json` and the `.enc` files from the commit that sealed them.
360
+
361
+ ### SEAL_GENERATOR_FOUND
362
+
363
+ Why: The eval file declares `generate.test`. With that generator and `seed`, anyone who can read the eval file rebuilds the sealed test rows without the key, so level 3 guarantees nothing.
364
+
365
+ Fix: Remove `test` from `defineDataset({ generate })`, or move the generator to a script outside the package, then seal or run `doctor` again. The test set it already wrote stays.
366
+
367
+ ### SEAL_WORKFLOW_MISSING
368
+
369
+ Why: The package is sealed at level 3, but `.github/workflows/promote.yml` is missing or does not run `gpu-engine promote` and `gpu-engine promote --scan` with `GPU_ENGINE_TEST_KEY`, so nothing can promote it safely.
370
+
371
+ Fix: Restore `.github/workflows/promote.yml` from the commit that sealed the test set. A workflow written before `promote --scan` existed: move it aside and run `promote --seal` on a fresh copy, or add the scan step before the commit step by hand.
372
+
373
+ ### SEAL_HISTORY_PLAINTEXT
374
+
375
+ Why: The test set is sealed now, but git history still holds the plaintext test files, so anyone with a clone can read the rows from an old commit.
376
+
377
+ Fix: Purge the plaintext files from every branch (`git filter-repo --invert-paths --path <file>`), force-push and replace every clone, or write a new test set that was never committed in plaintext and seal that. `docs/sealed-test-set.md` shows both.
378
+
379
+ ## `promote --verify`
380
+
381
+ ### VERIFY_SCORE_CHANGED
382
+
383
+ Why: Re-scoring the committed weights on dev does not give the scores in `report.json`.
384
+
385
+ Fix: Run `gpu-engine promote` again to write a report for these weights. Never edit `report.json` by hand.
386
+
387
+ ### VERIFY_WEIGHTS_CHANGED
388
+
389
+ Why: The committed weights do not match the hash in `report.json`.
390
+
391
+ Fix: Restore the promoted weights, or run `gpu-engine promote` again.
392
+
393
+ ### VERIFY_FILE_STALE
394
+
395
+ Why: A generated file (`MODEL_CARD.md`, `RESULTS.md`, `src/weights.ts`) does not match what the report regenerates.
396
+
397
+ Fix: Run `gpu-engine promote` again. Never edit generated files by hand.
398
+
399
+ ### VERIFY_READS_MISSING
400
+
401
+ Why: `reads.jsonl` has fewer test reads than the report counts.
402
+
403
+ Fix: Restore `reads.jsonl` from history. The read log is append-only.
404
+
405
+ ### VERIFY_REPORT_INVALID
406
+
407
+ Why: `report.json` is missing or is not the report `gpu-engine promote` writes.
408
+
409
+ Fix: Run `gpu-engine promote` to write it, or restore it from history. Never edit `report.json` by hand.
410
+
411
+ ## Parity
412
+
413
+ ### PARITY_ADAPTER_MISSING
414
+
415
+ Why: No WebGPU adapter was found, so the WGSL output cannot be compared.
416
+
417
+ Fix: Install the `webgpu` package in the model package (`npm install --save-dev webgpu@^0.6.2`) and a Vulkan driver (on Linux, `apt-get install mesa-vulkan-drivers` for lavapipe).
418
+
419
+ ### PARITY_DECODE_DIFFERS
420
+
421
+ Why: The WGSL and CPU outputs decode to different results on a fixture.
422
+
423
+ Fix: Find the layer that diverges with the layer tests in `test/gpu`, and fix its WGSL template.
424
+
425
+ ### PARITY_TOLERANCE_EXCEEDED
426
+
427
+ Why: The largest logit difference between WGSL and CPU is above `parity.tolerance`.
428
+
429
+ Fix: Fix the diverging WGSL template. Raise `parity.tolerance` only with a measured reason.
430
+
431
+ ## Ship checks
432
+
433
+ ### SHIP_SIZE_EXCEEDED
434
+
435
+ Why: The built model package, with its weights, is larger than `ship.brotliBytes` after Brotli.
436
+
437
+ Fix: Shrink the model or the decode code, or raise `ship.brotliBytes`.
438
+
439
+ ### SHIP_PACKAGE_INVALID
440
+
441
+ Why: The ship checks read what the package ships from `package.json` and `npm pack --dry-run --json`, and one of them is missing, does not parse or failed.
442
+
443
+ Fix: Run doctor in the model package folder, fix `package.json` until `npm pack --dry-run` lists its files, and check that `npm` is on the PATH.
444
+
445
+ ### SHIP_DEPENDENCY_FOUND
446
+
447
+ Why: The model package declares a runtime dependency (`dependencies`, `peerDependencies`, `optionalDependencies` or `bundleDependencies`), or a shipped script imports another module. The shipped model must have zero runtime dependencies.
448
+
449
+ Fix: Move the package to `devDependencies` and bundle what the model needs into the build with `npm run build`.
450
+
451
+ ### SHIP_BUILD_STALE
452
+
453
+ Why: The package has promoted weights, or a report that records a retrieve table, but no packed file holds those weights or that table, so the build predates the promotion and would ship another model than the one measured.
454
+
455
+ Fix: Run `npm run build` (`gpu-engine build`) after `gpu-engine promote` or a table change, then run doctor again.
456
+
457
+ ### SHIP_FILE_NOT_ALLOWED
458
+
459
+ Why: The packed model package contains a file outside `ship.files`.
460
+
461
+ Fix: Add the file to `files` in package.json only if it must ship, and list it in `ship.files`; otherwise exclude it.
462
+
463
+ ## Build, `gpu-engine build`
464
+
465
+ ### BUILD_SOURCE_UNSUPPORTED
466
+
467
+ Why: `gpu-engine build` bundles static ES module syntax into one module that runs in browsers, and a bundled file uses something it cannot bundle: a dynamic `import()`, an import with attributes, a JSON file, a Node built-in, an absolute path, an import cycle, TypeScript syntax that has no erasable form, an export a `let` or `var` holds (the bundle reads it once), or a top-level `await` (each module runs inside a function); or the declarations it wrote for an exported type would not typecheck.
468
+
469
+ Fix: Import with a static `import` from a relative path or an installed package, export data from a `.ts` file instead of JSON, export a `const` (or a function that returns the current value), move an `await` into an async function, keep Node-only code out of `src/index.ts` and what it imports, and export the types and symbols an exported type names.
470
+
471
+ ### BUILD_IMPORT_UNRESOLVED
472
+
473
+ Why: A module that `src/index.ts` reaches imports a file that does not exist or a package that is not installed, or the package exports no ES module entry for that path.
474
+
475
+ Fix: Check the path, with its `.ts` extension, or run `npm install`.
476
+
477
+ ### BUILD_TYPES_FAILED
478
+
479
+ Why: `gpu-engine build` writes `dist/index.d.mts` with the TypeScript checker, and TypeScript is not installed, the package has a type error, or an export is a kind the declarations cannot hold (a class, an enum or a namespace).
480
+
481
+ Fix: Install TypeScript (`npm install --save-dev typescript`), fix what `npx tsc -p .` reports, and export functions, constants, interfaces and type aliases from `src/index.ts`.
482
+
483
+ ## Scaffolding, `gpu-engine new`
484
+
485
+ ### NEW_NAME_INVALID
486
+
487
+ Why: The model name becomes the package name, the file names and the weights file name, so it must be a lowercase npm package name without a scope.
488
+
489
+ Fix: Use lowercase letters, digits and `-`, starting with a letter, at most 64 characters, such as `unit-phrases`.
490
+
491
+ ### NEW_TARGET_EXISTS
492
+
493
+ Why: `gpu-engine new` writes a fresh package and never overwrites a file, and the target folder already holds files.
494
+
495
+ Fix: Pick another name, pass `--dir` to create the package somewhere else, or remove the folder first.
496
+
497
+ ## Command line
498
+
499
+ ### CLI_COMMAND_UNKNOWN
500
+
501
+ Why: The command is not one of `new`, `loop`, `promote`, `parity`, `inspect`, `doctor` or `build`.
502
+
503
+ Fix: Run `gpu-engine --help` to see the commands.
504
+
505
+ ### CLI_FLAG_INVALID
506
+
507
+ Why: A flag is unknown for this command, is missing its value, is given twice, would be ignored, or cannot be combined with another flag given, or a required argument is missing.
508
+
509
+ Fix: Run `gpu-engine <command> --help` to see its arguments and flags.