doppler-gpu 0.4.9 → 0.4.10
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/CHANGELOG.md +19 -0
- package/README.md +62 -12
- package/package.json +18 -1
- package/src/gpu/device.js +100 -32
- package/src/tooling/runtime-optimization.d.ts +109 -0
- package/src/tooling/runtime-optimization.js +872 -0
- package/src/tooling-exports.shared.d.ts +19 -0
- package/src/tooling-exports.shared.js +11 -0
- package/src/version.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,25 @@ docs so the `0.1.x` line has one conventional npm-visible history surface.
|
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
+
## [0.4.10] - 2026-07-18
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- Unified duplicate runtime module instances behind one authoritative WebGPU
|
|
16
|
+
device state and one in-flight initialization, preventing concurrent model
|
|
17
|
+
handles from creating incompatible devices.
|
|
18
|
+
- Rejected tracked cross-device GPU buffers before native bind-group creation
|
|
19
|
+
and prevented stale device-loss callbacks from clearing a replacement device.
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
- Included the WGSL Writer V3 package and campaign schemas in the generated npm
|
|
24
|
+
source closure.
|
|
25
|
+
- Retained the experimental
|
|
26
|
+
`translategemma-4b-1b-enes-q4k-ehf16-af32` NativeKD2 EN/ES candidate first
|
|
27
|
+
shipped in `0.4.8`, without changing its weights, evidence boundary, or
|
|
28
|
+
promotion status. Version `0.4.10` makes no new translation-model claim.
|
|
29
|
+
|
|
11
30
|
## [0.4.9] - 2026-07-14
|
|
12
31
|
|
|
13
32
|
### Fixed
|
package/README.md
CHANGED
|
@@ -24,13 +24,13 @@ npx doppler-gpu
|
|
|
24
24
|
|
|
25
25
|
## Evidence
|
|
26
26
|
|
|
27
|
-
Doppler has
|
|
27
|
+
Doppler has higher steady-state inference throughput than Transformers.js in each
|
|
28
28
|
of the comparable browser WebGPU results indexed below.
|
|
29
29
|
|
|
30
|
-

