doppler-gpu 0.4.14 → 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/CHANGELOG.md +9 -0
- package/README.md +83 -52
- 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 +116 -1
- package/src/client/runtime/model-session.js +351 -1
- 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
|
@@ -12,7 +12,6 @@ import type { KernelThresholdsConfigSchema } from './kernel-thresholds.schema.js
|
|
|
12
12
|
import type { BufferPoolConfigSchema } from './buffer-pool.schema.js';
|
|
13
13
|
import type { GpuCacheConfigSchema } from './gpu-cache.schema.js';
|
|
14
14
|
import type { MemoryLimitsConfigSchema } from './memory-limits.schema.js';
|
|
15
|
-
import type { TunerConfigSchema } from './tuner.schema.js';
|
|
16
15
|
import type { KernelWarmupConfigSchema } from './kernel-warmup.schema.js';
|
|
17
16
|
import type { HotSwapConfigSchema } from './hotswap.schema.js';
|
|
18
17
|
import type { IntentBundleConfigSchema } from './intent-bundle.schema.js';
|
|
@@ -53,7 +52,7 @@ export interface SharedRuntimeConfigSchema {
|
|
|
53
52
|
kernelRegistry: KernelRegistryConfigSchema;
|
|
54
53
|
/** Kernel selection thresholds */
|
|
55
54
|
kernelThresholds: KernelThresholdsConfigSchema;
|
|
56
|
-
/** Kernel
|
|
55
|
+
/** Kernel prewarming settings */
|
|
57
56
|
kernelWarmup: KernelWarmupConfigSchema;
|
|
58
57
|
/** GPU buffer pool sizing */
|
|
59
58
|
bufferPool: BufferPoolConfigSchema;
|
|
@@ -61,8 +60,6 @@ export interface SharedRuntimeConfigSchema {
|
|
|
61
60
|
gpuCache: GpuCacheConfigSchema;
|
|
62
61
|
/** WASM heap and segment limits */
|
|
63
62
|
memory: MemoryLimitsConfigSchema;
|
|
64
|
-
/** Kernel autotuning settings */
|
|
65
|
-
tuner: TunerConfigSchema;
|
|
66
63
|
/** Hot-swap security policy */
|
|
67
64
|
hotSwap: HotSwapConfigSchema;
|
|
68
65
|
/** Intent bundle gating policy */
|
|
@@ -3,7 +3,6 @@ import { DEFAULT_KERNEL_THRESHOLDS } from './kernel-thresholds.schema.js';
|
|
|
3
3
|
import { DEFAULT_BUFFER_POOL_CONFIG } from './buffer-pool.schema.js';
|
|
4
4
|
import { DEFAULT_GPU_CACHE_CONFIG } from './gpu-cache.schema.js';
|
|
5
5
|
import { DEFAULT_MEMORY_LIMITS_CONFIG } from './memory-limits.schema.js';
|
|
6
|
-
import { DEFAULT_TUNER_CONFIG } from './tuner.schema.js';
|
|
7
6
|
import { DEFAULT_KERNEL_WARMUP_CONFIG } from './kernel-warmup.schema.js';
|
|
8
7
|
import { DEFAULT_HOTSWAP_CONFIG } from './hotswap.schema.js';
|
|
9
8
|
import { DEFAULT_BRIDGE_CONFIG } from './bridge.schema.js';
|
|
@@ -38,7 +37,6 @@ export const DEFAULT_SHARED_RUNTIME_CONFIG = {
|
|
|
38
37
|
bufferPool: DEFAULT_BUFFER_POOL_CONFIG,
|
|
39
38
|
gpuCache: DEFAULT_GPU_CACHE_CONFIG,
|
|
40
39
|
memory: DEFAULT_MEMORY_LIMITS_CONFIG,
|
|
41
|
-
tuner: DEFAULT_TUNER_CONFIG,
|
|
42
40
|
hotSwap: DEFAULT_HOTSWAP_CONFIG,
|
|
43
41
|
intentBundle: DEFAULT_INTENT_BUNDLE_CONFIG,
|
|
44
42
|
bridge: DEFAULT_BRIDGE_CONFIG,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Tooling Intent Config Schema Definitions
|
|
3
3
|
*
|
|
4
|
-
* Defines
|
|
5
|
-
*
|
|
4
|
+
* Defines runtime-owned tooling observation and converter configuration.
|
|
5
|
+
* Active command intent lives in ToolingCommandRequest.
|
|
6
6
|
*
|
|
7
7
|
* @module config/schema/tooling
|
|
8
8
|
*/
|
|
@@ -11,19 +11,22 @@ import type { ConverterConfigSchema } from './converter.schema.js';
|
|
|
11
11
|
|
|
12
12
|
export type ToolingIntent = 'verify' | 'investigate' | 'calibrate' | null;
|
|
13
13
|
export type ToolingDiagnosticsMode = 'off' | 'on_failure' | 'always';
|
|
14
|
+
export type RefactorReceiptPolicy = 'off' | 'on_failure' | 'always';
|
|
14
15
|
|
|
15
16
|
export interface ToolingConfigSchema {
|
|
16
|
-
/** High-level tooling intent for the run */
|
|
17
|
-
intent: ToolingIntent;
|
|
18
17
|
/** Diagnostics policy for verification runs */
|
|
19
18
|
diagnostics: ToolingDiagnosticsMode;
|
|
19
|
+
/** Permanent behavior-receipt capture policy */
|
|
20
|
+
refactorReceipts: RefactorReceiptPolicy;
|
|
20
21
|
/** Optional converter config overrides for browser tooling */
|
|
21
22
|
converter?: Partial<ConverterConfigSchema> | null;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
/** Allowed
|
|
25
|
+
/** Allowed command and runtime-profile metadata intents */
|
|
25
26
|
export declare const TOOLING_INTENTS: ToolingIntent[];
|
|
26
27
|
/** Allowed diagnostics modes */
|
|
27
28
|
export declare const TOOLING_DIAGNOSTICS: ToolingDiagnosticsMode[];
|
|
29
|
+
/** Allowed behavior-receipt capture policies */
|
|
30
|
+
export declare const REFACTOR_RECEIPT_POLICIES: RefactorReceiptPolicy[];
|
|
28
31
|
/** Default tooling configuration */
|
|
29
32
|
export declare const DEFAULT_TOOLING_CONFIG: ToolingConfigSchema;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
// =============================================================================
|
|
2
|
-
// Tooling
|
|
2
|
+
// Tooling Observation Config
|
|
3
3
|
// =============================================================================
|
|
4
4
|
|
|
5
5
|
export const TOOLING_INTENTS = ['verify', 'investigate', 'calibrate'];
|
|
6
6
|
export const TOOLING_DIAGNOSTICS = ['off', 'on_failure', 'always'];
|
|
7
|
+
export const REFACTOR_RECEIPT_POLICIES = ['off', 'on_failure', 'always'];
|
|
7
8
|
|
|
8
9
|
export const DEFAULT_TOOLING_CONFIG = {
|
|
9
|
-
intent: null,
|
|
10
10
|
diagnostics: 'on_failure',
|
|
11
|
+
refactorReceipts: 'off',
|
|
11
12
|
converter: null,
|
|
12
13
|
};
|
package/src/debug/tensor.d.ts
CHANGED
package/src/debug/tensor.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { gpuDevice } from './config.js';
|
|
4
4
|
import { log } from './log.js';
|
|
5
5
|
import { computeArrayStats } from './stats.js';
|
|
6
|
+
import { sha256BytesHex } from '../utils/sha256.js';
|
|
6
7
|
|
|
7
8
|
// ============================================================================
|
|
8
9
|
// Internal Helpers
|
|
@@ -251,6 +252,8 @@ export async function snapshotTensor(buffer, shape, dtype = 'f32', options = {})
|
|
|
251
252
|
dtype,
|
|
252
253
|
stats: { min: 0, max: 0, maxAbs: 0, mean: 0, std: 0 },
|
|
253
254
|
sample: [],
|
|
255
|
+
sampleCoordinates: [],
|
|
256
|
+
fullTensorDigest: null,
|
|
254
257
|
hasNaN: false,
|
|
255
258
|
hasInf: false,
|
|
256
259
|
};
|
|
@@ -259,10 +262,24 @@ export async function snapshotTensor(buffer, shape, dtype = 'f32', options = {})
|
|
|
259
262
|
|
|
260
263
|
export function snapshotFromArray(arr, shape, dtype = 'f32', options = {}) {
|
|
261
264
|
const numElements = shape.reduce((a, b) => a * b, 1);
|
|
262
|
-
const
|
|
265
|
+
const capturedElements = Math.min(arr.length, numElements);
|
|
266
|
+
const stats = computeArrayStats(arr, capturedElements);
|
|
263
267
|
const data = options.includeData === true
|
|
264
268
|
? Array.from(arr.slice(0, numElements))
|
|
265
269
|
: undefined;
|
|
270
|
+
const sampleLength = Math.min(8, capturedElements);
|
|
271
|
+
const sampleCoordinates = [];
|
|
272
|
+
for (let flatIndex = 0; flatIndex < sampleLength; flatIndex += 1) {
|
|
273
|
+
let remainder = flatIndex;
|
|
274
|
+
const coordinate = new Array(shape.length);
|
|
275
|
+
for (let axis = shape.length - 1; axis >= 0; axis -= 1) {
|
|
276
|
+
coordinate[axis] = remainder % shape[axis];
|
|
277
|
+
remainder = Math.floor(remainder / shape[axis]);
|
|
278
|
+
}
|
|
279
|
+
sampleCoordinates.push(coordinate);
|
|
280
|
+
}
|
|
281
|
+
const byteLength = capturedElements * arr.BYTES_PER_ELEMENT;
|
|
282
|
+
const digestBytes = new Uint8Array(arr.buffer, arr.byteOffset, byteLength);
|
|
266
283
|
|
|
267
284
|
const snapshot = {
|
|
268
285
|
ok: true,
|
|
@@ -276,7 +293,9 @@ export function snapshotFromArray(arr, shape, dtype = 'f32', options = {}) {
|
|
|
276
293
|
mean: stats.mean,
|
|
277
294
|
std: stats.std,
|
|
278
295
|
},
|
|
279
|
-
sample: Array.from(arr.slice(0,
|
|
296
|
+
sample: Array.from(arr.slice(0, sampleLength)),
|
|
297
|
+
sampleCoordinates,
|
|
298
|
+
fullTensorDigest: `sha256:${sha256BytesHex(digestBytes)}`,
|
|
280
299
|
hasNaN: stats.nanCount > 0,
|
|
281
300
|
hasInf: stats.infCount > 0,
|
|
282
301
|
};
|
|
@@ -157,6 +157,11 @@ export declare class CommandRecorder {
|
|
|
157
157
|
getStats(): {
|
|
158
158
|
opCount: number;
|
|
159
159
|
opLabelCounts: Record<string, number>;
|
|
160
|
+
dispatches: Array<{
|
|
161
|
+
label: string;
|
|
162
|
+
kind: 'direct' | 'indirect';
|
|
163
|
+
workgroups: number[] | null;
|
|
164
|
+
}>;
|
|
160
165
|
computePassCount: number;
|
|
161
166
|
tempBufferCount: number;
|
|
162
167
|
pooledBufferCount: number;
|
|
@@ -43,6 +43,8 @@ export class CommandRecorder {
|
|
|
43
43
|
|
|
44
44
|
#opLabelCounts;
|
|
45
45
|
|
|
46
|
+
#dispatchRecords;
|
|
47
|
+
|
|
46
48
|
#recordLabels;
|
|
47
49
|
|
|
48
50
|
#computePassCount;
|
|
@@ -96,6 +98,7 @@ export class CommandRecorder {
|
|
|
96
98
|
this.#opCount = 0;
|
|
97
99
|
this.#recordLabels = options.recordLabels !== false;
|
|
98
100
|
this.#opLabelCounts = this.#recordLabels ? Object.create(null) : null;
|
|
101
|
+
this.#dispatchRecords = [];
|
|
99
102
|
this.#computePassCount = 0;
|
|
100
103
|
this.#activeComputePass = null;
|
|
101
104
|
// Initialize profiling if requested and available
|
|
@@ -316,6 +319,11 @@ export class CommandRecorder {
|
|
|
316
319
|
throw new Error('[CommandRecorder] Cannot record dispatch after submit');
|
|
317
320
|
}
|
|
318
321
|
const opLabel = this.#recordDispatchOperation(label);
|
|
322
|
+
this.#dispatchRecords.push({
|
|
323
|
+
label: opLabel ?? this.#normalizeOperationLabel(label),
|
|
324
|
+
kind: 'direct',
|
|
325
|
+
workgroups: Array.from(workgroups),
|
|
326
|
+
});
|
|
319
327
|
if (this.#profilingEnabled) {
|
|
320
328
|
const pass = this.#beginRawComputePass(opLabel);
|
|
321
329
|
pass.setPipeline(pipeline);
|
|
@@ -335,6 +343,11 @@ export class CommandRecorder {
|
|
|
335
343
|
throw new Error('[CommandRecorder] Cannot record dispatch after submit');
|
|
336
344
|
}
|
|
337
345
|
const opLabel = this.#recordDispatchOperation(label);
|
|
346
|
+
this.#dispatchRecords.push({
|
|
347
|
+
label: opLabel ?? this.#normalizeOperationLabel(label),
|
|
348
|
+
kind: 'indirect',
|
|
349
|
+
workgroups: null,
|
|
350
|
+
});
|
|
338
351
|
if (this.#profilingEnabled) {
|
|
339
352
|
const pass = this.#beginRawComputePass(opLabel);
|
|
340
353
|
pass.setPipeline(pipeline);
|
|
@@ -524,6 +537,10 @@ export class CommandRecorder {
|
|
|
524
537
|
return {
|
|
525
538
|
opCount: this.#opCount,
|
|
526
539
|
opLabelCounts,
|
|
540
|
+
dispatches: this.#dispatchRecords.map((record) => ({
|
|
541
|
+
...record,
|
|
542
|
+
workgroups: record.workgroups ? [...record.workgroups] : null,
|
|
543
|
+
})),
|
|
527
544
|
computePassCount: this.#computePassCount,
|
|
528
545
|
tempBufferCount: this.#tempBuffers.length,
|
|
529
546
|
pooledBufferCount: this.#pooledBuffers.length,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { prewarmKernels, clearKernelCaches } from './kernels/utils.js';
|
|
4
4
|
import { getRuntimeConfig } from '../config/runtime.js';
|
|
5
5
|
|
|
6
6
|
|
|
@@ -14,26 +14,18 @@ export async function prepareKernelRuntime(
|
|
|
14
14
|
const {
|
|
15
15
|
prewarm = kernelWarmup.prewarm,
|
|
16
16
|
prewarmMode = kernelWarmup.prewarmMode,
|
|
17
|
-
autoTune = kernelWarmup.autoTune,
|
|
18
17
|
clearCaches = false,
|
|
19
|
-
modelConfig = {},
|
|
20
18
|
} = options;
|
|
21
19
|
|
|
22
20
|
if (clearCaches) {
|
|
23
21
|
clearKernelCaches();
|
|
24
22
|
}
|
|
25
23
|
|
|
26
|
-
let tuned = false;
|
|
27
|
-
if (autoTune) {
|
|
28
|
-
await autoTuneKernels(modelConfig);
|
|
29
|
-
tuned = true;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
24
|
let warmed = false;
|
|
33
25
|
if (prewarm) {
|
|
34
26
|
await prewarmKernels({ mode: prewarmMode });
|
|
35
27
|
warmed = true;
|
|
36
28
|
}
|
|
37
29
|
|
|
38
|
-
return { warmed
|
|
30
|
+
return { warmed };
|
|
39
31
|
}
|
package/src/gpu/kernels/index.js
CHANGED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { getKernelCapabilities } from '../device.js';
|
|
2
|
+
import { KERNEL_CONFIGS } from './kernel-configs.js';
|
|
3
|
+
import { createPipeline, clearPipelineCaches } from './pipeline-cache.js';
|
|
4
|
+
import { clearShaderCaches } from './shader-cache.js';
|
|
5
|
+
import { hasRequiredFeatures } from './feature-check.js';
|
|
6
|
+
import { log } from '../../debug/index.js';
|
|
7
|
+
|
|
8
|
+
export async function prewarmKernels(options = {}) {
|
|
9
|
+
const capabilities = getKernelCapabilities();
|
|
10
|
+
const mode = options.mode ?? 'parallel';
|
|
11
|
+
const entries = Object.entries(KERNEL_CONFIGS)
|
|
12
|
+
.sort(([left], [right]) => left.localeCompare(right))
|
|
13
|
+
.map(([operation, variants]) => [
|
|
14
|
+
operation,
|
|
15
|
+
Object.entries(variants).sort(([left], [right]) => left.localeCompare(right)),
|
|
16
|
+
]);
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
if (mode === 'sequential') {
|
|
20
|
+
let count = 0;
|
|
21
|
+
for (const [operation, variants] of entries) {
|
|
22
|
+
for (const [variant, config] of variants) {
|
|
23
|
+
if (config.requires && !hasRequiredFeatures(config.requires, capabilities)) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
await createPipeline(operation, variant);
|
|
28
|
+
count += 1;
|
|
29
|
+
} catch (error) {
|
|
30
|
+
log.warn('KernelPrewarm', `Prewarm failed for ${operation}/${variant}: ${error.message}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
log.debug('KernelPrewarm', `Prewarmed ${count} kernel pipelines`);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const jobs = [];
|
|
39
|
+
for (const [operation, variants] of entries) {
|
|
40
|
+
for (const [variant, config] of variants) {
|
|
41
|
+
if (config.requires && !hasRequiredFeatures(config.requires, capabilities)) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
jobs.push(
|
|
45
|
+
createPipeline(operation, variant)
|
|
46
|
+
.then(() => {})
|
|
47
|
+
.catch((error) => {
|
|
48
|
+
log.warn('KernelPrewarm', `Prewarm failed for ${operation}/${variant}: ${error.message}`);
|
|
49
|
+
})
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
await Promise.all(jobs);
|
|
54
|
+
log.debug('KernelPrewarm', `Prewarmed ${jobs.length} kernel pipelines`);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
clearPipelineCaches();
|
|
57
|
+
clearShaderCaches();
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -62,14 +62,12 @@ export {
|
|
|
62
62
|
} from './feature-check.js';
|
|
63
63
|
|
|
64
64
|
// ============================================================================
|
|
65
|
-
// Re-exports from kernel
|
|
65
|
+
// Re-exports from kernel prewarming
|
|
66
66
|
// ============================================================================
|
|
67
67
|
|
|
68
68
|
export {
|
|
69
|
-
getTunedWorkgroupSize,
|
|
70
|
-
autoTuneKernels,
|
|
71
69
|
prewarmKernels,
|
|
72
|
-
} from './kernel-
|
|
70
|
+
} from './kernel-prewarm.js';
|
|
73
71
|
|
|
74
72
|
// ============================================================================
|
|
75
73
|
// Re-exports from uniform-utils
|
package/src/gpu/kernels/utils.js
CHANGED
|
@@ -81,14 +81,12 @@ export {
|
|
|
81
81
|
} from './feature-check.js';
|
|
82
82
|
|
|
83
83
|
// ============================================================================
|
|
84
|
-
// Re-exports from kernel
|
|
84
|
+
// Re-exports from kernel prewarming
|
|
85
85
|
// ============================================================================
|
|
86
86
|
|
|
87
87
|
export {
|
|
88
|
-
getTunedWorkgroupSize,
|
|
89
|
-
autoTuneKernels,
|
|
90
88
|
prewarmKernels,
|
|
91
|
-
} from './kernel-
|
|
89
|
+
} from './kernel-prewarm.js';
|
|
92
90
|
|
|
93
91
|
// ============================================================================
|
|
94
92
|
// Re-exports from uniform-utils
|
package/src/index.d.ts
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
1
|
export { DOPPLER_VERSION } from './version.js';
|
|
2
|
-
export {
|
|
2
|
+
export {
|
|
3
|
+
doppler,
|
|
4
|
+
doppler as dr,
|
|
5
|
+
generate,
|
|
6
|
+
load,
|
|
7
|
+
open,
|
|
8
|
+
} from './client/doppler-api.js';
|
|
9
|
+
export type {
|
|
10
|
+
DopplerGenerationResult,
|
|
11
|
+
DopplerPromptInput,
|
|
12
|
+
DopplerScopedGenerateOptions,
|
|
13
|
+
DopplerScopedModelSession,
|
|
14
|
+
} from './client/doppler-api.js';
|
|
3
15
|
export { createDopplerProvider } from './client/provider.js';
|
package/src/index.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
export { DOPPLER_VERSION } from './version.js';
|
|
2
|
-
export {
|
|
2
|
+
export {
|
|
3
|
+
doppler,
|
|
4
|
+
doppler as dr,
|
|
5
|
+
generate,
|
|
6
|
+
load,
|
|
7
|
+
open,
|
|
8
|
+
} from './client/doppler-api.js';
|
|
3
9
|
export { createDopplerProvider } from './client/provider.js';
|
|
@@ -156,6 +156,7 @@ async function initializeInferenceFromStorage(modelId, options = {}) {
|
|
|
156
156
|
: `Using default shard-store context for "${modelId}"`
|
|
157
157
|
);
|
|
158
158
|
const pipeline = await createPipeline(manifest, {
|
|
159
|
+
commandContext: options.commandContext ?? null,
|
|
159
160
|
gpu: { device },
|
|
160
161
|
runtime: options.runtime,
|
|
161
162
|
...(storage ? { storage } : {}),
|
|
@@ -209,6 +210,7 @@ async function initializeInferenceFromSourcePath(sourcePath, options = {}) {
|
|
|
209
210
|
|
|
210
211
|
onProgress?.('pipeline', 0.3, 'Creating pipeline...');
|
|
211
212
|
const pipeline = await createPipeline(sourceBundle.manifest, {
|
|
213
|
+
commandContext: options.commandContext ?? null,
|
|
212
214
|
gpu: { device },
|
|
213
215
|
runtime: effectiveRuntime,
|
|
214
216
|
storage: sourceBundle.storageContext,
|
|
@@ -345,6 +347,8 @@ export async function initializeSuiteModel(options = {}) {
|
|
|
345
347
|
onProgress: options.onProgress,
|
|
346
348
|
log: options.log,
|
|
347
349
|
loadMode,
|
|
350
|
+
modelId: options.modelId ?? null,
|
|
351
|
+
commandContext: options.commandContext ?? null,
|
|
348
352
|
});
|
|
349
353
|
}
|
|
350
354
|
const modelLoadMs = Math.max(0, performance.now() - loadStart);
|
|
@@ -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;
|