doppler-gpu 0.5.1 → 0.6.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 +33 -577
- package/LICENSE +21 -201
- package/README.md +165 -222
- package/models/catalog.json +241 -33
- package/package.json +106 -87
- package/src/capsule-runtime.d.ts +25 -0
- package/src/capsule-runtime.js +24 -0
- package/src/capsule.d.ts +8 -0
- package/src/capsule.js +4 -0
- package/src/cli/argument-contract.js +200 -0
- package/src/cli/browser-report-output.js +24 -0
- package/src/cli/cli-model-resolution.js +2 -2
- package/src/cli/cli-output.js +10 -0
- package/src/cli/commands/bundle.js +828 -0
- package/src/cli/doppler-cli.js +50 -1457
- package/src/cli/doppler-serve.js +18 -244
- package/src/cli/output/manifest.js +368 -0
- package/src/cli/runtime-profiles.js +1 -1
- package/src/cli/serve/capsule-handler.d.ts +33 -0
- package/src/cli/serve/capsule-handler.js +105 -0
- package/src/cli/serve/capsule-http.js +102 -0
- package/src/cli/serve/receipt.js +269 -0
- package/src/client/capsule-host.browser.js +2 -0
- package/src/client/capsule-host.d.ts +5 -0
- package/src/client/capsule-host.js +2 -0
- package/src/client/doppler-api.browser.js +42 -0
- package/src/client/doppler-api.d.ts +38 -1
- package/src/client/doppler-api.js +41 -1
- package/src/client/doppler-registry.js +15 -7
- package/src/client/electron/index.d.ts +4 -0
- package/src/client/electron/index.js +13 -0
- package/src/client/electron/ipc-contract.d.ts +9 -0
- package/src/client/electron/ipc-contract.js +56 -0
- package/src/client/electron/release-state.d.ts +53 -0
- package/src/client/electron/release-state.js +425 -0
- package/src/client/electron/renderer-runtime.d.ts +19 -0
- package/src/client/electron/renderer-runtime.js +104 -0
- package/src/client/failure-taxonomy.js +1 -28
- package/src/client/fault-injection.js +0 -8
- package/src/client/inspection.js +1 -1
- package/src/client/model-host/index.d.ts +140 -0
- package/src/client/model-host/index.js +548 -0
- package/src/client/model-host/model-evidence.js +255 -0
- package/src/client/model-host/model-session.d.ts +323 -0
- package/src/client/{runtime → model-host}/model-session.js +202 -148
- package/src/client/provider.d.ts +18 -2
- package/src/client/provider.js +26 -3
- package/src/client/receipt.js +30 -72
- package/src/client/runtime/capsule-acquisition.d.ts +18 -0
- package/src/client/runtime/capsule-acquisition.js +103 -0
- package/src/client/runtime/capsule-adapter-execution.d.ts +17 -0
- package/src/client/runtime/capsule-adapter-execution.js +63 -0
- package/src/client/runtime/capsule-artifact-source.js +62 -0
- package/src/client/runtime/capsule-embedding.d.ts +29 -0
- package/src/client/runtime/capsule-embedding.js +76 -0
- package/src/client/runtime/capsule-forecast-program.d.ts +2 -0
- package/src/client/runtime/capsule-forecast-program.js +85 -0
- package/src/client/runtime/capsule-forecast.d.ts +17 -0
- package/src/client/runtime/capsule-forecast.js +31 -0
- package/src/client/runtime/capsule-operation-adapters.d.ts +12 -0
- package/src/client/runtime/capsule-operation-adapters.js +69 -0
- package/src/client/runtime/capsule-operation-executor.d.ts +25 -0
- package/src/client/runtime/capsule-operation-executor.js +101 -0
- package/src/client/runtime/capsule-program-adapter.js +153 -0
- package/src/client/runtime/capsule-release-authorization.js +25 -0
- package/src/client/runtime/capsule-rerank.d.ts +50 -0
- package/src/client/runtime/capsule-rerank.js +105 -0
- package/src/client/runtime/capsule-session-execution.js +89 -0
- package/src/client/runtime/command-executor.d.ts +15 -0
- package/src/client/runtime/command-executor.js +128 -0
- package/src/client/runtime/composition-root.d.ts +77 -0
- package/src/client/runtime/composition-root.js +352 -0
- package/src/client/runtime/fetch-capsule-artifact-store.d.ts +10 -0
- package/src/client/runtime/fetch-capsule-artifact-store.js +25 -0
- package/src/client/runtime/index.d.ts +1 -117
- package/src/client/runtime/index.js +1 -433
- package/src/client/runtime/lora.d.ts +14 -0
- package/src/client/runtime/lora.js +19 -1
- package/src/client/runtime/model-manager.js +12 -0
- package/src/client/runtime/model-rerank.js +30 -0
- package/src/client/runtime/model-session.d.ts +1 -221
- package/src/client/runtime/model-source.d.ts +9 -0
- package/src/client/runtime/model-source.js +46 -17
- package/src/client/runtime/node-quickstart-cache.js +1 -1
- package/src/client/runtime/resolution-policy.d.ts +20 -0
- package/src/client/runtime/resolution-policy.js +84 -0
- package/src/client/runtime/resource-binder.d.ts +24 -0
- package/src/client/runtime/resource-binder.js +135 -0
- package/src/client/runtime/scoped-session.d.ts +10 -1
- package/src/client/runtime/scoped-session.js +20 -1
- package/src/client/runtime/session-controller.d.ts +19 -0
- package/src/client/runtime/session-controller.js +92 -0
- package/src/client/runtime/source-runtime.js +1 -1
- package/src/client/runtime/target-selector.d.ts +9 -0
- package/src/client/runtime/target-selector.js +2 -0
- package/src/client/runtime/types.d.ts +1 -0
- package/src/client/runtime/verified-capsule-artifact-store.js +101 -0
- package/src/client/wrap-pipeline-handle.js +3 -9
- package/src/config/backward-registry-loader.js +1 -1
- package/src/config/capsule-adapter-policy.js +30 -0
- package/src/config/capsule-adapters.d.ts +21 -0
- package/src/config/capsule-adapters.js +40 -0
- package/src/config/capsule-adapters.json +9 -0
- package/src/config/capsule-loading.d.ts +2 -0
- package/src/config/capsule-loading.js +14 -0
- package/src/config/capsule-loading.schema.json +12 -0
- package/src/config/capsule-operation.d.ts +19 -0
- package/src/config/capsule-operation.js +63 -0
- package/src/config/capsule-operations.json +17 -0
- package/src/config/capsule-release-contract.d.ts +66 -0
- package/src/config/capsule-release-contract.js +197 -0
- package/src/config/capsule-release-events.d.ts +53 -0
- package/src/config/capsule-release-events.js +172 -0
- package/src/config/capsule-sequence-receipt.js +19 -0
- package/src/config/capsule-serve.d.ts +9 -0
- package/src/config/capsule-serve.js +28 -0
- package/src/config/capsule-serve.schema.json +14 -0
- package/src/config/capsule-signature.d.ts +6 -0
- package/src/config/capsule-signature.js +50 -0
- package/src/config/capsule-v2.d.ts +70 -0
- package/src/config/capsule-v2.js +431 -0
- package/src/config/capsule-v3.d.ts +19 -0
- package/src/config/capsule-v3.js +72 -0
- package/src/config/capsule.d.ts +22 -0
- package/src/config/capsule.js +52 -0
- package/src/config/conversion/amplify/amplify-120m-f16-af32.json +1 -1
- package/src/config/conversion/diffusiongemma/diffusiongemma-26b-a4b-it-q4k-ehf16-af16.json +3 -3
- package/src/config/conversion/embeddinggemma/google-embeddinggemma-300m-q4k-ehf16-af32.json +2 -2
- package/src/config/conversion/esm/esm2-t12-35m-ur50d-f32-af32.json +62 -4
- package/src/config/conversion/esmc/esmc-300m-f32-af32.json +1 -1
- package/src/config/conversion/gemma3/gemma-3-1b-it-f16-af32.json +2 -2
- package/src/config/conversion/gemma3/gemma-3-1b-it-q4k-ehf16-af32.json +3 -3
- package/src/config/conversion/gemma3/gemma-3-270m-it-f16-af32.json +3 -3
- package/src/config/conversion/gemma3/gemma-3-270m-it-q4k-ehf16-af16.json +3 -3
- package/src/config/conversion/gemma3/gemma-3-270m-it-q4k-ehf16-af32.json +3 -3
- package/src/config/conversion/gemma3/translategemma-4b-1b-enes-q4k-ehf16-af32.json +3 -3
- package/src/config/conversion/gemma3/translategemma-4b-it-q4k-ehf16-af32.json +3 -3
- package/src/config/conversion/gemma4/gemma-4-12b-it-text-q4k-ehf16-af16.json +5 -5
- package/src/config/conversion/gemma4/gemma-4-12b-it-text-q4k-ehf16-af32.json +4 -4
- package/src/config/conversion/gemma4/gemma-4-12b-it-text-q4k-ehf16-hq4k-af16.json +6 -6
- package/src/config/conversion/gemma4/gemma-4-12b-it-text-w4a16-ct-ehf16-af16.json +3 -3
- package/src/config/conversion/gemma4/gemma-4-31b-it-text-q4k-ehf16-af16.json +5 -5
- package/src/config/conversion/gemma4/gemma-4-31b-it-text-q4k-ehf16-af32.json +4 -4
- package/src/config/conversion/gemma4/gemma-4-e2b-it-q4k-ehf16-af16-int4ple.json +6 -6
- package/src/config/conversion/gemma4/gemma-4-e2b-it-q4k-ehf16-af32-int4ple.json +3 -3
- package/src/config/conversion/gemma4/gemma-4-e2b-it-q4k-ehf16-af32.json +3 -3
- package/src/config/conversion/gemma4/gemma-4-moe-q4k-ehf16-af32.json +2 -2
- package/src/config/conversion/glmocr/glm-ocr-f16-af32.json +442 -0
- package/src/config/conversion/gpt-oss-20b-f16-xmxfp4.json +2 -2
- package/src/config/conversion/janus/janus-pro-1b-text-q4k-ehaf16.json +2 -2
- package/src/config/conversion/lfm2/lfm2.5-1.2b-instruct-q4k-ehf16-af32.json +2 -2
- package/src/config/conversion/minicpm/minicpm4-0-5b-f16-af32.json +3 -3
- package/src/config/conversion/muse-glimmer/muse-glimmer-30b-text-bf16-af32.json +529 -0
- package/src/config/conversion/muse-glimmer/muse-glimmer-30b-text-f16-af32.json +529 -0
- package/src/config/conversion/nucleotide-transformer/nucleotide-transformer-v2-50m-f32-af32.json +1 -1
- package/src/config/conversion/qwen3/qwen-3-5-0-8b-q4k-ehaf16.json +6 -6
- package/src/config/conversion/qwen3/qwen-3-5-2b-q4k-ehaf16.json +6 -6
- package/src/config/conversion/qwen3/qwen-3-5-9b-f16-af32.json +1 -1
- package/src/config/conversion/qwen3/qwen-3-5-9b-q4k-ehaf16.json +6 -6
- package/src/config/conversion/qwen3/qwen-3-6-27b-q4k-eaf16.json +7 -7
- package/src/config/conversion/qwen3/qwen-3-6-27b-q4k-ehaf16.json +6 -6
- package/src/config/conversion/qwen3/qwen-3-embedding-0-6b-f16-af32.json +463 -0
- package/src/config/conversion/qwen3/qwen-3-embedding-0-6b-q4k-ehf16-af32.json +3 -3
- package/src/config/conversion/qwen3/qwen-3-reranker-0-6b-f16-af32.json +3 -3
- package/src/config/conversion/qwen3/qwen-3-reranker-0-6b-f16-true-logit-af32.json +481 -0
- package/src/config/conversion/qwen3/qwen-3-reranker-0-6b-q4k-ehf16-af32.json +60 -8
- package/src/config/conversion/qwen3/qwen3.8-27b-text-f16-af32.json +561 -0
- package/src/config/conversion/qwen3/qwen3.8-27b-text-q4k-ehaf16.json +558 -0
- package/src/config/dtype-transition-contract.js +40 -0
- package/src/config/embedding-contract.js +26 -0
- package/src/config/embedding-reference.js +85 -0
- package/src/config/evidence/source-intake-policy.json +1 -1
- package/src/config/execution-contract-check.d.ts +16 -73
- package/src/config/execution-contract-check.js +7 -429
- package/src/config/forecast-manifest.js +56 -0
- package/src/config/generation-contract.d.ts +39 -0
- package/src/config/generation-contract.js +66 -0
- package/src/config/generation-contract.json +32 -0
- package/src/config/heterogeneous-attention-contract.js +46 -0
- package/src/config/initial-execution-identity.d.ts +58 -0
- package/src/config/initial-execution-identity.js +331 -0
- package/src/config/kernel-path-loader.d.ts +17 -0
- package/src/config/kernel-path-loader.js +42 -8
- package/src/config/kernel-registry-contract.d.ts +25 -0
- package/src/config/kernel-registry-contract.js +46 -0
- package/src/config/kernels/kernel-ref-digests.js +66 -18
- package/src/config/kernels/registry.js +1 -1
- package/src/config/kernels/registry.json +13617 -11377
- package/src/config/lora-layouts.d.ts +10 -0
- package/src/config/lora-layouts.js +17 -0
- package/src/config/lora-layouts.json +9 -0
- package/src/config/manifest-inference-validation.js +575 -0
- package/src/config/merge/execution-patches.js +12 -0
- package/src/config/{merge-helpers.js → merge/kernel-path-policy.js} +0 -52
- package/src/config/merge/value-selection.js +38 -0
- package/src/config/merge.js +43 -11
- package/src/config/model-ir-v2.d.ts +57 -0
- package/src/config/model-ir-v2.js +258 -0
- package/src/config/model-ir.d.ts +49 -0
- package/src/config/model-ir.js +180 -0
- package/src/config/param-validator.js +1 -1
- package/src/config/platforms/amd-strix-halo-gfx1151.json +17 -0
- package/src/config/platforms/loader.js +2 -1
- package/src/config/production-release-evidence.d.ts +23 -0
- package/src/config/production-release-evidence.js +423 -0
- package/src/config/production-release.js +321 -0
- package/src/{client/doppler-registry.json → config/quickstart-registry.json} +7 -7
- package/src/config/required-inference-fields-contract-check.js +2 -2
- package/src/config/rerank-reference.d.ts +28 -0
- package/src/config/rerank-reference.js +89 -0
- package/src/config/revocation-policy.d.ts +65 -0
- package/src/config/revocation-policy.js +290 -0
- package/src/config/revocation-registry.json +11 -0
- package/src/config/revocation-updates.d.ts +68 -0
- package/src/config/revocation-updates.js +440 -0
- package/src/config/runtime/profiles/gemma4-31b-f16-activations-probe.json +1 -1
- package/src/config/runtime/profiles/muse-glimmer-30b-source-parity-f32kv.json +30 -0
- package/src/config/runtime/profiles/muse-glimmer-30b-source-parity.json +110 -0
- package/src/config/runtime/profiles/qwen3-6-27b-f16-activations-probe.json +1 -1
- package/src/config/runtime/profiles/qwen3-8-27b-source-parity.json +87 -0
- package/src/config/runtime-merge.js +1 -1
- package/src/config/runtime.js +1 -1
- package/src/config/schema/browser-suite-metrics.schema.d.ts +1 -0
- package/src/config/schema/browser-suite-metrics.schema.js +2 -0
- package/src/config/schema/conversion-report.schema.d.ts +3 -0
- package/src/config/schema/conversion-report.schema.js +29 -0
- package/src/config/schema/converter.schema.d.ts +1 -0
- package/src/config/schema/debug.schema.d.ts +1 -0
- package/src/config/schema/doppler.schema.js +6 -5
- package/src/config/schema/emulation.schema.js +1 -1
- package/src/config/schema/execution-v1.schema.d.ts +3 -0
- package/src/config/schema/execution-v1.schema.js +19 -0
- package/src/config/schema/harness.schema.d.ts +13 -0
- package/src/config/schema/harness.schema.js +6 -0
- package/src/config/schema/inference.schema.d.ts +21 -2
- package/src/config/schema/kernel-thresholds.schema.js +1 -1
- package/src/config/schema/manifest.schema.d.ts +26 -7
- package/src/config/schema/manifest.schema.js +10 -1
- package/src/config/schema/program-bundle.schema.d.ts +52 -6
- package/src/config/schema/program-bundle.schema.js +145 -10
- package/src/config/sequence-reference.d.ts +26 -0
- package/src/config/sequence-reference.js +100 -0
- package/src/config/source-packages/litert/gemma-4-e2b-it.json +2 -2
- package/src/config/target-plan.d.ts +108 -0
- package/src/config/target-plan.js +411 -0
- package/src/config/training-defaults.js +1 -1
- package/src/config/transforms/capability-transform-resolver.js +4 -105
- package/src/config/transforms/execution-graph/dtype.js +591 -0
- package/src/config/transforms/execution-graph/fusion.js +436 -0
- package/src/config/transforms/execution-graph/validation.js +414 -0
- package/src/config/transforms/execution-graph-transforms.js +13 -1419
- package/src/converter/artifact-identity.js +475 -0
- package/src/converter/conversion-plan.js +1 -1
- package/src/converter/core.js +94 -2096
- package/src/converter/forge-candidate-evaluation.js +271 -0
- package/src/converter/forge-qualification.js +163 -0
- package/src/converter/forge-stages.js +800 -0
- package/src/converter/manifest-builder.js +683 -0
- package/src/converter/quantization-info.js +4 -1
- package/src/converter/quantizer.js +76 -13
- package/src/converter/shard-packer.d.ts +1 -1
- package/src/converter/shard-packer.js +2 -2
- package/src/converter/tensor-transform.js +640 -0
- package/src/converter/tokenizer-contract.js +243 -0
- package/src/converter/tokenizer-manifest.js +243 -0
- package/src/debug/history.js +0 -8
- package/src/debug/index.js +0 -10
- package/src/debug/tensor.js +1 -1
- package/src/debug/trace.js +0 -7
- package/src/experimental/adapters/adapter-manager.js +2 -0
- package/src/experimental/adapters/adapter-manifest.d.ts +6 -0
- package/src/experimental/adapters/adapter-manifest.js +11 -0
- package/src/experimental/adapters/artifact-contract.d.ts +2 -2
- package/src/experimental/adapters/artifact-contract.js +5 -2
- package/src/experimental/adapters/lora-loader.d.ts +10 -1
- package/src/experimental/adapters/lora-loader.js +110 -48
- package/src/{inference/pipelines → experimental}/audio/gemma4.js +9 -31
- package/src/experimental/bdpa/basis-decomposed-paged.d.ts +50 -0
- package/src/experimental/bdpa/basis-decomposed-paged.js +276 -0
- package/src/experimental/bridge/trainer-artifact-bridge.js +3 -3
- package/src/experimental/browser/browser-converter.js +11 -11
- package/src/experimental/diffusion/index.d.ts +1 -1
- package/src/experimental/diffusion/index.js +1 -1
- package/src/{inference/pipelines → experimental}/diffusion/pipeline.d.ts +2 -2
- package/src/{inference/pipelines → experimental}/diffusion/pipeline.js +17 -17
- package/src/{inference/pipelines → experimental}/diffusion/text-encoder-gpu.js +21 -19
- package/src/experimental/diffusion/vae.js +596 -0
- package/src/experimental/distribution/shard-delivery/receipt.js +588 -0
- package/src/experimental/distribution/shard-delivery/retry.js +392 -0
- package/src/experimental/distribution/shard-delivery/transport.js +831 -0
- package/src/experimental/distribution/shard-delivery.js +4 -1709
- package/src/experimental/energy/index.d.ts +2 -2
- package/src/experimental/energy/index.js +2 -2
- package/src/{inference/pipelines → experimental}/energy/pipeline.js +13 -13
- package/src/{inference/pipelines → experimental}/energy/types.d.ts +2 -2
- package/src/experimental/logits/cpu-output.d.ts +27 -0
- package/src/{inference/pipelines/text/logits/utils.js → experimental/logits/cpu-output.js} +19 -27
- package/src/experimental/logits/cpu.d.ts +87 -0
- package/src/experimental/logits/cpu.js +95 -0
- package/src/experimental/orchestration/energy-row-head-pipeline.d.ts +103 -0
- package/src/{inference/pipelines/energy-head/row-head-pipeline.js → experimental/orchestration/energy-row-head-pipeline.js} +13 -13
- package/src/experimental/orchestration/index.d.ts +1 -1
- package/src/experimental/orchestration/index.js +1 -1
- package/src/experimental/training/artifacts.js +2 -2
- package/src/experimental/training/checkpoint.js +2 -2
- package/src/experimental/training/distillation/artifacts.js +1 -1
- package/src/experimental/training/distillation/dataset.js +2 -2
- package/src/experimental/training/distillation/eval.js +1 -1
- package/src/experimental/training/distillation/runtime.js +2 -2
- package/src/experimental/training/distillation/student-fixture/execution.js +166 -0
- package/src/experimental/training/distillation/student-fixture/model.js +353 -0
- package/src/experimental/training/distillation/student-fixture.js +2 -469
- package/src/experimental/training/lora/checkpoint.js +746 -0
- package/src/experimental/training/lora/execution.js +550 -0
- package/src/experimental/training/lora/plan.js +387 -0
- package/src/experimental/training/lora/recovery.js +418 -0
- package/src/experimental/training/lora-pipeline.js +7 -1949
- package/src/experimental/training/operator-artifacts.js +2 -2
- package/src/experimental/training/operator-command.js +4 -4
- package/src/experimental/training/runner/evaluation.js +62 -0
- package/src/experimental/training/runner/lifecycle.js +257 -0
- package/src/experimental/training/runner.js +5 -268
- package/src/experimental/training/suite/execution.js +879 -0
- package/src/experimental/training/suite/plan.js +855 -0
- package/src/experimental/training/suite.js +5 -1659
- package/src/experimental/training/workloads.d.ts +5 -5
- package/src/experimental/training/workloads.js +6 -6
- package/src/experimental/turboquant/codebook.js +470 -0
- package/src/formats/quantization-constants.d.ts +11 -0
- package/src/formats/quantization-constants.js +11 -0
- package/src/formats/rdrr/integrity.js +1 -1
- package/src/formats/rdrr/lowerings.js +0 -29
- package/src/formats/rdrr/merkle.js +1 -1
- package/src/formats/rdrr/tensor-config-validator.js +25 -5
- package/src/formats/rdrr/validation.js +3 -3
- package/src/gpu/command-recorder.d.ts +10 -1
- package/src/gpu/command-recorder.js +58 -14
- package/src/gpu/constant-buffer.js +29 -0
- package/src/gpu/device-state.js +44 -0
- package/src/gpu/device.js +11 -41
- package/src/gpu/kernel-runtime.js +2 -1
- package/src/gpu/kernels/activation-static-qdq.js +1 -1
- package/src/gpu/kernels/append_embedding.wgsl +14 -0
- package/src/gpu/kernels/attention/executors.js +960 -0
- package/src/gpu/kernels/attention/plan.js +472 -0
- package/src/gpu/kernels/attention.d.ts +4 -0
- package/src/gpu/kernels/attention.js +145 -1545
- package/src/gpu/kernels/attention_relative.wgsl +59 -0
- package/src/gpu/kernels/backward/adam.js +2 -1
- package/src/gpu/kernels/backward/attention_backward.js +1 -1
- package/src/gpu/kernels/backward/bias_add_backward.d.ts +1 -1
- package/src/gpu/kernels/backward/bias_add_backward.js +1 -1
- package/src/gpu/kernels/backward/causal_conv1d_silu_backward.js +2 -1
- package/src/gpu/kernels/backward/conv2d_backward.d.ts +1 -1
- package/src/gpu/kernels/backward/conv2d_backward.js +2 -1
- package/src/gpu/kernels/backward/cross_entropy_backward.d.ts +1 -1
- package/src/gpu/kernels/backward/cross_entropy_backward.js +1 -1
- package/src/gpu/kernels/backward/embed_backward.js +2 -1
- package/src/gpu/kernels/backward/executor.d.ts +34 -0
- package/src/gpu/kernels/backward/executor.js +158 -0
- package/src/gpu/kernels/backward/gated_delta_recurrent_backward.js +2 -1
- package/src/gpu/kernels/backward/gated_rmsnorm_backward.js +2 -1
- package/src/gpu/kernels/backward/gelu_backward.d.ts +1 -1
- package/src/gpu/kernels/backward/gelu_backward.js +1 -1
- package/src/gpu/kernels/backward/groupnorm_backward.d.ts +1 -1
- package/src/gpu/kernels/backward/groupnorm_backward.js +1 -1
- package/src/gpu/kernels/backward/layernorm_backward.d.ts +1 -1
- package/src/gpu/kernels/backward/layernorm_backward.js +2 -1
- package/src/gpu/kernels/backward/matmul.js +133 -0
- package/src/gpu/kernels/backward/matmul_backward.d.ts +0 -1
- package/src/gpu/kernels/backward/matmul_backward.js +1 -1
- package/src/gpu/kernels/backward/pixel_shuffle_backward.d.ts +1 -1
- package/src/gpu/kernels/backward/pixel_shuffle_backward.js +1 -1
- package/src/gpu/kernels/backward/rmsnorm_backward.d.ts +1 -1
- package/src/gpu/kernels/backward/rmsnorm_backward.js +2 -1
- package/src/gpu/kernels/backward/rope_backward.d.ts +1 -1
- package/src/gpu/kernels/backward/rope_backward.js +2 -1
- package/src/gpu/kernels/backward/scale_backward.d.ts +1 -1
- package/src/gpu/kernels/backward/scale_backward.js +2 -1
- package/src/gpu/kernels/backward/silu_backward.d.ts +1 -1
- package/src/gpu/kernels/backward/silu_backward.js +1 -1
- package/src/gpu/kernels/backward/softmax_backward.d.ts +1 -1
- package/src/gpu/kernels/backward/softmax_backward.js +1 -1
- package/src/gpu/kernels/backward/upsample2d_backward.d.ts +1 -1
- package/src/gpu/kernels/backward/upsample2d_backward.js +1 -1
- package/src/gpu/kernels/backward/utils.js +2 -392
- package/src/gpu/kernels/bind-group-validation.js +16 -0
- package/src/gpu/kernels/cast.js +2 -1
- package/src/gpu/kernels/check-finiteness.js +13 -49
- package/src/gpu/kernels/check-hot-vocab-stop.js +13 -39
- package/src/gpu/kernels/check-stop.js +14 -33
- package/src/gpu/kernels/check_finiteness.wgsl +33 -0
- package/src/gpu/kernels/check_hot_vocab_stop.wgsl +29 -0
- package/src/gpu/kernels/check_stop.wgsl +20 -0
- package/src/gpu/kernels/clamp.js +1 -1
- package/src/gpu/kernels/conv2d.js +1 -1
- package/src/gpu/kernels/cross_entropy_loss.js +1 -1
- package/src/gpu/kernels/depthwise_conv1d.js +1 -1
- package/src/gpu/kernels/depthwise_conv2d.js +1 -1
- package/src/gpu/kernels/dequant.js +7 -2
- package/src/gpu/kernels/diffusion-gemma-sampling.js +3 -5
- package/src/gpu/kernels/dispatch.js +12 -1
- package/src/gpu/kernels/embedding-pool.js +72 -0
- package/src/gpu/kernels/embedding_pool_f16.wgsl +38 -0
- package/src/gpu/kernels/embedding_pool_f32.wgsl +36 -0
- package/src/gpu/kernels/energy.js +2 -1
- package/src/gpu/kernels/forecast_output.wgsl +17 -0
- package/src/gpu/kernels/fused-gate-up-gelu.js +1 -1
- package/src/gpu/kernels/fused_ffn.js +10 -220
- package/src/gpu/kernels/fused_matmul_residual.js +2 -1
- package/src/gpu/kernels/fused_matmul_rmsnorm.js +2 -1
- package/src/gpu/kernels/fused_normed_ffn_q4k.wgsl +208 -0
- package/src/gpu/kernels/gated-short-conv.js +11 -69
- package/src/gpu/kernels/gated_delta_conv.wgsl +66 -0
- package/src/gpu/kernels/gated_delta_conv_f16.wgsl +68 -0
- package/src/gpu/kernels/gated_delta_fused_decode.wgsl +173 -0
- package/src/gpu/kernels/gated_delta_fused_decode_f16.wgsl +175 -0
- package/src/gpu/kernels/gated_delta_recurrent.wgsl +165 -0
- package/src/gpu/kernels/gated_delta_recurrent_f16.wgsl +167 -0
- package/src/gpu/kernels/gated_short_conv.wgsl +47 -0
- package/src/gpu/kernels/gather.d.ts +1 -1
- package/src/gpu/kernels/gather.js +30 -6
- package/src/gpu/kernels/gather_bf16.wgsl +69 -0
- package/src/gpu/kernels/gelu.d.ts +4 -0
- package/src/gpu/kernels/gelu.js +12 -2
- package/src/gpu/kernels/gelu.wgsl +16 -0
- package/src/gpu/kernels/gelu_f16.wgsl +16 -0
- package/src/gpu/kernels/gemma4-route-expert.js +1 -1
- package/src/gpu/kernels/grouped_pointwise_conv2d.js +1 -1
- package/src/gpu/kernels/groupnorm.js +1 -1
- package/src/gpu/kernels/index.d.ts +38 -5
- package/src/gpu/kernels/index.js +18 -4
- package/src/gpu/kernels/instance_stats.wgsl +26 -0
- package/src/gpu/kernels/kernel-base.js +1 -1
- package/src/gpu/kernels/kernel-cache-lifecycle.d.ts +9 -0
- package/src/gpu/kernels/kernel-cache-lifecycle.js +26 -0
- package/src/gpu/kernels/kernel-configs.d.ts +10 -61
- package/src/gpu/kernels/kernel-configs.js +26 -54
- package/src/gpu/kernels/kernel-execution.js +141 -0
- package/src/gpu/kernels/kv-cache-write.js +4 -4
- package/src/gpu/kernels/kv-quantize.js +4 -1
- package/src/gpu/kernels/l2-normalize.js +36 -0
- package/src/gpu/kernels/l2_normalize.wgsl +53 -0
- package/src/gpu/kernels/layernorm.d.ts +4 -4
- package/src/gpu/kernels/layernorm.js +44 -7
- package/src/gpu/kernels/linear-attention-core.js +29 -449
- package/src/gpu/kernels/linear_attention.js +1 -1
- package/src/gpu/kernels/lm-head-argmax.js +2 -2
- package/src/gpu/kernels/lm-head-select-logits.js +2 -2
- package/src/gpu/kernels/logit-finalize.js +103 -0
- package/src/gpu/kernels/logit-merge.js +13 -125
- package/src/gpu/kernels/logit-scatter.js +40 -0
- package/src/gpu/kernels/logit_finalize_f16.wgsl +43 -0
- package/src/gpu/kernels/logit_finalize_f32.wgsl +41 -0
- package/src/gpu/kernels/logit_merge_geometric.wgsl +23 -0
- package/src/gpu/kernels/logit_merge_max.wgsl +23 -0
- package/src/gpu/kernels/logit_merge_weighted.wgsl +23 -0
- package/src/gpu/kernels/logit_scatter_f16.wgsl +26 -0
- package/src/gpu/kernels/logit_scatter_f32.wgsl +24 -0
- package/src/gpu/kernels/matmul-dispatch.js +6 -1
- package/src/gpu/kernels/matmul-selection.js +3 -2
- package/src/gpu/kernels/matmul.js +4 -15
- package/src/gpu/kernels/matmul_bf16w_f32a.wgsl +93 -0
- package/src/gpu/kernels/matmul_gemv_subgroup_bf16w.wgsl +433 -0
- package/src/gpu/kernels/modulate.js +1 -1
- package/src/gpu/kernels/moe.js +3 -1
- package/src/gpu/kernels/moe_router_bias_add_f16_f16.wgsl +23 -0
- package/src/gpu/kernels/moe_router_bias_add_f16_f32.wgsl +23 -0
- package/src/gpu/kernels/moe_router_bias_add_f32_f16.wgsl +23 -0
- package/src/gpu/kernels/moe_router_bias_add_f32_f32.wgsl +21 -0
- package/src/gpu/kernels/patch_context.wgsl +29 -0
- package/src/gpu/kernels/pipeline-cache.js +3 -1
- package/src/gpu/kernels/pixel_shuffle.js +1 -1
- package/src/gpu/kernels/probe_shader_f16.wgsl +7 -0
- package/src/gpu/kernels/relu.js +1 -1
- package/src/gpu/kernels/rep-penalty.js +30 -5
- package/src/gpu/kernels/rep_penalty.wgsl +25 -30
- package/src/gpu/kernels/rep_penalty_f16.wgsl +24 -25
- package/src/gpu/kernels/repeat_channels.js +1 -1
- package/src/gpu/kernels/residual.js +2 -2
- package/src/gpu/kernels/rmsnorm-pair.js +1 -1
- package/src/gpu/kernels/rmsnorm-qk.js +1 -1
- package/src/gpu/kernels/rmsnorm-stats.js +14 -113
- package/src/gpu/kernels/rmsnorm.js +1 -1
- package/src/gpu/kernels/rmsnorm_serial.wgsl +19 -0
- package/src/gpu/kernels/rmsnorm_stats.wgsl +59 -0
- package/src/gpu/kernels/rmsnorm_stats_subgroups.wgsl +76 -0
- package/src/gpu/kernels/rope-precompute.js +160 -0
- package/src/gpu/kernels/rope-qk.js +1 -1
- package/src/gpu/kernels/rope.js +2 -2
- package/src/gpu/kernels/rope_precompute.wgsl +74 -0
- package/src/gpu/kernels/sample.d.ts +1 -0
- package/src/gpu/kernels/sample.js +36 -17
- package/src/gpu/kernels/sample.wgsl +112 -157
- package/src/gpu/kernels/sample_f16.wgsl +168 -162
- package/src/gpu/kernels/scale.js +1 -1
- package/src/gpu/kernels/shader-cache.js +8 -4
- package/src/gpu/kernels/shader-source-scope.js +68 -0
- package/src/gpu/kernels/silu.js +2 -1
- package/src/gpu/kernels/soft-embedding.js +3 -1
- package/src/gpu/kernels/softmax.js +4 -2
- package/src/gpu/kernels/split-qkv-rmsnorm-qk.js +1 -1
- package/src/gpu/kernels/split-qkv-rmsnorm-rope-qk.js +1 -1
- package/src/gpu/kernels/split_qg.js +1 -1
- package/src/gpu/kernels/split_qkv.d.ts +2 -0
- package/src/gpu/kernels/split_qkv.js +18 -3
- package/src/gpu/kernels/split_qkv.wgsl +5 -2
- package/src/gpu/kernels/split_qkv_f16.wgsl +5 -2
- package/src/gpu/kernels/submit_probe.wgsl +6 -0
- package/src/gpu/kernels/transpose.js +1 -1
- package/src/gpu/kernels/turboquant-codebook.js +4 -535
- package/src/gpu/kernels/uniform-utils.js +7 -2
- package/src/gpu/kernels/upsample2d.js +1 -1
- package/src/gpu/kernels/utils.js +9 -330
- package/src/gpu/kernels/vision-average-pool.d.ts +13 -0
- package/src/gpu/kernels/vision-average-pool.js +68 -0
- package/src/gpu/kernels/vision-patch-embed.d.ts +17 -0
- package/src/gpu/kernels/vision-patch-embed.js +117 -0
- package/src/gpu/kernels/vision-position-embedding.d.ts +13 -0
- package/src/gpu/kernels/vision-position-embedding.js +79 -0
- package/src/gpu/kernels/vision-rope-2d.d.ts +16 -0
- package/src/gpu/kernels/vision-rope-2d.js +73 -0
- package/src/gpu/kernels/vision-spatial-merge.d.ts +19 -0
- package/src/gpu/kernels/vision-spatial-merge.js +100 -0
- package/src/gpu/kernels/vision_average_pool.wgsl +42 -0
- package/src/gpu/kernels/vision_patch_embed.wgsl +59 -0
- package/src/gpu/kernels/vision_patch_embed_f16w.wgsl +61 -0
- package/src/gpu/kernels/vision_position_embedding.wgsl +33 -0
- package/src/gpu/kernels/vision_position_embedding_f16.wgsl +35 -0
- package/src/gpu/kernels/vision_rope_2d.wgsl +60 -0
- package/src/gpu/kernels/vision_spatial_merge.wgsl +48 -0
- package/src/gpu/readback-buffer.js +20 -0
- package/src/gpu/submit-probe.js +2 -26
- package/src/gpu/weight-buffer.d.ts +1 -0
- package/src/gpu/weight-buffer.js +7 -0
- package/src/index.d.ts +12 -0
- package/src/index.js +2 -0
- package/src/inference/browser-harness/benchmark-execution.js +872 -0
- package/src/inference/browser-harness/benchmark-rerank.js +284 -0
- package/src/inference/browser-harness/decode-diagnostics.js +241 -0
- package/src/inference/browser-harness/diffusion-performance.js +102 -0
- package/src/inference/browser-harness/inference-execution.js +543 -0
- package/src/inference/{browser-harness-model-helpers.js → browser-harness/model-initialization.js} +14 -145
- package/src/inference/browser-harness/model-resolution.js +137 -0
- package/src/inference/browser-harness/report.js +338 -0
- package/src/inference/browser-harness/request.js +263 -0
- package/src/inference/browser-harness/runtime-config.d.ts +25 -0
- package/src/inference/browser-harness/runtime-config.js +255 -0
- package/src/inference/browser-harness/runtime-isolation.d.ts +13 -0
- package/src/inference/browser-harness/runtime-isolation.js +45 -0
- package/src/inference/browser-harness/runtime-report.d.ts +26 -0
- package/src/inference/browser-harness/runtime-report.js +117 -0
- package/src/inference/browser-harness/suite-summary.js +39 -0
- package/src/inference/browser-harness/text-evidence.js +694 -0
- package/src/inference/browser-harness/text-execution.js +757 -0
- package/src/inference/browser-harness/text-input.js +725 -0
- package/src/inference/{browser-harness-suite-helpers.js → browser-harness/timing-diagnostics.js} +1 -379
- package/src/inference/browser-harness-contract-helpers.js +1 -1
- package/src/inference/browser-harness-diffusion-energy-suites.js +8 -3
- package/src/inference/browser-harness-runtime-helpers.d.ts +3 -56
- package/src/inference/browser-harness-runtime-helpers.js +3 -423
- package/src/inference/browser-harness-text-helpers.js +31 -2199
- package/src/inference/browser-harness.d.ts +15 -2
- package/src/inference/browser-harness.js +38 -1952
- package/src/inference/kv-cache/base.js +67 -381
- package/src/inference/kv-cache/basis-decomposed-paged.d.ts +2 -50
- package/src/inference/kv-cache/basis-decomposed-paged.js +1 -276
- package/src/inference/kv-cache/quantized.d.ts +2 -2
- package/src/inference/kv-cache/quantized.js +4 -8
- package/src/inference/kv-cache/update.js +309 -0
- package/src/inference/model-checkpoint-evidence.d.ts +75 -0
- package/src/inference/model-checkpoint-evidence.js +264 -0
- package/src/inference/moe-router.js +36 -216
- package/src/inference/multi-model-network.js +5 -341
- package/src/inference/pipelines/audio/index.js +1 -20
- package/src/inference/pipelines/audio/mel.js +0 -38
- package/src/inference/pipelines/context.js +6 -2
- package/src/inference/pipelines/diffusion/profile-timing.js +10 -0
- package/src/inference/pipelines/diffusion/runtime-resources.js +54 -0
- package/src/inference/pipelines/diffusion/sd3/execution.js +805 -0
- package/src/inference/pipelines/diffusion/sd3/plan.js +125 -0
- package/src/inference/pipelines/diffusion/sd3-transformer.js +44 -895
- package/src/inference/pipelines/diffusion/{vae.js → vae/execution.js} +46 -618
- package/src/inference/pipelines/diffusion/{helpers.js → weight-contract.js} +1 -68
- package/src/inference/pipelines/energy-head/row-head-pipeline.d.ts +1 -103
- package/src/inference/pipelines/factory.js +14 -3
- package/src/inference/pipelines/shader-scoped-pipeline.js +29 -0
- package/src/inference/pipelines/structured/json-grammar-mask.d.ts +2 -0
- package/src/inference/pipelines/structured/json-grammar-mask.js +115 -124
- package/src/inference/pipelines/text/abort-contract.js +22 -0
- package/src/inference/pipelines/text/attention/attn-config.js +1 -16
- package/src/inference/pipelines/text/attention/gate-projection.js +30 -0
- package/src/inference/pipelines/text/attention/heterogeneous-contract.js +8 -0
- package/src/inference/pipelines/text/attention/interpreter/immediate.js +211 -0
- package/src/inference/pipelines/text/attention/interpreter/recorded.js +451 -0
- package/src/inference/pipelines/text/attention/interpreter.js +89 -439
- package/src/inference/pipelines/text/attention/plan.d.ts +1 -0
- package/src/inference/pipelines/text/attention/plan.js +17 -0
- package/src/inference/pipelines/text/attention/projection-executor.js +331 -0
- package/src/inference/pipelines/text/attention/projection-plan.js +259 -0
- package/src/inference/pipelines/text/attention/projections.js +20 -537
- package/src/inference/pipelines/text/attention/query-transform.js +11 -0
- package/src/inference/pipelines/text/attention/record.js +0 -6
- package/src/inference/pipelines/text/attention/recorded-health.js +21 -0
- package/src/inference/pipelines/text/attention/rope-observation.js +40 -0
- package/src/inference/pipelines/text/attention/run.js +0 -6
- package/src/inference/pipelines/text/attention/types.js +3 -31
- package/src/inference/pipelines/text/chat-format.d.ts +3 -0
- package/src/inference/pipelines/text/chat-format.js +42 -0
- package/src/inference/pipelines/text/config/normalization.js +729 -0
- package/src/inference/pipelines/text/config/validation.js +9 -0
- package/src/inference/pipelines/text/config.d.ts +12 -1
- package/src/inference/pipelines/text/config.js +14 -1228
- package/src/inference/pipelines/text/debug-utils/health-metrics.js +57 -0
- package/src/inference/pipelines/text/debug-utils/index.js +3 -8
- package/src/inference/pipelines/text/debug-utils/profiles.js +8 -0
- package/src/inference/pipelines/text/debug-utils/readback-decoding.js +24 -0
- package/src/inference/pipelines/text/debug-utils/tensor.js +1 -1
- package/src/inference/pipelines/text/dtype-contract.js +1 -68
- package/src/inference/pipelines/text/embed.js +178 -241
- package/src/inference/pipelines/text/embedding-contract.d.ts +7 -0
- package/src/inference/pipelines/text/embedding-contract.js +21 -0
- package/src/inference/pipelines/text/embedding-extraction.js +225 -0
- package/src/inference/pipelines/text/embedding-normalization.js +39 -0
- package/src/inference/pipelines/text/execution-runtime-builders.js +0 -32
- package/src/inference/pipelines/text/execution-v1/plan.js +69 -0
- package/src/inference/pipelines/text/execution-v1/validation.js +233 -0
- package/src/inference/pipelines/text/execution-v1.js +7 -283
- package/src/inference/pipelines/text/execution.js +517 -0
- package/src/inference/pipelines/text/ffn/dense-executor.js +723 -0
- package/src/inference/pipelines/text/ffn/dense-plan.js +327 -0
- package/src/inference/pipelines/text/ffn/dense.js +6 -970
- package/src/inference/pipelines/text/ffn/sandwich.js +10 -9
- package/src/inference/pipelines/text/ffn/standard.js +2 -1
- package/src/inference/pipelines/text/generator/attention-lifecycle.js +24 -0
- package/src/inference/pipelines/text/generator/decode-runtime.js +985 -0
- package/src/inference/pipelines/text/generator/decode.js +964 -0
- package/src/inference/pipelines/text/generator/diffusion.js +607 -0
- package/src/inference/pipelines/text/generator/logits-config.js +63 -0
- package/src/inference/pipelines/text/generator/prefill-observation.js +29 -0
- package/src/inference/pipelines/text/generator/prefill-policy.js +56 -0
- package/src/inference/pipelines/text/generator/prefill-runtime.js +896 -0
- package/src/inference/pipelines/text/{generator-prefill-helpers.js → generator/prefix-embedding.js} +16 -121
- package/src/inference/pipelines/text/generator/prompt-input.js +47 -0
- package/src/inference/pipelines/text/generator/recovery.js +310 -0
- package/src/inference/pipelines/text/{generator-helpers.js → generator/session-context.js} +42 -110
- package/src/inference/pipelines/text/generator/text.js +448 -0
- package/src/inference/pipelines/text/generator/training.js +753 -0
- package/src/inference/pipelines/text/generator-decode-policy.js +1 -1
- package/src/inference/pipelines/text/generator-logits-observation.js +48 -0
- package/src/inference/pipelines/text/generator-runtime.js +23 -154
- package/src/inference/pipelines/text/generator-steps.js +45 -980
- package/src/inference/pipelines/text/generator.js +179 -3552
- package/src/inference/pipelines/text/image-transcription.js +304 -0
- package/src/inference/pipelines/text/init-qkv-fusion.js +18 -9
- package/src/inference/pipelines/text/init-rope.js +37 -189
- package/src/inference/pipelines/text/init.d.ts +8 -3
- package/src/inference/pipelines/text/init.js +6 -216
- package/src/inference/pipelines/text/layer-execution-contract.js +97 -0
- package/src/inference/pipelines/text/layer-input-execution.js +435 -0
- package/src/inference/pipelines/text/layer-plan-gpu.js +13 -6
- package/src/inference/pipelines/text/layer-plan.d.ts +21 -5
- package/src/inference/pipelines/text/layer-plan.js +45 -3
- package/src/inference/pipelines/text/layer.js +52 -522
- package/src/inference/pipelines/text/lifecycle.js +839 -0
- package/src/inference/pipelines/text/linear-attention/plan.js +554 -0
- package/src/inference/pipelines/text/linear-attention-ab-fusion.js +2 -2
- package/src/inference/pipelines/text/linear-attention.d.ts +2 -2
- package/src/inference/pipelines/text/linear-attention.js +28 -534
- package/src/inference/pipelines/text/logits/cpu-output.d.ts +1 -0
- package/src/inference/pipelines/text/logits/cpu-output.js +5 -0
- package/src/inference/pipelines/text/logits/cpu.d.ts +1 -87
- package/src/inference/pipelines/text/logits/cpu.js +8 -95
- package/src/inference/pipelines/text/logits/gpu-executor.js +368 -0
- package/src/inference/pipelines/text/logits/gpu.d.ts +27 -0
- package/src/inference/pipelines/text/logits/gpu.js +116 -579
- package/src/inference/pipelines/text/logits/index.d.ts +2 -1
- package/src/inference/pipelines/text/logits/index.js +62 -102
- package/src/inference/pipelines/text/logits/output-transform.js +54 -0
- package/src/inference/pipelines/text/logits/plan.js +184 -0
- package/src/inference/pipelines/text/logits/readback.d.ts +6 -0
- package/src/inference/pipelines/text/logits/readback.js +9 -0
- package/src/inference/pipelines/text/logits/scale-policy.js +20 -0
- package/src/inference/pipelines/text/logits/types.d.ts +1 -0
- package/src/inference/pipelines/text/lora-apply.js +12 -4
- package/src/inference/pipelines/text/lora-types.d.ts +12 -0
- package/src/inference/pipelines/text/modality-token-contract.js +115 -0
- package/src/inference/pipelines/text/model-load.js +0 -20
- package/src/inference/pipelines/text/moe/expert-loading.js +9 -0
- package/src/inference/pipelines/text/moe/gpu-executor.js +513 -0
- package/src/inference/pipelines/text/moe/plan.js +47 -0
- package/src/inference/pipelines/text/moe-cpu.js +9 -135
- package/src/inference/pipelines/text/moe-gpu.js +21 -545
- package/src/inference/pipelines/text/normalization-contract.js +17 -0
- package/src/inference/pipelines/text/per-layer/materialize.js +736 -0
- package/src/inference/pipelines/text/per-layer/plan.js +362 -0
- package/src/inference/pipelines/text/per-layer-inputs.js +4 -1037
- package/src/inference/pipelines/text/pipeline-load-timing.js +77 -0
- package/src/inference/pipelines/text/probes.js +20 -0
- package/src/inference/pipelines/text/sampling-config.js +22 -113
- package/src/inference/pipelines/text/sampling.d.ts +9 -1
- package/src/inference/pipelines/text/sampling.js +18 -375
- package/src/inference/pipelines/text/state.d.ts +8 -0
- package/src/inference/pipelines/text/state.js +1 -0
- package/src/inference/pipelines/text/tsir-fixture-writer.js +88 -16
- package/src/inference/pipelines/text/types.d.ts +7 -3
- package/src/inference/pipelines/text/weight-loading-config.js +194 -0
- package/src/inference/pipelines/text.d.ts +2 -2
- package/src/inference/pipelines/text.js +46 -1633
- package/src/inference/pipelines/video/frame-sampler.js +0 -13
- package/src/inference/pipelines/video/index.js +0 -21
- package/src/inference/pipelines/vision/attention.js +59 -0
- package/src/inference/pipelines/vision/encoder.js +254 -369
- package/src/inference/pipelines/vision/gemma4.js +204 -318
- package/src/inference/pipelines/vision/glmocr-preprocess.js +273 -0
- package/src/inference/pipelines/vision/glmocr-rope.js +106 -0
- package/src/inference/pipelines/vision/glmocr.js +557 -0
- package/src/inference/pipelines/vision/image-preprocess.js +0 -27
- package/src/inference/pipelines/vision/index.js +8 -27
- package/src/inference/pipelines/vision/ops.js +11 -33
- package/src/inference/pipelines/vision/patch-embed.js +51 -145
- package/src/inference/pipelines/vision/spatial-merge.js +78 -0
- package/src/inference/pipelines/vision/weight-loading.js +79 -0
- package/src/inference/refactor-receipt.js +2 -2
- package/src/inference/rerank.js +182 -0
- package/src/inference/token-sampling.js +319 -0
- package/src/inference/tokenizer.js +1 -1
- package/src/inference/tokenizers/behavior-flags.js +6 -3
- package/src/inference/tokenizers/bundled/decoders.js +133 -0
- package/src/inference/tokenizers/bundled/registry.js +216 -0
- package/src/inference/tokenizers/bundled.js +23 -353
- package/src/loader/doppler-loader.d.ts +4 -0
- package/src/loader/doppler-loader.js +119 -930
- package/src/loader/embedding-limit-preflight.js +11 -4
- package/src/loader/embedding-loader.js +1 -3
- package/src/loader/gpu-tensor-materialization.js +20 -0
- package/src/loader/layer-loader.js +15 -119
- package/src/loader/layer-tensor-aliases.js +99 -0
- package/src/loader/layer-weight-shape.js +29 -0
- package/src/loader/load-timing.js +64 -0
- package/src/loader/loader-types.d.ts +3 -0
- package/src/loader/model-executor.js +819 -0
- package/src/loader/model-load-validation.js +15 -0
- package/src/loader/quantization-constants.d.ts +11 -29
- package/src/loader/quantization-constants.js +1 -2
- package/src/loader/shard-resolver.js +0 -14
- package/src/loader/tensor-load-error.js +14 -0
- package/src/loader/tensor-shard-indices.js +8 -0
- package/src/loader/tensors/bf16-loader.js +125 -0
- package/src/loader/tensors/functional-descriptor-loader.js +3 -375
- package/src/loader/tensors/load-executor.js +577 -0
- package/src/loader/tensors/source-transform/executor.js +123 -0
- package/src/loader/tensors/source-transform/plan.js +107 -0
- package/src/loader/tensors/source-transform.js +15 -264
- package/src/loader/tensors/tensor-loader.d.ts +4 -4
- package/src/loader/tensors/tensor-loader.js +7 -653
- package/src/memory/buffer-pool.js +7 -29
- package/src/rules/capability-transform-resolver.js +80 -0
- package/src/rules/execution-contract.d.ts +73 -0
- package/src/rules/execution-contract.js +429 -0
- package/src/rules/execution-rules-contract-check.js +1 -1
- package/src/rules/generated/rule-bundle.json +4305 -0
- package/src/rules/inference/capability-transforms.rules.json +3 -3
- package/src/rules/layer-pattern-contract-check.js +1 -1
- package/src/rules/rule-registry.js +70 -57
- package/src/storage/artifact-storage-context.js +2 -2
- package/src/storage/backend-selection.js +43 -0
- package/src/storage/backends/opfs-store.d.ts +41 -0
- package/src/storage/distribution-transport.js +5 -0
- package/src/storage/download/integrity.d.ts +33 -0
- package/src/storage/download/integrity.js +130 -0
- package/src/storage/download/resume-inspection.d.ts +22 -0
- package/src/storage/download/resume-inspection.js +134 -0
- package/src/storage/download/retry.js +57 -0
- package/src/storage/download/state.js +131 -0
- package/src/storage/download/transport.js +99 -0
- package/src/storage/downloader.js +74 -453
- package/src/storage/model-cache.d.ts +1 -0
- package/src/storage/model-cache.js +51 -11
- package/src/storage/shard-manager.d.ts +5 -0
- package/src/storage/shard-manager.js +50 -369
- package/src/storage/shards/index.js +60 -0
- package/src/storage/shards/integrity.js +225 -0
- package/src/storage/shards/lifecycle.js +22 -0
- package/src/storage/source-artifact-store.js +14 -4
- package/src/tooling/boundary-evidence.d.ts +4 -4
- package/src/tooling/boundary-evidence.js +20 -20
- package/src/tooling/browser-command-runner.js +13 -6
- package/src/tooling/capsule-v2.d.ts +11 -0
- package/src/tooling/capsule-v2.js +58 -0
- package/src/tooling/capsule.js +20 -0
- package/src/tooling/command-api-constants.js +1 -1
- package/src/tooling/command-api-family-normalizers.js +163 -5
- package/src/tooling/command-api.d.ts +42 -3
- package/src/tooling/command-api.js +7 -2
- package/src/tooling/command-envelope.js +1 -1
- package/src/tooling/{command-api-helpers.js → command-request-normalization.js} +1 -1
- package/src/tooling/command-runner.html +49 -1
- package/src/tooling/command-validation.js +1 -24
- package/src/tooling/conversion-run-timing.js +24 -0
- package/src/tooling/diagnose-runner.js +11 -9
- package/src/tooling/distribution-shard-transport.js +11 -0
- package/src/tooling/execution-cost-ledger.d.ts +76 -2
- package/src/tooling/execution-cost-ledger.js +197 -15
- package/src/tooling/hf-registry/catalog-io.js +63 -0
- package/src/tooling/litert/package.js +863 -0
- package/src/tooling/litert-package-runtime.js +3 -849
- package/src/tooling/model-capsule-forge.js +478 -0
- package/src/tooling/node-browser/execution.d.ts +40 -0
- package/src/tooling/node-browser/execution.js +308 -0
- package/src/tooling/node-browser/static-server.js +189 -0
- package/src/tooling/node-browser/transport.d.ts +80 -0
- package/src/tooling/node-browser/transport.js +622 -0
- package/src/tooling/node-browser-command-runner.d.ts +18 -78
- package/src/tooling/node-browser-command-runner.js +10 -1112
- package/src/tooling/node-capsule-artifact-store.js +44 -0
- package/src/tooling/node-command-execution.js +237 -0
- package/src/tooling/node-command-runner.js +26 -205
- package/src/tooling/node-converter/input.js +521 -0
- package/src/tooling/node-converter/output.js +244 -0
- package/src/tooling/node-converter-chunk-batches.js +21 -0
- package/src/tooling/node-converter.js +7 -720
- package/src/tooling/node-source-runtime.js +16 -276
- package/src/tooling/node-webgpu-provider.v1.json +33 -0
- package/src/tooling/node-webgpu.js +178 -453
- package/src/tooling/opfs-cache.d.ts +5 -0
- package/src/tooling/opfs-cache.js +4 -0
- package/src/tooling/production-release.d.ts +19 -0
- package/src/tooling/production-release.js +647 -0
- package/src/tooling/program-bundle/embedding-reference.js +19 -0
- package/src/tooling/program-bundle/materialize.js +324 -0
- package/src/tooling/program-bundle/rerank-reference.js +22 -0
- package/src/tooling/program-bundle/sequence-reference.js +42 -0
- package/src/tooling/program-bundle/validation.js +31 -0
- package/src/tooling/program-bundle/wgsl-closure.js +254 -0
- package/src/tooling/program-bundle-parity.d.ts +11 -4
- package/src/tooling/program-bundle-parity.js +262 -109
- package/src/tooling/program-bundle.d.ts +7 -0
- package/src/tooling/program-bundle.js +186 -591
- package/src/tooling/provider-v1-contract.d.ts +61 -0
- package/src/tooling/provider-v1-contract.js +192 -0
- package/src/tooling/registered-variant-calibration-job.d.ts +98 -0
- package/src/tooling/registered-variant-calibration-job.js +210 -0
- package/src/tooling/registered-variant-calibration.d.ts +167 -7
- package/src/tooling/registered-variant-calibration.js +57 -7
- package/src/tooling/runtime-optimization/candidates.js +664 -0
- package/src/tooling/runtime-optimization-campaign.js +166 -0
- package/src/tooling/runtime-optimization-index.js +16 -1
- package/src/tooling/runtime-optimization.d.ts +44 -0
- package/src/tooling/runtime-optimization.js +13 -656
- package/src/tooling/source-intake.d.ts +1 -1
- package/src/tooling/source-intake.js +34 -17
- package/src/tooling/source-package-profiles.js +1 -1
- package/src/tooling/source-runtime/bundle-materialize.js +298 -0
- package/src/tooling/source-runtime/bundle-plan.js +121 -0
- package/src/tooling/source-runtime/node-loader.js +258 -0
- package/src/tooling/source-runtime-bundle.js +26 -411
- package/src/tooling/source-runtime-converter-config.js +1 -1
- package/src/tooling-experimental-exports.js +0 -5
- package/src/tooling-exports/evidence.d.ts +14 -3
- package/src/tooling-exports/evidence.js +14 -3
- package/src/tooling-exports/storage.d.ts +7 -0
- package/src/tooling-exports/storage.js +5 -0
- package/src/tooling-exports.d.ts +3 -0
- package/src/tooling-exports.js +2 -0
- package/src/tooling-exports.shared.d.ts +17 -3
- package/src/tooling-exports.shared.js +9 -3
- package/src/training.d.ts +6 -6
- package/src/training.js +4 -4
- package/src/version.js +1 -1
- package/tests/kernels/browser/kernel-suite.js +512 -0
- package/tests/kernels/browser/test-page.js +170 -14
- package/tests/kernels/harness/tolerance.js +1 -0
- package/tests/kernels/reference/index.js +13 -1
- package/tests/kernels/reference/vision.js +160 -0
- package/src/converter/quantizer.d.ts +0 -121
- package/src/gpu/kernels/backward/utils.d.ts +0 -90
- package/src/gpu/kernels/uniform-utils.d.ts +0 -66
- package/src/gpu/kernels/utils.d.ts +0 -147
- package/src/inference/pipelines/text/debug-utils/utils.js +0 -118
- package/src/inference/pipelines/text/logits/utils.d.ts +0 -58
- package/src/inference/pipelines/text/moe-cpu-gptoss.js +0 -115
- package/src/inference/pipelines/text/moe-helpers.js +0 -21
- package/src/rules/converter/execution.rules.json +0 -20
- package/src/rules/converter/tensor-roles.rules.json +0 -13
- package/src/rules/converter/tokenizer.rules.json +0 -12
- package/src/rules/inference/attention.rules.json +0 -69
- package/src/rules/inference/config.rules.json +0 -82
- package/src/rules/inference/dtype.rules.json +0 -113
- package/src/rules/inference/execution.rules.json +0 -195
- package/src/rules/inference/ffn.rules.json +0 -123
- package/src/rules/inference/layer-pattern.rules.json +0 -16
- package/src/rules/inference/layer.rules.json +0 -7
- package/src/rules/inference/moe.rules.json +0 -145
- package/src/rules/kernels/attention.rules.json +0 -68
- package/src/rules/kernels/conv2d.rules.json +0 -6
- package/src/rules/kernels/depthwise-conv2d.rules.json +0 -6
- package/src/rules/kernels/dequant.rules.json +0 -58
- package/src/rules/kernels/energy.rules.json +0 -22
- package/src/rules/kernels/fused-ffn.rules.json +0 -15
- package/src/rules/kernels/fused-matmul-residual.rules.json +0 -6
- package/src/rules/kernels/fused-matmul-rmsnorm.rules.json +0 -8
- package/src/rules/kernels/gather.rules.json +0 -93
- package/src/rules/kernels/gelu.rules.json +0 -11
- package/src/rules/kernels/grouped-pointwise-conv2d.rules.json +0 -6
- package/src/rules/kernels/groupnorm.rules.json +0 -10
- package/src/rules/kernels/kv_quantize.rules.json +0 -9
- package/src/rules/kernels/layernorm.rules.json +0 -6
- package/src/rules/kernels/linear-attention.rules.json +0 -6
- package/src/rules/kernels/lm-head-argmax.rules.json +0 -10
- package/src/rules/kernels/matmul.rules.json +0 -95
- package/src/rules/kernels/modulate.rules.json +0 -6
- package/src/rules/kernels/moe.rules.gptoss.json +0 -105
- package/src/rules/kernels/moe.rules.json +0 -14
- package/src/rules/kernels/moe.rules.mixtral.json +0 -75
- package/src/rules/kernels/pixel_shuffle.rules.json +0 -6
- package/src/rules/kernels/relu.rules.json +0 -6
- package/src/rules/kernels/rep-penalty.rules.json +0 -6
- package/src/rules/kernels/repeat-channels.rules.json +0 -6
- package/src/rules/kernels/residual.rules.json +0 -12
- package/src/rules/kernels/rmsnorm-qk.rules.json +0 -6
- package/src/rules/kernels/rmsnorm.rules.json +0 -46
- package/src/rules/kernels/rope-qk.rules.json +0 -6
- package/src/rules/kernels/rope.rules.json +0 -6
- package/src/rules/kernels/sample.rules.json +0 -6
- package/src/rules/kernels/scale.rules.json +0 -8
- package/src/rules/kernels/silu.rules.json +0 -22
- package/src/rules/kernels/softmax.rules.json +0 -25
- package/src/rules/kernels/split-qg.rules.json +0 -6
- package/src/rules/kernels/split-qkv.rules.json +0 -6
- package/src/rules/kernels/upsample2d.rules.json +0 -6
- package/src/rules/loader/tensor-loader.rules.json +0 -42
- package/src/rules/loader/weights.rules.json +0 -42
- package/src/rules/tooling/command-runtime.rules.json +0 -65
- package/src/tooling/hf-registry-utils.js +0 -395
- /package/src/converter/{tokenizer-utils.js → tokenizer-special-tokens.js} +0 -0
- /package/src/{inference/pipelines/text/bdpa-steamroller.js → experimental/bdpa/steamroller.js} +0 -0
- /package/src/{inference/pipelines → experimental}/diffusion/scheduler.js +0 -0
- /package/src/{inference/pipelines → experimental}/energy/pipeline.d.ts +0 -0
- /package/src/{inference/pipelines → experimental}/energy/quintel.d.ts +0 -0
- /package/src/{inference/pipelines → experimental}/energy/quintel.js +0 -0
- /package/src/{utils → formats}/array-buffer.js +0 -0
- /package/src/{utils → formats}/canonical-hash.js +0 -0
- /package/src/{utils → formats}/clone-json.js +0 -0
- /package/src/{utils → formats}/encode-utf8.js +0 -0
- /package/src/{utils → formats}/load-json.js +0 -0
- /package/src/{utils → formats}/plain-object.js +0 -0
- /package/src/{utils → formats}/sha256.js +0 -0
- /package/src/{utils → formats}/stable-sort-object.js +0 -0
- /package/src/{gpu/kernels → rules}/rule-matcher.js +0 -0
- /package/src/{utils → storage}/hf-resolve-url.js +0 -0
- /package/src/{utils → storage}/runtime-env.js +0 -0
- /package/src/tooling/{command-runner-shared.js → command-runtime-execution.js} +0 -0
|
@@ -11,153 +11,91 @@ import {
|
|
|
11
11
|
getActiveKernelPathPolicy,
|
|
12
12
|
} from '../config/kernel-path-loader.js';
|
|
13
13
|
import { validateTrainingMetricsReport } from '../config/schema/training-metrics.schema.js';
|
|
14
|
-
import { modelSupportsEmbedding, modelSupportsRerank } from '../config/schema/manifest.schema.js';
|
|
15
14
|
import {
|
|
16
|
-
|
|
15
|
+
modelSupportsEmbedding,
|
|
16
|
+
modelSupportsRerank,
|
|
17
|
+
modelSupportsSequence,
|
|
18
|
+
} from '../config/schema/manifest.schema.js';
|
|
19
|
+
import {
|
|
17
20
|
resolveRuntime,
|
|
18
|
-
cloneRuntimeConfig,
|
|
19
|
-
runWithRuntimeIsolationForSuite,
|
|
20
|
-
sanitizeReportOutput,
|
|
21
21
|
loadRuntimeConfigFromUrl,
|
|
22
22
|
applyRuntimeConfigFromUrl,
|
|
23
23
|
loadRuntimeProfile,
|
|
24
24
|
applyRuntimeProfile,
|
|
25
25
|
applyRuntimeForRun,
|
|
26
|
+
} from './browser-harness/runtime-config.js';
|
|
27
|
+
import {
|
|
28
|
+
cloneRuntimeConfig,
|
|
29
|
+
runWithRuntimeIsolationForSuite,
|
|
30
|
+
} from './browser-harness/runtime-isolation.js';
|
|
31
|
+
import {
|
|
32
|
+
resolveReportTimestamp,
|
|
33
|
+
sanitizeReportOutput,
|
|
26
34
|
normalizeManifest,
|
|
27
35
|
mergeRunDefaults,
|
|
28
36
|
summarizeManifestRuns,
|
|
29
|
-
} from './browser-harness
|
|
37
|
+
} from './browser-harness/runtime-report.js';
|
|
30
38
|
import {
|
|
31
39
|
buildSuiteSummary,
|
|
32
40
|
normalizeCacheMode,
|
|
33
41
|
normalizeLoadMode,
|
|
34
42
|
normalizeWorkloadType,
|
|
43
|
+
} from './browser-harness/suite-summary.js';
|
|
44
|
+
import {
|
|
35
45
|
assertDiffusionPerformanceArtifact,
|
|
46
|
+
} from './browser-harness/diffusion-performance.js';
|
|
47
|
+
import {
|
|
36
48
|
toTimingNumber,
|
|
37
49
|
buildFirstLoadComposition,
|
|
38
50
|
safeToFixed,
|
|
39
51
|
sampleTimingNumber,
|
|
40
52
|
buildCanonicalTiming,
|
|
41
53
|
buildLoadTimingDiagnostics,
|
|
42
|
-
buildDecodeBottleneckDiagnostics,
|
|
43
54
|
buildTimingDiagnostics,
|
|
44
|
-
} from './browser-harness-
|
|
55
|
+
} from './browser-harness/timing-diagnostics.js';
|
|
56
|
+
import { buildDecodeBottleneckDiagnostics } from './browser-harness/decode-diagnostics.js';
|
|
45
57
|
import {
|
|
46
58
|
resolveDeviceInfo,
|
|
47
59
|
resolveKernelPathForModel,
|
|
48
|
-
|
|
49
|
-
} from './browser-harness
|
|
60
|
+
} from './browser-harness/model-resolution.js';
|
|
61
|
+
import { initializeSuiteModel } from './browser-harness/model-initialization.js';
|
|
50
62
|
import {
|
|
51
63
|
resolveBenchmarkRunSettings,
|
|
64
|
+
} from './browser-harness/text-input.js';
|
|
65
|
+
import {
|
|
52
66
|
normalizeDecodeRecordOpLabels,
|
|
53
67
|
normalizeUniformCacheStats,
|
|
54
68
|
buildDecodeRecordTopOps,
|
|
55
69
|
buildDecodeRecordTopOpGroups,
|
|
70
|
+
isCoherentOutput,
|
|
71
|
+
} from './browser-harness/text-evidence.js';
|
|
72
|
+
import {
|
|
56
73
|
runEmbeddingSemanticChecks,
|
|
57
74
|
runRerank,
|
|
58
75
|
runRerankSemanticChecks,
|
|
59
|
-
|
|
76
|
+
runSequenceEncoding,
|
|
60
77
|
runTextInference,
|
|
61
78
|
runEmbedding,
|
|
62
|
-
} from './browser-harness
|
|
79
|
+
} from './browser-harness/text-execution.js';
|
|
63
80
|
import { buildSuiteContractMetrics } from './browser-harness-contract-helpers.js';
|
|
64
81
|
import {
|
|
65
82
|
runDiffusionSuite,
|
|
66
83
|
runEnergySuite,
|
|
67
84
|
} from './browser-harness-diffusion-energy-suites.js';
|
|
68
85
|
import { collectTrainingArtifactsFromSuiteResult } from './browser-harness-report-helpers.js';
|
|
69
|
-
import { sha256Hex } from '../
|
|
70
|
-
import { stableSortObject } from '../
|
|
86
|
+
import { sha256Hex } from '../formats/sha256.js';
|
|
87
|
+
import { stableSortObject } from '../formats/stable-sort-object.js';
|
|
71
88
|
import { assertCommandContextMatchesOptions } from '../tooling/command-context.js';
|
|
72
89
|
import {
|
|
73
90
|
buildTokenCostLedger,
|
|
74
91
|
isExecutionObservationRequested,
|
|
75
92
|
} from '../tooling/execution-cost-ledger.js';
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return { loadTiming: null, pipelineLoadTiming: null };
|
|
83
|
-
}
|
|
84
|
-
try {
|
|
85
|
-
const stats = pipeline.getStats() ?? {};
|
|
86
|
-
return {
|
|
87
|
-
loadTiming: stats.loadTiming ?? null,
|
|
88
|
-
pipelineLoadTiming: stats.pipelineLoadTiming ?? null,
|
|
89
|
-
};
|
|
90
|
-
} catch {
|
|
91
|
-
return { loadTiming: null, pipelineLoadTiming: null };
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function getNestedSampleValue(sample, key) {
|
|
96
|
-
if (!sample || typeof sample !== 'object' || typeof key !== 'string' || key.length === 0) {
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
|
-
let current = sample;
|
|
100
|
-
for (const part of key.split('.')) {
|
|
101
|
-
if (!current || typeof current !== 'object') {
|
|
102
|
-
return null;
|
|
103
|
-
}
|
|
104
|
-
current = current[part];
|
|
105
|
-
}
|
|
106
|
-
return current;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function getNestedPhaseValue(sample, key) {
|
|
110
|
-
const value = getNestedSampleValue(sample, key);
|
|
111
|
-
return Number.isFinite(value) ? value : null;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function summarizeTimingPhaseSamples(samples, keys) {
|
|
115
|
-
const rows = Array.isArray(samples) ? samples.filter((sample) => sample && typeof sample === 'object') : [];
|
|
116
|
-
const summary = {};
|
|
117
|
-
for (const key of keys) {
|
|
118
|
-
const values = rows
|
|
119
|
-
.map((sample) => getNestedPhaseValue(sample, key))
|
|
120
|
-
.filter((value) => Number.isFinite(value));
|
|
121
|
-
summary[key] = computeSampleStats(values);
|
|
122
|
-
}
|
|
123
|
-
return summary;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function summarizePrefillRecordOps(samples) {
|
|
127
|
-
const rows = Array.isArray(samples) ? samples.filter((sample) => sample && typeof sample === 'object') : [];
|
|
128
|
-
const labelSums = {};
|
|
129
|
-
let labelSampleCount = 0;
|
|
130
|
-
for (const sample of rows) {
|
|
131
|
-
const labelCounts = normalizeDecodeRecordOpLabels(getNestedSampleValue(sample, 'prefillRecordOpLabels'));
|
|
132
|
-
if (!labelCounts) {
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
labelSampleCount += 1;
|
|
136
|
-
for (const [label, count] of Object.entries(labelCounts)) {
|
|
137
|
-
labelSums[label] = (labelSums[label] ?? 0) + count;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
if (labelSampleCount === 0) {
|
|
141
|
-
return {};
|
|
142
|
-
}
|
|
143
|
-
const meanLabels = {};
|
|
144
|
-
for (const [label, count] of Object.entries(labelSums)) {
|
|
145
|
-
meanLabels[label] = count / labelSampleCount;
|
|
146
|
-
}
|
|
147
|
-
const prefillRecordOps = summarizeTimingPhaseSamples(rows, ['prefillRecordOps']).prefillRecordOps;
|
|
148
|
-
return {
|
|
149
|
-
prefillRecordUniqueOpLabels: Object.keys(meanLabels).length,
|
|
150
|
-
prefillRecordTopOps: buildDecodeRecordTopOps(meanLabels, prefillRecordOps?.mean),
|
|
151
|
-
prefillRecordTopOpGroups: buildDecodeRecordTopOpGroups(meanLabels, prefillRecordOps?.mean),
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
async function loadTrainingSuiteModule() {
|
|
156
|
-
if (!trainingSuiteModulePromise) {
|
|
157
|
-
trainingSuiteModulePromise = import(TRAINING_SUITE_MODULE_PATH);
|
|
158
|
-
}
|
|
159
|
-
return trainingSuiteModulePromise;
|
|
160
|
-
}
|
|
93
|
+
import { createUnsupportedWorkloadError, hashStableJson, resolveDecodeCadence, resolveDispatchSuite, resolveExecutionGraphHash, resolveHarnessContext, resolveHarnessMode, resolveWorkload } from './browser-harness/request.js';
|
|
94
|
+
import { attachExecutionCostLedger, buildReferenceTranscriptSeed, resolvePipelineLoadTimings, serializeSequenceProbeRows, summarizePrefillRecordOps, summarizeTimingPhaseSamples } from './browser-harness/report.js';
|
|
95
|
+
import { runInferenceSuite, runKernelSuite, withHarnessPhase } from './browser-harness/inference-execution.js';
|
|
96
|
+
import { loadTrainingSuiteModule, runBenchSuite } from './browser-harness/benchmark-execution.js';
|
|
97
|
+
export { buildReferenceTranscriptSeed } from './browser-harness/report.js';
|
|
98
|
+
export { getBrowserSuiteDispatchMap, getBrowserSupportedSuites, resolveExecutionGraphHash } from './browser-harness/request.js';
|
|
161
99
|
|
|
162
100
|
export async function runTrainingSuite(options = {}) {
|
|
163
101
|
const module = await loadTrainingSuiteModule();
|
|
@@ -173,1829 +111,6 @@ export {
|
|
|
173
111
|
buildSuiteSummary,
|
|
174
112
|
};
|
|
175
113
|
|
|
176
|
-
async function runTrainingBenchSuite(options = {}) {
|
|
177
|
-
const module = await loadTrainingSuiteModule();
|
|
178
|
-
return module.runTrainingBenchSuite(options);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
const BROWSER_WORKLOAD_SET = Object.freeze([
|
|
182
|
-
'kernels',
|
|
183
|
-
'inference',
|
|
184
|
-
'embedding',
|
|
185
|
-
'rerank',
|
|
186
|
-
'training',
|
|
187
|
-
'diffusion',
|
|
188
|
-
'energy',
|
|
189
|
-
]);
|
|
190
|
-
|
|
191
|
-
const BROWSER_MODE_SET = Object.freeze(['verify', 'debug', 'bench', 'diagnose']);
|
|
192
|
-
|
|
193
|
-
const BROWSER_WORKLOAD_DISPATCH_MAP = Object.freeze({
|
|
194
|
-
verify: Object.freeze({
|
|
195
|
-
kernels: 'runKernelSuite',
|
|
196
|
-
inference: 'runInferenceSuite',
|
|
197
|
-
embedding: 'runEmbeddingSuite',
|
|
198
|
-
rerank: 'runRerankSuite',
|
|
199
|
-
training: 'runTrainingSuite',
|
|
200
|
-
diffusion: 'runDiffusionSuite',
|
|
201
|
-
energy: 'runEnergySuite',
|
|
202
|
-
}),
|
|
203
|
-
debug: Object.freeze({
|
|
204
|
-
inference: 'runInferenceSuite(debug)',
|
|
205
|
-
embedding: 'runEmbeddingSuite(debug)',
|
|
206
|
-
}),
|
|
207
|
-
diagnose: Object.freeze({
|
|
208
|
-
inference: 'runInferenceSuite(diagnose)',
|
|
209
|
-
}),
|
|
210
|
-
bench: Object.freeze({
|
|
211
|
-
inference: 'runBenchSuite',
|
|
212
|
-
embedding: 'runBenchSuite',
|
|
213
|
-
rerank: 'runBenchSuite',
|
|
214
|
-
training: 'runBenchSuite(training)',
|
|
215
|
-
diffusion: 'runBenchSuite(diffusion)',
|
|
216
|
-
}),
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
function isPlainObject(value) {
|
|
220
|
-
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
function resolveExecutionPlanCadence(executionPlan) {
|
|
224
|
-
if (!isPlainObject(executionPlan)) {
|
|
225
|
-
return null;
|
|
226
|
-
}
|
|
227
|
-
const finalActivePlanId = typeof executionPlan.finalActivePlanId === 'string'
|
|
228
|
-
? executionPlan.finalActivePlanId
|
|
229
|
-
: null;
|
|
230
|
-
for (const candidate of [executionPlan.primary, executionPlan.fallback]) {
|
|
231
|
-
if (!isPlainObject(candidate)) {
|
|
232
|
-
continue;
|
|
233
|
-
}
|
|
234
|
-
if (finalActivePlanId == null || candidate.id === finalActivePlanId) {
|
|
235
|
-
return candidate;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
return isPlainObject(executionPlan.primary) ? executionPlan.primary : null;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
function resolveDecodeCadence(runtimeConfig, executionPlan = null) {
|
|
242
|
-
const inference = runtimeConfig?.inference;
|
|
243
|
-
const batching = inference?.batching;
|
|
244
|
-
const session = inference?.session;
|
|
245
|
-
const decodeLoop = session?.decodeLoop;
|
|
246
|
-
if (!isPlainObject(batching) || !isPlainObject(decodeLoop)) {
|
|
247
|
-
return null;
|
|
248
|
-
}
|
|
249
|
-
const executionPlanCadence = resolveExecutionPlanCadence(executionPlan);
|
|
250
|
-
const batchSize = executionPlanCadence?.batchSize ?? decodeLoop.batchSize ?? batching.batchSize ?? null;
|
|
251
|
-
const readbackInterval = executionPlanCadence?.readbackInterval ?? decodeLoop.readbackInterval ?? batching.readbackInterval ?? null;
|
|
252
|
-
const maxBatchDecodeTokens = executionPlanCadence?.maxBatchDecodeTokens
|
|
253
|
-
?? decodeLoop.maxBatchDecodeTokens
|
|
254
|
-
?? null;
|
|
255
|
-
return {
|
|
256
|
-
batchSize,
|
|
257
|
-
readbackInterval,
|
|
258
|
-
maxBatchDecodeTokens,
|
|
259
|
-
stopCheckMode: executionPlanCadence?.stopCheckMode ?? decodeLoop.stopCheckMode ?? batching.stopCheckMode ?? null,
|
|
260
|
-
readbackMode: executionPlanCadence?.readbackMode ?? decodeLoop.readbackMode ?? batching.readbackMode ?? null,
|
|
261
|
-
disableCommandBatching: executionPlanCadence?.disableCommandBatching ?? decodeLoop.disableCommandBatching ?? null,
|
|
262
|
-
disableMultiTokenDecode: inference?.generation?.disableMultiTokenDecode === true,
|
|
263
|
-
speculationMode: session?.speculation?.mode ?? null,
|
|
264
|
-
tokensPerReadback: Number.isFinite(batchSize) && Number.isFinite(readbackInterval)
|
|
265
|
-
? batchSize * readbackInterval
|
|
266
|
-
: null,
|
|
267
|
-
runtimeMirror: {
|
|
268
|
-
batching: {
|
|
269
|
-
batchSize: batching.batchSize ?? null,
|
|
270
|
-
readbackInterval: batching.readbackInterval ?? null,
|
|
271
|
-
stopCheckMode: batching.stopCheckMode ?? null,
|
|
272
|
-
readbackMode: batching.readbackMode ?? null,
|
|
273
|
-
},
|
|
274
|
-
decodeLoop: {
|
|
275
|
-
batchSize: decodeLoop.batchSize ?? null,
|
|
276
|
-
readbackInterval: decodeLoop.readbackInterval ?? null,
|
|
277
|
-
maxBatchDecodeTokens: decodeLoop.maxBatchDecodeTokens ?? null,
|
|
278
|
-
stopCheckMode: decodeLoop.stopCheckMode ?? null,
|
|
279
|
-
readbackMode: decodeLoop.readbackMode ?? null,
|
|
280
|
-
ringTokens: decodeLoop.ringTokens ?? null,
|
|
281
|
-
ringStop: decodeLoop.ringStop ?? null,
|
|
282
|
-
ringStaging: decodeLoop.ringStaging ?? null,
|
|
283
|
-
},
|
|
284
|
-
},
|
|
285
|
-
executionPlan: executionPlanCadence
|
|
286
|
-
? {
|
|
287
|
-
id: executionPlanCadence.id ?? null,
|
|
288
|
-
batchSize: executionPlanCadence.batchSize ?? null,
|
|
289
|
-
readbackInterval: executionPlanCadence.readbackInterval ?? null,
|
|
290
|
-
maxBatchDecodeTokens: executionPlanCadence.maxBatchDecodeTokens ?? null,
|
|
291
|
-
stopCheckMode: executionPlanCadence.stopCheckMode ?? null,
|
|
292
|
-
readbackMode: executionPlanCadence.readbackMode ?? null,
|
|
293
|
-
disableCommandBatching: executionPlanCadence.disableCommandBatching ?? null,
|
|
294
|
-
ringTokens: executionPlanCadence.ringTokens ?? null,
|
|
295
|
-
ringStop: executionPlanCadence.ringStop ?? null,
|
|
296
|
-
ringStaging: executionPlanCadence.ringStaging ?? null,
|
|
297
|
-
}
|
|
298
|
-
: null,
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
export function getBrowserSupportedSuites() {
|
|
303
|
-
return [...BROWSER_WORKLOAD_SET];
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
export function getBrowserSuiteDispatchMap() {
|
|
307
|
-
return {
|
|
308
|
-
verify: { ...BROWSER_WORKLOAD_DISPATCH_MAP.verify },
|
|
309
|
-
debug: { ...BROWSER_WORKLOAD_DISPATCH_MAP.debug },
|
|
310
|
-
bench: { ...BROWSER_WORKLOAD_DISPATCH_MAP.bench },
|
|
311
|
-
};
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
function getAllowedWorkloadsForMode(mode) {
|
|
315
|
-
return Object.keys(BROWSER_WORKLOAD_DISPATCH_MAP[mode] || {});
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
function createUnsupportedWorkloadError(requestedWorkload, context = {}) {
|
|
319
|
-
const command = typeof context.command === 'string' && context.command.trim()
|
|
320
|
-
? context.command.trim()
|
|
321
|
-
: 'run-browser-suite';
|
|
322
|
-
const surface = typeof context.surface === 'string' && context.surface.trim()
|
|
323
|
-
? context.surface.trim()
|
|
324
|
-
: 'browser';
|
|
325
|
-
const mode = typeof context.mode === 'string' && context.mode.trim()
|
|
326
|
-
? context.mode.trim()
|
|
327
|
-
: 'verify';
|
|
328
|
-
const allowedWorkloads = getAllowedWorkloadsForMode(mode);
|
|
329
|
-
const error = new Error(
|
|
330
|
-
`Unsupported workload "${requestedWorkload}". Allowed workloads: ${allowedWorkloads.join(', ')}. ` +
|
|
331
|
-
`command="${command}" mode="${mode}" surface="${surface}".`
|
|
332
|
-
);
|
|
333
|
-
error.code = 'unsupported_workload';
|
|
334
|
-
error.requestedWorkload = requestedWorkload;
|
|
335
|
-
error.allowedWorkloads = allowedWorkloads;
|
|
336
|
-
error.command = command;
|
|
337
|
-
error.mode = mode;
|
|
338
|
-
error.surface = surface;
|
|
339
|
-
error.details = {
|
|
340
|
-
requestedWorkload,
|
|
341
|
-
allowedWorkloads,
|
|
342
|
-
command,
|
|
343
|
-
mode,
|
|
344
|
-
surface,
|
|
345
|
-
};
|
|
346
|
-
return error;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
function resolveHarnessContext(options = {}) {
|
|
350
|
-
const command = typeof options.command === 'string' ? options.command : null;
|
|
351
|
-
const surface = typeof options.surface === 'string' ? options.surface : null;
|
|
352
|
-
const mode = typeof options.mode === 'string' ? options.mode : null;
|
|
353
|
-
return {
|
|
354
|
-
command: command ?? 'run-browser-suite',
|
|
355
|
-
mode: mode ?? command ?? 'verify',
|
|
356
|
-
surface: surface ?? 'browser',
|
|
357
|
-
};
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
function normalizeLegacySuite(value) {
|
|
361
|
-
const suite = String(value || '').trim().toLowerCase();
|
|
362
|
-
if (!suite) {
|
|
363
|
-
return null;
|
|
364
|
-
}
|
|
365
|
-
return suite === 'benchmark' ? 'bench' : suite;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
function normalizeMode(value, context = {}) {
|
|
369
|
-
const mode = String(value || '').trim().toLowerCase();
|
|
370
|
-
if (!mode) {
|
|
371
|
-
return 'verify';
|
|
372
|
-
}
|
|
373
|
-
if (!BROWSER_MODE_SET.includes(mode)) {
|
|
374
|
-
throw new Error(`Unsupported browser harness mode "${mode}" for command "${context.command || 'run-browser-suite'}".`);
|
|
375
|
-
}
|
|
376
|
-
return mode;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
function resolveHarnessMode(options = {}, context = {}) {
|
|
380
|
-
const explicitMode = options.mode ?? options.command ?? null;
|
|
381
|
-
if (explicitMode) {
|
|
382
|
-
return normalizeMode(explicitMode, context);
|
|
383
|
-
}
|
|
384
|
-
const legacySuite = normalizeLegacySuite(options.suite);
|
|
385
|
-
if (legacySuite === 'debug' || legacySuite === 'bench') {
|
|
386
|
-
return legacySuite;
|
|
387
|
-
}
|
|
388
|
-
return 'verify';
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
function normalizeWorkload(value, mode, context = {}) {
|
|
392
|
-
const workload = String(value || '').trim().toLowerCase();
|
|
393
|
-
if (!workload) {
|
|
394
|
-
throw createUnsupportedWorkloadError(workload, { ...context, mode });
|
|
395
|
-
}
|
|
396
|
-
if (!getAllowedWorkloadsForMode(mode).includes(workload)) {
|
|
397
|
-
throw createUnsupportedWorkloadError(workload, { ...context, mode });
|
|
398
|
-
}
|
|
399
|
-
return workload;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
function resolveWorkload(options = {}, mode, context = {}) {
|
|
403
|
-
if (options.workload) {
|
|
404
|
-
return normalizeWorkload(options.workload, mode, context);
|
|
405
|
-
}
|
|
406
|
-
const legacySuite = normalizeLegacySuite(options.suite);
|
|
407
|
-
if (legacySuite && legacySuite !== 'debug' && legacySuite !== 'bench') {
|
|
408
|
-
return normalizeWorkload(legacySuite, mode, context);
|
|
409
|
-
}
|
|
410
|
-
if (mode === 'debug' || mode === 'bench') {
|
|
411
|
-
return 'inference';
|
|
412
|
-
}
|
|
413
|
-
return normalizeWorkload('', mode, context);
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
function resolveDispatchSuite(mode, workload) {
|
|
417
|
-
if (mode === 'debug') {
|
|
418
|
-
return 'debug';
|
|
419
|
-
}
|
|
420
|
-
if (mode === 'bench') {
|
|
421
|
-
return 'bench';
|
|
422
|
-
}
|
|
423
|
-
return workload;
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
function stableJson(value) {
|
|
427
|
-
return JSON.stringify(stableSortObject(value)) ?? 'null';
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
function hashStableJson(value) {
|
|
431
|
-
return `sha256:${sha256Hex(stableJson(value))}`;
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
export function resolveExecutionGraphHash(manifest) {
|
|
435
|
-
const execution = manifest?.inference?.execution;
|
|
436
|
-
if (!execution || typeof execution !== 'object') {
|
|
437
|
-
return null;
|
|
438
|
-
}
|
|
439
|
-
return hashStableJson(execution);
|
|
440
|
-
}
|
|
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
|
-
|
|
515
|
-
function buildPerStepTokenProof(tokenIds) {
|
|
516
|
-
return tokenIds.map((tokenId, index) => ({
|
|
517
|
-
index,
|
|
518
|
-
tokenId,
|
|
519
|
-
tokenHash: hashStableJson({ index, tokenId }),
|
|
520
|
-
}));
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
function buildKvCacheTranscriptSeed(kvCache, byteProof = null) {
|
|
524
|
-
const source = kvCache && typeof kvCache === 'object' ? kvCache : null;
|
|
525
|
-
const proof = byteProof && typeof byteProof === 'object' ? byteProof : null;
|
|
526
|
-
const seed = {
|
|
527
|
-
mode: proof ? 'stats+sha256-layer-kv-bytes' : (source ? 'stats' : 'not-captured'),
|
|
528
|
-
layout: typeof source?.layout === 'string' ? source.layout : null,
|
|
529
|
-
kvDtype: typeof source?.kvDtype === 'string' ? source.kvDtype : null,
|
|
530
|
-
seqLen: Number.isFinite(source?.seqLen) ? source.seqLen : null,
|
|
531
|
-
maxSeqLen: Number.isFinite(source?.maxSeqLen) ? source.maxSeqLen : null,
|
|
532
|
-
usedBytes: Number.isFinite(source?.usedBytes) ? source.usedBytes : null,
|
|
533
|
-
allocatedBytes: Number.isFinite(source?.allocatedBytes) ? source.allocatedBytes : null,
|
|
534
|
-
counters: source?.counters ?? null,
|
|
535
|
-
byteDigestMode: typeof proof?.mode === 'string' ? proof.mode : null,
|
|
536
|
-
byteDigest: typeof proof?.digest === 'string' ? proof.digest : null,
|
|
537
|
-
byteDigests: Array.isArray(proof?.layers) ? proof.layers : null,
|
|
538
|
-
};
|
|
539
|
-
return {
|
|
540
|
-
...seed,
|
|
541
|
-
stateHash: hashStableJson(seed),
|
|
542
|
-
};
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
export function buildReferenceTranscriptSeed(run, context = {}) {
|
|
546
|
-
const promptPayload = run.promptInput ?? run.prompt ?? null;
|
|
547
|
-
const outputText = typeof run.output === 'string' ? run.output : '';
|
|
548
|
-
const tokenIds = Array.isArray(run.tokenIds)
|
|
549
|
-
? run.tokenIds.map((value) => Number(value)).filter((value) => Number.isInteger(value))
|
|
550
|
-
: [];
|
|
551
|
-
const promptTokenIds = Array.isArray(run.promptTokenIds)
|
|
552
|
-
? run.promptTokenIds.map((value) => Number(value)).filter((value) => Number.isInteger(value))
|
|
553
|
-
: null;
|
|
554
|
-
const logitsDigests = Array.isArray(run.logitsDigests)
|
|
555
|
-
? run.logitsDigests
|
|
556
|
-
: [];
|
|
557
|
-
const hasCompleteLogitsDigests = logitsDigests.length === tokenIds.length && tokenIds.length > 0;
|
|
558
|
-
const transcript = {
|
|
559
|
-
schema: 'doppler.reference-transcript/v1',
|
|
560
|
-
source: {
|
|
561
|
-
kind: 'inline-browser-suite',
|
|
562
|
-
path: 'inline',
|
|
563
|
-
hash: 'sha256:' + '0'.repeat(64),
|
|
564
|
-
},
|
|
565
|
-
executionGraphHash: context.executionGraphHash ?? null,
|
|
566
|
-
surface: 'browser-webgpu',
|
|
567
|
-
prompt: {
|
|
568
|
-
identity: typeof run.prompt === 'string' && run.prompt.trim() ? run.prompt : 'promptInput',
|
|
569
|
-
hash: hashStableJson(promptPayload),
|
|
570
|
-
tokenIdsHash: promptTokenIds ? hashStableJson(promptTokenIds) : null,
|
|
571
|
-
tokenCount: promptTokenIds ? promptTokenIds.length : null,
|
|
572
|
-
},
|
|
573
|
-
output: {
|
|
574
|
-
textHash: `sha256:${sha256Hex(outputText)}`,
|
|
575
|
-
tokensGenerated: tokenIds.length,
|
|
576
|
-
stopReason: typeof run.phase?.stopReason === 'string' ? run.phase.stopReason : 'unknown',
|
|
577
|
-
stopTokenId: Number.isInteger(run.phase?.stopTokenId) ? run.phase.stopTokenId : null,
|
|
578
|
-
},
|
|
579
|
-
tokens: {
|
|
580
|
-
ids: tokenIds,
|
|
581
|
-
generatedTokenIdsHash: hashStableJson(tokenIds),
|
|
582
|
-
generatedTextHash: `sha256:${sha256Hex(outputText)}`,
|
|
583
|
-
preview: Array.isArray(run.tokenDiagnostics?.preview) ? run.tokenDiagnostics.preview : [],
|
|
584
|
-
perStep: buildPerStepTokenProof(tokenIds),
|
|
585
|
-
coverage: {
|
|
586
|
-
mode: 'full-token-ids',
|
|
587
|
-
omitted: 0,
|
|
588
|
-
},
|
|
589
|
-
},
|
|
590
|
-
phase: {
|
|
591
|
-
prefillMs: Number.isFinite(run.phase?.prefillMs) ? run.phase.prefillMs : null,
|
|
592
|
-
decodeMs: Number.isFinite(run.phase?.decodeMs) ? run.phase.decodeMs : null,
|
|
593
|
-
prefillTokens: Number.isFinite(run.phase?.prefillTokens) ? run.phase.prefillTokens : null,
|
|
594
|
-
decodeTokens: Number.isFinite(run.phase?.decodeTokens) ? run.phase.decodeTokens : null,
|
|
595
|
-
},
|
|
596
|
-
kvCache: buildKvCacheTranscriptSeed(
|
|
597
|
-
run.phase?.kvCache ?? context.kvCache ?? null,
|
|
598
|
-
run.kvCacheByteProof ?? null
|
|
599
|
-
),
|
|
600
|
-
logits: hasCompleteLogitsDigests ? {
|
|
601
|
-
mode: 'sha256-per-step',
|
|
602
|
-
perStepDigests: logitsDigests.map((entry) => entry.digest),
|
|
603
|
-
steps: logitsDigests,
|
|
604
|
-
} : {
|
|
605
|
-
mode: 'not-captured',
|
|
606
|
-
reason: logitsDigests.length > 0
|
|
607
|
-
? 'Per-step logits digest count did not match generated token count.'
|
|
608
|
-
: 'Per-step logits digests were not requested for this browser harness run.',
|
|
609
|
-
perStepDigests: null,
|
|
610
|
-
},
|
|
611
|
-
tolerance: {
|
|
612
|
-
tokenPolicy: 'exact generated token IDs',
|
|
613
|
-
logitsPolicy: hasCompleteLogitsDigests
|
|
614
|
-
? 'exact sha256 digest per generated step over finalized f32 logits before sampling'
|
|
615
|
-
: 'not captured',
|
|
616
|
-
kvPolicy: run.kvCacheByteProof
|
|
617
|
-
? 'exact sha256 digest over used KV cache bytes by layer/key/value'
|
|
618
|
-
: 'metadata hash only; KV tensor bytes are not read back by default',
|
|
619
|
-
},
|
|
620
|
-
};
|
|
621
|
-
return {
|
|
622
|
-
...transcript,
|
|
623
|
-
source: {
|
|
624
|
-
...transcript.source,
|
|
625
|
-
hash: hashStableJson({
|
|
626
|
-
prompt: transcript.prompt,
|
|
627
|
-
output: transcript.output,
|
|
628
|
-
tokens: {
|
|
629
|
-
generatedTokenIdsHash: transcript.tokens.generatedTokenIdsHash,
|
|
630
|
-
generatedTextHash: transcript.tokens.generatedTextHash,
|
|
631
|
-
},
|
|
632
|
-
phase: transcript.phase,
|
|
633
|
-
kvCache: transcript.kvCache,
|
|
634
|
-
logits: transcript.logits,
|
|
635
|
-
}),
|
|
636
|
-
},
|
|
637
|
-
};
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
async function runKernelSuite(options = {}) {
|
|
641
|
-
const startTime = performance.now();
|
|
642
|
-
const { testHarness, initGPU } = await import('../../tests/kernels/browser/test-page.js');
|
|
643
|
-
const { runKernelSuite: runAllKernelTests } = await import('../../tests/kernels/browser/kernel-suite.js');
|
|
644
|
-
await initGPU();
|
|
645
|
-
|
|
646
|
-
const previousKernelPath = getActiveKernelPath();
|
|
647
|
-
const previousKernelSource = getActiveKernelPathSource();
|
|
648
|
-
const previousKernelPathPolicy = getActiveKernelPathPolicy();
|
|
649
|
-
if (options.modelId) {
|
|
650
|
-
await resolveKernelPathForModel(options);
|
|
651
|
-
}
|
|
652
|
-
let results = [];
|
|
653
|
-
try {
|
|
654
|
-
results = await runAllKernelTests(testHarness);
|
|
655
|
-
} finally {
|
|
656
|
-
setActiveKernelPath(previousKernelPath, previousKernelSource, previousKernelPathPolicy);
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
const summary = buildSuiteSummary('kernels', results, startTime);
|
|
660
|
-
return {
|
|
661
|
-
...summary,
|
|
662
|
-
deviceInfo: resolveDeviceInfo(),
|
|
663
|
-
};
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
async function runInferenceSuite(options = {}) {
|
|
667
|
-
const startTime = performance.now();
|
|
668
|
-
const cacheMode = normalizeCacheMode(options.cacheMode);
|
|
669
|
-
const loadMode = normalizeLoadMode(options.loadMode, !!options.modelUrl, options.modelUrl);
|
|
670
|
-
const harness = await withHarnessPhase(
|
|
671
|
-
'inference.initializeSuiteModel',
|
|
672
|
-
{
|
|
673
|
-
modelId: options.modelId ?? null,
|
|
674
|
-
loadMode,
|
|
675
|
-
cacheMode,
|
|
676
|
-
},
|
|
677
|
-
() => initializeSuiteModel(options)
|
|
678
|
-
);
|
|
679
|
-
const runtimeConfig = getRuntimeConfig();
|
|
680
|
-
const modelType = harness.manifest?.modelType || 'transformer';
|
|
681
|
-
const supportsEmbedding = modelSupportsEmbedding(harness.manifest);
|
|
682
|
-
const supportsRerank = modelSupportsRerank(harness.manifest);
|
|
683
|
-
if (options.expectedModelType === 'embedding' && !supportsEmbedding) {
|
|
684
|
-
throw new Error(
|
|
685
|
-
`Expected an embedding-capable model for workload "${options.workload || 'inference'}", got modelType="${modelType}". ` +
|
|
686
|
-
`Set inference.supportsEmbedding=true in the manifest for text-generation models that should expose pipeline.embed().`
|
|
687
|
-
);
|
|
688
|
-
}
|
|
689
|
-
if (options.expectedModelType === 'rerank' && !supportsRerank) {
|
|
690
|
-
throw new Error(
|
|
691
|
-
`Expected a rerank-capable model for workload "${options.workload || 'inference'}", got modelType="${modelType}". ` +
|
|
692
|
-
'Set inference.supportsRerank=true and inference.rerank in the manifest for models that should expose rerank scoring.'
|
|
693
|
-
);
|
|
694
|
-
}
|
|
695
|
-
const safeModelLoadMs = toTimingNumber(harness.modelLoadMs, 0);
|
|
696
|
-
|
|
697
|
-
let results;
|
|
698
|
-
let output = null;
|
|
699
|
-
let metrics;
|
|
700
|
-
|
|
701
|
-
if (options.workload === 'rerank' && supportsRerank) {
|
|
702
|
-
const run = await runRerank(harness.pipeline, runtimeConfig);
|
|
703
|
-
const semantic = await runRerankSemanticChecks(harness.pipeline, options);
|
|
704
|
-
const allScoresFinite = run.scores.every((entry) => (
|
|
705
|
-
Number.isFinite(entry.score)
|
|
706
|
-
&& Number.isFinite(entry.probability)
|
|
707
|
-
&& Number.isFinite(entry.trueLogit)
|
|
708
|
-
&& Number.isFinite(entry.falseLogit)
|
|
709
|
-
));
|
|
710
|
-
const hasRanking = Array.isArray(run.ranking) && run.ranking.length === run.documentCount;
|
|
711
|
-
const isValidRerank = allScoresFinite && hasRanking && run.documentCount > 0;
|
|
712
|
-
const isSemanticValid = semantic.passed;
|
|
713
|
-
output = {
|
|
714
|
-
mode: 'rerank',
|
|
715
|
-
query: run.query,
|
|
716
|
-
documentCount: run.documentCount,
|
|
717
|
-
topDocument: run.topDocument,
|
|
718
|
-
ranking: run.ranking,
|
|
719
|
-
semantic: {
|
|
720
|
-
passed: isSemanticValid,
|
|
721
|
-
pairAcc: Number(semantic.pairAcc.toFixed(4)),
|
|
722
|
-
failedCaseIds: semantic.failedCaseIds,
|
|
723
|
-
details: {
|
|
724
|
-
pairs: semantic.pairs,
|
|
725
|
-
},
|
|
726
|
-
},
|
|
727
|
-
};
|
|
728
|
-
results = [
|
|
729
|
-
{
|
|
730
|
-
name: 'rerank',
|
|
731
|
-
passed: isValidRerank,
|
|
732
|
-
duration: run.durationMs,
|
|
733
|
-
error: isValidRerank
|
|
734
|
-
? undefined
|
|
735
|
-
: 'Rerank scores must be finite and produce a full ranking.',
|
|
736
|
-
},
|
|
737
|
-
{
|
|
738
|
-
name: 'rerank-semantic',
|
|
739
|
-
passed: isSemanticValid,
|
|
740
|
-
duration: semantic.durationMs,
|
|
741
|
-
error: isSemanticValid
|
|
742
|
-
? undefined
|
|
743
|
-
: (
|
|
744
|
-
`Rerank semantic checks below threshold: pairs=${(semantic.pairAcc * 100).toFixed(1)}% `
|
|
745
|
-
+ `(min ${(semantic.minPairAcc * 100).toFixed(1)}%). `
|
|
746
|
-
+ (semantic.failedCaseIds.length > 0 ? `Failed: ${semantic.failedCaseIds.join(', ')}` : '')
|
|
747
|
-
),
|
|
748
|
-
},
|
|
749
|
-
];
|
|
750
|
-
metrics = {
|
|
751
|
-
query: run.query,
|
|
752
|
-
documentCount: run.documentCount,
|
|
753
|
-
topDocumentIndex: run.topDocument?.index ?? null,
|
|
754
|
-
topDocumentScore: run.topDocument?.score == null ? null : Number(run.topDocument.score.toFixed(6)),
|
|
755
|
-
topDocumentProbability: run.topDocument?.probability == null ? null : Number(run.topDocument.probability.toFixed(6)),
|
|
756
|
-
rerankMs: Number(run.durationMs.toFixed(2)),
|
|
757
|
-
rerankRanking: run.ranking,
|
|
758
|
-
semanticPassed: isSemanticValid,
|
|
759
|
-
semanticDurationMs: Number(semantic.durationMs.toFixed(2)),
|
|
760
|
-
semanticPairAcc: Number(semantic.pairAcc.toFixed(4)),
|
|
761
|
-
semanticPairPassed: semantic.pairPassed,
|
|
762
|
-
semanticPairTotal: semantic.pairTotal,
|
|
763
|
-
semanticMinPairAcc: Number(semantic.minPairAcc.toFixed(4)),
|
|
764
|
-
semanticMinScoreMargin: Number(semantic.minScoreMargin.toFixed(4)),
|
|
765
|
-
semanticFailedCases: semantic.failedCaseIds,
|
|
766
|
-
semanticDetails: {
|
|
767
|
-
pairs: semantic.pairs,
|
|
768
|
-
},
|
|
769
|
-
modelLoadMs: safeModelLoadMs,
|
|
770
|
-
endToEndMs: safeToFixed(safeModelLoadMs + run.durationMs),
|
|
771
|
-
};
|
|
772
|
-
} else if (modelType === 'embedding' || (options.workload === 'embedding' && supportsEmbedding)) {
|
|
773
|
-
const run = await runEmbedding(harness.pipeline, runtimeConfig);
|
|
774
|
-
const semantic = await runEmbeddingSemanticChecks(harness.pipeline, options);
|
|
775
|
-
const isValidEmbedding = run.embeddingDim > 0 && run.nonFiniteCount === 0;
|
|
776
|
-
const isSemanticValid = semantic.passed;
|
|
777
|
-
output = {
|
|
778
|
-
mode: 'embedding',
|
|
779
|
-
tokens: run.tokenCount,
|
|
780
|
-
embeddingDim: run.embeddingDim,
|
|
781
|
-
finiteValues: run.finiteCount,
|
|
782
|
-
nonFiniteValues: run.nonFiniteCount,
|
|
783
|
-
finiteRatio: Number((run.finiteRatio ?? 0).toFixed(6)),
|
|
784
|
-
min: run.min == null ? null : Number(run.min.toFixed(6)),
|
|
785
|
-
max: run.max == null ? null : Number(run.max.toFixed(6)),
|
|
786
|
-
maxAbs: run.maxAbs == null ? null : Number(run.maxAbs.toFixed(6)),
|
|
787
|
-
mean: run.mean == null ? null : Number(run.mean.toFixed(6)),
|
|
788
|
-
stdDev: run.stdDev == null ? null : Number(run.stdDev.toFixed(6)),
|
|
789
|
-
l2Norm: run.l2Norm == null ? null : Number(run.l2Norm.toFixed(6)),
|
|
790
|
-
preview: run.preview,
|
|
791
|
-
semantic: {
|
|
792
|
-
passed: isSemanticValid,
|
|
793
|
-
style: semantic.style,
|
|
794
|
-
retrievalTop1Acc: Number(semantic.retrievalTop1Acc.toFixed(4)),
|
|
795
|
-
pairAcc: Number(semantic.pairAcc.toFixed(4)),
|
|
796
|
-
failedCaseIds: semantic.failedCaseIds,
|
|
797
|
-
details: {
|
|
798
|
-
retrieval: semantic.retrieval,
|
|
799
|
-
pairs: semantic.pairs,
|
|
800
|
-
},
|
|
801
|
-
},
|
|
802
|
-
};
|
|
803
|
-
results = [
|
|
804
|
-
{
|
|
805
|
-
name: 'embedding',
|
|
806
|
-
passed: isValidEmbedding,
|
|
807
|
-
duration: run.durationMs,
|
|
808
|
-
error: isValidEmbedding
|
|
809
|
-
? undefined
|
|
810
|
-
: (
|
|
811
|
-
run.embeddingDim <= 0
|
|
812
|
-
? 'No embedding returned'
|
|
813
|
-
: `Embedding contains non-finite values (${run.nonFiniteCount}/${run.embeddingDim})`
|
|
814
|
-
),
|
|
815
|
-
},
|
|
816
|
-
{
|
|
817
|
-
name: 'embedding-semantic',
|
|
818
|
-
passed: isSemanticValid,
|
|
819
|
-
duration: semantic.durationMs,
|
|
820
|
-
error: isSemanticValid
|
|
821
|
-
? undefined
|
|
822
|
-
: (
|
|
823
|
-
`Semantic checks below threshold: retrieval=${(semantic.retrievalTop1Acc * 100).toFixed(1)}% `
|
|
824
|
-
+ `(min ${(semantic.minRetrievalTop1Acc * 100).toFixed(1)}%), `
|
|
825
|
-
+ `pairs=${(semantic.pairAcc * 100).toFixed(1)}% `
|
|
826
|
-
+ `(min ${(semantic.minPairAcc * 100).toFixed(1)}%). `
|
|
827
|
-
+ (semantic.failedCaseIds.length > 0 ? `Failed: ${semantic.failedCaseIds.join(', ')}` : '')
|
|
828
|
-
),
|
|
829
|
-
},
|
|
830
|
-
];
|
|
831
|
-
metrics = {
|
|
832
|
-
prompt: run.prompt,
|
|
833
|
-
embeddingTokens: run.tokenCount,
|
|
834
|
-
embeddingDim: run.embeddingDim,
|
|
835
|
-
finiteValues: run.finiteCount,
|
|
836
|
-
finiteRatio: Number((run.finiteRatio ?? 0).toFixed(6)),
|
|
837
|
-
nonFiniteValues: run.nonFiniteCount,
|
|
838
|
-
embeddingMin: run.min == null ? null : Number(run.min.toFixed(6)),
|
|
839
|
-
embeddingMax: run.max == null ? null : Number(run.max.toFixed(6)),
|
|
840
|
-
embeddingMaxAbs: run.maxAbs == null ? null : Number(run.maxAbs.toFixed(6)),
|
|
841
|
-
embeddingMean: run.mean == null ? null : Number(run.mean.toFixed(6)),
|
|
842
|
-
embeddingStdDev: run.stdDev == null ? null : Number(run.stdDev.toFixed(6)),
|
|
843
|
-
embeddingL2Norm: run.l2Norm == null ? null : Number(run.l2Norm.toFixed(6)),
|
|
844
|
-
embeddingMs: Number(run.durationMs.toFixed(2)),
|
|
845
|
-
semanticPassed: isSemanticValid,
|
|
846
|
-
semanticDurationMs: Number(semantic.durationMs.toFixed(2)),
|
|
847
|
-
semanticRetrievalTop1Acc: Number(semantic.retrievalTop1Acc.toFixed(4)),
|
|
848
|
-
semanticPairAcc: Number(semantic.pairAcc.toFixed(4)),
|
|
849
|
-
semanticRetrievalPassed: semantic.retrievalPassed,
|
|
850
|
-
semanticRetrievalTotal: semantic.retrievalTotal,
|
|
851
|
-
semanticPairPassed: semantic.pairPassed,
|
|
852
|
-
semanticPairTotal: semantic.pairTotal,
|
|
853
|
-
semanticMinRetrievalTop1Acc: Number(semantic.minRetrievalTop1Acc.toFixed(4)),
|
|
854
|
-
semanticMinPairAcc: Number(semantic.minPairAcc.toFixed(4)),
|
|
855
|
-
semanticPairMarginThreshold: Number(semantic.pairMarginThreshold.toFixed(4)),
|
|
856
|
-
semanticStyle: semantic.style,
|
|
857
|
-
semanticFailedCases: semantic.failedCaseIds,
|
|
858
|
-
semanticDetails: {
|
|
859
|
-
retrieval: semantic.retrieval,
|
|
860
|
-
pairs: semantic.pairs,
|
|
861
|
-
},
|
|
862
|
-
modelLoadMs: safeModelLoadMs,
|
|
863
|
-
endToEndMs: safeToFixed(safeModelLoadMs + run.durationMs),
|
|
864
|
-
embeddingPreview: run.preview,
|
|
865
|
-
};
|
|
866
|
-
} else {
|
|
867
|
-
const run = await runTextInference(
|
|
868
|
-
harness.pipeline,
|
|
869
|
-
runtimeConfig,
|
|
870
|
-
options.inferenceInput ?? null
|
|
871
|
-
);
|
|
872
|
-
const coherent = isCoherentOutput(run.tokens, run.output);
|
|
873
|
-
results = [
|
|
874
|
-
{
|
|
875
|
-
name: 'generation',
|
|
876
|
-
passed: run.tokens.length > 0 && coherent,
|
|
877
|
-
duration: run.durationMs,
|
|
878
|
-
error: run.tokens.length === 0
|
|
879
|
-
? 'No tokens generated'
|
|
880
|
-
: (!coherent ? 'Output dominated by padding or special tokens' : undefined),
|
|
881
|
-
},
|
|
882
|
-
];
|
|
883
|
-
output = run.output;
|
|
884
|
-
metrics = {
|
|
885
|
-
prompt: run.prompt,
|
|
886
|
-
maxTokens: run.maxTokens,
|
|
887
|
-
tokensGenerated: run.tokens.length,
|
|
888
|
-
tokensPerSec: safeToFixed(run.tokensPerSec),
|
|
889
|
-
totalRunMs: safeToFixed(run.phase.totalMs),
|
|
890
|
-
firstTokenMs: safeToFixed(run.phase.ttftMs),
|
|
891
|
-
firstResponseMs: safeToFixed(safeModelLoadMs + run.phase.ttftMs),
|
|
892
|
-
prefillMs: safeToFixed(run.phase.prefillMs),
|
|
893
|
-
decodeMs: safeToFixed(run.phase.decodeMs),
|
|
894
|
-
wallRunMs: safeToFixed(run.phase.wallMs ?? run.durationMs),
|
|
895
|
-
prefillTokens: Math.round(run.phase.prefillTokens),
|
|
896
|
-
decodeTokens: Math.round(run.phase.decodeTokens),
|
|
897
|
-
stopReason: run.phase.stopReason ?? null,
|
|
898
|
-
stopTokenId: Number.isInteger(run.phase.stopTokenId) ? run.phase.stopTokenId : null,
|
|
899
|
-
prefillTokensPerSec: safeToFixed(run.phase.prefillTokensPerSec),
|
|
900
|
-
prefillTokensPerSecTtft: safeToFixed(run.phase.prefillTokensPerSecTtft),
|
|
901
|
-
decodeTokensPerSec: safeToFixed(run.phase.decodeTokensPerSec),
|
|
902
|
-
modelLoadMs: safeModelLoadMs,
|
|
903
|
-
gpu: run.phase.gpu,
|
|
904
|
-
batching: run.phase.batching ?? null,
|
|
905
|
-
plePreparedTokenCache: run.phase.plePreparedTokenCache ?? null,
|
|
906
|
-
prefillProfileSteps: run.phase.prefillProfileSteps,
|
|
907
|
-
decodeProfileSteps: run.phase.decodeProfileSteps,
|
|
908
|
-
executionPlan: run.phase.executionPlan,
|
|
909
|
-
kernelPathId: run.phase.kernelPathId,
|
|
910
|
-
kernelPathSource: run.phase.kernelPathSource,
|
|
911
|
-
generationDiagnostics: run.tokenDiagnostics,
|
|
912
|
-
kvCache: run.phase.kvCache ?? null,
|
|
913
|
-
referenceTranscript: buildReferenceTranscriptSeed(run, {
|
|
914
|
-
executionGraphHash: resolveExecutionGraphHash(harness.manifest),
|
|
915
|
-
kvCache: run.phase.kvCache ?? null,
|
|
916
|
-
}),
|
|
917
|
-
operatorDiagnostics: run.phase.operatorDiagnostics ?? null,
|
|
918
|
-
};
|
|
919
|
-
}
|
|
920
|
-
|
|
921
|
-
const memoryStats = typeof harness.pipeline?.getMemoryStats === 'function'
|
|
922
|
-
? harness.pipeline.getMemoryStats()
|
|
923
|
-
: null;
|
|
924
|
-
const loadTimings = resolvePipelineLoadTimings(harness.pipeline);
|
|
925
|
-
const loadDiagnostics = buildLoadTimingDiagnostics(
|
|
926
|
-
safeModelLoadMs,
|
|
927
|
-
loadTimings.loadTiming,
|
|
928
|
-
loadTimings.pipelineLoadTiming
|
|
929
|
-
);
|
|
930
|
-
if (typeof harness.pipeline.unload === 'function' && !options.keepPipeline) {
|
|
931
|
-
await harness.pipeline.unload();
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
const summary = buildSuiteSummary(options.suiteName || 'inference', results, startTime);
|
|
935
|
-
const timing = buildCanonicalTiming({
|
|
936
|
-
modelLoadMs: safeModelLoadMs,
|
|
937
|
-
firstTokenMs: metrics.firstTokenMs ?? null,
|
|
938
|
-
firstResponseMs: Number.isFinite(metrics.firstTokenMs)
|
|
939
|
-
? safeModelLoadMs + metrics.firstTokenMs
|
|
940
|
-
: null,
|
|
941
|
-
prefillMs: metrics.prefillMs ?? 0,
|
|
942
|
-
decodeMs: metrics.decodeMs ?? 0,
|
|
943
|
-
decodeMsPerTokenP50: metrics.decodeMsPerTokenP50 ?? null,
|
|
944
|
-
decodeMsPerTokenP95: metrics.decodeMsPerTokenP95 ?? null,
|
|
945
|
-
decodeMsPerTokenP99: metrics.decodeMsPerTokenP99 ?? null,
|
|
946
|
-
totalRunMs: metrics.totalRunMs ?? metrics.decodeMs ?? 0,
|
|
947
|
-
decodeTokensPerSec: metrics.decodeTokensPerSec,
|
|
948
|
-
prefillTokensPerSec: metrics.prefillTokensPerSec,
|
|
949
|
-
cacheMode,
|
|
950
|
-
loadMode,
|
|
951
|
-
});
|
|
952
|
-
const timingDiagnostics = buildTimingDiagnostics(timing, {
|
|
953
|
-
source: 'doppler',
|
|
954
|
-
prefillSemantics: 'internal_prefill_phase',
|
|
955
|
-
loadTiming: loadTimings.loadTiming,
|
|
956
|
-
pipelineLoadTiming: loadTimings.pipelineLoadTiming,
|
|
957
|
-
});
|
|
958
|
-
const decodeBottleneck = buildDecodeBottleneckDiagnostics(metrics, timing);
|
|
959
|
-
const metricsWithTimingDiagnostics = decodeBottleneck
|
|
960
|
-
? { ...metrics, decodeBottleneck }
|
|
961
|
-
: metrics;
|
|
962
|
-
if (decodeBottleneck) {
|
|
963
|
-
timingDiagnostics.decodeBottleneck = decodeBottleneck;
|
|
964
|
-
}
|
|
965
|
-
const firstLoad = buildFirstLoadComposition({
|
|
966
|
-
modelLoadMs: timing.modelLoadMs,
|
|
967
|
-
firstTokenMs: timing.firstTokenMs,
|
|
968
|
-
firstResponseMs: timing.firstResponseMs,
|
|
969
|
-
});
|
|
970
|
-
const metricsWithContracts = attachExecutionCostLedger(buildSuiteContractMetrics(
|
|
971
|
-
options.suiteName || 'inference',
|
|
972
|
-
loadDiagnostics
|
|
973
|
-
? { ...metricsWithTimingDiagnostics, load: loadDiagnostics }
|
|
974
|
-
: metricsWithTimingDiagnostics,
|
|
975
|
-
harness.manifest
|
|
976
|
-
), runtimeConfig, harness.manifest);
|
|
977
|
-
return {
|
|
978
|
-
...summary,
|
|
979
|
-
modelId: options.modelId || harness.manifest?.modelId || 'unknown',
|
|
980
|
-
cacheMode,
|
|
981
|
-
loadMode,
|
|
982
|
-
env: {
|
|
983
|
-
library: 'doppler',
|
|
984
|
-
runtime: 'browser',
|
|
985
|
-
device: 'webgpu',
|
|
986
|
-
browserUserAgent: typeof navigator !== 'undefined' ? (navigator.userAgent || null) : null,
|
|
987
|
-
browserPlatform: typeof navigator !== 'undefined' ? (navigator.platform || null) : null,
|
|
988
|
-
browserLanguage: typeof navigator !== 'undefined' ? (navigator.language || null) : null,
|
|
989
|
-
browserVendor: typeof navigator !== 'undefined' ? (navigator.vendor || null) : null,
|
|
990
|
-
},
|
|
991
|
-
timing,
|
|
992
|
-
timingDiagnostics,
|
|
993
|
-
firstLoad,
|
|
994
|
-
output,
|
|
995
|
-
metrics: metricsWithContracts,
|
|
996
|
-
memoryStats,
|
|
997
|
-
deviceInfo: resolveDeviceInfo(),
|
|
998
|
-
pipeline: options.keepPipeline ? harness.pipeline : null,
|
|
999
|
-
};
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
function resolveBenchmarkIterationSettings(runtimeConfig) {
|
|
1003
|
-
const benchConfig = runtimeConfig?.shared?.benchmark?.run || {};
|
|
1004
|
-
return {
|
|
1005
|
-
warmupRuns: Math.max(0, Math.floor(benchConfig.warmupRuns ?? 0)),
|
|
1006
|
-
timedRuns: Math.max(1, Math.floor(benchConfig.timedRuns ?? 1)),
|
|
1007
|
-
};
|
|
1008
|
-
}
|
|
1009
|
-
|
|
1010
|
-
async function runBenchSuite(options = {}) {
|
|
1011
|
-
const startTime = performance.now();
|
|
1012
|
-
const runtimeConfig = getRuntimeConfig();
|
|
1013
|
-
const iterationSettings = resolveBenchmarkIterationSettings(runtimeConfig);
|
|
1014
|
-
const warmupRuns = iterationSettings.warmupRuns;
|
|
1015
|
-
const timedRuns = iterationSettings.timedRuns;
|
|
1016
|
-
const cacheMode = normalizeCacheMode(options.cacheMode);
|
|
1017
|
-
const loadMode = normalizeLoadMode(options.loadMode, !!options.modelUrl, options.modelUrl);
|
|
1018
|
-
const workloadType = normalizeWorkloadType(
|
|
1019
|
-
options.workloadType
|
|
1020
|
-
?? (
|
|
1021
|
-
options.mode === 'bench' && (options.workload === 'training' || options.workload === 'diffusion')
|
|
1022
|
-
? options.workload
|
|
1023
|
-
: null
|
|
1024
|
-
)
|
|
1025
|
-
);
|
|
1026
|
-
|
|
1027
|
-
if (workloadType === 'training') {
|
|
1028
|
-
const trainingBench = await runTrainingBenchSuite({
|
|
1029
|
-
...options,
|
|
1030
|
-
benchRun: iterationSettings,
|
|
1031
|
-
workloadType,
|
|
1032
|
-
});
|
|
1033
|
-
const trainingReport = trainingBench?.metrics?.trainingMetricsReport;
|
|
1034
|
-
if (Array.isArray(trainingReport) && trainingReport.length > 0) {
|
|
1035
|
-
validateTrainingMetricsReport(trainingReport);
|
|
1036
|
-
}
|
|
1037
|
-
const runStats = trainingBench?.metrics?.latency?.runMs || computeSampleStats([]);
|
|
1038
|
-
const stepStats = trainingBench?.metrics?.latency?.stepMs || computeSampleStats([]);
|
|
1039
|
-
const throughputStats = trainingBench?.metrics?.throughput?.stepsPerSec || computeSampleStats([]);
|
|
1040
|
-
const timing = buildCanonicalTiming({
|
|
1041
|
-
modelLoadMs: 0,
|
|
1042
|
-
firstTokenMs: null,
|
|
1043
|
-
firstResponseMs: null,
|
|
1044
|
-
prefillMs: null,
|
|
1045
|
-
decodeMs: stepStats.median,
|
|
1046
|
-
totalRunMs: runStats.median,
|
|
1047
|
-
decodeTokensPerSec: throughputStats.median,
|
|
1048
|
-
prefillTokensPerSec: null,
|
|
1049
|
-
cacheMode,
|
|
1050
|
-
loadMode,
|
|
1051
|
-
});
|
|
1052
|
-
const timingDiagnostics = buildTimingDiagnostics(timing, {
|
|
1053
|
-
source: 'doppler',
|
|
1054
|
-
prefillSemantics: 'not_applicable_training_workload',
|
|
1055
|
-
});
|
|
1056
|
-
const firstLoad = buildFirstLoadComposition({
|
|
1057
|
-
modelLoadMs: timing.modelLoadMs,
|
|
1058
|
-
firstTokenMs: timing.firstTokenMs,
|
|
1059
|
-
firstResponseMs: timing.firstResponseMs,
|
|
1060
|
-
});
|
|
1061
|
-
return {
|
|
1062
|
-
...trainingBench,
|
|
1063
|
-
modelId: trainingBench.modelId || options.modelId || options.modelUrl || 'training',
|
|
1064
|
-
cacheMode,
|
|
1065
|
-
loadMode,
|
|
1066
|
-
env: {
|
|
1067
|
-
library: 'doppler',
|
|
1068
|
-
runtime: 'browser',
|
|
1069
|
-
device: 'webgpu',
|
|
1070
|
-
browserUserAgent: typeof navigator !== 'undefined' ? (navigator.userAgent || null) : null,
|
|
1071
|
-
browserPlatform: typeof navigator !== 'undefined' ? (navigator.platform || null) : null,
|
|
1072
|
-
browserLanguage: typeof navigator !== 'undefined' ? (navigator.language || null) : null,
|
|
1073
|
-
browserVendor: typeof navigator !== 'undefined' ? (navigator.vendor || null) : null,
|
|
1074
|
-
},
|
|
1075
|
-
timing,
|
|
1076
|
-
timingDiagnostics,
|
|
1077
|
-
firstLoad,
|
|
1078
|
-
output: null,
|
|
1079
|
-
memoryStats: null,
|
|
1080
|
-
deviceInfo: trainingBench.deviceInfo ?? resolveDeviceInfo(),
|
|
1081
|
-
pipeline: null,
|
|
1082
|
-
};
|
|
1083
|
-
}
|
|
1084
|
-
|
|
1085
|
-
if (workloadType === 'diffusion' || workloadType === 'diffusion_gemma') {
|
|
1086
|
-
const diffusionBench = await runDiffusionSuite({
|
|
1087
|
-
...options,
|
|
1088
|
-
command: 'bench',
|
|
1089
|
-
workload: 'diffusion',
|
|
1090
|
-
captureOutput: options.captureOutput === true,
|
|
1091
|
-
cacheMode,
|
|
1092
|
-
loadMode,
|
|
1093
|
-
});
|
|
1094
|
-
|
|
1095
|
-
const benchResults = [
|
|
1096
|
-
{
|
|
1097
|
-
name: 'benchmark-diffusion',
|
|
1098
|
-
passed: diffusionBench.passed > 0 && diffusionBench.failed === 0,
|
|
1099
|
-
duration: diffusionBench.duration,
|
|
1100
|
-
error: diffusionBench.failed === 0 ? undefined : 'Diffusion benchmark run failed.',
|
|
1101
|
-
},
|
|
1102
|
-
];
|
|
1103
|
-
const summary = buildSuiteSummary('bench', benchResults, startTime);
|
|
1104
|
-
|
|
1105
|
-
return {
|
|
1106
|
-
...diffusionBench,
|
|
1107
|
-
...summary,
|
|
1108
|
-
suite: 'bench',
|
|
1109
|
-
results: benchResults,
|
|
1110
|
-
metrics: {
|
|
1111
|
-
...(diffusionBench.metrics || {}),
|
|
1112
|
-
workloadType,
|
|
1113
|
-
},
|
|
1114
|
-
};
|
|
1115
|
-
}
|
|
1116
|
-
|
|
1117
|
-
const harness = await withHarnessPhase(
|
|
1118
|
-
'bench.initializeSuiteModel',
|
|
1119
|
-
{
|
|
1120
|
-
modelId: options.modelId ?? null,
|
|
1121
|
-
loadMode,
|
|
1122
|
-
cacheMode,
|
|
1123
|
-
},
|
|
1124
|
-
() => initializeSuiteModel(options)
|
|
1125
|
-
);
|
|
1126
|
-
const benchRun = options.workload === 'rerank'
|
|
1127
|
-
? iterationSettings
|
|
1128
|
-
: resolveBenchmarkRunSettings(runtimeConfig, harness.pipeline ?? harness);
|
|
1129
|
-
const modelType = harness.manifest?.modelType || 'transformer';
|
|
1130
|
-
const supportsEmbedding = modelSupportsEmbedding(harness.manifest);
|
|
1131
|
-
const supportsRerank = modelSupportsRerank(harness.manifest);
|
|
1132
|
-
if (options.expectedModelType === 'embedding' && !supportsEmbedding) {
|
|
1133
|
-
throw new Error(
|
|
1134
|
-
`Expected an embedding-capable model for bench workload "${options.workload || 'inference'}", got modelType="${modelType}". ` +
|
|
1135
|
-
`Set inference.supportsEmbedding=true in the manifest for text-generation models that should expose pipeline.embed().`
|
|
1136
|
-
);
|
|
1137
|
-
}
|
|
1138
|
-
if (options.expectedModelType === 'rerank' && !supportsRerank) {
|
|
1139
|
-
throw new Error(
|
|
1140
|
-
`Expected a rerank-capable model for bench workload "${options.workload || 'inference'}", got modelType="${modelType}". ` +
|
|
1141
|
-
'Set inference.supportsRerank=true and inference.rerank in the manifest for models that should expose rerank scoring.'
|
|
1142
|
-
);
|
|
1143
|
-
}
|
|
1144
|
-
const safeModelLoadMs = toTimingNumber(harness.modelLoadMs, 0);
|
|
1145
|
-
|
|
1146
|
-
let results;
|
|
1147
|
-
let metrics;
|
|
1148
|
-
let output = null;
|
|
1149
|
-
let timing;
|
|
1150
|
-
|
|
1151
|
-
if (options.workload === 'rerank' && supportsRerank) {
|
|
1152
|
-
const durations = [];
|
|
1153
|
-
const timedDurations = [];
|
|
1154
|
-
const documentCounts = [];
|
|
1155
|
-
const topDocumentScores = [];
|
|
1156
|
-
const topDocumentProbabilities = [];
|
|
1157
|
-
const rerankPhases = [];
|
|
1158
|
-
const rerankDocumentPhases = [];
|
|
1159
|
-
let invalidRuns = 0;
|
|
1160
|
-
let nonFiniteScores = 0;
|
|
1161
|
-
let lastRun = null;
|
|
1162
|
-
|
|
1163
|
-
for (let i = 0; i < warmupRuns + timedRuns; i++) {
|
|
1164
|
-
harness.pipeline.reset?.();
|
|
1165
|
-
const run = await runRerank(harness.pipeline, runtimeConfig, {
|
|
1166
|
-
...benchRun,
|
|
1167
|
-
benchmark: true,
|
|
1168
|
-
});
|
|
1169
|
-
if (i >= warmupRuns) {
|
|
1170
|
-
timedDurations.push(run.durationMs);
|
|
1171
|
-
const finiteScores = run.scores.filter((entry) => (
|
|
1172
|
-
Number.isFinite(entry.score)
|
|
1173
|
-
&& Number.isFinite(entry.probability)
|
|
1174
|
-
&& Number.isFinite(entry.trueLogit)
|
|
1175
|
-
&& Number.isFinite(entry.falseLogit)
|
|
1176
|
-
));
|
|
1177
|
-
nonFiniteScores += run.scores.length - finiteScores.length;
|
|
1178
|
-
const hasRanking = Array.isArray(run.ranking) && run.ranking.length === run.documentCount;
|
|
1179
|
-
if (finiteScores.length === run.scores.length && hasRanking && run.documentCount > 0) {
|
|
1180
|
-
durations.push(run.durationMs);
|
|
1181
|
-
if (run.phase && typeof run.phase === 'object') {
|
|
1182
|
-
rerankPhases.push(run.phase);
|
|
1183
|
-
if (Array.isArray(run.phase.documents)) {
|
|
1184
|
-
for (const documentPhase of run.phase.documents) {
|
|
1185
|
-
if (documentPhase?.phase && typeof documentPhase.phase === 'object') {
|
|
1186
|
-
rerankDocumentPhases.push(documentPhase.phase);
|
|
1187
|
-
}
|
|
1188
|
-
}
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
documentCounts.push(run.documentCount);
|
|
1192
|
-
if (Number.isFinite(run.topDocument?.score)) {
|
|
1193
|
-
topDocumentScores.push(run.topDocument.score);
|
|
1194
|
-
}
|
|
1195
|
-
if (Number.isFinite(run.topDocument?.probability)) {
|
|
1196
|
-
topDocumentProbabilities.push(run.topDocument.probability);
|
|
1197
|
-
}
|
|
1198
|
-
} else {
|
|
1199
|
-
invalidRuns++;
|
|
1200
|
-
}
|
|
1201
|
-
lastRun = run;
|
|
1202
|
-
}
|
|
1203
|
-
}
|
|
1204
|
-
|
|
1205
|
-
const semantic = await runRerankSemanticChecks(harness.pipeline, options);
|
|
1206
|
-
const rerankMsStats = computeSampleStats(durations);
|
|
1207
|
-
const timedRerankMsStats = computeSampleStats(timedDurations);
|
|
1208
|
-
const documentCountStats = computeSampleStats(documentCounts);
|
|
1209
|
-
const topScoreStats = computeSampleStats(topDocumentScores);
|
|
1210
|
-
const topProbabilityStats = computeSampleStats(topDocumentProbabilities);
|
|
1211
|
-
const avgMs = rerankMsStats.mean;
|
|
1212
|
-
const semanticPassed = semantic.passed;
|
|
1213
|
-
const rerankPrefixPhases = rerankPhases
|
|
1214
|
-
.map((phase) => phase?.prefix)
|
|
1215
|
-
.filter((phase) => phase && typeof phase === 'object');
|
|
1216
|
-
|
|
1217
|
-
results = [
|
|
1218
|
-
{
|
|
1219
|
-
name: 'benchmark-rerank',
|
|
1220
|
-
passed: durations.length > 0 && invalidRuns === 0,
|
|
1221
|
-
duration: durations.reduce((sum, value) => sum + value, 0),
|
|
1222
|
-
error: durations.length > 0
|
|
1223
|
-
? (
|
|
1224
|
-
invalidRuns === 0
|
|
1225
|
-
? undefined
|
|
1226
|
-
: `Invalid rerank runs: ${invalidRuns} (non-finite scores or incomplete ranking observed)`
|
|
1227
|
-
)
|
|
1228
|
-
: 'No valid rerank benchmark runs completed',
|
|
1229
|
-
},
|
|
1230
|
-
{
|
|
1231
|
-
name: 'benchmark-rerank-semantic',
|
|
1232
|
-
passed: semanticPassed,
|
|
1233
|
-
duration: semantic.durationMs,
|
|
1234
|
-
error: semanticPassed
|
|
1235
|
-
? undefined
|
|
1236
|
-
: (
|
|
1237
|
-
`Rerank semantic checks below threshold: pairs=${(semantic.pairAcc * 100).toFixed(1)}% `
|
|
1238
|
-
+ `(min ${(semantic.minPairAcc * 100).toFixed(1)}%). `
|
|
1239
|
-
+ (semantic.failedCaseIds.length > 0 ? `Failed: ${semantic.failedCaseIds.join(', ')}` : '')
|
|
1240
|
-
),
|
|
1241
|
-
},
|
|
1242
|
-
];
|
|
1243
|
-
|
|
1244
|
-
output = {
|
|
1245
|
-
mode: 'rerank',
|
|
1246
|
-
query: lastRun?.query ?? null,
|
|
1247
|
-
documentCount: lastRun?.documentCount ?? null,
|
|
1248
|
-
topDocument: lastRun?.topDocument ?? null,
|
|
1249
|
-
ranking: lastRun?.ranking ?? [],
|
|
1250
|
-
semantic: {
|
|
1251
|
-
passed: semanticPassed,
|
|
1252
|
-
pairAcc: Number(semantic.pairAcc.toFixed(4)),
|
|
1253
|
-
failedCaseIds: semantic.failedCaseIds,
|
|
1254
|
-
details: {
|
|
1255
|
-
pairs: semantic.pairs,
|
|
1256
|
-
},
|
|
1257
|
-
},
|
|
1258
|
-
};
|
|
1259
|
-
|
|
1260
|
-
metrics = {
|
|
1261
|
-
warmupRuns,
|
|
1262
|
-
timedRuns,
|
|
1263
|
-
validRuns: durations.length,
|
|
1264
|
-
invalidRuns,
|
|
1265
|
-
invalidRatePct: Number((timedRuns > 0 ? (invalidRuns / timedRuns) * 100 : 0).toFixed(2)),
|
|
1266
|
-
query: lastRun?.query ?? null,
|
|
1267
|
-
documentCount: Math.round(documentCountStats.mean),
|
|
1268
|
-
topDocumentIndex: lastRun?.topDocument?.index ?? null,
|
|
1269
|
-
topDocumentScore: lastRun?.topDocument?.score == null ? null : Number(lastRun.topDocument.score.toFixed(6)),
|
|
1270
|
-
topDocumentProbability: lastRun?.topDocument?.probability == null ? null : Number(lastRun.topDocument.probability.toFixed(6)),
|
|
1271
|
-
topDocumentScoreStats: topScoreStats,
|
|
1272
|
-
topDocumentProbabilityStats: topProbabilityStats,
|
|
1273
|
-
nonFiniteScores,
|
|
1274
|
-
firstTimedRerankMs: Number((timedDurations[0] ?? 0).toFixed(2)),
|
|
1275
|
-
minRerankMs: Number(rerankMsStats.min.toFixed(2)),
|
|
1276
|
-
medianRerankMs: Number(rerankMsStats.median.toFixed(2)),
|
|
1277
|
-
p95RerankMs: Number(rerankMsStats.p95.toFixed(2)),
|
|
1278
|
-
p99RerankMs: Number(rerankMsStats.p99.toFixed(2)),
|
|
1279
|
-
maxRerankMs: Number(rerankMsStats.max.toFixed(2)),
|
|
1280
|
-
stdDevRerankMs: Number(rerankMsStats.stdDev.toFixed(2)),
|
|
1281
|
-
ci95RerankMs: Number(rerankMsStats.ci95.toFixed(2)),
|
|
1282
|
-
avgRerankMs: Number(avgMs.toFixed(2)),
|
|
1283
|
-
avgReranksPerSec: Number((avgMs > 0 ? (1000 / avgMs) : 0).toFixed(2)),
|
|
1284
|
-
semanticPassed,
|
|
1285
|
-
semanticDurationMs: Number(semantic.durationMs.toFixed(2)),
|
|
1286
|
-
semanticPairAcc: Number(semantic.pairAcc.toFixed(4)),
|
|
1287
|
-
semanticPairPassed: semantic.pairPassed,
|
|
1288
|
-
semanticPairTotal: semantic.pairTotal,
|
|
1289
|
-
semanticMinPairAcc: Number(semantic.minPairAcc.toFixed(4)),
|
|
1290
|
-
semanticMinScoreMargin: Number(semantic.minScoreMargin.toFixed(4)),
|
|
1291
|
-
semanticFailedCases: semantic.failedCaseIds,
|
|
1292
|
-
semanticDetails: {
|
|
1293
|
-
pairs: semantic.pairs,
|
|
1294
|
-
},
|
|
1295
|
-
modelLoadMs: safeModelLoadMs,
|
|
1296
|
-
latency: {
|
|
1297
|
-
timedRerankMs: timedRerankMsStats,
|
|
1298
|
-
rerankMs: rerankMsStats,
|
|
1299
|
-
},
|
|
1300
|
-
phase: summarizeTimingPhaseSamples(rerankPhases, [
|
|
1301
|
-
'totalMs',
|
|
1302
|
-
'prefixMs',
|
|
1303
|
-
'prefixTokens',
|
|
1304
|
-
'documentCount',
|
|
1305
|
-
'documentTotalMs',
|
|
1306
|
-
'maxDocumentMs',
|
|
1307
|
-
'avgDocumentMs',
|
|
1308
|
-
'prefix.totalMs',
|
|
1309
|
-
'prefix.prefillMs',
|
|
1310
|
-
'prefix.prefillRecordMs',
|
|
1311
|
-
'prefix.prefillRecordOps',
|
|
1312
|
-
'prefix.prefillRecordPasses',
|
|
1313
|
-
'prefix.prefillSubmitWaitMs',
|
|
1314
|
-
]),
|
|
1315
|
-
prefixPhase: {
|
|
1316
|
-
...summarizeTimingPhaseSamples(rerankPrefixPhases, [
|
|
1317
|
-
'totalMs',
|
|
1318
|
-
'prefillMs',
|
|
1319
|
-
'prefillRecordMs',
|
|
1320
|
-
'prefillRecordOps',
|
|
1321
|
-
'prefillRecordPasses',
|
|
1322
|
-
'prefillSubmitWaitMs',
|
|
1323
|
-
'gpuPrefillMs',
|
|
1324
|
-
'tokens',
|
|
1325
|
-
]),
|
|
1326
|
-
...summarizePrefillRecordOps(rerankPrefixPhases),
|
|
1327
|
-
},
|
|
1328
|
-
documentPhase: {
|
|
1329
|
-
...summarizeTimingPhaseSamples(rerankDocumentPhases, [
|
|
1330
|
-
'totalMs',
|
|
1331
|
-
'prefillCallMs',
|
|
1332
|
-
'inputMs',
|
|
1333
|
-
'prefillMs',
|
|
1334
|
-
'prefillRecordMs',
|
|
1335
|
-
'prefillRecordOps',
|
|
1336
|
-
'prefillRecordPasses',
|
|
1337
|
-
'prefillSubmitWaitMs',
|
|
1338
|
-
'gpuPrefillMs',
|
|
1339
|
-
'tokens',
|
|
1340
|
-
'selectedTokenCount',
|
|
1341
|
-
'prefixTokens',
|
|
1342
|
-
'suffixTokens',
|
|
1343
|
-
'promptChars',
|
|
1344
|
-
]),
|
|
1345
|
-
...summarizePrefillRecordOps(rerankDocumentPhases),
|
|
1346
|
-
},
|
|
1347
|
-
documents: {
|
|
1348
|
-
count: documentCountStats,
|
|
1349
|
-
},
|
|
1350
|
-
};
|
|
1351
|
-
|
|
1352
|
-
timing = buildCanonicalTiming({
|
|
1353
|
-
modelLoadMs: safeModelLoadMs,
|
|
1354
|
-
firstTokenMs: null,
|
|
1355
|
-
firstResponseMs: Number.isFinite(timedDurations[0])
|
|
1356
|
-
? safeModelLoadMs + timedDurations[0]
|
|
1357
|
-
: null,
|
|
1358
|
-
prefillMs: null,
|
|
1359
|
-
decodeMs: null,
|
|
1360
|
-
totalRunMs: rerankMsStats.median,
|
|
1361
|
-
cacheMode,
|
|
1362
|
-
loadMode,
|
|
1363
|
-
});
|
|
1364
|
-
} else if (modelType === 'embedding' || (options.workload === 'embedding' && supportsEmbedding)) {
|
|
1365
|
-
const durations = [];
|
|
1366
|
-
const timedDurations = [];
|
|
1367
|
-
const embeddingDims = [];
|
|
1368
|
-
const embeddingTokenCounts = [];
|
|
1369
|
-
const embeddingNorms = [];
|
|
1370
|
-
const embeddingPhases = [];
|
|
1371
|
-
let firstTimedEmbeddingMs = null;
|
|
1372
|
-
let invalidRuns = 0;
|
|
1373
|
-
let totalNonFiniteValues = 0;
|
|
1374
|
-
for (let i = 0; i < warmupRuns + timedRuns; i++) {
|
|
1375
|
-
harness.pipeline.reset?.();
|
|
1376
|
-
const run = await runEmbedding(harness.pipeline, runtimeConfig, {
|
|
1377
|
-
...benchRun,
|
|
1378
|
-
benchmark: true,
|
|
1379
|
-
});
|
|
1380
|
-
if (i >= warmupRuns) {
|
|
1381
|
-
timedDurations.push(run.durationMs);
|
|
1382
|
-
if (firstTimedEmbeddingMs == null) {
|
|
1383
|
-
firstTimedEmbeddingMs = run.durationMs;
|
|
1384
|
-
}
|
|
1385
|
-
totalNonFiniteValues += run.nonFiniteCount;
|
|
1386
|
-
if (Number.isFinite(run.tokenCount)) {
|
|
1387
|
-
embeddingTokenCounts.push(run.tokenCount);
|
|
1388
|
-
}
|
|
1389
|
-
if (Number.isFinite(run.l2Norm)) {
|
|
1390
|
-
embeddingNorms.push(run.l2Norm);
|
|
1391
|
-
}
|
|
1392
|
-
if (run.embeddingDim > 0 && run.nonFiniteCount === 0) {
|
|
1393
|
-
durations.push(run.durationMs);
|
|
1394
|
-
embeddingDims.push(run.embeddingDim);
|
|
1395
|
-
if (run.phase && typeof run.phase === 'object') {
|
|
1396
|
-
embeddingPhases.push(run.phase);
|
|
1397
|
-
}
|
|
1398
|
-
} else {
|
|
1399
|
-
invalidRuns++;
|
|
1400
|
-
}
|
|
1401
|
-
}
|
|
1402
|
-
}
|
|
1403
|
-
|
|
1404
|
-
const embeddingMsStats = computeSampleStats(durations);
|
|
1405
|
-
const timedEmbeddingMsStats = computeSampleStats(timedDurations);
|
|
1406
|
-
const embeddingDimStats = computeSampleStats(embeddingDims);
|
|
1407
|
-
const embeddingTokensStats = computeSampleStats(embeddingTokenCounts);
|
|
1408
|
-
const embeddingNormStats = computeSampleStats(embeddingNorms);
|
|
1409
|
-
const avgMs = embeddingMsStats.mean;
|
|
1410
|
-
|
|
1411
|
-
results = [
|
|
1412
|
-
{
|
|
1413
|
-
name: 'benchmark-embedding',
|
|
1414
|
-
passed: durations.length > 0 && invalidRuns === 0,
|
|
1415
|
-
duration: durations.reduce((sum, value) => sum + value, 0),
|
|
1416
|
-
error: durations.length > 0
|
|
1417
|
-
? (
|
|
1418
|
-
invalidRuns === 0
|
|
1419
|
-
? undefined
|
|
1420
|
-
: `Invalid embedding runs: ${invalidRuns} (non-finite values observed)`
|
|
1421
|
-
)
|
|
1422
|
-
: 'No valid embedding benchmark runs completed',
|
|
1423
|
-
},
|
|
1424
|
-
];
|
|
1425
|
-
|
|
1426
|
-
metrics = {
|
|
1427
|
-
warmupRuns,
|
|
1428
|
-
timedRuns,
|
|
1429
|
-
validRuns: durations.length,
|
|
1430
|
-
invalidRuns,
|
|
1431
|
-
invalidRatePct: Number((timedRuns > 0 ? (invalidRuns / timedRuns) * 100 : 0).toFixed(2)),
|
|
1432
|
-
prompt: benchRun.promptLabel,
|
|
1433
|
-
embeddingDim: Math.round(embeddingDims.reduce((a, b) => a + b, 0) / (embeddingDims.length || 1)),
|
|
1434
|
-
nonFiniteValues: totalNonFiniteValues,
|
|
1435
|
-
firstTimedEmbeddingMs: Number((firstTimedEmbeddingMs ?? 0).toFixed(2)),
|
|
1436
|
-
minEmbeddingMs: Number(embeddingMsStats.min.toFixed(2)),
|
|
1437
|
-
medianEmbeddingMs: Number(embeddingMsStats.median.toFixed(2)),
|
|
1438
|
-
p95EmbeddingMs: Number(embeddingMsStats.p95.toFixed(2)),
|
|
1439
|
-
p99EmbeddingMs: Number(embeddingMsStats.p99.toFixed(2)),
|
|
1440
|
-
maxEmbeddingMs: Number(embeddingMsStats.max.toFixed(2)),
|
|
1441
|
-
stdDevEmbeddingMs: Number(embeddingMsStats.stdDev.toFixed(2)),
|
|
1442
|
-
ci95EmbeddingMs: Number(embeddingMsStats.ci95.toFixed(2)),
|
|
1443
|
-
avgEmbeddingMs: Number(avgMs.toFixed(2)),
|
|
1444
|
-
avgEmbeddingsPerSec: Number((avgMs > 0 ? (1000 / avgMs) : 0).toFixed(2)),
|
|
1445
|
-
avgEmbeddingTokens: Number(embeddingTokensStats.mean.toFixed(2)),
|
|
1446
|
-
avgEmbeddingL2Norm: Number(embeddingNormStats.mean.toFixed(4)),
|
|
1447
|
-
modelLoadMs: safeModelLoadMs,
|
|
1448
|
-
latency: {
|
|
1449
|
-
timedEmbeddingMs: timedEmbeddingMsStats,
|
|
1450
|
-
embeddingMs: embeddingMsStats,
|
|
1451
|
-
},
|
|
1452
|
-
phase: {
|
|
1453
|
-
...summarizeTimingPhaseSamples(embeddingPhases, [
|
|
1454
|
-
'totalMs',
|
|
1455
|
-
'inputMs',
|
|
1456
|
-
'prefillMs',
|
|
1457
|
-
'submitWaitMs',
|
|
1458
|
-
'readbackMs',
|
|
1459
|
-
'decodeHiddenMs',
|
|
1460
|
-
'finalNormMs',
|
|
1461
|
-
'extractMs',
|
|
1462
|
-
'hiddenBytes',
|
|
1463
|
-
'tokens',
|
|
1464
|
-
'prefillRecordMs',
|
|
1465
|
-
'prefillRecordOps',
|
|
1466
|
-
'prefillRecordPasses',
|
|
1467
|
-
'prefillSubmitWaitMs',
|
|
1468
|
-
'gpuPrefillMs',
|
|
1469
|
-
]),
|
|
1470
|
-
...summarizePrefillRecordOps(embeddingPhases),
|
|
1471
|
-
},
|
|
1472
|
-
dimensions: {
|
|
1473
|
-
embedding: embeddingDimStats,
|
|
1474
|
-
},
|
|
1475
|
-
embedding: {
|
|
1476
|
-
tokens: embeddingTokensStats,
|
|
1477
|
-
l2Norm: embeddingNormStats,
|
|
1478
|
-
},
|
|
1479
|
-
};
|
|
1480
|
-
|
|
1481
|
-
const timedStats = computeSampleStats(durations);
|
|
1482
|
-
timing = buildCanonicalTiming({
|
|
1483
|
-
modelLoadMs: safeModelLoadMs,
|
|
1484
|
-
firstTokenMs: null,
|
|
1485
|
-
firstResponseMs: Number.isFinite(firstTimedEmbeddingMs)
|
|
1486
|
-
? safeModelLoadMs + firstTimedEmbeddingMs
|
|
1487
|
-
: null,
|
|
1488
|
-
prefillMs: null,
|
|
1489
|
-
decodeMs: null,
|
|
1490
|
-
totalRunMs: timedStats.median,
|
|
1491
|
-
cacheMode,
|
|
1492
|
-
loadMode,
|
|
1493
|
-
});
|
|
1494
|
-
} else {
|
|
1495
|
-
const tokensPerSec = [];
|
|
1496
|
-
const durations = [];
|
|
1497
|
-
const phaseTotals = [];
|
|
1498
|
-
const tokensGenerated = [];
|
|
1499
|
-
const decodeMsPerToken = [];
|
|
1500
|
-
const ttftMs = [];
|
|
1501
|
-
const prefillMs = [];
|
|
1502
|
-
const decodeMs = [];
|
|
1503
|
-
const prefillTokens = [];
|
|
1504
|
-
const decodeTokens = [];
|
|
1505
|
-
const decodeTokensPerSec = [];
|
|
1506
|
-
const prefillTokensPerSec = [];
|
|
1507
|
-
const prefillTokensPerSecTtft = [];
|
|
1508
|
-
const gpuPrefillMs = [];
|
|
1509
|
-
const gpuDecodeMs = [];
|
|
1510
|
-
const gpuDecodeRecordMs = [];
|
|
1511
|
-
const gpuDecodeRecordOps = [];
|
|
1512
|
-
const gpuDecodeRecordPasses = [];
|
|
1513
|
-
const gpuDecodeRecordMsPerOp = [];
|
|
1514
|
-
const gpuDecodeRecordMsPerPass = [];
|
|
1515
|
-
const gpuDecodeRecordPassesPerOp = [];
|
|
1516
|
-
const gpuDecodeRecordMsPerExecutedBatchToken = [];
|
|
1517
|
-
const gpuDecodeRecordOpsPerExecutedBatchToken = [];
|
|
1518
|
-
const gpuDecodeRecordPassesPerExecutedBatchToken = [];
|
|
1519
|
-
const gpuDecodeRecordOpLabels = {};
|
|
1520
|
-
let hasGpuDecodeRecordOpLabels = false;
|
|
1521
|
-
const gpuDecodeSubmitWaitMs = [];
|
|
1522
|
-
const gpuDecodeReadbackWaitMs = [];
|
|
1523
|
-
const gpuDecodeReadbackMapWaitMs = [];
|
|
1524
|
-
const gpuDecodeReadbackCleanupMs = [];
|
|
1525
|
-
const gpuDecodeReadbackCopyMs = [];
|
|
1526
|
-
const gpuDecodeOrchestrationMs = [];
|
|
1527
|
-
const gpuPrefillRecordMs = [];
|
|
1528
|
-
const gpuPrefillRecordOps = [];
|
|
1529
|
-
const gpuPrefillRecordPasses = [];
|
|
1530
|
-
const gpuPrefillRecordOpLabels = {};
|
|
1531
|
-
let hasGpuPrefillRecordOpLabels = false;
|
|
1532
|
-
const gpuPrefillSubmitWaitMs = [];
|
|
1533
|
-
const singleTokenSubmitWaitMs = [];
|
|
1534
|
-
const singleTokenReadbackWaitMs = [];
|
|
1535
|
-
const singleTokenReadbackMapWaitMs = [];
|
|
1536
|
-
const singleTokenReadbackCleanupMs = [];
|
|
1537
|
-
const singleTokenReadbackCopyMs = [];
|
|
1538
|
-
const singleTokenOrchestrationMs = [];
|
|
1539
|
-
const batchedForwardCalls = [];
|
|
1540
|
-
const unbatchedForwardCalls = [];
|
|
1541
|
-
const totalBatchedTimeMs = [];
|
|
1542
|
-
const totalUnbatchedTimeMs = [];
|
|
1543
|
-
const gpuSubmissions = [];
|
|
1544
|
-
const requestedBatchTokens = [];
|
|
1545
|
-
const effectiveBatchTokens = [];
|
|
1546
|
-
const executedBatchTokens = [];
|
|
1547
|
-
const resolvedBatchTokens = [];
|
|
1548
|
-
const maxBatchTokenCap = [];
|
|
1549
|
-
const batchClampCount = [];
|
|
1550
|
-
const plePreparedTokenCacheHits = [];
|
|
1551
|
-
const plePreparedTokenCacheMisses = [];
|
|
1552
|
-
const plePreparedTokenCacheEntries = [];
|
|
1553
|
-
const plePreparedTokenCacheBytes = [];
|
|
1554
|
-
|
|
1555
|
-
let generatedText = null;
|
|
1556
|
-
let generatedPromptInput = null;
|
|
1557
|
-
let generatedReferenceTranscript = null;
|
|
1558
|
-
let lastPromptLabel = benchRun.promptLabel;
|
|
1559
|
-
let lastMaxTokens = benchRun.maxTokens;
|
|
1560
|
-
let lastDecodeMode = null;
|
|
1561
|
-
let lastBatchGuardReason = null;
|
|
1562
|
-
let lastExecutionPlan = null;
|
|
1563
|
-
let lastPrefillProfileSteps = null;
|
|
1564
|
-
let lastDecodeProfileSteps = null;
|
|
1565
|
-
let lastGpuUniformCache = null;
|
|
1566
|
-
for (let i = 0; i < warmupRuns + timedRuns; i++) {
|
|
1567
|
-
harness.pipeline.reset?.();
|
|
1568
|
-
const run = await withHarnessPhase(
|
|
1569
|
-
`bench.runTextInference[${i}]`,
|
|
1570
|
-
{
|
|
1571
|
-
modelId: options.modelId ?? harness.manifest?.modelId ?? null,
|
|
1572
|
-
loadMode,
|
|
1573
|
-
cacheMode,
|
|
1574
|
-
warmupRuns,
|
|
1575
|
-
timedRuns,
|
|
1576
|
-
},
|
|
1577
|
-
() => runTextInference(harness.pipeline, runtimeConfig, {
|
|
1578
|
-
...benchRun,
|
|
1579
|
-
benchmark: true,
|
|
1580
|
-
...(options.inferenceInput ?? {}),
|
|
1581
|
-
})
|
|
1582
|
-
);
|
|
1583
|
-
if (i === warmupRuns + timedRuns - 1) {
|
|
1584
|
-
generatedText = run?.output ?? null;
|
|
1585
|
-
generatedPromptInput = run?.promptInput ?? null;
|
|
1586
|
-
generatedReferenceTranscript = buildReferenceTranscriptSeed(run, {
|
|
1587
|
-
executionGraphHash: resolveExecutionGraphHash(harness.manifest),
|
|
1588
|
-
kvCache: run?.phase?.kvCache ?? null,
|
|
1589
|
-
});
|
|
1590
|
-
lastPromptLabel = run?.prompt ?? benchRun.promptLabel;
|
|
1591
|
-
lastMaxTokens = Number.isFinite(run?.maxTokens) ? run.maxTokens : benchRun.maxTokens;
|
|
1592
|
-
lastDecodeMode = run?.phase?.decodeMode ?? null;
|
|
1593
|
-
lastBatchGuardReason = run?.phase?.batchGuardReason ?? null;
|
|
1594
|
-
lastExecutionPlan = run?.phase?.executionPlan ?? null;
|
|
1595
|
-
lastPrefillProfileSteps = run?.phase?.prefillProfileSteps ?? null;
|
|
1596
|
-
lastDecodeProfileSteps = run?.phase?.decodeProfileSteps ?? null;
|
|
1597
|
-
}
|
|
1598
|
-
if (i >= warmupRuns) {
|
|
1599
|
-
const phase = run?.phase ?? {};
|
|
1600
|
-
const phaseTokens = Array.isArray(run?.tokens) ? run.tokens : [];
|
|
1601
|
-
const phaseGpu = phase.gpu;
|
|
1602
|
-
const phaseBatching = phase.batching;
|
|
1603
|
-
const phasePlePreparedTokenCache = phase.plePreparedTokenCache;
|
|
1604
|
-
tokensPerSec.push(run?.tokensPerSec);
|
|
1605
|
-
durations.push(run?.durationMs);
|
|
1606
|
-
phaseTotals.push(phase.totalMs);
|
|
1607
|
-
tokensGenerated.push(phaseTokens.length);
|
|
1608
|
-
ttftMs.push(phase.ttftMs);
|
|
1609
|
-
prefillMs.push(phase.prefillMs);
|
|
1610
|
-
decodeMs.push(phase.decodeMs);
|
|
1611
|
-
prefillTokens.push(phase.prefillTokens);
|
|
1612
|
-
decodeTokens.push(phase.decodeTokens);
|
|
1613
|
-
decodeTokensPerSec.push(phase.decodeTokensPerSec);
|
|
1614
|
-
prefillTokensPerSec.push(phase.prefillTokensPerSec);
|
|
1615
|
-
prefillTokensPerSecTtft.push(phase.prefillTokensPerSecTtft);
|
|
1616
|
-
if (phase.decodeMs > 0 && phase.decodeTokens > 0) {
|
|
1617
|
-
decodeMsPerToken.push(phase.decodeMs / phase.decodeTokens);
|
|
1618
|
-
}
|
|
1619
|
-
const phaseGpuUniformCache = normalizeUniformCacheStats(phaseGpu?.uniformCache);
|
|
1620
|
-
if (phaseGpuUniformCache) {
|
|
1621
|
-
lastGpuUniformCache = phaseGpuUniformCache;
|
|
1622
|
-
}
|
|
1623
|
-
if (Number.isFinite(phaseGpu?.prefillMs)) gpuPrefillMs.push(phaseGpu.prefillMs);
|
|
1624
|
-
if (Number.isFinite(phaseGpu?.decodeMs)) gpuDecodeMs.push(phaseGpu.decodeMs);
|
|
1625
|
-
if (Number.isFinite(phaseGpu?.decodeRecordMs)) gpuDecodeRecordMs.push(phaseGpu.decodeRecordMs);
|
|
1626
|
-
if (Number.isFinite(phaseGpu?.decodeRecordOps)) gpuDecodeRecordOps.push(phaseGpu.decodeRecordOps);
|
|
1627
|
-
if (Number.isFinite(phaseGpu?.decodeRecordPasses)) gpuDecodeRecordPasses.push(phaseGpu.decodeRecordPasses);
|
|
1628
|
-
const phaseDecodeRecordOpLabels = normalizeDecodeRecordOpLabels(phaseGpu?.decodeRecordOpLabels);
|
|
1629
|
-
if (phaseDecodeRecordOpLabels) {
|
|
1630
|
-
hasGpuDecodeRecordOpLabels = true;
|
|
1631
|
-
for (const [label, count] of Object.entries(phaseDecodeRecordOpLabels)) {
|
|
1632
|
-
gpuDecodeRecordOpLabels[label] = (gpuDecodeRecordOpLabels[label] ?? 0) + count;
|
|
1633
|
-
}
|
|
1634
|
-
}
|
|
1635
|
-
if (Number.isFinite(phaseGpu?.decodeRecordMsPerOp)) {
|
|
1636
|
-
gpuDecodeRecordMsPerOp.push(phaseGpu.decodeRecordMsPerOp);
|
|
1637
|
-
}
|
|
1638
|
-
if (Number.isFinite(phaseGpu?.decodeRecordMsPerPass)) {
|
|
1639
|
-
gpuDecodeRecordMsPerPass.push(phaseGpu.decodeRecordMsPerPass);
|
|
1640
|
-
}
|
|
1641
|
-
if (Number.isFinite(phaseGpu?.decodeRecordPassesPerOp)) {
|
|
1642
|
-
gpuDecodeRecordPassesPerOp.push(phaseGpu.decodeRecordPassesPerOp);
|
|
1643
|
-
}
|
|
1644
|
-
if (Number.isFinite(phaseGpu?.decodeRecordMsPerExecutedBatchToken)) {
|
|
1645
|
-
gpuDecodeRecordMsPerExecutedBatchToken.push(phaseGpu.decodeRecordMsPerExecutedBatchToken);
|
|
1646
|
-
}
|
|
1647
|
-
if (Number.isFinite(phaseGpu?.decodeRecordOpsPerExecutedBatchToken)) {
|
|
1648
|
-
gpuDecodeRecordOpsPerExecutedBatchToken.push(phaseGpu.decodeRecordOpsPerExecutedBatchToken);
|
|
1649
|
-
}
|
|
1650
|
-
if (Number.isFinite(phaseGpu?.decodeRecordPassesPerExecutedBatchToken)) {
|
|
1651
|
-
gpuDecodeRecordPassesPerExecutedBatchToken.push(phaseGpu.decodeRecordPassesPerExecutedBatchToken);
|
|
1652
|
-
}
|
|
1653
|
-
if (Number.isFinite(phaseGpu?.decodeSubmitWaitMs)) gpuDecodeSubmitWaitMs.push(phaseGpu.decodeSubmitWaitMs);
|
|
1654
|
-
if (Number.isFinite(phaseGpu?.decodeReadbackWaitMs)) gpuDecodeReadbackWaitMs.push(phaseGpu.decodeReadbackWaitMs);
|
|
1655
|
-
if (Number.isFinite(phaseGpu?.decodeReadbackMapWaitMs)) gpuDecodeReadbackMapWaitMs.push(phaseGpu.decodeReadbackMapWaitMs);
|
|
1656
|
-
if (Number.isFinite(phaseGpu?.decodeReadbackCleanupMs)) gpuDecodeReadbackCleanupMs.push(phaseGpu.decodeReadbackCleanupMs);
|
|
1657
|
-
if (Number.isFinite(phaseGpu?.decodeReadbackCopyMs)) gpuDecodeReadbackCopyMs.push(phaseGpu.decodeReadbackCopyMs);
|
|
1658
|
-
if (Number.isFinite(phaseGpu?.prefillRecordMs)) gpuPrefillRecordMs.push(phaseGpu.prefillRecordMs);
|
|
1659
|
-
if (Number.isFinite(phaseGpu?.prefillRecordOps)) gpuPrefillRecordOps.push(phaseGpu.prefillRecordOps);
|
|
1660
|
-
if (Number.isFinite(phaseGpu?.prefillRecordPasses)) gpuPrefillRecordPasses.push(phaseGpu.prefillRecordPasses);
|
|
1661
|
-
const phasePrefillRecordOpLabels = normalizeDecodeRecordOpLabels(phaseGpu?.prefillRecordOpLabels);
|
|
1662
|
-
if (phasePrefillRecordOpLabels) {
|
|
1663
|
-
hasGpuPrefillRecordOpLabels = true;
|
|
1664
|
-
for (const [label, count] of Object.entries(phasePrefillRecordOpLabels)) {
|
|
1665
|
-
gpuPrefillRecordOpLabels[label] = (gpuPrefillRecordOpLabels[label] ?? 0) + count;
|
|
1666
|
-
}
|
|
1667
|
-
}
|
|
1668
|
-
if (Number.isFinite(phaseGpu?.prefillSubmitWaitMs)) gpuPrefillSubmitWaitMs.push(phaseGpu.prefillSubmitWaitMs);
|
|
1669
|
-
if (Number.isFinite(phaseGpu?.decodeOrchestrationMs)) {
|
|
1670
|
-
gpuDecodeOrchestrationMs.push(phaseGpu.decodeOrchestrationMs);
|
|
1671
|
-
}
|
|
1672
|
-
if (Number.isFinite(phaseGpu?.singleTokenSubmitWaitMs)) singleTokenSubmitWaitMs.push(phaseGpu.singleTokenSubmitWaitMs);
|
|
1673
|
-
if (Number.isFinite(phaseGpu?.singleTokenReadbackWaitMs)) singleTokenReadbackWaitMs.push(phaseGpu.singleTokenReadbackWaitMs);
|
|
1674
|
-
if (Number.isFinite(phaseGpu?.singleTokenReadbackMapWaitMs)) singleTokenReadbackMapWaitMs.push(phaseGpu.singleTokenReadbackMapWaitMs);
|
|
1675
|
-
if (Number.isFinite(phaseGpu?.singleTokenReadbackCleanupMs)) singleTokenReadbackCleanupMs.push(phaseGpu.singleTokenReadbackCleanupMs);
|
|
1676
|
-
if (Number.isFinite(phaseGpu?.singleTokenReadbackCopyMs)) singleTokenReadbackCopyMs.push(phaseGpu.singleTokenReadbackCopyMs);
|
|
1677
|
-
if (Number.isFinite(phaseGpu?.singleTokenOrchestrationMs)) singleTokenOrchestrationMs.push(phaseGpu.singleTokenOrchestrationMs);
|
|
1678
|
-
if (Number.isFinite(phaseBatching?.batchedForwardCalls)) batchedForwardCalls.push(phaseBatching.batchedForwardCalls);
|
|
1679
|
-
if (Number.isFinite(phaseBatching?.unbatchedForwardCalls)) unbatchedForwardCalls.push(phaseBatching.unbatchedForwardCalls);
|
|
1680
|
-
if (Number.isFinite(phaseBatching?.totalBatchedTimeMs)) totalBatchedTimeMs.push(phaseBatching.totalBatchedTimeMs);
|
|
1681
|
-
if (Number.isFinite(phaseBatching?.totalUnbatchedTimeMs)) totalUnbatchedTimeMs.push(phaseBatching.totalUnbatchedTimeMs);
|
|
1682
|
-
if (Number.isFinite(phaseBatching?.gpuSubmissions)) gpuSubmissions.push(phaseBatching.gpuSubmissions);
|
|
1683
|
-
if (Number.isFinite(phaseBatching?.requestedBatchTokens)) requestedBatchTokens.push(phaseBatching.requestedBatchTokens);
|
|
1684
|
-
if (Number.isFinite(phaseBatching?.effectiveBatchTokens)) effectiveBatchTokens.push(phaseBatching.effectiveBatchTokens);
|
|
1685
|
-
if (Number.isFinite(phaseBatching?.executedBatchTokens)) executedBatchTokens.push(phaseBatching.executedBatchTokens);
|
|
1686
|
-
if (Number.isFinite(phaseBatching?.resolvedBatchTokens)) resolvedBatchTokens.push(phaseBatching.resolvedBatchTokens);
|
|
1687
|
-
if (Number.isFinite(phaseBatching?.maxBatchTokenCap)) maxBatchTokenCap.push(phaseBatching.maxBatchTokenCap);
|
|
1688
|
-
if (Number.isFinite(phaseBatching?.batchClampCount)) batchClampCount.push(phaseBatching.batchClampCount);
|
|
1689
|
-
if (Number.isFinite(phasePlePreparedTokenCache?.hits)) plePreparedTokenCacheHits.push(phasePlePreparedTokenCache.hits);
|
|
1690
|
-
if (Number.isFinite(phasePlePreparedTokenCache?.misses)) plePreparedTokenCacheMisses.push(phasePlePreparedTokenCache.misses);
|
|
1691
|
-
if (Number.isFinite(phasePlePreparedTokenCache?.entries)) plePreparedTokenCacheEntries.push(phasePlePreparedTokenCache.entries);
|
|
1692
|
-
if (Number.isFinite(phasePlePreparedTokenCache?.bytes)) plePreparedTokenCacheBytes.push(phasePlePreparedTokenCache.bytes);
|
|
1693
|
-
}
|
|
1694
|
-
}
|
|
1695
|
-
|
|
1696
|
-
const totalMsStats = computeSampleStats(phaseTotals);
|
|
1697
|
-
const wallRunMsStats = computeSampleStats(durations);
|
|
1698
|
-
const tokensPerSecStats = computeSampleStats(tokensPerSec);
|
|
1699
|
-
const decodeTokensPerSecStats = computeSampleStats(decodeTokensPerSec);
|
|
1700
|
-
const prefillTokensPerSecStats = computeSampleStats(prefillTokensPerSec);
|
|
1701
|
-
const prefillTokensPerSecTtftStats = computeSampleStats(prefillTokensPerSecTtft);
|
|
1702
|
-
const decodeMsPerTokenStats = computeSampleStats(decodeMsPerToken);
|
|
1703
|
-
const ttftMsStats = computeSampleStats(ttftMs);
|
|
1704
|
-
const prefillMsStats = computeSampleStats(prefillMs);
|
|
1705
|
-
const decodeMsStats = computeSampleStats(decodeMs);
|
|
1706
|
-
const tokensGeneratedStats = computeSampleStats(tokensGenerated);
|
|
1707
|
-
const prefillTokensStats = computeSampleStats(prefillTokens);
|
|
1708
|
-
const decodeTokensStats = computeSampleStats(decodeTokens);
|
|
1709
|
-
const gpuDecodeRecordOpsStats = computeSampleStats(gpuDecodeRecordOps);
|
|
1710
|
-
const gpuDecodeRecordPassesStats = computeSampleStats(gpuDecodeRecordPasses);
|
|
1711
|
-
const gpuPrefillRecordOpsStats = computeSampleStats(gpuPrefillRecordOps);
|
|
1712
|
-
const gpuPrefillRecordPassesStats = computeSampleStats(gpuPrefillRecordPasses);
|
|
1713
|
-
const gpuDecodeRecordOpLabelSampleCount = gpuDecodeRecordOps.length > 0
|
|
1714
|
-
? gpuDecodeRecordOps.length
|
|
1715
|
-
: 1;
|
|
1716
|
-
const gpuDecodeRecordMeanOpLabels = {};
|
|
1717
|
-
if (hasGpuDecodeRecordOpLabels) {
|
|
1718
|
-
for (const [label, count] of Object.entries(gpuDecodeRecordOpLabels)) {
|
|
1719
|
-
gpuDecodeRecordMeanOpLabels[label] = count / gpuDecodeRecordOpLabelSampleCount;
|
|
1720
|
-
}
|
|
1721
|
-
}
|
|
1722
|
-
const gpuPrefillRecordOpLabelSampleCount = gpuPrefillRecordOps.length > 0
|
|
1723
|
-
? gpuPrefillRecordOps.length
|
|
1724
|
-
: 1;
|
|
1725
|
-
const gpuPrefillRecordMeanOpLabels = {};
|
|
1726
|
-
if (hasGpuPrefillRecordOpLabels) {
|
|
1727
|
-
for (const [label, count] of Object.entries(gpuPrefillRecordOpLabels)) {
|
|
1728
|
-
gpuPrefillRecordMeanOpLabels[label] = count / gpuPrefillRecordOpLabelSampleCount;
|
|
1729
|
-
}
|
|
1730
|
-
}
|
|
1731
|
-
const hasGpuStats = gpuPrefillMs.length > 0 || gpuDecodeMs.length > 0 || gpuDecodeRecordMs.length > 0
|
|
1732
|
-
|| gpuDecodeRecordOps.length > 0 || gpuDecodeRecordPasses.length > 0
|
|
1733
|
-
|| gpuPrefillRecordOps.length > 0 || gpuPrefillRecordPasses.length > 0
|
|
1734
|
-
|| gpuDecodeRecordMsPerOp.length > 0 || gpuDecodeRecordMsPerPass.length > 0
|
|
1735
|
-
|| gpuDecodeRecordPassesPerOp.length > 0
|
|
1736
|
-
|| gpuDecodeRecordMsPerExecutedBatchToken.length > 0
|
|
1737
|
-
|| gpuDecodeRecordOpsPerExecutedBatchToken.length > 0
|
|
1738
|
-
|| gpuDecodeRecordPassesPerExecutedBatchToken.length > 0
|
|
1739
|
-
|| hasGpuDecodeRecordOpLabels
|
|
1740
|
-
|| hasGpuPrefillRecordOpLabels
|
|
1741
|
-
|| gpuDecodeSubmitWaitMs.length > 0 || gpuDecodeReadbackWaitMs.length > 0
|
|
1742
|
-
|| gpuDecodeReadbackMapWaitMs.length > 0 || gpuDecodeReadbackCleanupMs.length > 0
|
|
1743
|
-
|| gpuDecodeReadbackCopyMs.length > 0
|
|
1744
|
-
|| gpuDecodeOrchestrationMs.length > 0
|
|
1745
|
-
|| lastGpuUniformCache
|
|
1746
|
-
|| singleTokenSubmitWaitMs.length > 0 || singleTokenReadbackWaitMs.length > 0
|
|
1747
|
-
|| singleTokenReadbackMapWaitMs.length > 0 || singleTokenReadbackCleanupMs.length > 0
|
|
1748
|
-
|| singleTokenReadbackCopyMs.length > 0
|
|
1749
|
-
|| singleTokenOrchestrationMs.length > 0;
|
|
1750
|
-
const gpuPhaseStats = hasGpuStats
|
|
1751
|
-
? {
|
|
1752
|
-
prefillMs: computeSampleStats(gpuPrefillMs),
|
|
1753
|
-
decodeMs: computeSampleStats(gpuDecodeMs),
|
|
1754
|
-
decodeRecordMs: computeSampleStats(gpuDecodeRecordMs),
|
|
1755
|
-
decodeRecordOps: gpuDecodeRecordOpsStats,
|
|
1756
|
-
decodeRecordPasses: gpuDecodeRecordPassesStats,
|
|
1757
|
-
decodeRecordMsPerOp: computeSampleStats(gpuDecodeRecordMsPerOp),
|
|
1758
|
-
decodeRecordMsPerPass: computeSampleStats(gpuDecodeRecordMsPerPass),
|
|
1759
|
-
decodeRecordPassesPerOp: computeSampleStats(gpuDecodeRecordPassesPerOp),
|
|
1760
|
-
decodeRecordMsPerExecutedBatchToken: computeSampleStats(gpuDecodeRecordMsPerExecutedBatchToken),
|
|
1761
|
-
decodeRecordOpsPerExecutedBatchToken: computeSampleStats(gpuDecodeRecordOpsPerExecutedBatchToken),
|
|
1762
|
-
decodeRecordPassesPerExecutedBatchToken: computeSampleStats(gpuDecodeRecordPassesPerExecutedBatchToken),
|
|
1763
|
-
decodeRecordUniqueOpLabels: hasGpuDecodeRecordOpLabels ? Object.keys(gpuDecodeRecordOpLabels).length : null,
|
|
1764
|
-
decodeRecordTopOps: hasGpuDecodeRecordOpLabels
|
|
1765
|
-
? buildDecodeRecordTopOps(
|
|
1766
|
-
gpuDecodeRecordMeanOpLabels,
|
|
1767
|
-
gpuDecodeRecordOpsStats?.mean
|
|
1768
|
-
)
|
|
1769
|
-
: [],
|
|
1770
|
-
decodeRecordTopOpGroups: hasGpuDecodeRecordOpLabels
|
|
1771
|
-
? buildDecodeRecordTopOpGroups(
|
|
1772
|
-
gpuDecodeRecordMeanOpLabels,
|
|
1773
|
-
gpuDecodeRecordOpsStats?.mean
|
|
1774
|
-
)
|
|
1775
|
-
: [],
|
|
1776
|
-
decodeSubmitWaitMs: computeSampleStats(gpuDecodeSubmitWaitMs),
|
|
1777
|
-
decodeReadbackWaitMs: computeSampleStats(gpuDecodeReadbackWaitMs),
|
|
1778
|
-
decodeReadbackMapWaitMs: computeSampleStats(gpuDecodeReadbackMapWaitMs),
|
|
1779
|
-
decodeReadbackCleanupMs: computeSampleStats(gpuDecodeReadbackCleanupMs),
|
|
1780
|
-
decodeReadbackCopyMs: computeSampleStats(gpuDecodeReadbackCopyMs),
|
|
1781
|
-
decodeOrchestrationMs: computeSampleStats(gpuDecodeOrchestrationMs),
|
|
1782
|
-
prefillRecordMs: computeSampleStats(gpuPrefillRecordMs),
|
|
1783
|
-
prefillRecordOps: gpuPrefillRecordOpsStats,
|
|
1784
|
-
prefillRecordPasses: gpuPrefillRecordPassesStats,
|
|
1785
|
-
prefillRecordUniqueOpLabels: hasGpuPrefillRecordOpLabels ? Object.keys(gpuPrefillRecordOpLabels).length : null,
|
|
1786
|
-
prefillRecordTopOps: hasGpuPrefillRecordOpLabels
|
|
1787
|
-
? buildDecodeRecordTopOps(
|
|
1788
|
-
gpuPrefillRecordMeanOpLabels,
|
|
1789
|
-
gpuPrefillRecordOpsStats?.mean
|
|
1790
|
-
)
|
|
1791
|
-
: [],
|
|
1792
|
-
prefillRecordTopOpGroups: hasGpuPrefillRecordOpLabels
|
|
1793
|
-
? buildDecodeRecordTopOpGroups(
|
|
1794
|
-
gpuPrefillRecordMeanOpLabels,
|
|
1795
|
-
gpuPrefillRecordOpsStats?.mean
|
|
1796
|
-
)
|
|
1797
|
-
: [],
|
|
1798
|
-
prefillSubmitWaitMs: computeSampleStats(gpuPrefillSubmitWaitMs),
|
|
1799
|
-
uniformCache: lastGpuUniformCache,
|
|
1800
|
-
singleTokenSubmitWaitMs: computeSampleStats(singleTokenSubmitWaitMs),
|
|
1801
|
-
singleTokenReadbackWaitMs: computeSampleStats(singleTokenReadbackWaitMs),
|
|
1802
|
-
singleTokenReadbackMapWaitMs: computeSampleStats(singleTokenReadbackMapWaitMs),
|
|
1803
|
-
singleTokenReadbackCleanupMs: computeSampleStats(singleTokenReadbackCleanupMs),
|
|
1804
|
-
singleTokenReadbackCopyMs: computeSampleStats(singleTokenReadbackCopyMs),
|
|
1805
|
-
singleTokenOrchestrationMs: computeSampleStats(singleTokenOrchestrationMs),
|
|
1806
|
-
}
|
|
1807
|
-
: null;
|
|
1808
|
-
const hasBatchingStats = batchedForwardCalls.length > 0
|
|
1809
|
-
|| unbatchedForwardCalls.length > 0
|
|
1810
|
-
|| totalBatchedTimeMs.length > 0
|
|
1811
|
-
|| totalUnbatchedTimeMs.length > 0
|
|
1812
|
-
|| gpuSubmissions.length > 0
|
|
1813
|
-
|| requestedBatchTokens.length > 0
|
|
1814
|
-
|| effectiveBatchTokens.length > 0
|
|
1815
|
-
|| executedBatchTokens.length > 0
|
|
1816
|
-
|| resolvedBatchTokens.length > 0
|
|
1817
|
-
|| maxBatchTokenCap.length > 0
|
|
1818
|
-
|| batchClampCount.length > 0;
|
|
1819
|
-
const batchingPhaseStats = hasBatchingStats
|
|
1820
|
-
? {
|
|
1821
|
-
batchedForwardCalls: computeSampleStats(batchedForwardCalls),
|
|
1822
|
-
unbatchedForwardCalls: computeSampleStats(unbatchedForwardCalls),
|
|
1823
|
-
totalBatchedTimeMs: computeSampleStats(totalBatchedTimeMs),
|
|
1824
|
-
totalUnbatchedTimeMs: computeSampleStats(totalUnbatchedTimeMs),
|
|
1825
|
-
gpuSubmissions: computeSampleStats(gpuSubmissions),
|
|
1826
|
-
requestedBatchTokens: computeSampleStats(requestedBatchTokens),
|
|
1827
|
-
effectiveBatchTokens: computeSampleStats(effectiveBatchTokens),
|
|
1828
|
-
executedBatchTokens: computeSampleStats(executedBatchTokens),
|
|
1829
|
-
resolvedBatchTokens: computeSampleStats(resolvedBatchTokens),
|
|
1830
|
-
maxBatchTokenCap: computeSampleStats(maxBatchTokenCap),
|
|
1831
|
-
batchClampCount: computeSampleStats(batchClampCount),
|
|
1832
|
-
}
|
|
1833
|
-
: null;
|
|
1834
|
-
const hasPlePreparedTokenCacheStats = plePreparedTokenCacheHits.length > 0
|
|
1835
|
-
|| plePreparedTokenCacheMisses.length > 0
|
|
1836
|
-
|| plePreparedTokenCacheEntries.length > 0
|
|
1837
|
-
|| plePreparedTokenCacheBytes.length > 0;
|
|
1838
|
-
const plePreparedTokenCacheStats = hasPlePreparedTokenCacheStats
|
|
1839
|
-
? {
|
|
1840
|
-
hits: computeSampleStats(plePreparedTokenCacheHits),
|
|
1841
|
-
misses: computeSampleStats(plePreparedTokenCacheMisses),
|
|
1842
|
-
entries: computeSampleStats(plePreparedTokenCacheEntries),
|
|
1843
|
-
bytes: computeSampleStats(plePreparedTokenCacheBytes),
|
|
1844
|
-
}
|
|
1845
|
-
: null;
|
|
1846
|
-
|
|
1847
|
-
results = [
|
|
1848
|
-
{
|
|
1849
|
-
name: 'benchmark',
|
|
1850
|
-
passed: tokensPerSec.length > 0,
|
|
1851
|
-
duration: durations.reduce((sum, value) => sum + value, 0),
|
|
1852
|
-
error: tokensPerSec.length > 0 ? undefined : 'No benchmark runs completed',
|
|
1853
|
-
},
|
|
1854
|
-
];
|
|
1855
|
-
|
|
1856
|
-
const normalizedFirstTokenMs = sampleTimingNumber(ttftMsStats, 'median', null);
|
|
1857
|
-
|
|
1858
|
-
metrics = {
|
|
1859
|
-
warmupRuns,
|
|
1860
|
-
timedRuns,
|
|
1861
|
-
...(Number.isFinite(benchRun?.seed) ? { seed: benchRun.seed } : {}),
|
|
1862
|
-
prompt: lastPromptLabel,
|
|
1863
|
-
maxTokens: lastMaxTokens,
|
|
1864
|
-
decodeTokensPerSec: sampleTimingNumber(decodeTokensPerSecStats, 'median'),
|
|
1865
|
-
avgTokensGenerated: Math.round(tokensGeneratedStats.mean),
|
|
1866
|
-
avgPrefillTokens: Math.round(prefillTokensStats.mean),
|
|
1867
|
-
avgDecodeTokens: Math.round(decodeTokensStats.mean),
|
|
1868
|
-
medianPrefillTokensPerSec: sampleTimingNumber(prefillTokensPerSecStats, 'median'),
|
|
1869
|
-
avgPrefillTokensPerSec: sampleTimingNumber(prefillTokensPerSecStats, 'mean'),
|
|
1870
|
-
medianPrefillTokensPerSecTtft: sampleTimingNumber(prefillTokensPerSecTtftStats, 'median'),
|
|
1871
|
-
avgPrefillTokensPerSecTtft: sampleTimingNumber(prefillTokensPerSecTtftStats, 'mean'),
|
|
1872
|
-
avgDecodeTokensPerSec: sampleTimingNumber(decodeTokensPerSecStats, 'mean'),
|
|
1873
|
-
firstTokenMs: normalizedFirstTokenMs,
|
|
1874
|
-
firstResponseMs: safeToFixed(safeModelLoadMs + normalizedFirstTokenMs, null),
|
|
1875
|
-
prefillMs: sampleTimingNumber(prefillMsStats, 'median'),
|
|
1876
|
-
decodeMs: sampleTimingNumber(decodeMsStats, 'median'),
|
|
1877
|
-
totalRunMs: sampleTimingNumber(totalMsStats, 'median'),
|
|
1878
|
-
decodeMsPerTokenP50: sampleTimingNumber(decodeMsPerTokenStats, 'median'),
|
|
1879
|
-
decodeMsPerTokenP95: sampleTimingNumber(decodeMsPerTokenStats, 'p95'),
|
|
1880
|
-
decodeMsPerTokenP99: sampleTimingNumber(decodeMsPerTokenStats, 'p99'),
|
|
1881
|
-
avgPrefillMs: sampleTimingNumber(prefillMsStats, 'mean'),
|
|
1882
|
-
wallRunMs: sampleTimingNumber(wallRunMsStats, 'median'),
|
|
1883
|
-
modelLoadMs: safeModelLoadMs,
|
|
1884
|
-
throughput: {
|
|
1885
|
-
tokensPerSec: tokensPerSecStats,
|
|
1886
|
-
prefillTokensPerSec: prefillTokensPerSecStats,
|
|
1887
|
-
prefillTokensPerSecTtft: prefillTokensPerSecTtftStats,
|
|
1888
|
-
decodeTokensPerSec: decodeTokensPerSecStats,
|
|
1889
|
-
},
|
|
1890
|
-
latency: {
|
|
1891
|
-
totalMs: totalMsStats,
|
|
1892
|
-
wallRunMs: wallRunMsStats,
|
|
1893
|
-
prefillMs: prefillMsStats,
|
|
1894
|
-
decodeMs: decodeMsStats,
|
|
1895
|
-
firstTokenMs: ttftMsStats,
|
|
1896
|
-
},
|
|
1897
|
-
tokens: {
|
|
1898
|
-
generated: tokensGeneratedStats,
|
|
1899
|
-
prefill: prefillTokensStats,
|
|
1900
|
-
decode: decodeTokensStats,
|
|
1901
|
-
},
|
|
1902
|
-
gpu: gpuPhaseStats,
|
|
1903
|
-
batching: batchingPhaseStats,
|
|
1904
|
-
decodeCadence: resolveDecodeCadence(getRuntimeConfig(), lastExecutionPlan),
|
|
1905
|
-
plePreparedTokenCache: plePreparedTokenCacheStats,
|
|
1906
|
-
decodeMode: lastDecodeMode,
|
|
1907
|
-
batchGuardReason: lastBatchGuardReason,
|
|
1908
|
-
executionPlan: lastExecutionPlan,
|
|
1909
|
-
prefillProfileSteps: lastPrefillProfileSteps,
|
|
1910
|
-
decodeProfileSteps: lastDecodeProfileSteps,
|
|
1911
|
-
generatedText,
|
|
1912
|
-
referenceTranscript: generatedReferenceTranscript,
|
|
1913
|
-
promptInput: generatedPromptInput,
|
|
1914
|
-
};
|
|
1915
|
-
|
|
1916
|
-
timing = buildCanonicalTiming({
|
|
1917
|
-
modelLoadMs: safeModelLoadMs,
|
|
1918
|
-
firstTokenMs: normalizedFirstTokenMs,
|
|
1919
|
-
firstResponseMs: Number.isFinite(normalizedFirstTokenMs)
|
|
1920
|
-
? safeModelLoadMs + normalizedFirstTokenMs
|
|
1921
|
-
: null,
|
|
1922
|
-
prefillMs: prefillMsStats?.median ?? null,
|
|
1923
|
-
decodeMs: decodeMsStats?.median ?? null,
|
|
1924
|
-
decodeMsPerTokenP50: decodeMsPerTokenStats?.median ?? null,
|
|
1925
|
-
decodeMsPerTokenP95: decodeMsPerTokenStats?.p95 ?? null,
|
|
1926
|
-
decodeMsPerTokenP99: decodeMsPerTokenStats?.p99 ?? null,
|
|
1927
|
-
totalRunMs: totalMsStats.median,
|
|
1928
|
-
decodeTokensPerSec: decodeTokensPerSecStats?.median,
|
|
1929
|
-
prefillTokensPerSec: prefillTokensPerSecStats?.median,
|
|
1930
|
-
prefillTokensPerSecTtft: prefillTokensPerSecTtftStats?.median,
|
|
1931
|
-
cacheMode,
|
|
1932
|
-
loadMode,
|
|
1933
|
-
});
|
|
1934
|
-
}
|
|
1935
|
-
|
|
1936
|
-
const memoryStats = typeof harness.pipeline?.getMemoryStats === 'function'
|
|
1937
|
-
? harness.pipeline.getMemoryStats()
|
|
1938
|
-
: null;
|
|
1939
|
-
const loadTimings = resolvePipelineLoadTimings(harness.pipeline);
|
|
1940
|
-
const loadDiagnostics = buildLoadTimingDiagnostics(
|
|
1941
|
-
safeModelLoadMs,
|
|
1942
|
-
loadTimings.loadTiming,
|
|
1943
|
-
loadTimings.pipelineLoadTiming
|
|
1944
|
-
);
|
|
1945
|
-
const decodeBottleneck = buildDecodeBottleneckDiagnostics(metrics, timing);
|
|
1946
|
-
if (decodeBottleneck) {
|
|
1947
|
-
metrics.decodeBottleneck = decodeBottleneck;
|
|
1948
|
-
}
|
|
1949
|
-
|
|
1950
|
-
if (typeof harness.pipeline.unload === 'function' && !options.keepPipeline) {
|
|
1951
|
-
await harness.pipeline.unload();
|
|
1952
|
-
}
|
|
1953
|
-
|
|
1954
|
-
const summary = buildSuiteSummary('bench', results, startTime);
|
|
1955
|
-
const timingDiagnostics = buildTimingDiagnostics(timing, {
|
|
1956
|
-
source: 'doppler',
|
|
1957
|
-
prefillSemantics: 'internal_prefill_phase',
|
|
1958
|
-
loadTiming: loadTimings.loadTiming,
|
|
1959
|
-
pipelineLoadTiming: loadTimings.pipelineLoadTiming,
|
|
1960
|
-
});
|
|
1961
|
-
if (decodeBottleneck) {
|
|
1962
|
-
timingDiagnostics.decodeBottleneck = decodeBottleneck;
|
|
1963
|
-
}
|
|
1964
|
-
const firstLoad = buildFirstLoadComposition({
|
|
1965
|
-
modelLoadMs: timing.modelLoadMs,
|
|
1966
|
-
firstTokenMs: timing.firstTokenMs,
|
|
1967
|
-
firstResponseMs: timing.firstResponseMs,
|
|
1968
|
-
});
|
|
1969
|
-
const metricsWithContracts = attachExecutionCostLedger(buildSuiteContractMetrics(
|
|
1970
|
-
'bench',
|
|
1971
|
-
loadDiagnostics ? { ...metrics, load: loadDiagnostics } : metrics,
|
|
1972
|
-
harness.manifest
|
|
1973
|
-
), runtimeConfig, harness.manifest);
|
|
1974
|
-
return {
|
|
1975
|
-
...summary,
|
|
1976
|
-
modelId: options.modelId || harness.manifest?.modelId || 'unknown',
|
|
1977
|
-
cacheMode,
|
|
1978
|
-
loadMode,
|
|
1979
|
-
env: {
|
|
1980
|
-
library: 'doppler',
|
|
1981
|
-
runtime: 'browser',
|
|
1982
|
-
device: 'webgpu',
|
|
1983
|
-
browserUserAgent: typeof navigator !== 'undefined' ? (navigator.userAgent || null) : null,
|
|
1984
|
-
browserPlatform: typeof navigator !== 'undefined' ? (navigator.platform || null) : null,
|
|
1985
|
-
browserLanguage: typeof navigator !== 'undefined' ? (navigator.language || null) : null,
|
|
1986
|
-
browserVendor: typeof navigator !== 'undefined' ? (navigator.vendor || null) : null,
|
|
1987
|
-
},
|
|
1988
|
-
timing,
|
|
1989
|
-
timingDiagnostics,
|
|
1990
|
-
firstLoad,
|
|
1991
|
-
output,
|
|
1992
|
-
metrics: metricsWithContracts,
|
|
1993
|
-
memoryStats,
|
|
1994
|
-
deviceInfo: resolveDeviceInfo(),
|
|
1995
|
-
pipeline: options.keepPipeline ? harness.pipeline : null,
|
|
1996
|
-
};
|
|
1997
|
-
}
|
|
1998
|
-
|
|
1999
114
|
async function dispatchBrowserSuite(mode, workload, options) {
|
|
2000
115
|
if (mode === 'verify' && workload === 'kernels') {
|
|
2001
116
|
return runKernelSuite(options);
|
|
@@ -2050,35 +165,6 @@ function shouldCaptureDebugSnapshot(mode, runtimeConfig) {
|
|
|
2050
165
|
|| logLevel === 'verbose';
|
|
2051
166
|
}
|
|
2052
167
|
|
|
2053
|
-
function createHarnessPhaseError(error, phase, context = {}) {
|
|
2054
|
-
const message = error?.message || String(error);
|
|
2055
|
-
const wrapped = new Error(
|
|
2056
|
-
`Browser harness phase "${phase}" failed: ${message}`,
|
|
2057
|
-
error instanceof Error ? { cause: error } : undefined
|
|
2058
|
-
);
|
|
2059
|
-
wrapped.name = error?.name || 'Error';
|
|
2060
|
-
if (error?.code !== undefined) {
|
|
2061
|
-
wrapped.code = error.code;
|
|
2062
|
-
}
|
|
2063
|
-
wrapped.details = {
|
|
2064
|
-
...(error?.details && typeof error.details === 'object' ? error.details : {}),
|
|
2065
|
-
harnessPhase: phase,
|
|
2066
|
-
...context,
|
|
2067
|
-
};
|
|
2068
|
-
return wrapped;
|
|
2069
|
-
}
|
|
2070
|
-
|
|
2071
|
-
async function withHarnessPhase(phase, context, run) {
|
|
2072
|
-
try {
|
|
2073
|
-
return await run();
|
|
2074
|
-
} catch (error) {
|
|
2075
|
-
if (error?.details?.harnessPhase) {
|
|
2076
|
-
throw error;
|
|
2077
|
-
}
|
|
2078
|
-
throw createHarnessPhaseError(error, phase, context);
|
|
2079
|
-
}
|
|
2080
|
-
}
|
|
2081
|
-
|
|
2082
168
|
export async function runBrowserSuite(options = {}) {
|
|
2083
169
|
return runWithRuntimeIsolationForSuite(async () => {
|
|
2084
170
|
if (options.commandContext) {
|
|
@@ -2136,7 +222,7 @@ export async function runBrowserSuite(options = {}) {
|
|
|
2136
222
|
mode,
|
|
2137
223
|
workload,
|
|
2138
224
|
suite,
|
|
2139
|
-
modelId,
|
|
225
|
+
modelId, surface: options.surface ?? 'browser',
|
|
2140
226
|
runtimeProfile: options.runtimeProfile ?? null,
|
|
2141
227
|
deviceInfo: suiteResult.deviceInfo ?? null,
|
|
2142
228
|
results: suiteResult.results,
|