doppler-gpu 0.4.15 → 0.5.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/README.md +9 -0
- package/package.json +25 -2
- package/src/cli/doppler-cli.js +253 -94
- package/src/cli/runtime-profiles.js +3 -7
- package/src/client/doppler-api.d.ts +28 -0
- package/src/client/doppler-api.js +2 -0
- package/src/client/inspection.d.ts +122 -0
- package/src/client/inspection.js +343 -0
- package/src/client/runtime/index.d.ts +54 -0
- package/src/client/runtime/index.js +190 -18
- package/src/client/runtime/model-manager.d.ts +0 -4
- package/src/client/runtime/model-manager.js +0 -28
- package/src/client/runtime/model-session.d.ts +48 -1
- package/src/client/runtime/model-session.js +149 -30
- package/src/client/runtime/model-source.d.ts +10 -1
- package/src/client/runtime/scoped-session.d.ts +117 -0
- package/src/client/runtime/scoped-session.js +257 -0
- package/src/client/runtime/types.d.ts +0 -1
- package/src/client/runtime/types.js +0 -1
- package/src/config/evidence/boundary-evidence-policy.json +54 -0
- package/src/config/evidence/source-intake-policy.json +122 -0
- package/src/config/inspection/observation-policies.json +80 -0
- package/src/config/param-validator.js +21 -36
- package/src/config/runtime/compute/f16-activations.json +1 -0
- package/src/config/runtime/compute/f16-batched.json +1 -0
- package/src/config/runtime/default.json +1 -0
- package/src/config/runtime/diagnostics/debug-logits.json +1 -0
- package/src/config/runtime/experiments/bench/gemma3-bench-q4k-alt.json +1 -0
- package/src/config/runtime/experiments/bench/gemma3-bench-q4k-batched.json +1 -0
- package/src/config/runtime/experiments/bench/gemma3-bench-q4k.json +1 -0
- package/src/config/runtime/experiments/bench/gemma4-bench-q4k.json +1 -0
- package/src/config/runtime/experiments/bench/qwen3-bench-q4k-alt.json +1 -0
- package/src/config/runtime/experiments/bench/qwen3-bench-q4k-batched.json +1 -0
- package/src/config/runtime/experiments/debug/gemma3-browser-diagnose-q4k.json +1 -1
- package/src/config/runtime/experiments/debug/gemma3-debug-q4k.json +1 -3
- package/src/config/runtime/experiments/debug/gemma4-e2b-browser-diagnose-q4k.json +1 -1
- package/src/config/runtime/experiments/debug/qwen35-browser-diagnose-q4k.json +1 -1
- package/src/config/runtime/experiments/verify/gemma3-verify.json +1 -3
- package/src/config/runtime/experiments/verify/gemma4-e2b-verify.json +1 -3
- package/src/config/runtime/experiments/verify/lfm2-verify.json +1 -3
- package/src/config/runtime/experiments/verify/translategemma-verify.json +1 -3
- package/src/config/runtime/model/gemma2-debug.json +1 -0
- package/src/config/runtime/model/gemma2-pipeline-debug.json +1 -0
- package/src/config/runtime/model/gemma2-pipeline.json +1 -0
- package/src/config/runtime/model/gemma3-layer-probe.json +1 -0
- package/src/config/runtime/model/qwen3-5-layer-probe.json +1 -0
- package/src/config/runtime/model/qwen3-5-layer3-boundary-probe.json +1 -0
- package/src/config/runtime/model/qwen3-5-linear-attn-debug.json +1 -0
- package/src/config/runtime/optimization-candidates/registry.json +5 -0
- package/src/config/runtime/platform/metal-apple-q4k.json +1 -0
- package/src/config/runtime/profiles/default.json +1 -0
- package/src/config/runtime/profiles/diffusiongemma-26b-a4b-throughput.json +1 -0
- package/src/config/runtime/profiles/gemma3-270m-q4k-throughput-overlapped-probe.json +1 -0
- package/src/config/runtime/profiles/gemma3-270m-q4k-throughput-probe.json +1 -0
- package/src/config/runtime/profiles/gemma4-12b-rdrr-safe-b4.json +1 -3
- package/src/config/runtime/profiles/gemma4-12b-rdrr-safe-single.json +1 -3
- package/src/config/runtime/profiles/gemma4-31b-f16-activations-probe.json +1 -5
- package/src/config/runtime/profiles/gemma4-e2b-baseline-probe.json +1 -3
- package/src/config/runtime/profiles/gemma4-e2b-fused-rmsnorm-probe.json +1 -3
- package/src/config/runtime/profiles/gemma4-e2b-fused-rmsnorm-test.json +1 -0
- package/src/config/runtime/profiles/gemma4-e2b-int4ple-baseline-probe.json +1 -5
- package/src/config/runtime/profiles/gemma4-e2b-int4ple-f16a-probe.json +1 -5
- package/src/config/runtime/profiles/gemma4-e2b-int4ple-reference-export.json +1 -3
- package/src/config/runtime/profiles/gemma4-e2b-int4ple-retain-q4k-probe.json +1 -5
- package/src/config/runtime/profiles/gemma4-e2b-low-memory.json +1 -0
- package/src/config/runtime/profiles/gemma4-e2b-prefill-profile.json +1 -3
- package/src/config/runtime/profiles/gemma4-e2b-throughput-probe.json +1 -0
- package/src/config/runtime/profiles/low-memory.json +1 -0
- package/src/config/runtime/profiles/production.json +1 -3
- package/src/config/runtime/profiles/qwen-3-5-0-8b-metal-attn128-candidate.json +1 -0
- package/src/config/runtime/profiles/qwen-3-5-0-8b-metal-maxbatch64-candidate.json +1 -0
- package/src/config/runtime/profiles/qwen-3-5-0-8b-metal-normed-ffn-candidate.json +1 -0
- package/src/config/runtime/profiles/qwen-3-5-0-8b-metal-overlap-ringtokens1-candidate.json +1 -0
- package/src/config/runtime/profiles/qwen-3-5-0-8b-metal-parity.json +1 -0
- package/src/config/runtime/profiles/qwen-3-5-0-8b-metal-sequential-candidate.json +1 -0
- package/src/config/runtime/profiles/qwen-3-5-0-8b-metal-throughput.json +1 -0
- package/src/config/runtime/profiles/qwen-3-5-0-8b-prefill-profile.json +1 -3
- package/src/config/runtime/profiles/qwen-3-5-0-8b-throughput-probe.json +1 -0
- package/src/config/runtime/profiles/qwen-3-5-2b-f16-primary-throughput.json +1 -5
- package/src/config/runtime/profiles/qwen-3-5-2b-metal-parity.json +1 -0
- package/src/config/runtime/profiles/qwen-3-5-2b-metal-throughput.json +1 -0
- package/src/config/runtime/profiles/qwen-3-5-9b-metal-correctness.json +1 -0
- package/src/config/runtime/profiles/qwen-3-embedding-0-6b-metal-stability.json +1 -3
- package/src/config/runtime/profiles/qwen-3-embedding-0-6b-metal-throughput.json +1 -0
- package/src/config/runtime/profiles/qwen-3-reranker-0-6b-metal-stability.json +1 -0
- package/src/config/runtime/profiles/qwen-3-reranker-0-6b-metal-throughput.json +1 -0
- package/src/config/runtime/profiles/qwen3-6-27b-f16-activations-probe.json +1 -5
- package/src/config/runtime/profiles/rerank-stability.json +1 -3
- package/src/config/runtime/profiles/rerank-throughput.json +1 -3
- package/src/config/runtime/profiles/simulation.json +1 -3
- package/src/config/runtime/profiles/throughput.json +1 -3
- package/src/config/runtime/profiles/trace-layers.json +1 -3
- package/src/config/runtime/profiles/translategemma-1b-nativekd2-q4k-rdna3-throughput-probe.json +1 -0
- package/src/config/runtime/profiles/turboquant-contiguous-prod.json +1 -0
- package/src/config/runtime/profiles/turboquant-contiguous.json +1 -0
- package/src/config/runtime/profiles/turboquant.json +1 -0
- package/src/config/runtime/profiles/vector-stability.json +1 -3
- package/src/config/runtime/profiles/vector-throughput.json +1 -0
- package/src/config/runtime/profiles/verbose-trace.json +1 -3
- package/src/config/runtime/tiers/gemma4-128gb.json +1 -0
- package/src/config/runtime/tiers/gemma4-16gb.json +1 -0
- package/src/config/runtime/tiers/gemma4-24gb.json +1 -0
- package/src/config/runtime/tiers/gemma4-32gb.json +1 -0
- package/src/config/schema/benchmark.schema.d.ts +7 -0
- package/src/config/schema/benchmark.schema.js +5 -0
- package/src/config/schema/index.d.ts +8 -16
- package/src/config/schema/index.js +5 -8
- package/src/config/schema/kernel-thresholds.schema.d.ts +0 -12
- package/src/config/schema/kernel-thresholds.schema.js +0 -12
- package/src/config/schema/kernel-warmup.schema.d.ts +1 -3
- package/src/config/schema/kernel-warmup.schema.js +0 -1
- package/src/config/schema/runtime-profile.schema.d.ts +24 -0
- package/src/config/schema/runtime-profile.schema.js +92 -0
- package/src/config/schema/shared-runtime.schema.d.ts +1 -4
- package/src/config/schema/shared-runtime.schema.js +0 -2
- package/src/config/schema/tooling.schema.d.ts +8 -5
- package/src/config/schema/tooling.schema.js +3 -2
- package/src/debug/tensor.d.ts +2 -0
- package/src/debug/tensor.js +21 -2
- package/src/gpu/command-recorder.d.ts +5 -0
- package/src/gpu/command-recorder.js +17 -0
- package/src/gpu/kernel-runtime.js +2 -10
- package/src/gpu/kernels/index.d.ts +0 -2
- package/src/gpu/kernels/index.js +0 -2
- package/src/gpu/kernels/kernel-prewarm.d.ts +3 -0
- package/src/gpu/kernels/kernel-prewarm.js +60 -0
- package/src/gpu/kernels/utils.d.ts +2 -4
- package/src/gpu/kernels/utils.js +2 -4
- package/src/index.d.ts +13 -1
- package/src/index.js +7 -1
- package/src/inference/browser-harness-model-helpers.js +4 -0
- package/src/inference/browser-harness-runtime-helpers.js +25 -10
- package/src/inference/browser-harness-text-helpers.js +4 -1
- package/src/inference/browser-harness.d.ts +4 -0
- package/src/inference/browser-harness.js +91 -4
- package/src/inference/observation-context.d.ts +22 -0
- package/src/inference/observation-context.js +41 -0
- package/src/inference/pipelines/text/attention/attn-config.js +1 -1
- package/src/inference/pipelines/text/attention/executor-immediate.js +42 -0
- package/src/inference/pipelines/text/attention/executor-recorded.js +29 -0
- package/src/inference/pipelines/text/attention/index.js +7 -0
- package/src/inference/pipelines/text/attention/interpreter.js +1334 -0
- package/src/inference/pipelines/text/attention/plan.d.ts +36 -0
- package/src/inference/pipelines/text/attention/plan.js +328 -0
- package/src/inference/pipelines/text/attention/receipt.js +60 -0
- package/src/inference/pipelines/text/attention/record.js +8 -1278
- package/src/inference/pipelines/text/attention/run.js +8 -1386
- package/src/inference/pipelines/text/generator-decode-policy.js +4 -1
- package/src/inference/pipelines/text/generator-helpers.js +2 -0
- package/src/inference/pipelines/text/generator-steps.js +32 -15
- package/src/inference/pipelines/text/generator.js +10 -5
- package/src/inference/pipelines/text/init.d.ts +3 -0
- package/src/inference/pipelines/text/layer-plan-gpu.js +2 -0
- package/src/inference/pipelines/text/layer.js +2 -0
- package/src/inference/pipelines/text/model-load.d.ts +0 -1
- package/src/inference/pipelines/text/model-load.js +2 -11
- package/src/inference/pipelines/text/probes.js +10 -0
- package/src/inference/pipelines/text/resolved-runtime-session.d.ts +56 -0
- package/src/inference/pipelines/text/resolved-runtime-session.js +175 -0
- package/src/inference/pipelines/text/state.d.ts +6 -0
- package/src/inference/pipelines/text/state.js +3 -0
- package/src/inference/pipelines/text/types.d.ts +6 -0
- package/src/inference/pipelines/text.js +16 -1
- package/src/inference/refactor-receipt.d.ts +49 -0
- package/src/inference/refactor-receipt.js +188 -0
- package/src/inference/resource-scope.d.ts +33 -0
- package/src/inference/resource-scope.js +168 -0
- package/src/inference/test-harness.d.ts +3 -0
- package/src/inference/test-harness.js +1 -0
- package/src/storage/model-cache.d.ts +53 -0
- package/src/storage/model-cache.js +550 -0
- package/src/tooling/boundary-evidence.d.ts +51 -0
- package/src/tooling/boundary-evidence.js +408 -0
- package/src/tooling/browser-command-runner.js +4 -4
- package/src/tooling/command-context.d.ts +25 -0
- package/src/tooling/command-context.js +53 -0
- package/src/tooling/command-runner-shared.js +22 -5
- package/src/tooling/demo-receipts.d.ts +56 -0
- package/src/tooling/demo-receipts.js +113 -0
- package/src/tooling/diagnose-runner.js +2 -2
- package/src/tooling/execution-cost-ledger.d.ts +21 -0
- package/src/tooling/execution-cost-ledger.js +199 -0
- package/src/tooling/node-command-runner.js +2 -2
- package/src/tooling/opfs-cache.d.ts +11 -49
- package/src/tooling/opfs-cache.js +4 -510
- package/src/tooling/precision-replay-math.d.ts +42 -0
- package/src/tooling/precision-replay-math.js +174 -0
- package/src/tooling/program-bundle-parity.d.ts +3 -0
- package/src/tooling/program-bundle-parity.js +8 -0
- package/src/tooling/program-bundle.d.ts +1 -52
- package/src/tooling/program-bundle.js +0 -139
- package/src/tooling/registered-variant-calibration.d.ts +24 -0
- package/src/tooling/registered-variant-calibration.js +286 -0
- package/src/tooling/runtime-input-composition.js +105 -53
- package/src/tooling/runtime-intent.js +41 -0
- package/src/tooling/runtime-optimization-index.d.ts +6 -0
- package/src/tooling/runtime-optimization-index.js +72 -0
- package/src/tooling/runtime-optimization.d.ts +47 -6
- package/src/tooling/runtime-optimization.js +559 -40
- package/src/tooling/source-intake.d.ts +49 -0
- package/src/tooling/source-intake.js +414 -0
- package/src/tooling-exports/evidence.d.ts +34 -0
- package/src/tooling-exports/evidence.js +34 -0
- package/src/tooling-exports/runtime.d.ts +7 -0
- package/src/tooling-exports/runtime.js +7 -0
- package/src/tooling-exports.d.ts +11 -0
- package/src/tooling-exports.js +6 -3
- package/src/tooling-exports.shared.d.ts +32 -0
- package/src/tooling-exports.shared.js +31 -0
- package/src/version.js +1 -1
- package/src/config/schema/tuner.schema.d.ts +0 -39
- package/src/config/schema/tuner.schema.js +0 -13
- package/src/gpu/kernel-tuner/benchmarks.js +0 -902
- package/src/gpu/kernel-tuner/cache.js +0 -145
- package/src/gpu/kernel-tuner/index.js +0 -38
- package/src/gpu/kernel-tuner/tuner.js +0 -247
- package/src/gpu/kernel-tuner.js +0 -12
- package/src/gpu/kernels/kernel-tuning.d.ts +0 -42
- package/src/gpu/kernels/kernel-tuning.js +0 -158
- package/src/gpu/profiler.js +0 -382
- package/src/inference/pipelines/text/attention/output-gate-fusion.js +0 -37
|
@@ -8,9 +8,15 @@ import {
|
|
|
8
8
|
} from '../config/kernel-path-loader.js';
|
|
9
9
|
import { mergeRuntimeValues } from '../config/runtime-merge.js';
|
|
10
10
|
import {
|
|
11
|
-
|
|
11
|
+
resolveOrderedRuntimeInputs,
|
|
12
12
|
resolveRuntimeFromConfig,
|
|
13
13
|
} from '../tooling/runtime-input-composition.js';
|
|
14
|
+
import { validateRuntimeProfileMetadata } from '../config/schema/runtime-profile.schema.js';
|
|
15
|
+
import { resolveCommandRuntimeContract } from '../tooling/command-api-helpers.js';
|
|
16
|
+
import {
|
|
17
|
+
assertRuntimeInputIntentCompatibility,
|
|
18
|
+
stripLegacyRuntimeIntent,
|
|
19
|
+
} from '../tooling/runtime-intent.js';
|
|
14
20
|
|
|
15
21
|
function parseReportTimestamp(rawTimestamp, label = 'timestamp') {
|
|
16
22
|
if (rawTimestamp == null) {
|
|
@@ -305,7 +311,7 @@ export async function loadRuntimeConfigFromUrl(url, options = {}) {
|
|
|
305
311
|
|
|
306
312
|
export async function applyRuntimeConfigFromUrl(url, options = {}) {
|
|
307
313
|
const { runtime } = await loadRuntimeConfigFromUrl(url, options);
|
|
308
|
-
const mergedRuntime = mergeRuntimeValues(getRuntimeConfig(), runtime);
|
|
314
|
+
const mergedRuntime = mergeRuntimeValues(getRuntimeConfig(), stripLegacyRuntimeIntent(runtime));
|
|
309
315
|
setRuntimeConfig(mergedRuntime);
|
|
310
316
|
return mergedRuntime;
|
|
311
317
|
}
|
|
@@ -317,12 +323,15 @@ export async function loadRuntimeProfile(profileId, options = {}) {
|
|
|
317
323
|
throw new Error('runtime profile id is required');
|
|
318
324
|
}
|
|
319
325
|
const url = `${baseUrl.replace(/\/$/, '')}/${normalized}`;
|
|
320
|
-
|
|
326
|
+
const loaded = await loadRuntimeConfigFromUrl(url, { ...options, profileBaseUrl: baseUrl });
|
|
327
|
+
validateRuntimeProfileMetadata(loaded.config, `runtime profile "${profileId}"`);
|
|
328
|
+
return loaded;
|
|
321
329
|
}
|
|
322
330
|
|
|
323
331
|
export async function applyRuntimeProfile(profileId, options = {}) {
|
|
324
332
|
const { runtime } = await loadRuntimeProfile(profileId, options);
|
|
325
|
-
const
|
|
333
|
+
const normalizedRuntime = stripLegacyRuntimeIntent(runtime);
|
|
334
|
+
const mergedRuntime = mergeRuntimeValues(getRuntimeConfig(), normalizedRuntime);
|
|
326
335
|
setRuntimeConfig(mergedRuntime);
|
|
327
336
|
return mergedRuntime;
|
|
328
337
|
}
|
|
@@ -342,19 +351,25 @@ export async function applyRuntimeForRun(run, options = {}) {
|
|
|
342
351
|
?? run.runtime?.configChain
|
|
343
352
|
?? options.runtime?.configChain
|
|
344
353
|
);
|
|
345
|
-
await
|
|
346
|
-
getRuntimeConfig,
|
|
347
|
-
setRuntimeConfig,
|
|
348
|
-
}, {
|
|
354
|
+
const resolved = await resolveOrderedRuntimeInputs(getRuntimeConfig(), {
|
|
349
355
|
configChain,
|
|
350
356
|
runtimeProfile: run.runtimeProfile ?? null,
|
|
351
357
|
runtimeConfigUrl: run.runtimeConfigUrl ?? null,
|
|
352
358
|
runtimeConfig: run.runtimeConfig ?? null,
|
|
353
359
|
}, {
|
|
354
360
|
loadRuntimeConfigFromRef: (ref, runtimeOptions) => loadRuntimeConfigFromRef(ref, runtimeOptions),
|
|
355
|
-
|
|
356
|
-
|
|
361
|
+
loadRuntimeProfile,
|
|
362
|
+
loadRuntimeConfigFromUrl,
|
|
357
363
|
}, options);
|
|
364
|
+
const commandIntent = run.command
|
|
365
|
+
? resolveCommandRuntimeContract(run.command).intent
|
|
366
|
+
: null;
|
|
367
|
+
if (commandIntent !== null) {
|
|
368
|
+
assertRuntimeInputIntentCompatibility(commandIntent, resolved.documents);
|
|
369
|
+
}
|
|
370
|
+
if (resolved.documents.length > 0) {
|
|
371
|
+
setRuntimeConfig(stripLegacyRuntimeIntent(resolved.runtime));
|
|
372
|
+
}
|
|
358
373
|
}
|
|
359
374
|
|
|
360
375
|
export function normalizeManifest(manifest) {
|
|
@@ -6,6 +6,7 @@ import { isPlainObject } from '../utils/plain-object.js';
|
|
|
6
6
|
import { cloneJsonValue } from '../utils/clone-json.js';
|
|
7
7
|
import { sha256BytesHex } from '../utils/sha256.js';
|
|
8
8
|
import { resolvePromptInput } from './pipelines/text/generator-prefill-helpers.js';
|
|
9
|
+
import { isExecutionObservationRequested } from '../tooling/execution-cost-ledger.js';
|
|
9
10
|
|
|
10
11
|
const DEFAULT_IMAGE_TRANSCRIPTION_PROMPT = 'Describe the image in one short sentence.';
|
|
11
12
|
const DEFAULT_IMAGE_TRANSCRIPTION_SOFT_TOKEN_BUDGET = 70;
|
|
@@ -2037,7 +2038,8 @@ export async function runGeneration(pipeline, runtimeConfig, runOverrides = null
|
|
|
2037
2038
|
? Math.max(0, Math.floor(sampling.seed))
|
|
2038
2039
|
: null;
|
|
2039
2040
|
const debugProbes = runtimeConfig.shared?.debug?.probes || [];
|
|
2040
|
-
const
|
|
2041
|
+
const executionObserverEnabled = isExecutionObservationRequested(runtimeConfig);
|
|
2042
|
+
const profile = executionObserverEnabled;
|
|
2041
2043
|
const explicitDiagnosticsEnabled = runtimeConfig.shared?.harness?.mode === 'diagnose'
|
|
2042
2044
|
|| shouldEnableReferenceTranscriptDiagnostics(runOverrides, runtimeConfig);
|
|
2043
2045
|
const disableCommandBatchingForDiagnostics = explicitDiagnosticsEnabled
|
|
@@ -2057,6 +2059,7 @@ export async function runGeneration(pipeline, runtimeConfig, runOverrides = null
|
|
|
2057
2059
|
useChatTemplate,
|
|
2058
2060
|
benchmark: runOverrides?.benchmark === true,
|
|
2059
2061
|
profile,
|
|
2062
|
+
executionObserver: executionObserverEnabled,
|
|
2060
2063
|
...(disableCommandBatchingForDiagnostics ? { disableCommandBatching: true } : {}),
|
|
2061
2064
|
diagnostics,
|
|
2062
2065
|
...(captureLogits ? {
|
|
@@ -10,6 +10,8 @@ import type { DiffusionPipeline } from './pipelines/diffusion/pipeline.js';
|
|
|
10
10
|
import type { EnergyPipeline } from './pipelines/energy/pipeline.js';
|
|
11
11
|
import type { SavedReportInfo, SaveReportOptions } from '../storage/reports.js';
|
|
12
12
|
import type { DebugSnapshot } from '../debug/history.js';
|
|
13
|
+
import type { CommandContext } from '../tooling/command-context.js';
|
|
14
|
+
import type { ToolingIntent } from '../tooling/command-api.js';
|
|
13
15
|
|
|
14
16
|
|
|
15
17
|
export interface RuntimeConfigLoadOptions {
|
|
@@ -63,6 +65,8 @@ export interface BrowserSuiteOptions extends InferenceHarnessOptions {
|
|
|
63
65
|
workload?: BrowserWorkload;
|
|
64
66
|
suite?: BrowserSuite;
|
|
65
67
|
command?: string;
|
|
68
|
+
intent?: ToolingIntent;
|
|
69
|
+
commandContext?: CommandContext;
|
|
66
70
|
surface?: string;
|
|
67
71
|
expectedModelType?: 'embedding' | 'rerank';
|
|
68
72
|
modelUrl?: string;
|
|
@@ -68,6 +68,11 @@ import {
|
|
|
68
68
|
import { collectTrainingArtifactsFromSuiteResult } from './browser-harness-report-helpers.js';
|
|
69
69
|
import { sha256Hex } from '../utils/sha256.js';
|
|
70
70
|
import { stableSortObject } from '../utils/stable-sort-object.js';
|
|
71
|
+
import { assertCommandContextMatchesOptions } from '../tooling/command-context.js';
|
|
72
|
+
import {
|
|
73
|
+
buildTokenCostLedger,
|
|
74
|
+
isExecutionObservationRequested,
|
|
75
|
+
} from '../tooling/execution-cost-ledger.js';
|
|
71
76
|
|
|
72
77
|
const TRAINING_SUITE_MODULE_PATH = '../experimental/training/suite.js';
|
|
73
78
|
let trainingSuiteModulePromise = null;
|
|
@@ -434,6 +439,79 @@ export function resolveExecutionGraphHash(manifest) {
|
|
|
434
439
|
return hashStableJson(execution);
|
|
435
440
|
}
|
|
436
441
|
|
|
442
|
+
function resolveArtifactHash(manifest) {
|
|
443
|
+
const declaredDigest = manifest?.artifactIdentity?.artifactDigest;
|
|
444
|
+
if (typeof declaredDigest === 'string' && declaredDigest.trim()) {
|
|
445
|
+
return declaredDigest;
|
|
446
|
+
}
|
|
447
|
+
if (!Array.isArray(manifest?.shards) || manifest.shards.length === 0) {
|
|
448
|
+
return null;
|
|
449
|
+
}
|
|
450
|
+
return hashStableJson({
|
|
451
|
+
modelId: manifest.modelId ?? null,
|
|
452
|
+
artifactIdentity: manifest.artifactIdentity ?? null,
|
|
453
|
+
hashAlgorithm: manifest.hashAlgorithm ?? null,
|
|
454
|
+
totalSize: manifest.totalSize ?? null,
|
|
455
|
+
shards: manifest.shards.map((shard) => ({
|
|
456
|
+
index: shard?.index ?? null,
|
|
457
|
+
filename: shard?.filename ?? null,
|
|
458
|
+
size: shard?.size ?? null,
|
|
459
|
+
hash: shard?.hash ?? null,
|
|
460
|
+
blake3: shard?.blake3 ?? null,
|
|
461
|
+
offset: shard?.offset ?? null,
|
|
462
|
+
})),
|
|
463
|
+
tokenizer: manifest.tokenizer ?? null,
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
function resolveWrapperHash(manifest, metrics) {
|
|
468
|
+
const execution = manifest?.inference?.execution;
|
|
469
|
+
if (!execution || typeof execution !== 'object') {
|
|
470
|
+
return null;
|
|
471
|
+
}
|
|
472
|
+
return hashStableJson({
|
|
473
|
+
wrapperContract: 'doppler.text-execution-wrapper/v1',
|
|
474
|
+
kernelPathId: metrics?.kernelPathId ?? null,
|
|
475
|
+
kernelPathSource: metrics?.kernelPathSource ?? null,
|
|
476
|
+
executionPlan: metrics?.executionPlan ?? null,
|
|
477
|
+
preLayer: execution.preLayer ?? null,
|
|
478
|
+
prefill: execution.prefill ?? null,
|
|
479
|
+
decode: execution.decode ?? null,
|
|
480
|
+
postLayer: execution.postLayer ?? null,
|
|
481
|
+
policies: execution.policies ?? null,
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
function attachExecutionCostLedger(metrics, runtimeConfig, manifest) {
|
|
486
|
+
if (!isExecutionObservationRequested(runtimeConfig)) {
|
|
487
|
+
return metrics;
|
|
488
|
+
}
|
|
489
|
+
const device = resolveDeviceInfo();
|
|
490
|
+
const browser = {
|
|
491
|
+
userAgent: typeof navigator !== 'undefined' ? (navigator.userAgent || null) : null,
|
|
492
|
+
platform: typeof navigator !== 'undefined' ? (navigator.platform || null) : null,
|
|
493
|
+
vendor: typeof navigator !== 'undefined' ? (navigator.vendor || null) : null,
|
|
494
|
+
};
|
|
495
|
+
return {
|
|
496
|
+
...metrics,
|
|
497
|
+
tokenCostLedger: buildTokenCostLedger({
|
|
498
|
+
metrics,
|
|
499
|
+
identity: {
|
|
500
|
+
artifactDigest: resolveArtifactHash(manifest),
|
|
501
|
+
manifestDigest: hashStableJson(manifest),
|
|
502
|
+
executionGraphDigest: resolveExecutionGraphHash(manifest),
|
|
503
|
+
runtimeConfigDigest: hashStableJson(runtimeConfig),
|
|
504
|
+
kernelSetDigest: manifest?.inference?.execution?.kernels
|
|
505
|
+
? hashStableJson(manifest.inference.execution.kernels)
|
|
506
|
+
: null,
|
|
507
|
+
wrapperDigest: resolveWrapperHash(manifest, metrics),
|
|
508
|
+
},
|
|
509
|
+
device,
|
|
510
|
+
browser,
|
|
511
|
+
}),
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
|
|
437
515
|
function buildPerStepTokenProof(tokenIds) {
|
|
438
516
|
return tokenIds.map((tokenId, index) => ({
|
|
439
517
|
index,
|
|
@@ -889,13 +967,13 @@ async function runInferenceSuite(options = {}) {
|
|
|
889
967
|
firstTokenMs: timing.firstTokenMs,
|
|
890
968
|
firstResponseMs: timing.firstResponseMs,
|
|
891
969
|
});
|
|
892
|
-
const metricsWithContracts = buildSuiteContractMetrics(
|
|
970
|
+
const metricsWithContracts = attachExecutionCostLedger(buildSuiteContractMetrics(
|
|
893
971
|
options.suiteName || 'inference',
|
|
894
972
|
loadDiagnostics
|
|
895
973
|
? { ...metricsWithTimingDiagnostics, load: loadDiagnostics }
|
|
896
974
|
: metricsWithTimingDiagnostics,
|
|
897
975
|
harness.manifest
|
|
898
|
-
);
|
|
976
|
+
), runtimeConfig, harness.manifest);
|
|
899
977
|
return {
|
|
900
978
|
...summary,
|
|
901
979
|
modelId: options.modelId || harness.manifest?.modelId || 'unknown',
|
|
@@ -1482,6 +1560,8 @@ async function runBenchSuite(options = {}) {
|
|
|
1482
1560
|
let lastDecodeMode = null;
|
|
1483
1561
|
let lastBatchGuardReason = null;
|
|
1484
1562
|
let lastExecutionPlan = null;
|
|
1563
|
+
let lastPrefillProfileSteps = null;
|
|
1564
|
+
let lastDecodeProfileSteps = null;
|
|
1485
1565
|
let lastGpuUniformCache = null;
|
|
1486
1566
|
for (let i = 0; i < warmupRuns + timedRuns; i++) {
|
|
1487
1567
|
harness.pipeline.reset?.();
|
|
@@ -1512,6 +1592,8 @@ async function runBenchSuite(options = {}) {
|
|
|
1512
1592
|
lastDecodeMode = run?.phase?.decodeMode ?? null;
|
|
1513
1593
|
lastBatchGuardReason = run?.phase?.batchGuardReason ?? null;
|
|
1514
1594
|
lastExecutionPlan = run?.phase?.executionPlan ?? null;
|
|
1595
|
+
lastPrefillProfileSteps = run?.phase?.prefillProfileSteps ?? null;
|
|
1596
|
+
lastDecodeProfileSteps = run?.phase?.decodeProfileSteps ?? null;
|
|
1515
1597
|
}
|
|
1516
1598
|
if (i >= warmupRuns) {
|
|
1517
1599
|
const phase = run?.phase ?? {};
|
|
@@ -1824,6 +1906,8 @@ async function runBenchSuite(options = {}) {
|
|
|
1824
1906
|
decodeMode: lastDecodeMode,
|
|
1825
1907
|
batchGuardReason: lastBatchGuardReason,
|
|
1826
1908
|
executionPlan: lastExecutionPlan,
|
|
1909
|
+
prefillProfileSteps: lastPrefillProfileSteps,
|
|
1910
|
+
decodeProfileSteps: lastDecodeProfileSteps,
|
|
1827
1911
|
generatedText,
|
|
1828
1912
|
referenceTranscript: generatedReferenceTranscript,
|
|
1829
1913
|
promptInput: generatedPromptInput,
|
|
@@ -1882,11 +1966,11 @@ async function runBenchSuite(options = {}) {
|
|
|
1882
1966
|
firstTokenMs: timing.firstTokenMs,
|
|
1883
1967
|
firstResponseMs: timing.firstResponseMs,
|
|
1884
1968
|
});
|
|
1885
|
-
const metricsWithContracts = buildSuiteContractMetrics(
|
|
1969
|
+
const metricsWithContracts = attachExecutionCostLedger(buildSuiteContractMetrics(
|
|
1886
1970
|
'bench',
|
|
1887
1971
|
loadDiagnostics ? { ...metrics, load: loadDiagnostics } : metrics,
|
|
1888
1972
|
harness.manifest
|
|
1889
|
-
);
|
|
1973
|
+
), runtimeConfig, harness.manifest);
|
|
1890
1974
|
return {
|
|
1891
1975
|
...summary,
|
|
1892
1976
|
modelId: options.modelId || harness.manifest?.modelId || 'unknown',
|
|
@@ -1997,6 +2081,9 @@ async function withHarnessPhase(phase, context, run) {
|
|
|
1997
2081
|
|
|
1998
2082
|
export async function runBrowserSuite(options = {}) {
|
|
1999
2083
|
return runWithRuntimeIsolationForSuite(async () => {
|
|
2084
|
+
if (options.commandContext) {
|
|
2085
|
+
assertCommandContextMatchesOptions(options.commandContext, options);
|
|
2086
|
+
}
|
|
2000
2087
|
const suiteTimestamp = resolveReportTimestamp(options.timestamp, 'runBrowserSuite timestamp');
|
|
2001
2088
|
const harnessContext = resolveHarnessContext(options);
|
|
2002
2089
|
const mode = resolveHarnessMode(options, harnessContext);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { RuntimeConfigSchema } from '../config/schema/index.js';
|
|
2
|
+
import type { CommandContext } from '../tooling/command-context.js';
|
|
3
|
+
|
|
4
|
+
export const OBSERVATION_CONTEXT_SCHEMA: 'doppler.observation-context/v1';
|
|
5
|
+
|
|
6
|
+
export interface ObservationContext {
|
|
7
|
+
readonly schema: typeof OBSERVATION_CONTEXT_SCHEMA;
|
|
8
|
+
readonly commandContext: CommandContext | null;
|
|
9
|
+
readonly diagnostics: 'off' | 'on_failure' | 'always';
|
|
10
|
+
readonly probes: ReadonlyArray<Readonly<Record<string, unknown>>>;
|
|
11
|
+
readonly tracing: {
|
|
12
|
+
readonly pipelineEnabled: boolean;
|
|
13
|
+
readonly layers: ReadonlyArray<number> | null;
|
|
14
|
+
readonly kernelTrace: Readonly<Record<string, unknown>> | null;
|
|
15
|
+
};
|
|
16
|
+
readonly receiptPolicy: 'off' | 'on_failure' | 'always';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function createObservationContext(options: {
|
|
20
|
+
runtimeConfig: RuntimeConfigSchema;
|
|
21
|
+
commandContext?: CommandContext | null;
|
|
22
|
+
}): ObservationContext;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const OBSERVATION_CONTEXT_SCHEMA = 'doppler.observation-context/v1';
|
|
2
|
+
|
|
3
|
+
function cloneJsonValue(value) {
|
|
4
|
+
if (value == null) {
|
|
5
|
+
return value;
|
|
6
|
+
}
|
|
7
|
+
return JSON.parse(JSON.stringify(value));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function deepFreeze(value) {
|
|
11
|
+
if (!value || typeof value !== 'object' || Object.isFrozen(value)) {
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
Object.freeze(value);
|
|
15
|
+
for (const entry of Object.values(value)) {
|
|
16
|
+
deepFreeze(entry);
|
|
17
|
+
}
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function createObservationContext(options = {}) {
|
|
22
|
+
const runtimeConfig = options.runtimeConfig;
|
|
23
|
+
if (!runtimeConfig?.shared?.tooling || !runtimeConfig?.shared?.debug) {
|
|
24
|
+
throw new Error(
|
|
25
|
+
'[ObservationContext] runtime.shared.tooling and runtime.shared.debug are required.'
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
const debug = runtimeConfig.shared.debug;
|
|
29
|
+
return deepFreeze({
|
|
30
|
+
schema: OBSERVATION_CONTEXT_SCHEMA,
|
|
31
|
+
commandContext: options.commandContext ?? null,
|
|
32
|
+
diagnostics: runtimeConfig.shared.tooling.diagnostics,
|
|
33
|
+
probes: cloneJsonValue(debug.probes ?? []),
|
|
34
|
+
tracing: {
|
|
35
|
+
pipelineEnabled: debug.pipeline?.enabled === true,
|
|
36
|
+
layers: cloneJsonValue(debug.pipeline?.layers ?? null),
|
|
37
|
+
kernelTrace: cloneJsonValue(debug.kernelTrace ?? null),
|
|
38
|
+
},
|
|
39
|
+
receiptPolicy: runtimeConfig.shared.tooling.refactorReceipts,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -2,7 +2,7 @@ import { log } from '../../../../debug/index.js';
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Required fields that must not be undefined on every AttnConfig instance.
|
|
5
|
-
* These are the fields
|
|
5
|
+
* These are the fields consumed by both attention executor adapters
|
|
6
6
|
* entry points. Optional fields (skipInputNorm, tokenIds, kernelPath,
|
|
7
7
|
* disableRoPE) have defaults in the destructuring and are excluded.
|
|
8
8
|
*/
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createCommandRecorder } from '../../../../gpu/command-recorder.js';
|
|
2
|
+
import { interpretAttentionWithRecorder } from './interpreter.js';
|
|
3
|
+
|
|
4
|
+
export async function runLayerAttentionGPU(
|
|
5
|
+
input,
|
|
6
|
+
layerWeights,
|
|
7
|
+
config,
|
|
8
|
+
state,
|
|
9
|
+
debug,
|
|
10
|
+
debugFlags,
|
|
11
|
+
getWeightBuffer,
|
|
12
|
+
getNormWeightBuffer,
|
|
13
|
+
debugCheckBuffer,
|
|
14
|
+
lora
|
|
15
|
+
) {
|
|
16
|
+
const phase = config?.isPrefill ? 'prefill' : 'decode';
|
|
17
|
+
const layerIdx = Number.isInteger(config?.layerIdx) ? config.layerIdx : 'unknown';
|
|
18
|
+
const recorder = createCommandRecorder(
|
|
19
|
+
`attention_${phase}_layer_${layerIdx}`,
|
|
20
|
+
{ recordLabels: debug === true }
|
|
21
|
+
);
|
|
22
|
+
try {
|
|
23
|
+
const result = await interpretAttentionWithRecorder(
|
|
24
|
+
recorder,
|
|
25
|
+
input,
|
|
26
|
+
layerWeights,
|
|
27
|
+
config,
|
|
28
|
+
state,
|
|
29
|
+
debug,
|
|
30
|
+
debugFlags,
|
|
31
|
+
getWeightBuffer,
|
|
32
|
+
getNormWeightBuffer,
|
|
33
|
+
debugCheckBuffer,
|
|
34
|
+
lora
|
|
35
|
+
);
|
|
36
|
+
recorder.submit();
|
|
37
|
+
return result;
|
|
38
|
+
} catch (error) {
|
|
39
|
+
recorder.abort();
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { interpretAttentionWithRecorder } from './interpreter.js';
|
|
2
|
+
|
|
3
|
+
export async function recordLayerAttentionGPU(
|
|
4
|
+
recorder,
|
|
5
|
+
input,
|
|
6
|
+
layerWeights,
|
|
7
|
+
config,
|
|
8
|
+
state,
|
|
9
|
+
debug,
|
|
10
|
+
debugFlags,
|
|
11
|
+
getWeightBuffer,
|
|
12
|
+
getNormWeightBuffer,
|
|
13
|
+
debugCheckBuffer,
|
|
14
|
+
lora
|
|
15
|
+
) {
|
|
16
|
+
return interpretAttentionWithRecorder(
|
|
17
|
+
recorder,
|
|
18
|
+
input,
|
|
19
|
+
layerWeights,
|
|
20
|
+
config,
|
|
21
|
+
state,
|
|
22
|
+
debug,
|
|
23
|
+
debugFlags,
|
|
24
|
+
getWeightBuffer,
|
|
25
|
+
getNormWeightBuffer,
|
|
26
|
+
debugCheckBuffer,
|
|
27
|
+
lora
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -13,5 +13,12 @@ export { runLayerAttentionGPU } from './run.js';
|
|
|
13
13
|
|
|
14
14
|
// Record (batched submission)
|
|
15
15
|
export { recordLayerAttentionGPU } from './record.js';
|
|
16
|
+
export {
|
|
17
|
+
ATTENTION_PLAN_SCHEMA,
|
|
18
|
+
resolveAttentionPlan,
|
|
19
|
+
bindAttentionPlan,
|
|
20
|
+
executeBoundAttentionPlan,
|
|
21
|
+
createAttentionExecutor,
|
|
22
|
+
} from './plan.js';
|
|
16
23
|
export { runAttentionBDPA } from '../../../../gpu/kernel-selector.js';
|
|
17
24
|
export { recordAttentionBDPA } from '../../../../gpu/kernel-selector.js';
|