|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
Text uses tok/s, embeddings use embedding/s, and reranking uses rerank/s;
|
|
33
|
+
higher is faster. Every comparison passes its declared workload
|
|
34
34
|
correctness gate. Model loading is separate: Transformers.js loads the Vulkan
|
|
35
35
|
embedding and reranker artifacts faster. The
|
|
36
36
|
[competition scoreboard](https://github.com/clocksmith/doppler/blob/main/docs/model-competition-scoreboard.md) links every
|
|
@@ -68,14 +68,64 @@ benchmark gates.
|
|
|
68
68
|
|
|
69
69
|
## How it works
|
|
70
70
|
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
71
|
+
```mermaid
|
|
72
|
+
flowchart TB
|
|
73
|
+
subgraph Propose["1 · Propose"]
|
|
74
|
+
direction LR
|
|
75
|
+
HUMAN["Engineer or optimizer"]
|
|
76
|
+
CANDIDATE["Candidate edit<br/>manifest · plan · WGSL"]
|
|
77
|
+
HUMAN --> CANDIDATE
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
subgraph Run["2 · Resolve and run"]
|
|
81
|
+
direction LR
|
|
82
|
+
ARTIFACT["RDRR artifact<br/>manifest · weights · tokenizer"]
|
|
83
|
+
REQUEST["Request + runtime profile"]
|
|
84
|
+
VALIDATE["Validate contracts"]
|
|
85
|
+
RESOLVE["Resolve execution graph<br/>kernel refs · session"]
|
|
86
|
+
LOAD["Load + bind<br/>GPU buffers · cache"]
|
|
87
|
+
DISPATCH["Dispatch WGSL<br/>prefill · decode · retrieval"]
|
|
88
|
+
OUTPUT["Tokens · embeddings · scores"]
|
|
89
|
+
|
|
90
|
+
ARTIFACT --> VALIDATE
|
|
91
|
+
REQUEST --> VALIDATE
|
|
92
|
+
CANDIDATE --> VALIDATE
|
|
93
|
+
VALIDATE --> RESOLVE --> LOAD --> DISPATCH --> OUTPUT
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
subgraph Verify["3 · Evidence disposes"]
|
|
97
|
+
direction LR
|
|
98
|
+
PARITY{"Parity gate<br/>correct vs reference"}
|
|
99
|
+
BENCH{"Benchmark gate<br/>comparable speed vs prior"}
|
|
100
|
+
RETAIN["Retain<br/>versioned lane + receipt"]
|
|
101
|
+
REJECT["Reject<br/>finding + negative result"]
|
|
102
|
+
|
|
103
|
+
OUTPUT --> PARITY
|
|
104
|
+
PARITY -- pass --> BENCH
|
|
105
|
+
PARITY -- mismatch --> REJECT
|
|
106
|
+
BENCH -- pass --> RETAIN
|
|
107
|
+
BENCH -- fail --> REJECT
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
RETAIN -. reusable asset .-> HUMAN
|
|
111
|
+
REJECT -. search memory .-> HUMAN
|
|
112
|
+
|
|
113
|
+
classDef proposal fill:#fff1f3,stroke:#ff6b7a,color:#08090c,stroke-width:2px;
|
|
114
|
+
classDef runtime fill:#eef4ff,stroke:#5d8dff,color:#08090c,stroke-width:2px;
|
|
115
|
+
classDef gate fill:#f7f1ff,stroke:#b98cff,color:#08090c,stroke-width:2px;
|
|
116
|
+
classDef accepted fill:#08090c,stroke:#5d8dff,color:#ffffff,stroke-width:3px;
|
|
117
|
+
classDef rejected fill:#fff1f3,stroke:#ff6b7a,color:#08090c,stroke-width:2px;
|
|
118
|
+
|
|
119
|
+
class HUMAN,CANDIDATE proposal;
|
|
120
|
+
class ARTIFACT,REQUEST,VALIDATE,RESOLVE,LOAD,DISPATCH,OUTPUT runtime;
|
|
121
|
+
class PARITY,BENCH gate;
|
|
122
|
+
class RETAIN accepted;
|
|
123
|
+
class REJECT rejected;
|
|
124
|
+
|
|
125
|
+
style Propose fill:#fffafa,stroke:#ff6b7a,stroke-width:1px
|
|
126
|
+
style Run fill:#f8faff,stroke:#5d8dff,stroke-width:1px
|
|
127
|
+
style Verify fill:#fcfaff,stroke:#b98cff,stroke-width:1px
|
|
128
|
+
linkStyle default stroke:#5d8dff,stroke-width:2px;
|
|
79
129
|
```
|
|
80
130
|
|
|
81
131
|
The full resolve, load, bind, dispatch, and readback flow lives in the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "doppler-gpu",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.10",
|
|
4
4
|
"description": "Browser-native WebGPU inference engine for local intent and inference loops",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -41,6 +41,23 @@
|
|
|
41
41
|
"training:wgsl:corpus": "node tools/build-wgsl-repair-corpus.js",
|
|
42
42
|
"training:wgsl:experiment": "node tools/run-wgsl-repair-experiment.js",
|
|
43
43
|
"training:wgsl:rollouts": "node tools/run-wgsl-repair-rollouts.js",
|
|
44
|
+
"training:wgsl:semantic": "node tools/run-wgsl-repair-semantic-harness.js",
|
|
45
|
+
"training:wgsl:writer:semantic": "node tools/run-wgsl-writer-semantic-harness.js",
|
|
46
|
+
"training:wgsl:writer:candidate": "node tools/run-wgsl-writer-candidate.js",
|
|
47
|
+
"training:wgsl:writer:corpus": "node tools/build-wgsl-writer-corpus.js",
|
|
48
|
+
"training:wgsl:writer:corpus:check": "node tools/build-wgsl-writer-corpus.js --check",
|
|
49
|
+
"training:wgsl:writer:corpus:qualify": "node tools/qualify-wgsl-writer-corpus.js",
|
|
50
|
+
"training:wgsl:writer:workloads:check": "node tools/materialize-wgsl-writer-v2-seed-workloads.js --check",
|
|
51
|
+
"training:wgsl:writer:train": "node tools/run-wgsl-writer-v2-training.js",
|
|
52
|
+
"training:wgsl:writer:evaluate": "node tools/run-wgsl-writer-v2-evaluation.js",
|
|
53
|
+
"training:wgsl:writer:select": "node tools/select-wgsl-writer-v2-seed.js",
|
|
54
|
+
"training:wgsl:writer:confirm": "node tools/finalize-wgsl-writer-v2-confirmation.js",
|
|
55
|
+
"training:wgsl:writer:parity": "node tools/run-wgsl-writer-v2-parity.js",
|
|
56
|
+
"training:wgsl:writer:result": "node tools/finalize-wgsl-writer-v2-result.js",
|
|
57
|
+
"training:wgsl:author:contract": "node tools/run-node-tests.js tests/tooling/wgsl-author-package.test.js tests/tooling/wgsl-author-execution-plan.test.js tests/tooling/wgsl-author-browser-executor.test.js tests/tooling/wgsl-author-reference.test.js tests/training/wgsl-writer-v3-contract.test.js",
|
|
58
|
+
"training:wgsl:author:reference": "node tools/run-wgsl-author-v3-reference.js",
|
|
59
|
+
"training:wgsl:seed-candidates": "node tools/run-wgsl-repair-seed-candidates.js",
|
|
60
|
+
"training:wgsl:seed-select": "node tools/select-wgsl-repair-v13-seed.js",
|
|
44
61
|
"training:contract:delta": "node tools/emit-training-contract-delta.js",
|
|
45
62
|
"training:workloads:verify": "node tools/verify-training-workload-packs.js --registry src/experimental/training/workload-packs/registry.json",
|
|
46
63
|
"training:report-ids:publish": "node tools/publish-training-report-ids.js --registry src/experimental/training/workload-packs/registry.json",
|
package/src/gpu/device.js
CHANGED
|
@@ -14,6 +14,12 @@ const SHARED_DEVICE_STATE_KEY = '__dopplerGpuDeviceState';
|
|
|
14
14
|
function getSharedDeviceState() {
|
|
15
15
|
const existing = globalThis[SHARED_DEVICE_STATE_KEY];
|
|
16
16
|
if (existing && typeof existing === 'object') {
|
|
17
|
+
if (!(existing.bufferOwners instanceof WeakMap)) {
|
|
18
|
+
existing.bufferOwners = new WeakMap();
|
|
19
|
+
}
|
|
20
|
+
if (!('deviceInitPromise' in existing)) {
|
|
21
|
+
existing.deviceInitPromise = null;
|
|
22
|
+
}
|
|
17
23
|
return existing;
|
|
18
24
|
}
|
|
19
25
|
const created = {
|
|
@@ -23,6 +29,8 @@ function getSharedDeviceState() {
|
|
|
23
29
|
lastDeviceLossInfo: null,
|
|
24
30
|
platformInitialized: false,
|
|
25
31
|
deviceEpoch: 0,
|
|
32
|
+
bufferOwners: new WeakMap(),
|
|
33
|
+
deviceInitPromise: null,
|
|
26
34
|
};
|
|
27
35
|
Object.defineProperty(globalThis, SHARED_DEVICE_STATE_KEY, {
|
|
28
36
|
value: created,
|
|
@@ -58,14 +66,14 @@ function syncSharedDeviceState() {
|
|
|
58
66
|
}
|
|
59
67
|
|
|
60
68
|
function hydrateDeviceState() {
|
|
61
|
-
gpuDevice =
|
|
62
|
-
kernelCapabilities =
|
|
63
|
-
resolvedPlatformConfig =
|
|
64
|
-
lastDeviceLossInfo =
|
|
65
|
-
platformInitialized =
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
gpuDevice = sharedDeviceState.gpuDevice ?? null;
|
|
70
|
+
kernelCapabilities = sharedDeviceState.kernelCapabilities ?? null;
|
|
71
|
+
resolvedPlatformConfig = sharedDeviceState.resolvedPlatformConfig ?? null;
|
|
72
|
+
lastDeviceLossInfo = sharedDeviceState.lastDeviceLossInfo ?? null;
|
|
73
|
+
platformInitialized = sharedDeviceState.platformInitialized === true;
|
|
74
|
+
deviceEpoch = Number.isInteger(sharedDeviceState.deviceEpoch)
|
|
75
|
+
? sharedDeviceState.deviceEpoch
|
|
76
|
+
: 0;
|
|
69
77
|
}
|
|
70
78
|
|
|
71
79
|
function advanceDeviceEpoch() {
|
|
@@ -185,7 +193,7 @@ function describeBindGroupBufferValue(value) {
|
|
|
185
193
|
return typeof value;
|
|
186
194
|
}
|
|
187
195
|
|
|
188
|
-
function validateBindGroupDescriptor(descriptor) {
|
|
196
|
+
function validateBindGroupDescriptor(descriptor, device) {
|
|
189
197
|
const label = descriptor?.label || 'unlabeled_bind_group';
|
|
190
198
|
const entries = Array.isArray(descriptor?.entries) ? descriptor.entries : [];
|
|
191
199
|
for (const entry of entries) {
|
|
@@ -193,13 +201,18 @@ function validateBindGroupDescriptor(descriptor) {
|
|
|
193
201
|
if (!resource || typeof resource !== 'object' || !('buffer' in resource)) {
|
|
194
202
|
continue;
|
|
195
203
|
}
|
|
196
|
-
if (isValidGPUBuffer(resource.buffer)) {
|
|
197
|
-
|
|
204
|
+
if (!isValidGPUBuffer(resource.buffer)) {
|
|
205
|
+
throw new Error(
|
|
206
|
+
`[${label}] binding ${entry.binding} requires a GPUBuffer; ` +
|
|
207
|
+
`got ${describeBindGroupBufferValue(resource.buffer)}.`
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
const owner = sharedDeviceState.bufferOwners.get(resource.buffer);
|
|
211
|
+
if (owner && owner !== device) {
|
|
212
|
+
throw new Error(
|
|
213
|
+
`[${label}] binding ${entry.binding} uses a GPUBuffer created by a different GPUDevice.`
|
|
214
|
+
);
|
|
198
215
|
}
|
|
199
|
-
throw new Error(
|
|
200
|
-
`[${label}] binding ${entry.binding} requires a GPUBuffer; ` +
|
|
201
|
-
`got ${describeBindGroupBufferValue(resource.buffer)}.`
|
|
202
|
-
);
|
|
203
216
|
}
|
|
204
217
|
}
|
|
205
218
|
|
|
@@ -211,16 +224,49 @@ function shouldValidateBindGroupDescriptors() {
|
|
|
211
224
|
return false;
|
|
212
225
|
}
|
|
213
226
|
|
|
214
|
-
function
|
|
215
|
-
if (
|
|
227
|
+
function wrapDeviceCreateBuffer(device) {
|
|
228
|
+
if (
|
|
229
|
+
!device
|
|
230
|
+
|| device.__dopplerBufferOwnershipWrapped
|
|
231
|
+
|| typeof device.createBuffer !== 'function'
|
|
232
|
+
) {
|
|
216
233
|
return device;
|
|
217
234
|
}
|
|
218
|
-
|
|
235
|
+
const originalCreateBuffer = device.createBuffer.bind(device);
|
|
236
|
+
device.createBuffer = (descriptor) => {
|
|
237
|
+
const buffer = originalCreateBuffer(descriptor);
|
|
238
|
+
if (buffer && (typeof buffer === 'object' || typeof buffer === 'function')) {
|
|
239
|
+
sharedDeviceState.bufferOwners.set(buffer, device);
|
|
240
|
+
}
|
|
241
|
+
return buffer;
|
|
242
|
+
};
|
|
243
|
+
Object.defineProperty(device, '__dopplerBufferOwnershipWrapped', {
|
|
244
|
+
value: true,
|
|
245
|
+
configurable: true,
|
|
246
|
+
enumerable: false,
|
|
247
|
+
writable: false,
|
|
248
|
+
});
|
|
249
|
+
return device;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function wrapDeviceCreateBindGroup(device) {
|
|
253
|
+
if (!device || device.__dopplerBindGroupValidationWrapped) {
|
|
219
254
|
return device;
|
|
220
255
|
}
|
|
221
256
|
const originalCreateBindGroup = device.createBindGroup.bind(device);
|
|
222
257
|
device.createBindGroup = (descriptor) => {
|
|
223
|
-
|
|
258
|
+
if (shouldValidateBindGroupDescriptors()) {
|
|
259
|
+
validateBindGroupDescriptor(descriptor, device);
|
|
260
|
+
} else {
|
|
261
|
+
const entries = Array.isArray(descriptor?.entries) ? descriptor.entries : [];
|
|
262
|
+
for (const entry of entries) {
|
|
263
|
+
const buffer = entry?.resource?.buffer;
|
|
264
|
+
if (buffer && sharedDeviceState.bufferOwners.get(buffer) !== undefined) {
|
|
265
|
+
validateBindGroupDescriptor(descriptor, device);
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
224
270
|
return originalCreateBindGroup(descriptor);
|
|
225
271
|
};
|
|
226
272
|
Object.defineProperty(device, '__dopplerBindGroupValidationWrapped', {
|
|
@@ -240,9 +286,10 @@ function registerDeviceLostHandler(device) {
|
|
|
240
286
|
if (device.lost && typeof device.lost.then === 'function') {
|
|
241
287
|
const trackedDevice = device;
|
|
242
288
|
device.lost.then((info) => {
|
|
243
|
-
if (gpuDevice !== trackedDevice) {
|
|
289
|
+
if (sharedDeviceState.gpuDevice !== trackedDevice) {
|
|
244
290
|
return;
|
|
245
291
|
}
|
|
292
|
+
hydrateDeviceState();
|
|
246
293
|
lastDeviceLossInfo = {
|
|
247
294
|
message: info?.message ?? '',
|
|
248
295
|
reason: info?.reason ?? 'unknown',
|
|
@@ -254,9 +301,10 @@ function registerDeviceLostHandler(device) {
|
|
|
254
301
|
clearActiveDeviceState();
|
|
255
302
|
advanceDeviceEpoch();
|
|
256
303
|
}).catch((error) => {
|
|
257
|
-
if (gpuDevice !== trackedDevice) {
|
|
304
|
+
if (sharedDeviceState.gpuDevice !== trackedDevice) {
|
|
258
305
|
return;
|
|
259
306
|
}
|
|
307
|
+
hydrateDeviceState();
|
|
260
308
|
lastDeviceLossInfo = {
|
|
261
309
|
message: error?.message ?? String(error),
|
|
262
310
|
reason: 'device_lost_handler_failed',
|
|
@@ -478,17 +526,7 @@ async function initializePlatformAndRegistry(adapter) {
|
|
|
478
526
|
}
|
|
479
527
|
|
|
480
528
|
|
|
481
|
-
|
|
482
|
-
hydrateDeviceState();
|
|
483
|
-
// Return cached device if available
|
|
484
|
-
if (gpuDevice) {
|
|
485
|
-
if (isUsableGPUDevice(gpuDevice)) {
|
|
486
|
-
return gpuDevice;
|
|
487
|
-
}
|
|
488
|
-
clearActiveDeviceState();
|
|
489
|
-
advanceDeviceEpoch();
|
|
490
|
-
}
|
|
491
|
-
|
|
529
|
+
async function initializeDevice() {
|
|
492
530
|
if (!isWebGPUAvailable()) {
|
|
493
531
|
throw createDopplerError(ERROR_CODES.GPU_UNAVAILABLE, 'WebGPU is not available in this browser');
|
|
494
532
|
}
|
|
@@ -517,6 +555,7 @@ export async function initDevice() {
|
|
|
517
555
|
}
|
|
518
556
|
lastDeviceLossInfo = null;
|
|
519
557
|
ensureGpuBufferConstructor(gpuDevice);
|
|
558
|
+
wrapDeviceCreateBuffer(gpuDevice);
|
|
520
559
|
wrapDeviceCreateBindGroup(gpuDevice);
|
|
521
560
|
registerDeviceLostHandler(gpuDevice);
|
|
522
561
|
advanceDeviceEpoch();
|
|
@@ -563,6 +602,34 @@ export async function initDevice() {
|
|
|
563
602
|
return gpuDevice;
|
|
564
603
|
}
|
|
565
604
|
|
|
605
|
+
export async function initDevice() {
|
|
606
|
+
hydrateDeviceState();
|
|
607
|
+
// Return cached device if available
|
|
608
|
+
if (gpuDevice) {
|
|
609
|
+
if (isUsableGPUDevice(gpuDevice)) {
|
|
610
|
+
return gpuDevice;
|
|
611
|
+
}
|
|
612
|
+
clearActiveDeviceState();
|
|
613
|
+
advanceDeviceEpoch();
|
|
614
|
+
}
|
|
615
|
+
if (sharedDeviceState.deviceInitPromise) {
|
|
616
|
+
const device = await sharedDeviceState.deviceInitPromise;
|
|
617
|
+
hydrateDeviceState();
|
|
618
|
+
return device;
|
|
619
|
+
}
|
|
620
|
+
const initialization = initializeDevice();
|
|
621
|
+
sharedDeviceState.deviceInitPromise = initialization;
|
|
622
|
+
try {
|
|
623
|
+
const device = await initialization;
|
|
624
|
+
hydrateDeviceState();
|
|
625
|
+
return device;
|
|
626
|
+
} finally {
|
|
627
|
+
if (sharedDeviceState.deviceInitPromise === initialization) {
|
|
628
|
+
sharedDeviceState.deviceInitPromise = null;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
|
|
566
633
|
export function setDevice(device, options = {}) {
|
|
567
634
|
hydrateDeviceState();
|
|
568
635
|
if (!device) {
|
|
@@ -574,6 +641,7 @@ export function setDevice(device, options = {}) {
|
|
|
574
641
|
gpuDevice = device;
|
|
575
642
|
lastDeviceLossInfo = null;
|
|
576
643
|
ensureGpuBufferConstructor(gpuDevice);
|
|
644
|
+
wrapDeviceCreateBuffer(gpuDevice);
|
|
577
645
|
wrapDeviceCreateBindGroup(gpuDevice);
|
|
578
646
|
registerDeviceLostHandler(gpuDevice);
|
|
579
647
|
advanceDeviceEpoch();
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
export type RuntimeOptimizationWorkload = 'inference' | 'embedding' | 'rerank';
|
|
2
|
+
export type RuntimeOptimizationDirection = 'maximize' | 'minimize';
|
|
3
|
+
|
|
4
|
+
export interface RuntimeOptimizationContract {
|
|
5
|
+
schema: 'doppler.runtime-optimization-contract/v1';
|
|
6
|
+
contractId: string;
|
|
7
|
+
kind: 'runtime_profile';
|
|
8
|
+
model: {
|
|
9
|
+
modelId: string;
|
|
10
|
+
modelUrl: string | null;
|
|
11
|
+
expectedExecutionContractHash: `sha256:${string}` | null;
|
|
12
|
+
};
|
|
13
|
+
baseline: {
|
|
14
|
+
runtimeProfile: null;
|
|
15
|
+
runtimeConfig: Record<string, unknown>;
|
|
16
|
+
};
|
|
17
|
+
workload: {
|
|
18
|
+
type: RuntimeOptimizationWorkload;
|
|
19
|
+
request: {
|
|
20
|
+
inferenceInput?: Record<string, unknown> | null;
|
|
21
|
+
cacheMode?: 'cold' | 'warm' | null;
|
|
22
|
+
loadMode?: 'opfs' | 'http' | 'memory' | 'file' | null;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
mutationPolicy: {
|
|
26
|
+
dimensions: Array<{ path: string; values: unknown[] }>;
|
|
27
|
+
maxCandidates: number;
|
|
28
|
+
};
|
|
29
|
+
verification: {
|
|
30
|
+
comparisons: Array<{
|
|
31
|
+
path: 'result.output'
|
|
32
|
+
| 'result.metrics.referenceTranscript.tokens.generatedTokenIdsHash'
|
|
33
|
+
| 'result.metrics.referenceTranscript.output.textHash';
|
|
34
|
+
mode: 'canonical_exact';
|
|
35
|
+
}>;
|
|
36
|
+
};
|
|
37
|
+
measurement: {
|
|
38
|
+
metricPath: 'result.metrics.decodeTokensPerSec'
|
|
39
|
+
| 'result.metrics.embeddingMs'
|
|
40
|
+
| 'result.metrics.rerankMs'
|
|
41
|
+
| 'result.timing.decodeTokensPerSec'
|
|
42
|
+
| 'result.timing.totalRunMs';
|
|
43
|
+
direction: RuntimeOptimizationDirection;
|
|
44
|
+
pairCount: number;
|
|
45
|
+
minValidPairs: number;
|
|
46
|
+
minImprovementPercent: number;
|
|
47
|
+
requirePositiveConfidence: boolean;
|
|
48
|
+
maxRelativeStdDevPercent: number | null;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface RuntimeOptimizationCandidate {
|
|
53
|
+
schema: 'doppler.runtime-optimization-candidate/v1';
|
|
54
|
+
candidateId: string;
|
|
55
|
+
contractHash: `sha256:${string}`;
|
|
56
|
+
parentHash: `sha256:${string}`;
|
|
57
|
+
patch: Array<{ op: 'set'; path: string; value: unknown }>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface RuntimeOptimizationReceipt {
|
|
61
|
+
schema: 'doppler.runtime-optimization-receipt/v1';
|
|
62
|
+
contractId: string;
|
|
63
|
+
contractHash: `sha256:${string}`;
|
|
64
|
+
candidateId: string;
|
|
65
|
+
candidateHash: `sha256:${string}`;
|
|
66
|
+
parentHash: `sha256:${string}`;
|
|
67
|
+
model: RuntimeOptimizationContract['model'];
|
|
68
|
+
runtimeInputs: Record<string, unknown>;
|
|
69
|
+
verification: Record<string, unknown>;
|
|
70
|
+
measurement: Record<string, unknown>;
|
|
71
|
+
decision: {
|
|
72
|
+
accepted: boolean;
|
|
73
|
+
status: 'accepted' | 'rejected' | 'invalid';
|
|
74
|
+
reasons: string[];
|
|
75
|
+
};
|
|
76
|
+
receiptHash: `sha256:${string}`;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface RuntimeOptimizationEvaluationOptions {
|
|
80
|
+
runCommand?: (request: Record<string, unknown>, options?: Record<string, unknown>) => Promise<Record<string, unknown>>;
|
|
81
|
+
commandOptions?: Record<string, unknown>;
|
|
82
|
+
signal?: AbortSignal | null;
|
|
83
|
+
onEvent?: (event: Record<string, unknown>) => void;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export declare const RUNTIME_OPTIMIZATION_CONTRACT_SCHEMA: 'doppler.runtime-optimization-contract/v1';
|
|
87
|
+
export declare const RUNTIME_OPTIMIZATION_CANDIDATE_SCHEMA: 'doppler.runtime-optimization-candidate/v1';
|
|
88
|
+
export declare const RUNTIME_OPTIMIZATION_RECEIPT_SCHEMA: 'doppler.runtime-optimization-receipt/v1';
|
|
89
|
+
|
|
90
|
+
export declare function validateRuntimeOptimizationContract(
|
|
91
|
+
input: RuntimeOptimizationContract
|
|
92
|
+
): RuntimeOptimizationContract;
|
|
93
|
+
export declare function hashRuntimeOptimizationContract(input: RuntimeOptimizationContract): `sha256:${string}`;
|
|
94
|
+
export declare function enumerateRuntimeOptimizationCandidates(
|
|
95
|
+
input: RuntimeOptimizationContract
|
|
96
|
+
): RuntimeOptimizationCandidate[];
|
|
97
|
+
export declare function validateRuntimeOptimizationCandidate(
|
|
98
|
+
candidate: RuntimeOptimizationCandidate,
|
|
99
|
+
contract: RuntimeOptimizationContract
|
|
100
|
+
): RuntimeOptimizationCandidate;
|
|
101
|
+
export declare function materializeRuntimeOptimizationCandidate(
|
|
102
|
+
contract: RuntimeOptimizationContract,
|
|
103
|
+
candidate: RuntimeOptimizationCandidate
|
|
104
|
+
): { runtimeProfile: null; runtimeConfig: Record<string, unknown> };
|
|
105
|
+
export declare function evaluateBrowserRuntimeOptimizationCandidate(
|
|
106
|
+
contract: RuntimeOptimizationContract,
|
|
107
|
+
candidate: RuntimeOptimizationCandidate,
|
|
108
|
+
options?: RuntimeOptimizationEvaluationOptions
|
|
109
|
+
): Promise<RuntimeOptimizationReceipt>;
|