doppler-gpu 0.2.0
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/BRANDING.md +14 -0
- package/CHANGELOG.md +158 -0
- package/LICENSE +201 -0
- package/NOTICE +5 -0
- package/README.md +85 -0
- package/SECURITY.md +19 -0
- package/package.json +195 -0
- package/src/adapters/adapter-manager.d.ts +200 -0
- package/src/adapters/adapter-manager.js +509 -0
- package/src/adapters/adapter-manifest.d.ts +290 -0
- package/src/adapters/adapter-manifest.js +320 -0
- package/src/adapters/adapter-registry.d.ts +192 -0
- package/src/adapters/adapter-registry.js +477 -0
- package/src/adapters/index.d.ts +89 -0
- package/src/adapters/index.js +42 -0
- package/src/adapters/lora-loader.d.ts +105 -0
- package/src/adapters/lora-loader.js +425 -0
- package/src/bootstrap.d.ts +1 -0
- package/src/bootstrap.js +30 -0
- package/src/bridge/extension/background.d.ts +14 -0
- package/src/bridge/extension/background.js +168 -0
- package/src/bridge/extension/manifest.json +34 -0
- package/src/bridge/extension-client.d.ts +114 -0
- package/src/bridge/extension-client.js +409 -0
- package/src/bridge/index.d.ts +69 -0
- package/src/bridge/index.js +53 -0
- package/src/bridge/node-bridge.js +26 -0
- package/src/bridge/protocol.d.ts +96 -0
- package/src/bridge/protocol.js +130 -0
- package/src/browser/browser-converter.d.ts +71 -0
- package/src/browser/browser-converter.js +978 -0
- package/src/browser/file-picker.d.ts +63 -0
- package/src/browser/file-picker.js +281 -0
- package/src/browser/gguf-importer.d.ts +136 -0
- package/src/browser/gguf-importer.js +532 -0
- package/src/browser/gguf-parser-browser.d.ts +14 -0
- package/src/browser/gguf-parser-browser.js +17 -0
- package/src/browser/quantization.d.ts +69 -0
- package/src/browser/quantization.js +328 -0
- package/src/browser/safetensors-parser-browser.d.ts +193 -0
- package/src/browser/safetensors-parser-browser.js +347 -0
- package/src/browser/shard-io-browser.d.ts +57 -0
- package/src/browser/shard-io-browser.js +89 -0
- package/src/browser/tensor-source-download.d.ts +27 -0
- package/src/browser/tensor-source-download.js +245 -0
- package/src/browser/tensor-source-file.d.ts +26 -0
- package/src/browser/tensor-source-file.js +53 -0
- package/src/browser/tensor-source-http.d.ts +29 -0
- package/src/browser/tensor-source-http.js +130 -0
- package/src/cli/config/doppler-cli-policy.json +28 -0
- package/src/cli/doppler-cli.d.ts +28 -0
- package/src/cli/doppler-cli.js +1664 -0
- package/src/client/doppler-api.browser.d.ts +1 -0
- package/src/client/doppler-api.browser.js +389 -0
- package/src/client/doppler-api.d.ts +83 -0
- package/src/client/doppler-api.js +389 -0
- package/src/client/doppler-provider/generation.d.ts +25 -0
- package/src/client/doppler-provider/generation.js +126 -0
- package/src/client/doppler-provider/index.d.ts +2 -0
- package/src/client/doppler-provider/index.js +3 -0
- package/src/client/doppler-provider/model-manager.d.ts +71 -0
- package/src/client/doppler-provider/model-manager.js +739 -0
- package/src/client/doppler-provider/provider.d.ts +5 -0
- package/src/client/doppler-provider/provider.js +102 -0
- package/src/client/doppler-provider/source-runtime.d.ts +23 -0
- package/src/client/doppler-provider/source-runtime.js +677 -0
- package/src/client/doppler-provider/types.d.ts +127 -0
- package/src/client/doppler-provider/types.js +17 -0
- package/src/client/doppler-provider.d.ts +46 -0
- package/src/client/doppler-provider.js +36 -0
- package/src/client/doppler-registry.d.ts +23 -0
- package/src/client/doppler-registry.js +86 -0
- package/src/client/doppler-registry.json +41 -0
- package/src/config/README.md +57 -0
- package/src/config/backward-registry-loader.d.ts +3 -0
- package/src/config/backward-registry-loader.js +23 -0
- package/src/config/conversion/README.md +147 -0
- package/src/config/conversion/embeddinggemma/google-embeddinggemma-300m-q4k-ehf16-af32.json +285 -0
- package/src/config/conversion/gemma3/gemma-3-1b-it-f16-af32.json +321 -0
- package/src/config/conversion/gemma3/gemma-3-1b-it-q4k-ehf16-af32.json +322 -0
- package/src/config/conversion/gemma3/gemma-3-270m-it-q4k-ehf16-af32.json +322 -0
- package/src/config/conversion/gemma3/translategemma-4b-1b-enes-q4k-ehf16-af32.json +322 -0
- package/src/config/conversion/gemma3/translategemma-4b-it-q4k-ehf16-af32.json +323 -0
- package/src/config/conversion/gemma4/gemma-4-moe-q4k-ehf16-af32.json +158 -0
- package/src/config/conversion/gpt-oss-20b-f16-xmxfp4.json +164 -0
- package/src/config/conversion/janus/janus-pro-1b-text-q4k-ehaf16.json +158 -0
- package/src/config/conversion/lfm2/lfm2.5-1.2b-instruct-q4k-ehf16-af32.json +339 -0
- package/src/config/conversion/qwen3/qwen-3-5-0-8b-q4k-ehaf16.json +385 -0
- package/src/config/conversion/qwen3/qwen-3-5-2b-q4k-ehaf16.json +385 -0
- package/src/config/conversion/sana/sana-sprint-0.6b-f16.json +219 -0
- package/src/config/execution-contract-check.d.ts +72 -0
- package/src/config/execution-contract-check.js +290 -0
- package/src/config/index.d.ts +52 -0
- package/src/config/index.js +22 -0
- package/src/config/kernel-path-loader.d.ts +156 -0
- package/src/config/kernel-path-loader.js +396 -0
- package/src/config/kernels/backward-registry.json +99 -0
- package/src/config/kernels/kernel-ref-digests.d.ts +1 -0
- package/src/config/kernels/kernel-ref-digests.js +233 -0
- package/src/config/kernels/kernel-ref.d.ts +17 -0
- package/src/config/kernels/kernel-ref.js +75 -0
- package/src/config/kernels/moe/gpt-oss.paths.json +49 -0
- package/src/config/kernels/moe/mixtral.paths.json +46 -0
- package/src/config/kernels/registry.d.ts +86 -0
- package/src/config/kernels/registry.js +116 -0
- package/src/config/kernels/registry.json +9446 -0
- package/src/config/merge-contract-check.d.ts +16 -0
- package/src/config/merge-contract-check.js +311 -0
- package/src/config/merge-helpers.d.ts +58 -0
- package/src/config/merge-helpers.js +179 -0
- package/src/config/merge.d.ts +153 -0
- package/src/config/merge.js +445 -0
- package/src/config/param-categories.d.ts +17 -0
- package/src/config/param-categories.js +72 -0
- package/src/config/param-validator.d.ts +26 -0
- package/src/config/param-validator.js +274 -0
- package/src/config/platforms/amd-rdna3.json +16 -0
- package/src/config/platforms/apple-m1.json +16 -0
- package/src/config/platforms/apple-m2.json +16 -0
- package/src/config/platforms/apple-m3.json +16 -0
- package/src/config/platforms/generic.json +14 -0
- package/src/config/platforms/loader.d.ts +65 -0
- package/src/config/platforms/loader.js +158 -0
- package/src/config/platforms/nvidia-gb200-8gpu.json +45 -0
- package/src/config/platforms/nvidia-gb200-nvl72.json +45 -0
- package/src/config/platforms/nvidia-gh200-nvl2.json +44 -0
- package/src/config/platforms/nvidia-gh200.json +44 -0
- package/src/config/platforms/nvidia-rtx30.json +16 -0
- package/src/config/platforms/nvidia-rtx40.json +16 -0
- package/src/config/quantization-contract-check.d.ts +12 -0
- package/src/config/quantization-contract-check.js +91 -0
- package/src/config/required-inference-fields-contract-check.d.ts +24 -0
- package/src/config/required-inference-fields-contract-check.js +238 -0
- package/src/config/runtime/compute/f16-activations.json +30 -0
- package/src/config/runtime/compute/f16-batched.json +32 -0
- package/src/config/runtime/default.json +100 -0
- package/src/config/runtime/diagnostics/debug-logits.json +53 -0
- package/src/config/runtime/diagnostics/drift-policies.json +147 -0
- package/src/config/runtime/experiments/bench/gemma3-bench-q4k.json +54 -0
- package/src/config/runtime/experiments/debug/gemma3-debug-q4k.json +210 -0
- package/src/config/runtime/experiments/verify/gemma3-verify.json +39 -0
- package/src/config/runtime/experiments/verify/lfm2-verify.json +46 -0
- package/src/config/runtime/experiments/verify/translategemma-verify.json +39 -0
- package/src/config/runtime/kernels/dequant-f16-q4k.json +13 -0
- package/src/config/runtime/kernels/dequant-f32-q4k.json +13 -0
- package/src/config/runtime/kernels/embeddinggemma-q4k-dequant-f32a.json +37 -0
- package/src/config/runtime/kernels/fused-q4k.json +13 -0
- package/src/config/runtime/kernels/gemma2-q4k-dequant-f16a.json +33 -0
- package/src/config/runtime/kernels/gemma2-q4k-dequant-f32a-nosubgroups.json +33 -0
- package/src/config/runtime/kernels/gemma2-q4k-fused-f32a.json +33 -0
- package/src/config/runtime/kernels/safe-q4k.json +13 -0
- package/src/config/runtime/model/gemma2-debug.json +77 -0
- package/src/config/runtime/model/gemma2-pipeline-debug.json +66 -0
- package/src/config/runtime/model/gemma2-pipeline.json +75 -0
- package/src/config/runtime/model/gemma3-layer-probe.json +85 -0
- package/src/config/runtime/model/qwen3-5-layer-probe.json +52 -0
- package/src/config/runtime/model/qwen3-5-layer3-boundary-probe.json +108 -0
- package/src/config/runtime/model/qwen3-5-linear-attn-debug.json +90 -0
- package/src/config/runtime/overlays/debug-f32a.json +3 -0
- package/src/config/runtime/overlays/trace-config.json +28 -0
- package/src/config/runtime/platform/metal-apple-q4k.json +11 -0
- package/src/config/runtime/profiles/default.json +10 -0
- package/src/config/runtime/profiles/low-memory.json +40 -0
- package/src/config/runtime/profiles/production.json +48 -0
- package/src/config/runtime/profiles/simulation.json +31 -0
- package/src/config/runtime/profiles/throughput.json +37 -0
- package/src/config/runtime/profiles/trace-layers.json +127 -0
- package/src/config/runtime/profiles/vector-stability.json +54 -0
- package/src/config/runtime/profiles/vector-throughput.json +28 -0
- package/src/config/runtime/profiles/verbose-trace.json +39 -0
- package/src/config/runtime/tiers/gemma4-16gb.json +69 -0
- package/src/config/runtime/tiers/gemma4-24gb.json +66 -0
- package/src/config/runtime/tiers/gemma4-32gb.json +66 -0
- package/src/config/runtime-merge.d.ts +5 -0
- package/src/config/runtime-merge.js +30 -0
- package/src/config/runtime.d.ts +28 -0
- package/src/config/runtime.js +69 -0
- package/src/config/schema/adapter.schema.d.ts +53 -0
- package/src/config/schema/adapter.schema.js +60 -0
- package/src/config/schema/backward-registry.schema.d.ts +14 -0
- package/src/config/schema/backward-registry.schema.js +46 -0
- package/src/config/schema/benchmark.schema.d.ts +54 -0
- package/src/config/schema/benchmark.schema.js +74 -0
- package/src/config/schema/bridge.schema.d.ts +25 -0
- package/src/config/schema/bridge.schema.js +22 -0
- package/src/config/schema/browser-suite-metrics.schema.d.ts +16 -0
- package/src/config/schema/browser-suite-metrics.schema.js +44 -0
- package/src/config/schema/buffer-pool.schema.d.ts +92 -0
- package/src/config/schema/buffer-pool.schema.js +50 -0
- package/src/config/schema/conversion-report.schema.d.ts +36 -0
- package/src/config/schema/conversion-report.schema.js +97 -0
- package/src/config/schema/conversion.schema.d.ts +191 -0
- package/src/config/schema/conversion.schema.js +13 -0
- package/src/config/schema/converter.schema.d.ts +117 -0
- package/src/config/schema/converter.schema.js +140 -0
- package/src/config/schema/debug.schema.d.ts +292 -0
- package/src/config/schema/debug.schema.js +134 -0
- package/src/config/schema/diffusion.schema.d.ts +88 -0
- package/src/config/schema/diffusion.schema.js +62 -0
- package/src/config/schema/distill-training.schema.d.ts +48 -0
- package/src/config/schema/distill-training.schema.js +139 -0
- package/src/config/schema/distribution.schema.d.ts +155 -0
- package/src/config/schema/distribution.schema.js +81 -0
- package/src/config/schema/doppler.schema.d.ts +74 -0
- package/src/config/schema/doppler.schema.js +341 -0
- package/src/config/schema/ecosystem.schema.d.ts +255 -0
- package/src/config/schema/ecosystem.schema.js +534 -0
- package/src/config/schema/emulation.schema.d.ts +351 -0
- package/src/config/schema/emulation.schema.js +301 -0
- package/src/config/schema/energy.schema.d.ts +102 -0
- package/src/config/schema/energy.schema.js +72 -0
- package/src/config/schema/execution-v1.schema.d.ts +258 -0
- package/src/config/schema/execution-v1.schema.js +211 -0
- package/src/config/schema/gpu-cache.schema.d.ts +26 -0
- package/src/config/schema/gpu-cache.schema.js +8 -0
- package/src/config/schema/harness.schema.d.ts +34 -0
- package/src/config/schema/harness.schema.js +21 -0
- package/src/config/schema/hotswap.schema.d.ts +55 -0
- package/src/config/schema/hotswap.schema.js +18 -0
- package/src/config/schema/index.d.ts +869 -0
- package/src/config/schema/index.js +498 -0
- package/src/config/schema/inference-defaults.schema.d.ts +276 -0
- package/src/config/schema/inference-defaults.schema.js +189 -0
- package/src/config/schema/inference.schema.d.ts +298 -0
- package/src/config/schema/inference.schema.js +39 -0
- package/src/config/schema/intent-bundle.schema.d.ts +28 -0
- package/src/config/schema/intent-bundle.schema.js +12 -0
- package/src/config/schema/kernel-path.schema.d.ts +184 -0
- package/src/config/schema/kernel-path.schema.js +9 -0
- package/src/config/schema/kernel-registry.schema.d.ts +199 -0
- package/src/config/schema/kernel-registry.schema.js +46 -0
- package/src/config/schema/kernel-thresholds.schema.d.ts +302 -0
- package/src/config/schema/kernel-thresholds.schema.js +195 -0
- package/src/config/schema/kernel-warmup.schema.d.ts +19 -0
- package/src/config/schema/kernel-warmup.schema.js +5 -0
- package/src/config/schema/kvcache.schema.d.ts +131 -0
- package/src/config/schema/kvcache.schema.js +41 -0
- package/src/config/schema/loading.schema.d.ts +153 -0
- package/src/config/schema/loading.schema.js +84 -0
- package/src/config/schema/lora.schema.d.ts +12 -0
- package/src/config/schema/lora.schema.js +12 -0
- package/src/config/schema/manifest.schema.d.ts +520 -0
- package/src/config/schema/manifest.schema.js +145 -0
- package/src/config/schema/memory-limits.schema.d.ts +107 -0
- package/src/config/schema/memory-limits.schema.js +57 -0
- package/src/config/schema/moe.schema.d.ts +78 -0
- package/src/config/schema/moe.schema.js +40 -0
- package/src/config/schema/platform.schema.d.ts +121 -0
- package/src/config/schema/platform.schema.js +1 -0
- package/src/config/schema/quantization-defaults.schema.d.ts +34 -0
- package/src/config/schema/quantization-defaults.schema.js +5 -0
- package/src/config/schema/quantization.schema.d.ts +10 -0
- package/src/config/schema/quantization.schema.js +33 -0
- package/src/config/schema/shared-runtime.schema.d.ts +75 -0
- package/src/config/schema/shared-runtime.schema.js +45 -0
- package/src/config/schema/speculation-self.schema.js +54 -0
- package/src/config/schema/speculative.schema.d.ts +21 -0
- package/src/config/schema/speculative.schema.js +11 -0
- package/src/config/schema/storage.schema.d.ts +123 -0
- package/src/config/schema/storage.schema.js +66 -0
- package/src/config/schema/tooling.schema.d.ts +29 -0
- package/src/config/schema/tooling.schema.js +12 -0
- package/src/config/schema/training-metrics.schema.d.ts +89 -0
- package/src/config/schema/training-metrics.schema.js +374 -0
- package/src/config/schema/training.schema.d.ts +88 -0
- package/src/config/schema/training.schema.js +106 -0
- package/src/config/schema/tuner.schema.d.ts +39 -0
- package/src/config/schema/tuner.schema.js +13 -0
- package/src/config/schema/ul-training.schema.d.ts +61 -0
- package/src/config/schema/ul-training.schema.js +140 -0
- package/src/config/schema/units.schema.d.ts +27 -0
- package/src/config/schema/units.schema.js +30 -0
- package/src/config/training-defaults.d.ts +24 -0
- package/src/config/training-defaults.js +99 -0
- package/src/config/transforms/capability-transform-resolver.d.ts +34 -0
- package/src/config/transforms/capability-transform-resolver.js +62 -0
- package/src/config/transforms/execution-graph-transforms.d.ts +92 -0
- package/src/config/transforms/execution-graph-transforms.js +512 -0
- package/src/converter/conversion-plan.d.ts +54 -0
- package/src/converter/conversion-plan.js +268 -0
- package/src/converter/core.d.ts +263 -0
- package/src/converter/core.js +1530 -0
- package/src/converter/index.d.ts +98 -0
- package/src/converter/index.js +59 -0
- package/src/converter/parsers/diffusion.d.ts +50 -0
- package/src/converter/parsers/diffusion.js +327 -0
- package/src/converter/parsers/gguf.d.ts +22 -0
- package/src/converter/parsers/gguf.js +46 -0
- package/src/converter/parsers/index.d.ts +21 -0
- package/src/converter/parsers/index.js +12 -0
- package/src/converter/parsers/transformer.d.ts +31 -0
- package/src/converter/parsers/transformer.js +198 -0
- package/src/converter/quantization-info.d.ts +37 -0
- package/src/converter/quantization-info.js +422 -0
- package/src/converter/quantizer.d.ts +101 -0
- package/src/converter/quantizer.js +444 -0
- package/src/converter/rope-config.d.ts +15 -0
- package/src/converter/rope-config.js +262 -0
- package/src/converter/shard-packer.d.ts +138 -0
- package/src/converter/shard-packer.js +425 -0
- package/src/converter/tokenizer-utils.d.ts +12 -0
- package/src/converter/tokenizer-utils.js +104 -0
- package/src/debug/capture-policy.d.ts +88 -0
- package/src/debug/capture-policy.js +196 -0
- package/src/debug/config.d.ts +78 -0
- package/src/debug/config.js +347 -0
- package/src/debug/history.d.ts +65 -0
- package/src/debug/history.js +82 -0
- package/src/debug/index.d.ts +268 -0
- package/src/debug/index.js +215 -0
- package/src/debug/log.d.ts +46 -0
- package/src/debug/log.js +132 -0
- package/src/debug/perf.d.ts +33 -0
- package/src/debug/perf.js +51 -0
- package/src/debug/reference/README.md +114 -0
- package/src/debug/reference/hf_attn_debug.py +114 -0
- package/src/debug/reference/hf_embed_check.py +89 -0
- package/src/debug/reference/hf_layer_out.py +100 -0
- package/src/debug/reference/hf_qwen35_linear_attn_debug.py +268 -0
- package/src/debug/reference/hf_rope_check.py +116 -0
- package/src/debug/reference/hf_weights.py +75 -0
- package/src/debug/signals.d.ts +63 -0
- package/src/debug/signals.js +39 -0
- package/src/debug/stats.d.ts +47 -0
- package/src/debug/stats.js +160 -0
- package/src/debug/tensor.d.ts +125 -0
- package/src/debug/tensor.js +268 -0
- package/src/debug/trace.d.ts +17 -0
- package/src/debug/trace.js +188 -0
- package/src/diffusion/config/expansion-lanes.json +29 -0
- package/src/diffusion/image-regression.d.ts +31 -0
- package/src/diffusion/image-regression.js +107 -0
- package/src/diffusion/index.d.ts +8 -0
- package/src/diffusion/index.js +8 -0
- package/src/distribution/p2p-control-plane.d.ts +52 -0
- package/src/distribution/p2p-control-plane.js +272 -0
- package/src/distribution/p2p-observability.d.ts +116 -0
- package/src/distribution/p2p-observability.js +303 -0
- package/src/distribution/p2p-transport-contract.d.ts +57 -0
- package/src/distribution/p2p-transport-contract.js +310 -0
- package/src/distribution/p2p-transport.js +75 -0
- package/src/distribution/p2p-webrtc-browser.d.ts +37 -0
- package/src/distribution/p2p-webrtc-browser.js +454 -0
- package/src/distribution/shard-delivery.d.ts +251 -0
- package/src/distribution/shard-delivery.js +2186 -0
- package/src/energy/index.d.ts +2 -0
- package/src/energy/index.js +2 -0
- package/src/errors/doppler-error.d.ts +20 -0
- package/src/errors/doppler-error.js +37 -0
- package/src/errors/index.d.ts +1 -0
- package/src/errors/index.js +1 -0
- package/src/formats/gguf/index.d.ts +8 -0
- package/src/formats/gguf/index.js +4 -0
- package/src/formats/gguf/types.d.ts +137 -0
- package/src/formats/gguf/types.js +460 -0
- package/src/formats/index.d.ts +51 -0
- package/src/formats/index.js +13 -0
- package/src/formats/rdrr/classification.d.ts +54 -0
- package/src/formats/rdrr/classification.js +329 -0
- package/src/formats/rdrr/groups.d.ts +35 -0
- package/src/formats/rdrr/groups.js +73 -0
- package/src/formats/rdrr/index.d.ts +25 -0
- package/src/formats/rdrr/index.js +19 -0
- package/src/formats/rdrr/manifest.d.ts +32 -0
- package/src/formats/rdrr/manifest.js +108 -0
- package/src/formats/rdrr/parsing.d.ts +27 -0
- package/src/formats/rdrr/parsing.js +167 -0
- package/src/formats/rdrr/tensor-config-validator.d.ts +42 -0
- package/src/formats/rdrr/tensor-config-validator.js +156 -0
- package/src/formats/rdrr/types.d.ts +201 -0
- package/src/formats/rdrr/types.js +16 -0
- package/src/formats/rdrr/validation.d.ts +9 -0
- package/src/formats/rdrr/validation.js +213 -0
- package/src/formats/safetensors/index.d.ts +8 -0
- package/src/formats/safetensors/index.js +4 -0
- package/src/formats/safetensors/types.d.ts +67 -0
- package/src/formats/safetensors/types.js +102 -0
- package/src/formats/tokenizer/index.d.ts +5 -0
- package/src/formats/tokenizer/index.js +3 -0
- package/src/formats/tokenizer/types.d.ts +9 -0
- package/src/formats/tokenizer/types.js +22 -0
- package/src/generation/index.d.ts +18 -0
- package/src/generation/index.js +32 -0
- package/src/gpu/command-recorder.d.ts +175 -0
- package/src/gpu/command-recorder.js +498 -0
- package/src/gpu/device.d.ts +142 -0
- package/src/gpu/device.js +532 -0
- package/src/gpu/kernel-runtime.d.ts +20 -0
- package/src/gpu/kernel-runtime.js +39 -0
- package/src/gpu/kernel-selection-cache.d.ts +13 -0
- package/src/gpu/kernel-selection-cache.js +13 -0
- package/src/gpu/kernel-selection-log.d.ts +12 -0
- package/src/gpu/kernel-selection-log.js +28 -0
- package/src/gpu/kernel-selector.d.ts +11 -0
- package/src/gpu/kernel-selector.js +10 -0
- package/src/gpu/kernel-tuner/benchmarks.d.ts +144 -0
- package/src/gpu/kernel-tuner/benchmarks.js +902 -0
- package/src/gpu/kernel-tuner/cache.d.ts +55 -0
- package/src/gpu/kernel-tuner/cache.js +152 -0
- package/src/gpu/kernel-tuner/index.d.ts +59 -0
- package/src/gpu/kernel-tuner/index.js +38 -0
- package/src/gpu/kernel-tuner/tuner.d.ts +82 -0
- package/src/gpu/kernel-tuner/tuner.js +247 -0
- package/src/gpu/kernel-tuner/types.d.ts +101 -0
- package/src/gpu/kernel-tuner/types.js +4 -0
- package/src/gpu/kernel-tuner.d.ts +33 -0
- package/src/gpu/kernel-tuner.js +12 -0
- package/src/gpu/kernels/README.md +127 -0
- package/src/gpu/kernels/attention.d.ts +236 -0
- package/src/gpu/kernels/attention.js +1437 -0
- package/src/gpu/kernels/attention.wgsl +249 -0
- package/src/gpu/kernels/attention_bdpa_decode_f16.wgsl +246 -0
- package/src/gpu/kernels/attention_decode.wgsl +233 -0
- package/src/gpu/kernels/attention_decode_chunked_f16.wgsl +183 -0
- package/src/gpu/kernels/attention_decode_chunked_f16kv.wgsl +208 -0
- package/src/gpu/kernels/attention_decode_f16.wgsl +202 -0
- package/src/gpu/kernels/attention_decode_f16kv.wgsl +224 -0
- package/src/gpu/kernels/attention_decode_online_f16.wgsl +223 -0
- package/src/gpu/kernels/attention_decode_online_f16kv.wgsl +225 -0
- package/src/gpu/kernels/attention_decode_optimized.wgsl +445 -0
- package/src/gpu/kernels/attention_decode_paged_f16.wgsl +172 -0
- package/src/gpu/kernels/attention_decode_paged_f16kv.wgsl +174 -0
- package/src/gpu/kernels/attention_decode_subgroup.wgsl +233 -0
- package/src/gpu/kernels/attention_decode_tiered_f16.wgsl +218 -0
- package/src/gpu/kernels/attention_decode_tiered_f16kv.wgsl +220 -0
- package/src/gpu/kernels/attention_decode_tiered_int4_f16kv.wgsl +242 -0
- package/src/gpu/kernels/attention_decode_tiered_int8_f16kv.wgsl +242 -0
- package/src/gpu/kernels/attention_f16.wgsl +214 -0
- package/src/gpu/kernels/attention_f16kv.wgsl +242 -0
- package/src/gpu/kernels/attention_small.wgsl +260 -0
- package/src/gpu/kernels/attention_small_f16.wgsl +240 -0
- package/src/gpu/kernels/attention_small_f16kv.wgsl +266 -0
- package/src/gpu/kernels/attention_streaming.wgsl +149 -0
- package/src/gpu/kernels/attention_streaming_f16.wgsl +147 -0
- package/src/gpu/kernels/attention_streaming_f16kv.wgsl +151 -0
- package/src/gpu/kernels/backward/adam.d.ts +28 -0
- package/src/gpu/kernels/backward/adam.js +203 -0
- package/src/gpu/kernels/backward/adam.wgsl +50 -0
- package/src/gpu/kernels/backward/attention_backward.d.ts +22 -0
- package/src/gpu/kernels/backward/attention_backward.js +364 -0
- package/src/gpu/kernels/backward/attention_backward.wgsl +49 -0
- package/src/gpu/kernels/backward/bias_add_backward.d.ts +17 -0
- package/src/gpu/kernels/backward/bias_add_backward.js +24 -0
- package/src/gpu/kernels/backward/bias_add_backward.wgsl +33 -0
- package/src/gpu/kernels/backward/conv2d_backward.d.ts +31 -0
- package/src/gpu/kernels/backward/conv2d_backward.js +148 -0
- package/src/gpu/kernels/backward/conv2d_backward_input.wgsl +83 -0
- package/src/gpu/kernels/backward/conv2d_backward_weight.wgsl +70 -0
- package/src/gpu/kernels/backward/cross_entropy_backward.d.ts +23 -0
- package/src/gpu/kernels/backward/cross_entropy_backward.js +29 -0
- package/src/gpu/kernels/backward/cross_entropy_backward.wgsl +39 -0
- package/src/gpu/kernels/backward/embed_backward.d.ts +29 -0
- package/src/gpu/kernels/backward/embed_backward.js +118 -0
- package/src/gpu/kernels/backward/embed_backward.wgsl +73 -0
- package/src/gpu/kernels/backward/gelu_backward.d.ts +16 -0
- package/src/gpu/kernels/backward/gelu_backward.js +39 -0
- package/src/gpu/kernels/backward/gelu_backward.wgsl +38 -0
- package/src/gpu/kernels/backward/groupnorm_backward.d.ts +24 -0
- package/src/gpu/kernels/backward/groupnorm_backward.js +29 -0
- package/src/gpu/kernels/backward/groupnorm_backward.wgsl +143 -0
- package/src/gpu/kernels/backward/index.d.ts +17 -0
- package/src/gpu/kernels/backward/index.js +23 -0
- package/src/gpu/kernels/backward/layernorm_backward.d.ts +22 -0
- package/src/gpu/kernels/backward/layernorm_backward.js +135 -0
- package/src/gpu/kernels/backward/layernorm_backward.wgsl +194 -0
- package/src/gpu/kernels/backward/matmul_backward.d.ts +32 -0
- package/src/gpu/kernels/backward/matmul_backward.js +124 -0
- package/src/gpu/kernels/backward/matmul_backward.wgsl +90 -0
- package/src/gpu/kernels/backward/matmul_transpose_a.wgsl +84 -0
- package/src/gpu/kernels/backward/pixel_shuffle_backward.d.ts +22 -0
- package/src/gpu/kernels/backward/pixel_shuffle_backward.js +30 -0
- package/src/gpu/kernels/backward/pixel_shuffle_backward.wgsl +54 -0
- package/src/gpu/kernels/backward/rmsnorm_backward.d.ts +24 -0
- package/src/gpu/kernels/backward/rmsnorm_backward.js +101 -0
- package/src/gpu/kernels/backward/rmsnorm_backward.wgsl +78 -0
- package/src/gpu/kernels/backward/rope_backward.d.ts +25 -0
- package/src/gpu/kernels/backward/rope_backward.js +109 -0
- package/src/gpu/kernels/backward/rope_backward.wgsl +59 -0
- package/src/gpu/kernels/backward/scale_backward.d.ts +16 -0
- package/src/gpu/kernels/backward/scale_backward.js +84 -0
- package/src/gpu/kernels/backward/scale_backward.wgsl +27 -0
- package/src/gpu/kernels/backward/silu_backward.d.ts +16 -0
- package/src/gpu/kernels/backward/silu_backward.js +39 -0
- package/src/gpu/kernels/backward/silu_backward.wgsl +31 -0
- package/src/gpu/kernels/backward/softmax_backward.d.ts +16 -0
- package/src/gpu/kernels/backward/softmax_backward.js +43 -0
- package/src/gpu/kernels/backward/softmax_backward.wgsl +44 -0
- package/src/gpu/kernels/backward/upsample2d_backward.d.ts +21 -0
- package/src/gpu/kernels/backward/upsample2d_backward.js +30 -0
- package/src/gpu/kernels/backward/upsample2d_backward.wgsl +59 -0
- package/src/gpu/kernels/backward/utils.d.ts +45 -0
- package/src/gpu/kernels/backward/utils.js +371 -0
- package/src/gpu/kernels/bf16_to_f16.wgsl +54 -0
- package/src/gpu/kernels/bf16_to_f32.wgsl +70 -0
- package/src/gpu/kernels/bias_add.wgsl +42 -0
- package/src/gpu/kernels/bias_add_f16.wgsl +47 -0
- package/src/gpu/kernels/cast.d.ts +67 -0
- package/src/gpu/kernels/cast.js +339 -0
- package/src/gpu/kernels/cast_f16_to_f32.wgsl +31 -0
- package/src/gpu/kernels/cast_f32_to_f16.wgsl +36 -0
- package/src/gpu/kernels/check-finiteness.d.ts +15 -0
- package/src/gpu/kernels/check-finiteness.js +149 -0
- package/src/gpu/kernels/check-stop.d.ts +31 -0
- package/src/gpu/kernels/check-stop.js +170 -0
- package/src/gpu/kernels/clamp.d.ts +22 -0
- package/src/gpu/kernels/clamp.js +42 -0
- package/src/gpu/kernels/clamp.wgsl +24 -0
- package/src/gpu/kernels/codegen/patches/attention_decode_f16.from.attention_decode.diff +213 -0
- package/src/gpu/kernels/codegen/patches/attention_decode_f16kv.from.attention_decode.diff +89 -0
- package/src/gpu/kernels/codegen/patches/attention_f16.from.attention.diff +258 -0
- package/src/gpu/kernels/codegen/patches/attention_f16kv.from.attention.diff +114 -0
- package/src/gpu/kernels/codegen/patches/attention_small_f16.from.attention_small.diff +193 -0
- package/src/gpu/kernels/codegen/patches/attention_small_f16kv.from.attention_small.diff +264 -0
- package/src/gpu/kernels/codegen/patches/attention_streaming_f16.from.attention_streaming.diff +109 -0
- package/src/gpu/kernels/codegen/patches/attention_streaming_f16kv.from.attention_streaming.diff +53 -0
- package/src/gpu/kernels/codegen/patches/bias_add_f16.from.bias_add.diff +54 -0
- package/src/gpu/kernels/codegen/patches/dequant_mxfp4_expert_f16.from.dequant_mxfp4_expert.diff +125 -0
- package/src/gpu/kernels/codegen/patches/fused_ffn_f16.from.fused_ffn.diff +428 -0
- package/src/gpu/kernels/codegen/patches/fused_matmul_q4_batched_f16.from.fused_matmul_q4_batched.diff +114 -0
- package/src/gpu/kernels/codegen/patches/fused_matmul_rmsnorm_f16.from.fused_matmul_rmsnorm.diff +477 -0
- package/src/gpu/kernels/codegen/patches/fused_swiglu_f16.from.fused_swiglu.diff +60 -0
- package/src/gpu/kernels/codegen/patches/gelu_f16.from.gelu.diff +58 -0
- package/src/gpu/kernels/codegen/patches/layernorm_f16.from.layernorm.diff +82 -0
- package/src/gpu/kernels/codegen/patches/matmul_gemv_residual_f16.from.matmul_gemv_residual.diff +87 -0
- package/src/gpu/kernels/codegen/patches/moe_gather_f16.from.moe_gather.diff +181 -0
- package/src/gpu/kernels/codegen/patches/residual_f16.from.residual.diff +62 -0
- package/src/gpu/kernels/codegen/patches/rmsnorm_f16.from.rmsnorm.diff +430 -0
- package/src/gpu/kernels/codegen/patches/rope_f16.from.rope.diff +462 -0
- package/src/gpu/kernels/codegen/patches/sample_f16.from.sample.diff +307 -0
- package/src/gpu/kernels/codegen/patches/scatter_add_dynamic_f16.from.scatter_add_dynamic.diff +65 -0
- package/src/gpu/kernels/codegen/patches/silu_f16.from.silu.diff +81 -0
- package/src/gpu/kernels/codegen/patches/topk_f16.from.topk.diff +231 -0
- package/src/gpu/kernels/codegen/wgsl-patch-variants.js +152 -0
- package/src/gpu/kernels/codegen/wgsl-variants.js +733 -0
- package/src/gpu/kernels/constants.d.ts +168 -0
- package/src/gpu/kernels/constants.js +142 -0
- package/src/gpu/kernels/conv2d.d.ts +34 -0
- package/src/gpu/kernels/conv2d.js +91 -0
- package/src/gpu/kernels/conv2d.wgsl +70 -0
- package/src/gpu/kernels/conv2d_f16.wgsl +72 -0
- package/src/gpu/kernels/cross_entropy_loss.d.ts +21 -0
- package/src/gpu/kernels/cross_entropy_loss.js +60 -0
- package/src/gpu/kernels/cross_entropy_loss.wgsl +39 -0
- package/src/gpu/kernels/depthwise_conv2d.d.ts +29 -0
- package/src/gpu/kernels/depthwise_conv2d.js +109 -0
- package/src/gpu/kernels/depthwise_conv2d.wgsl +55 -0
- package/src/gpu/kernels/depthwise_conv2d_f16.wgsl +59 -0
- package/src/gpu/kernels/dequant.d.ts +108 -0
- package/src/gpu/kernels/dequant.js +575 -0
- package/src/gpu/kernels/dequant_f16_out.wgsl +153 -0
- package/src/gpu/kernels/dequant_f16_out_vec4.wgsl +152 -0
- package/src/gpu/kernels/dequant_f16_rowwise.wgsl +139 -0
- package/src/gpu/kernels/dequant_f32_rowwise.wgsl +133 -0
- package/src/gpu/kernels/dequant_mxfp4.wgsl +120 -0
- package/src/gpu/kernels/dequant_mxfp4_expert.wgsl +129 -0
- package/src/gpu/kernels/dequant_mxfp4_expert_f16.wgsl +105 -0
- package/src/gpu/kernels/dequant_mxfp4_vec4.wgsl +116 -0
- package/src/gpu/kernels/dequant_q6k.wgsl +140 -0
- package/src/gpu/kernels/dequant_q8_0.wgsl +98 -0
- package/src/gpu/kernels/dequant_shared.wgsl +200 -0
- package/src/gpu/kernels/dequant_shared_vec4.wgsl +160 -0
- package/src/gpu/kernels/dequant_subgroup.wgsl +206 -0
- package/src/gpu/kernels/dispatch.d.ts +157 -0
- package/src/gpu/kernels/dispatch.js +235 -0
- package/src/gpu/kernels/energy.d.ts +113 -0
- package/src/gpu/kernels/energy.js +448 -0
- package/src/gpu/kernels/energy_eval.wgsl +26 -0
- package/src/gpu/kernels/energy_eval_f16.wgsl +30 -0
- package/src/gpu/kernels/energy_quintel_grad.wgsl +92 -0
- package/src/gpu/kernels/energy_quintel_grad_f16.wgsl +96 -0
- package/src/gpu/kernels/energy_quintel_reduce.wgsl +112 -0
- package/src/gpu/kernels/energy_quintel_reduce_f16.wgsl +116 -0
- package/src/gpu/kernels/energy_quintel_update.wgsl +92 -0
- package/src/gpu/kernels/energy_quintel_update_f16.wgsl +96 -0
- package/src/gpu/kernels/energy_update.wgsl +25 -0
- package/src/gpu/kernels/energy_update_f16.wgsl +30 -0
- package/src/gpu/kernels/feature-check.d.ts +42 -0
- package/src/gpu/kernels/feature-check.js +70 -0
- package/src/gpu/kernels/fused_ffn.d.ts +65 -0
- package/src/gpu/kernels/fused_ffn.js +326 -0
- package/src/gpu/kernels/fused_ffn.wgsl +420 -0
- package/src/gpu/kernels/fused_ffn_f16.wgsl +213 -0
- package/src/gpu/kernels/fused_ffn_q4k.wgsl +375 -0
- package/src/gpu/kernels/fused_matmul_q4.wgsl +404 -0
- package/src/gpu/kernels/fused_matmul_q4_batched.wgsl +194 -0
- package/src/gpu/kernels/fused_matmul_q4_batched_f16.wgsl +170 -0
- package/src/gpu/kernels/fused_matmul_q4_batched_f16a.wgsl +154 -0
- package/src/gpu/kernels/fused_matmul_q4_f16a.wgsl +219 -0
- package/src/gpu/kernels/fused_matmul_q4_multicol_f16.wgsl +216 -0
- package/src/gpu/kernels/fused_matmul_q4_multicol_f16a.wgsl +204 -0
- package/src/gpu/kernels/fused_matmul_residual.d.ts +46 -0
- package/src/gpu/kernels/fused_matmul_residual.js +175 -0
- package/src/gpu/kernels/fused_matmul_rmsnorm.d.ts +64 -0
- package/src/gpu/kernels/fused_matmul_rmsnorm.js +290 -0
- package/src/gpu/kernels/fused_matmul_rmsnorm.wgsl +324 -0
- package/src/gpu/kernels/fused_matmul_rmsnorm_f16.wgsl +303 -0
- package/src/gpu/kernels/fused_swiglu.wgsl +63 -0
- package/src/gpu/kernels/fused_swiglu_f16.wgsl +57 -0
- package/src/gpu/kernels/gated-short-conv.d.ts +63 -0
- package/src/gpu/kernels/gated-short-conv.js +284 -0
- package/src/gpu/kernels/gather.d.ts +64 -0
- package/src/gpu/kernels/gather.js +137 -0
- package/src/gpu/kernels/gather.wgsl +61 -0
- package/src/gpu/kernels/gather_f16.wgsl +65 -0
- package/src/gpu/kernels/gather_f16_f16_out.wgsl +55 -0
- package/src/gpu/kernels/gather_f16_out.wgsl +55 -0
- package/src/gpu/kernels/gather_f16_vec4.wgsl +76 -0
- package/src/gpu/kernels/gather_f16_vec4_f16_out.wgsl +68 -0
- package/src/gpu/kernels/gather_vec4.wgsl +74 -0
- package/src/gpu/kernels/gather_vec4_f16_out.wgsl +68 -0
- package/src/gpu/kernels/gelu.d.ts +33 -0
- package/src/gpu/kernels/gelu.js +55 -0
- package/src/gpu/kernels/gelu.wgsl +64 -0
- package/src/gpu/kernels/gelu_f16.wgsl +66 -0
- package/src/gpu/kernels/gptoss_mxfp4_expert_fused.wgsl +127 -0
- package/src/gpu/kernels/gptoss_router_topk.wgsl +119 -0
- package/src/gpu/kernels/grouped_pointwise_conv2d.d.ts +27 -0
- package/src/gpu/kernels/grouped_pointwise_conv2d.js +103 -0
- package/src/gpu/kernels/grouped_pointwise_conv2d.wgsl +44 -0
- package/src/gpu/kernels/grouped_pointwise_conv2d_f16.wgsl +48 -0
- package/src/gpu/kernels/groupnorm.d.ts +31 -0
- package/src/gpu/kernels/groupnorm.js +102 -0
- package/src/gpu/kernels/groupnorm_apply.wgsl +41 -0
- package/src/gpu/kernels/groupnorm_apply_f16.wgsl +46 -0
- package/src/gpu/kernels/groupnorm_stats.wgsl +76 -0
- package/src/gpu/kernels/groupnorm_stats_f16.wgsl +79 -0
- package/src/gpu/kernels/index.d.ts +374 -0
- package/src/gpu/kernels/index.js +315 -0
- package/src/gpu/kernels/kernel-base.d.ts +33 -0
- package/src/gpu/kernels/kernel-base.js +46 -0
- package/src/gpu/kernels/kernel-configs.d.ts +65 -0
- package/src/gpu/kernels/kernel-configs.js +60 -0
- package/src/gpu/kernels/kernel-tuning.d.ts +42 -0
- package/src/gpu/kernels/kernel-tuning.js +158 -0
- package/src/gpu/kernels/kv-quantize.d.ts +37 -0
- package/src/gpu/kernels/kv-quantize.js +141 -0
- package/src/gpu/kernels/kv_quantize_int4.wgsl +119 -0
- package/src/gpu/kernels/kv_quantize_int8.wgsl +119 -0
- package/src/gpu/kernels/layernorm.d.ts +37 -0
- package/src/gpu/kernels/layernorm.js +96 -0
- package/src/gpu/kernels/layernorm.wgsl +121 -0
- package/src/gpu/kernels/layernorm_f16.wgsl +103 -0
- package/src/gpu/kernels/linear-attention-core.d.ts +39 -0
- package/src/gpu/kernels/linear-attention-core.js +559 -0
- package/src/gpu/kernels/logit-merge.d.ts +110 -0
- package/src/gpu/kernels/logit-merge.js +394 -0
- package/src/gpu/kernels/matmul-dispatch.d.ts +38 -0
- package/src/gpu/kernels/matmul-dispatch.js +156 -0
- package/src/gpu/kernels/matmul-selection.d.ts +87 -0
- package/src/gpu/kernels/matmul-selection.js +518 -0
- package/src/gpu/kernels/matmul.d.ts +114 -0
- package/src/gpu/kernels/matmul.js +384 -0
- package/src/gpu/kernels/matmul_f16.wgsl +170 -0
- package/src/gpu/kernels/matmul_f16_tiled.wgsl +165 -0
- package/src/gpu/kernels/matmul_f16w_f32a.wgsl +89 -0
- package/src/gpu/kernels/matmul_f16w_f32a_tiled.wgsl +154 -0
- package/src/gpu/kernels/matmul_f32.wgsl +100 -0
- package/src/gpu/kernels/matmul_gemv.wgsl +80 -0
- package/src/gpu/kernels/matmul_gemv_f16a.wgsl +81 -0
- package/src/gpu/kernels/matmul_gemv_residual.wgsl +119 -0
- package/src/gpu/kernels/matmul_gemv_residual_f16.wgsl +78 -0
- package/src/gpu/kernels/matmul_gemv_subgroup.wgsl +429 -0
- package/src/gpu/kernels/matmul_gemv_subgroup_f16a.wgsl +674 -0
- package/src/gpu/kernels/modulate.d.ts +29 -0
- package/src/gpu/kernels/modulate.js +57 -0
- package/src/gpu/kernels/modulate.wgsl +40 -0
- package/src/gpu/kernels/modulate_f16.wgsl +43 -0
- package/src/gpu/kernels/moe.d.ts +164 -0
- package/src/gpu/kernels/moe.js +542 -0
- package/src/gpu/kernels/moe_gather.wgsl +170 -0
- package/src/gpu/kernels/moe_gather_f16.wgsl +82 -0
- package/src/gpu/kernels/moe_gather_vec4.wgsl +74 -0
- package/src/gpu/kernels/moe_offsets.wgsl +48 -0
- package/src/gpu/kernels/pipeline-cache.d.ts +88 -0
- package/src/gpu/kernels/pipeline-cache.js +305 -0
- package/src/gpu/kernels/pixel_shuffle.d.ts +27 -0
- package/src/gpu/kernels/pixel_shuffle.js +57 -0
- package/src/gpu/kernels/pixel_shuffle.wgsl +43 -0
- package/src/gpu/kernels/pixel_shuffle_f16.wgsl +46 -0
- package/src/gpu/kernels/relu.d.ts +18 -0
- package/src/gpu/kernels/relu.js +66 -0
- package/src/gpu/kernels/relu.wgsl +22 -0
- package/src/gpu/kernels/relu_f16.wgsl +24 -0
- package/src/gpu/kernels/rep-penalty.js +103 -0
- package/src/gpu/kernels/rep_penalty.wgsl +57 -0
- package/src/gpu/kernels/rep_penalty_f16.wgsl +54 -0
- package/src/gpu/kernels/repeat_channels.d.ts +21 -0
- package/src/gpu/kernels/repeat_channels.js +68 -0
- package/src/gpu/kernels/repeat_channels.wgsl +28 -0
- package/src/gpu/kernels/repeat_channels_f16.wgsl +30 -0
- package/src/gpu/kernels/residual.d.ts +74 -0
- package/src/gpu/kernels/residual.js +173 -0
- package/src/gpu/kernels/residual.wgsl +56 -0
- package/src/gpu/kernels/residual_f16.wgsl +36 -0
- package/src/gpu/kernels/residual_f16_vec4.wgsl +48 -0
- package/src/gpu/kernels/residual_vec4.wgsl +47 -0
- package/src/gpu/kernels/rmsnorm.d.ts +53 -0
- package/src/gpu/kernels/rmsnorm.js +256 -0
- package/src/gpu/kernels/rmsnorm.wgsl +449 -0
- package/src/gpu/kernels/rmsnorm_f16.wgsl +198 -0
- package/src/gpu/kernels/rope.d.ts +50 -0
- package/src/gpu/kernels/rope.js +91 -0
- package/src/gpu/kernels/rope.wgsl +344 -0
- package/src/gpu/kernels/rope_f16.wgsl +271 -0
- package/src/gpu/kernels/rule-matcher.d.ts +30 -0
- package/src/gpu/kernels/rule-matcher.js +42 -0
- package/src/gpu/kernels/rule-registry.d.ts +7 -0
- package/src/gpu/kernels/rule-registry.js +54 -0
- package/src/gpu/kernels/sample.d.ts +75 -0
- package/src/gpu/kernels/sample.js +565 -0
- package/src/gpu/kernels/sample.wgsl +407 -0
- package/src/gpu/kernels/sample_f16.wgsl +363 -0
- package/src/gpu/kernels/sana_linear_attention.d.ts +27 -0
- package/src/gpu/kernels/sana_linear_attention.js +129 -0
- package/src/gpu/kernels/sana_linear_attention_apply.wgsl +43 -0
- package/src/gpu/kernels/sana_linear_attention_apply_f16.wgsl +46 -0
- package/src/gpu/kernels/sana_linear_attention_summary.wgsl +51 -0
- package/src/gpu/kernels/sana_linear_attention_summary_f16.wgsl +53 -0
- package/src/gpu/kernels/scale.d.ts +35 -0
- package/src/gpu/kernels/scale.js +44 -0
- package/src/gpu/kernels/scale.wgsl +38 -0
- package/src/gpu/kernels/scatter_add.wgsl +88 -0
- package/src/gpu/kernels/scatter_add_dynamic.wgsl +59 -0
- package/src/gpu/kernels/scatter_add_dynamic_f16.wgsl +52 -0
- package/src/gpu/kernels/scatter_add_dynamic_f16_weights.wgsl +50 -0
- package/src/gpu/kernels/scatter_add_vec4.wgsl +70 -0
- package/src/gpu/kernels/shader-cache.d.ts +56 -0
- package/src/gpu/kernels/shader-cache.js +234 -0
- package/src/gpu/kernels/silu.d.ts +76 -0
- package/src/gpu/kernels/silu.js +406 -0
- package/src/gpu/kernels/silu.wgsl +109 -0
- package/src/gpu/kernels/silu_f16.wgsl +108 -0
- package/src/gpu/kernels/softmax.d.ts +57 -0
- package/src/gpu/kernels/softmax.js +125 -0
- package/src/gpu/kernels/softmax.wgsl +388 -0
- package/src/gpu/kernels/softmax_subgroup.wgsl +175 -0
- package/src/gpu/kernels/split_qg.d.ts +50 -0
- package/src/gpu/kernels/split_qg.js +46 -0
- package/src/gpu/kernels/split_qg.wgsl +58 -0
- package/src/gpu/kernels/split_qg_f16.wgsl +62 -0
- package/src/gpu/kernels/split_qkv.d.ts +51 -0
- package/src/gpu/kernels/split_qkv.js +51 -0
- package/src/gpu/kernels/split_qkv.wgsl +71 -0
- package/src/gpu/kernels/split_qkv_f16.wgsl +75 -0
- package/src/gpu/kernels/topk.wgsl +243 -0
- package/src/gpu/kernels/topk_f16.wgsl +108 -0
- package/src/gpu/kernels/topk_f16_weights.wgsl +101 -0
- package/src/gpu/kernels/transpose.d.ts +21 -0
- package/src/gpu/kernels/transpose.js +51 -0
- package/src/gpu/kernels/transpose.wgsl +33 -0
- package/src/gpu/kernels/types.d.ts +21 -0
- package/src/gpu/kernels/types.js +4 -0
- package/src/gpu/kernels/uniform-utils.d.ts +48 -0
- package/src/gpu/kernels/uniform-utils.js +94 -0
- package/src/gpu/kernels/upsample2d.d.ts +25 -0
- package/src/gpu/kernels/upsample2d.js +67 -0
- package/src/gpu/kernels/upsample2d.wgsl +34 -0
- package/src/gpu/kernels/upsample2d_f16.wgsl +38 -0
- package/src/gpu/kernels/utils.d.ts +106 -0
- package/src/gpu/kernels/utils.js +257 -0
- package/src/gpu/multi-model-recorder.d.ts +21 -0
- package/src/gpu/multi-model-recorder.js +31 -0
- package/src/gpu/partitioned-buffer-pool.d.ts +28 -0
- package/src/gpu/partitioned-buffer-pool.js +57 -0
- package/src/gpu/perf-guards.d.ts +25 -0
- package/src/gpu/perf-guards.js +133 -0
- package/src/gpu/profiler.d.ts +114 -0
- package/src/gpu/profiler.js +406 -0
- package/src/gpu/readback-utils.d.ts +16 -0
- package/src/gpu/readback-utils.js +41 -0
- package/src/gpu/submit-tracker.d.ts +111 -0
- package/src/gpu/submit-tracker.js +242 -0
- package/src/gpu/tensor.d.ts +69 -0
- package/src/gpu/tensor.js +75 -0
- package/src/gpu/uniform-cache.d.ts +109 -0
- package/src/gpu/uniform-cache.js +263 -0
- package/src/gpu/weight-buffer.d.ts +121 -0
- package/src/gpu/weight-buffer.js +132 -0
- package/src/hotswap/intent-bundle.d.ts +37 -0
- package/src/hotswap/intent-bundle.js +129 -0
- package/src/hotswap/manifest.d.ts +42 -0
- package/src/hotswap/manifest.js +124 -0
- package/src/hotswap/model-swap.js +42 -0
- package/src/hotswap/runtime.d.ts +31 -0
- package/src/hotswap/runtime.js +150 -0
- package/src/index-browser.d.ts +92 -0
- package/src/index-browser.js +68 -0
- package/src/index-internal.d.ts +2 -0
- package/src/index-internal.js +2 -0
- package/src/index.d.ts +103 -0
- package/src/index.js +76 -0
- package/src/inference/README.md +593 -0
- package/src/inference/browser-harness-contract-helpers.d.ts +5 -0
- package/src/inference/browser-harness-contract-helpers.js +26 -0
- package/src/inference/browser-harness-diffusion-energy-suites.d.ts +2 -0
- package/src/inference/browser-harness-diffusion-energy-suites.js +269 -0
- package/src/inference/browser-harness-model-helpers.d.ts +16 -0
- package/src/inference/browser-harness-model-helpers.js +217 -0
- package/src/inference/browser-harness-report-helpers.d.ts +7 -0
- package/src/inference/browser-harness-report-helpers.js +42 -0
- package/src/inference/browser-harness-runtime-helpers.d.ts +61 -0
- package/src/inference/browser-harness-runtime-helpers.js +416 -0
- package/src/inference/browser-harness-suite-helpers.d.ts +28 -0
- package/src/inference/browser-harness-suite-helpers.js +270 -0
- package/src/inference/browser-harness-text-helpers.d.ts +34 -0
- package/src/inference/browser-harness-text-helpers.js +879 -0
- package/src/inference/browser-harness.d.ts +249 -0
- package/src/inference/browser-harness.js +1150 -0
- package/src/inference/decode-buffers.d.ts +108 -0
- package/src/inference/decode-buffers.js +181 -0
- package/src/inference/decode-ring.d.ts +52 -0
- package/src/inference/decode-ring.js +273 -0
- package/src/inference/expert-router.d.ts +27 -0
- package/src/inference/expert-router.js +55 -0
- package/src/inference/fixtures/embedding-semantic-fixtures.json +382 -0
- package/src/inference/functiongemma.d.ts +15 -0
- package/src/inference/functiongemma.js +1 -0
- package/src/inference/kv-cache/base.d.ts +150 -0
- package/src/inference/kv-cache/base.js +1105 -0
- package/src/inference/kv-cache/basis-decomposed-paged.d.ts +50 -0
- package/src/inference/kv-cache/basis-decomposed-paged.js +276 -0
- package/src/inference/kv-cache/index.d.ts +35 -0
- package/src/inference/kv-cache/index.js +20 -0
- package/src/inference/kv-cache/sliding-window.d.ts +72 -0
- package/src/inference/kv-cache/sliding-window.js +243 -0
- package/src/inference/kv-cache/tiered.d.ts +89 -0
- package/src/inference/kv-cache/tiered.js +576 -0
- package/src/inference/kv-cache/types.d.ts +188 -0
- package/src/inference/kv-cache/types.js +80 -0
- package/src/inference/kv-cache.d.ts +36 -0
- package/src/inference/kv-cache.js +18 -0
- package/src/inference/moe-router.d.ts +212 -0
- package/src/inference/moe-router.js +600 -0
- package/src/inference/multi-model-network.d.ts +139 -0
- package/src/inference/multi-model-network.js +771 -0
- package/src/inference/multi-pipeline-pool.d.ts +62 -0
- package/src/inference/multi-pipeline-pool.js +161 -0
- package/src/inference/network-evolution.d.ts +55 -0
- package/src/inference/network-evolution.js +79 -0
- package/src/inference/pipelines/context.d.ts +21 -0
- package/src/inference/pipelines/context.js +184 -0
- package/src/inference/pipelines/diffusion/helpers.d.ts +29 -0
- package/src/inference/pipelines/diffusion/helpers.js +120 -0
- package/src/inference/pipelines/diffusion/index.d.ts +3 -0
- package/src/inference/pipelines/diffusion/index.js +3 -0
- package/src/inference/pipelines/diffusion/init.d.ts +24 -0
- package/src/inference/pipelines/diffusion/init.js +138 -0
- package/src/inference/pipelines/diffusion/pipeline.d.ts +38 -0
- package/src/inference/pipelines/diffusion/pipeline.js +782 -0
- package/src/inference/pipelines/diffusion/sana-transformer.d.ts +53 -0
- package/src/inference/pipelines/diffusion/sana-transformer.js +738 -0
- package/src/inference/pipelines/diffusion/scheduler.d.ts +35 -0
- package/src/inference/pipelines/diffusion/scheduler.js +153 -0
- package/src/inference/pipelines/diffusion/sd3-transformer.d.ts +20 -0
- package/src/inference/pipelines/diffusion/sd3-transformer.js +1194 -0
- package/src/inference/pipelines/diffusion/sd3-weights.d.ts +21 -0
- package/src/inference/pipelines/diffusion/sd3-weights.js +287 -0
- package/src/inference/pipelines/diffusion/text-encoder-gpu.d.ts +87 -0
- package/src/inference/pipelines/diffusion/text-encoder-gpu.js +1224 -0
- package/src/inference/pipelines/diffusion/text-encoder.d.ts +29 -0
- package/src/inference/pipelines/diffusion/text-encoder.js +195 -0
- package/src/inference/pipelines/diffusion/types.d.ts +116 -0
- package/src/inference/pipelines/diffusion/types.js +1 -0
- package/src/inference/pipelines/diffusion/vae.d.ts +20 -0
- package/src/inference/pipelines/diffusion/vae.js +1375 -0
- package/src/inference/pipelines/diffusion/weights.d.ts +40 -0
- package/src/inference/pipelines/diffusion/weights.js +155 -0
- package/src/inference/pipelines/dream/energy-head-pipeline.d.ts +29 -0
- package/src/inference/pipelines/dream/energy-head-pipeline.js +6 -0
- package/src/inference/pipelines/dream/pipeline.d.ts +17 -0
- package/src/inference/pipelines/dream/pipeline.js +8 -0
- package/src/inference/pipelines/energy/index.d.ts +1 -0
- package/src/inference/pipelines/energy/index.js +1 -0
- package/src/inference/pipelines/energy/pipeline.d.ts +27 -0
- package/src/inference/pipelines/energy/pipeline.js +697 -0
- package/src/inference/pipelines/energy/quintel.d.ts +92 -0
- package/src/inference/pipelines/energy/quintel.js +218 -0
- package/src/inference/pipelines/energy/types.d.ts +63 -0
- package/src/inference/pipelines/energy/types.js +1 -0
- package/src/inference/pipelines/energy-head/index.d.ts +6 -0
- package/src/inference/pipelines/energy-head/index.js +6 -0
- package/src/inference/pipelines/energy-head/row-head-pipeline.d.ts +103 -0
- package/src/inference/pipelines/energy-head/row-head-pipeline.js +491 -0
- package/src/inference/pipelines/factory.d.ts +10 -0
- package/src/inference/pipelines/factory.js +6 -0
- package/src/inference/pipelines/index.d.ts +22 -0
- package/src/inference/pipelines/index.js +19 -0
- package/src/inference/pipelines/registry.d.ts +15 -0
- package/src/inference/pipelines/registry.js +23 -0
- package/src/inference/pipelines/rng.d.ts +2 -0
- package/src/inference/pipelines/rng.js +17 -0
- package/src/inference/pipelines/structured/index.d.ts +8 -0
- package/src/inference/pipelines/structured/index.js +8 -0
- package/src/inference/pipelines/structured/json-head-pipeline.d.ts +58 -0
- package/src/inference/pipelines/structured/json-head-pipeline.js +196 -0
- package/src/inference/pipelines/text/attention/attn-config.d.ts +28 -0
- package/src/inference/pipelines/text/attention/attn-config.js +51 -0
- package/src/inference/pipelines/text/attention/dispatch-params.d.ts +148 -0
- package/src/inference/pipelines/text/attention/dispatch-params.js +251 -0
- package/src/inference/pipelines/text/attention/index.d.ts +24 -0
- package/src/inference/pipelines/text/attention/index.js +17 -0
- package/src/inference/pipelines/text/attention/output-projection.d.ts +12 -0
- package/src/inference/pipelines/text/attention/output-projection.js +8 -0
- package/src/inference/pipelines/text/attention/projections.d.ts +114 -0
- package/src/inference/pipelines/text/attention/projections.js +531 -0
- package/src/inference/pipelines/text/attention/record.d.ts +36 -0
- package/src/inference/pipelines/text/attention/record.js +523 -0
- package/src/inference/pipelines/text/attention/run.d.ts +38 -0
- package/src/inference/pipelines/text/attention/run.js +813 -0
- package/src/inference/pipelines/text/attention/types.d.ts +108 -0
- package/src/inference/pipelines/text/attention/types.js +67 -0
- package/src/inference/pipelines/text/attention.d.ts +23 -0
- package/src/inference/pipelines/text/attention.js +12 -0
- package/src/inference/pipelines/text/bdpa-steamroller.d.ts +22 -0
- package/src/inference/pipelines/text/bdpa-steamroller.js +158 -0
- package/src/inference/pipelines/text/buffer-types.d.ts +7 -0
- package/src/inference/pipelines/text/buffer-types.js +4 -0
- package/src/inference/pipelines/text/chat-format.d.ts +46 -0
- package/src/inference/pipelines/text/chat-format.js +365 -0
- package/src/inference/pipelines/text/config.d.ts +253 -0
- package/src/inference/pipelines/text/config.js +857 -0
- package/src/inference/pipelines/text/debug-utils/config.d.ts +144 -0
- package/src/inference/pipelines/text/debug-utils/config.js +156 -0
- package/src/inference/pipelines/text/debug-utils/index.d.ts +53 -0
- package/src/inference/pipelines/text/debug-utils/index.js +44 -0
- package/src/inference/pipelines/text/debug-utils/logging.d.ts +106 -0
- package/src/inference/pipelines/text/debug-utils/logging.js +152 -0
- package/src/inference/pipelines/text/debug-utils/tensor.d.ts +119 -0
- package/src/inference/pipelines/text/debug-utils/tensor.js +268 -0
- package/src/inference/pipelines/text/debug-utils/utils.d.ts +77 -0
- package/src/inference/pipelines/text/debug-utils/utils.js +139 -0
- package/src/inference/pipelines/text/debug-utils.d.ts +42 -0
- package/src/inference/pipelines/text/debug-utils.js +34 -0
- package/src/inference/pipelines/text/drift-policy.d.ts +57 -0
- package/src/inference/pipelines/text/drift-policy.js +133 -0
- package/src/inference/pipelines/text/dtype-contract.d.ts +38 -0
- package/src/inference/pipelines/text/dtype-contract.js +87 -0
- package/src/inference/pipelines/text/embed.d.ts +67 -0
- package/src/inference/pipelines/text/embed.js +490 -0
- package/src/inference/pipelines/text/execution-plan.d.ts +123 -0
- package/src/inference/pipelines/text/execution-plan.js +371 -0
- package/src/inference/pipelines/text/execution-runtime-builders.d.ts +45 -0
- package/src/inference/pipelines/text/execution-runtime-builders.js +382 -0
- package/src/inference/pipelines/text/execution-v1.d.ts +45 -0
- package/src/inference/pipelines/text/execution-v1.js +288 -0
- package/src/inference/pipelines/text/failure-reduction.d.ts +84 -0
- package/src/inference/pipelines/text/failure-reduction.js +180 -0
- package/src/inference/pipelines/text/ffn/dense.d.ts +40 -0
- package/src/inference/pipelines/text/ffn/dense.js +753 -0
- package/src/inference/pipelines/text/ffn/index.d.ts +23 -0
- package/src/inference/pipelines/text/ffn/index.js +16 -0
- package/src/inference/pipelines/text/ffn/moe.d.ts +21 -0
- package/src/inference/pipelines/text/ffn/moe.js +49 -0
- package/src/inference/pipelines/text/ffn/sandwich.d.ts +25 -0
- package/src/inference/pipelines/text/ffn/sandwich.js +196 -0
- package/src/inference/pipelines/text/ffn/standard.d.ts +23 -0
- package/src/inference/pipelines/text/ffn/standard.js +113 -0
- package/src/inference/pipelines/text/ffn/types.d.ts +30 -0
- package/src/inference/pipelines/text/ffn/types.js +25 -0
- package/src/inference/pipelines/text/ffn.d.ts +31 -0
- package/src/inference/pipelines/text/ffn.js +18 -0
- package/src/inference/pipelines/text/finiteness-guard-status.d.ts +11 -0
- package/src/inference/pipelines/text/finiteness-guard-status.js +21 -0
- package/src/inference/pipelines/text/finiteness-policy.d.ts +35 -0
- package/src/inference/pipelines/text/finiteness-policy.js +45 -0
- package/src/inference/pipelines/text/generator-helpers.d.ts +34 -0
- package/src/inference/pipelines/text/generator-helpers.js +178 -0
- package/src/inference/pipelines/text/generator-runtime.d.ts +95 -0
- package/src/inference/pipelines/text/generator-runtime.js +492 -0
- package/src/inference/pipelines/text/generator-steps.d.ts +136 -0
- package/src/inference/pipelines/text/generator-steps.js +1294 -0
- package/src/inference/pipelines/text/generator.d.ts +46 -0
- package/src/inference/pipelines/text/generator.js +1779 -0
- package/src/inference/pipelines/text/index.d.ts +5 -0
- package/src/inference/pipelines/text/index.js +6 -0
- package/src/inference/pipelines/text/init.d.ts +316 -0
- package/src/inference/pipelines/text/init.js +1187 -0
- package/src/inference/pipelines/text/kernel-trace.d.ts +152 -0
- package/src/inference/pipelines/text/kernel-trace.js +330 -0
- package/src/inference/pipelines/text/layer-plan.d.ts +65 -0
- package/src/inference/pipelines/text/layer-plan.js +249 -0
- package/src/inference/pipelines/text/layer.d.ts +56 -0
- package/src/inference/pipelines/text/layer.js +974 -0
- package/src/inference/pipelines/text/linear-attention.d.ts +109 -0
- package/src/inference/pipelines/text/linear-attention.js +948 -0
- package/src/inference/pipelines/text/logits/cpu.d.ts +81 -0
- package/src/inference/pipelines/text/logits/cpu.js +91 -0
- package/src/inference/pipelines/text/logits/gpu.d.ts +113 -0
- package/src/inference/pipelines/text/logits/gpu.js +419 -0
- package/src/inference/pipelines/text/logits/index.d.ts +62 -0
- package/src/inference/pipelines/text/logits/index.js +316 -0
- package/src/inference/pipelines/text/logits/types.d.ts +46 -0
- package/src/inference/pipelines/text/logits/types.js +4 -0
- package/src/inference/pipelines/text/logits/utils.d.ts +56 -0
- package/src/inference/pipelines/text/logits/utils.js +68 -0
- package/src/inference/pipelines/text/logits.d.ts +27 -0
- package/src/inference/pipelines/text/logits.js +16 -0
- package/src/inference/pipelines/text/lora-apply.d.ts +28 -0
- package/src/inference/pipelines/text/lora-apply.js +76 -0
- package/src/inference/pipelines/text/lora-types.d.ts +39 -0
- package/src/inference/pipelines/text/lora-types.js +18 -0
- package/src/inference/pipelines/text/lora.d.ts +18 -0
- package/src/inference/pipelines/text/lora.js +12 -0
- package/src/inference/pipelines/text/model-load.d.ts +58 -0
- package/src/inference/pipelines/text/model-load.js +778 -0
- package/src/inference/pipelines/text/moe-cache.d.ts +32 -0
- package/src/inference/pipelines/text/moe-cache.js +108 -0
- package/src/inference/pipelines/text/moe-cpu-gptoss.d.ts +9 -0
- package/src/inference/pipelines/text/moe-cpu-gptoss.js +115 -0
- package/src/inference/pipelines/text/moe-cpu.d.ts +13 -0
- package/src/inference/pipelines/text/moe-cpu.js +120 -0
- package/src/inference/pipelines/text/moe-gpu.d.ts +13 -0
- package/src/inference/pipelines/text/moe-gpu.js +653 -0
- package/src/inference/pipelines/text/moe-helpers.d.ts +12 -0
- package/src/inference/pipelines/text/moe-helpers.js +21 -0
- package/src/inference/pipelines/text/moe-impl.d.ts +117 -0
- package/src/inference/pipelines/text/moe-impl.js +9 -0
- package/src/inference/pipelines/text/moe-shape-validator.d.ts +40 -0
- package/src/inference/pipelines/text/moe-shape-validator.js +98 -0
- package/src/inference/pipelines/text/operator-events.d.ts +125 -0
- package/src/inference/pipelines/text/operator-events.js +305 -0
- package/src/inference/pipelines/text/operator-identity.d.ts +60 -0
- package/src/inference/pipelines/text/operator-identity.js +133 -0
- package/src/inference/pipelines/text/ops.d.ts +167 -0
- package/src/inference/pipelines/text/ops.js +437 -0
- package/src/inference/pipelines/text/probes.d.ts +31 -0
- package/src/inference/pipelines/text/probes.js +240 -0
- package/src/inference/pipelines/text/sampling-config.d.ts +54 -0
- package/src/inference/pipelines/text/sampling-config.js +71 -0
- package/src/inference/pipelines/text/sampling.d.ts +54 -0
- package/src/inference/pipelines/text/sampling.js +249 -0
- package/src/inference/pipelines/text/stage-names.d.ts +88 -0
- package/src/inference/pipelines/text/stage-names.js +202 -0
- package/src/inference/pipelines/text/state.d.ts +114 -0
- package/src/inference/pipelines/text/state.js +165 -0
- package/src/inference/pipelines/text/types.d.ts +682 -0
- package/src/inference/pipelines/text/types.js +4 -0
- package/src/inference/pipelines/text/weights.d.ts +110 -0
- package/src/inference/pipelines/text/weights.js +173 -0
- package/src/inference/pipelines/text.d.ts +162 -0
- package/src/inference/pipelines/text.js +852 -0
- package/src/inference/pipelines/vision/encoder.js +386 -0
- package/src/inference/pipelines/vision/image-preprocess.js +157 -0
- package/src/inference/pipelines/vision/index.js +173 -0
- package/src/inference/pipelines/vision/ops.js +78 -0
- package/src/inference/pipelines/vision/patch-embed.js +151 -0
- package/src/inference/speculative.d.ts +239 -0
- package/src/inference/speculative.js +402 -0
- package/src/inference/test-harness.d.ts +178 -0
- package/src/inference/test-harness.js +361 -0
- package/src/inference/tokenizer.d.ts +72 -0
- package/src/inference/tokenizer.js +251 -0
- package/src/inference/tokenizers/base.d.ts +39 -0
- package/src/inference/tokenizers/base.js +69 -0
- package/src/inference/tokenizers/bpe.d.ts +27 -0
- package/src/inference/tokenizers/bpe.js +180 -0
- package/src/inference/tokenizers/bundled.d.ts +63 -0
- package/src/inference/tokenizers/bundled.js +1009 -0
- package/src/inference/tokenizers/sentencepiece.d.ts +28 -0
- package/src/inference/tokenizers/sentencepiece.js +401 -0
- package/src/inference/tokenizers/types.d.ts +166 -0
- package/src/inference/tokenizers/types.js +7 -0
- package/src/loader/doppler-loader.d.ts +139 -0
- package/src/loader/doppler-loader.js +1103 -0
- package/src/loader/dtype-utils.d.ts +40 -0
- package/src/loader/dtype-utils.js +61 -0
- package/src/loader/embedding-loader.d.ts +56 -0
- package/src/loader/embedding-loader.js +211 -0
- package/src/loader/experts/expert-cache.d.ts +156 -0
- package/src/loader/experts/expert-cache.js +386 -0
- package/src/loader/experts/expert-loader.d.ts +108 -0
- package/src/loader/experts/expert-loader.js +392 -0
- package/src/loader/final-weights-loader.d.ts +88 -0
- package/src/loader/final-weights-loader.js +339 -0
- package/src/loader/index.d.ts +150 -0
- package/src/loader/index.js +124 -0
- package/src/loader/layer-loader.d.ts +63 -0
- package/src/loader/layer-loader.js +474 -0
- package/src/loader/loader-state.d.ts +51 -0
- package/src/loader/loader-state.js +142 -0
- package/src/loader/loader-types.d.ts +236 -0
- package/src/loader/loader-types.js +4 -0
- package/src/loader/manifest-config.d.ts +97 -0
- package/src/loader/manifest-config.js +134 -0
- package/src/loader/memory-monitor.d.ts +112 -0
- package/src/loader/memory-monitor.js +284 -0
- package/src/loader/multi-model-loader.d.ts +51 -0
- package/src/loader/multi-model-loader.js +133 -0
- package/src/loader/quantization-constants.d.ts +23 -0
- package/src/loader/quantization-constants.js +14 -0
- package/src/loader/shard-cache.d.ts +60 -0
- package/src/loader/shard-cache.js +663 -0
- package/src/loader/shard-resolver.d.ts +12 -0
- package/src/loader/shard-resolver.js +144 -0
- package/src/loader/tensors/tensor-loader.d.ts +157 -0
- package/src/loader/tensors/tensor-loader.js +652 -0
- package/src/loader/tensors/tensor-reader.d.ts +22 -0
- package/src/loader/tensors/tensor-reader.js +113 -0
- package/src/loader/tensors/tensor-role.d.ts +7 -0
- package/src/loader/tensors/tensor-role.js +12 -0
- package/src/loader/weight-downcast.d.ts +62 -0
- package/src/loader/weight-downcast.js +213 -0
- package/src/loader/weights.d.ts +22 -0
- package/src/loader/weights.js +4 -0
- package/src/memory/address-table.d.ts +104 -0
- package/src/memory/address-table.js +114 -0
- package/src/memory/buffer-pool.d.ts +204 -0
- package/src/memory/buffer-pool.js +867 -0
- package/src/memory/capability.d.ts +49 -0
- package/src/memory/capability.js +95 -0
- package/src/memory/heap-manager.d.ts +104 -0
- package/src/memory/heap-manager.js +264 -0
- package/src/memory/unified-detect.d.ts +59 -0
- package/src/memory/unified-detect.js +192 -0
- package/src/rules/converter/execution.rules.json +20 -0
- package/src/rules/converter/tensor-roles.rules.json +13 -0
- package/src/rules/converter/tokenizer.rules.json +7 -0
- package/src/rules/execution-rules-contract-check.d.ts +17 -0
- package/src/rules/execution-rules-contract-check.js +287 -0
- package/src/rules/inference/attention.rules.json +54 -0
- package/src/rules/inference/capability-transforms.rules.json +24 -0
- package/src/rules/inference/config.rules.json +57 -0
- package/src/rules/inference/dtype.rules.json +99 -0
- package/src/rules/inference/execution.rules.json +56 -0
- package/src/rules/inference/ffn.rules.json +35 -0
- package/src/rules/inference/layer-pattern.rules.json +16 -0
- package/src/rules/inference/layer.rules.json +7 -0
- package/src/rules/inference/moe.rules.json +48 -0
- package/src/rules/kernels/attention.rules.json +61 -0
- package/src/rules/kernels/conv2d.rules.json +6 -0
- package/src/rules/kernels/depthwise-conv2d.rules.json +6 -0
- package/src/rules/kernels/dequant.rules.json +58 -0
- package/src/rules/kernels/energy.rules.json +22 -0
- package/src/rules/kernels/fused-ffn.rules.json +13 -0
- package/src/rules/kernels/fused-matmul-residual.rules.json +6 -0
- package/src/rules/kernels/fused-matmul-rmsnorm.rules.json +8 -0
- package/src/rules/kernels/gather.rules.json +12 -0
- package/src/rules/kernels/gelu.rules.json +11 -0
- package/src/rules/kernels/grouped-pointwise-conv2d.rules.json +6 -0
- package/src/rules/kernels/groupnorm.rules.json +10 -0
- package/src/rules/kernels/kernel-validator.d.ts +24 -0
- package/src/rules/kernels/kernel-validator.js +160 -0
- package/src/rules/kernels/kv_quantize.rules.json +7 -0
- package/src/rules/kernels/layernorm.rules.json +6 -0
- package/src/rules/kernels/matmul.rules.json +60 -0
- package/src/rules/kernels/modulate.rules.json +6 -0
- package/src/rules/kernels/moe.rules.gptoss.json +105 -0
- package/src/rules/kernels/moe.rules.json +11 -0
- package/src/rules/kernels/moe.rules.mixtral.json +75 -0
- package/src/rules/kernels/pixel_shuffle.rules.json +6 -0
- package/src/rules/kernels/relu.rules.json +6 -0
- package/src/rules/kernels/repeat-channels.rules.json +6 -0
- package/src/rules/kernels/residual.rules.json +12 -0
- package/src/rules/kernels/rmsnorm.rules.json +11 -0
- package/src/rules/kernels/rope.rules.json +6 -0
- package/src/rules/kernels/sample.rules.json +6 -0
- package/src/rules/kernels/sana-linear-attention.rules.json +6 -0
- package/src/rules/kernels/scale.rules.json +6 -0
- package/src/rules/kernels/silu.rules.json +21 -0
- package/src/rules/kernels/softmax.rules.json +25 -0
- package/src/rules/kernels/split-qg.rules.json +6 -0
- package/src/rules/kernels/split-qkv.rules.json +6 -0
- package/src/rules/kernels/upsample2d.rules.json +6 -0
- package/src/rules/layer-pattern-contract-check.d.ts +17 -0
- package/src/rules/layer-pattern-contract-check.js +231 -0
- package/src/rules/loader/tensor-loader.rules.json +24 -0
- package/src/rules/loader/weights.rules.json +41 -0
- package/src/rules/rule-registry.d.ts +77 -0
- package/src/rules/rule-registry.js +264 -0
- package/src/rules/tooling/command-runtime.rules.json +65 -0
- package/src/storage/backends/idb-store.d.ts +52 -0
- package/src/storage/backends/idb-store.js +590 -0
- package/src/storage/backends/memory-store.d.ts +36 -0
- package/src/storage/backends/memory-store.js +242 -0
- package/src/storage/backends/opfs-store.d.ts +41 -0
- package/src/storage/backends/opfs-store.js +478 -0
- package/src/storage/blake3.d.ts +17 -0
- package/src/storage/blake3.js +269 -0
- package/src/storage/download-types.d.ts +157 -0
- package/src/storage/download-types.js +48 -0
- package/src/storage/downloader.d.ts +103 -0
- package/src/storage/downloader.js +1121 -0
- package/src/storage/emulated-vram.d.ts +264 -0
- package/src/storage/emulated-vram.js +576 -0
- package/src/storage/export.d.ts +20 -0
- package/src/storage/export.js +159 -0
- package/src/storage/index.d.ts +256 -0
- package/src/storage/index.js +188 -0
- package/src/storage/inventory.d.ts +26 -0
- package/src/storage/inventory.js +218 -0
- package/src/storage/preflight.d.ts +144 -0
- package/src/storage/preflight.js +316 -0
- package/src/storage/quickstart-downloader.d.ts +157 -0
- package/src/storage/quickstart-downloader.js +268 -0
- package/src/storage/quota.d.ts +150 -0
- package/src/storage/quota.js +305 -0
- package/src/storage/registry.d.ts +28 -0
- package/src/storage/registry.js +131 -0
- package/src/storage/reports.d.ts +20 -0
- package/src/storage/reports.js +94 -0
- package/src/storage/shard-manager.d.ts +151 -0
- package/src/storage/shard-manager.js +861 -0
- package/src/storage/source-artifact-store.d.ts +52 -0
- package/src/storage/source-artifact-store.js +234 -0
- package/src/sw.d.ts +1 -0
- package/src/sw.js +187 -0
- package/src/tooling/bench-runner.js +64 -0
- package/src/tooling/browser-command-runner.d.ts +28 -0
- package/src/tooling/browser-command-runner.js +85 -0
- package/src/tooling/command-api-constants.d.ts +9 -0
- package/src/tooling/command-api-constants.js +9 -0
- package/src/tooling/command-api-family-normalizers.d.ts +9 -0
- package/src/tooling/command-api-family-normalizers.js +395 -0
- package/src/tooling/command-api-helpers.d.ts +25 -0
- package/src/tooling/command-api-helpers.js +265 -0
- package/src/tooling/command-api.d.ts +177 -0
- package/src/tooling/command-api.js +82 -0
- package/src/tooling/command-envelope.d.ts +84 -0
- package/src/tooling/command-envelope.js +201 -0
- package/src/tooling/command-runner-shared.d.ts +75 -0
- package/src/tooling/command-runner-shared.js +191 -0
- package/src/tooling/command-runner.html +45 -0
- package/src/tooling/command-validation.js +44 -0
- package/src/tooling/conversion-config-materializer.d.ts +24 -0
- package/src/tooling/conversion-config-materializer.js +96 -0
- package/src/tooling/diagnose-runner.d.ts +28 -0
- package/src/tooling/diagnose-runner.js +333 -0
- package/src/tooling/distill-runner.js +56 -0
- package/src/tooling/hf-registry-utils.d.ts +59 -0
- package/src/tooling/hf-registry-utils.js +324 -0
- package/src/tooling/kernel-path-builder/custom-runtime-facts.d.ts +18 -0
- package/src/tooling/kernel-path-builder/custom-runtime-facts.js +72 -0
- package/src/tooling/kernel-path-builder/index.d.ts +65 -0
- package/src/tooling/kernel-path-builder/index.js +1348 -0
- package/src/tooling/kernel-path-builder/runtime-overlay.d.ts +9 -0
- package/src/tooling/kernel-path-builder/runtime-overlay.js +149 -0
- package/src/tooling/lean-execution-contract-runner.d.ts +43 -0
- package/src/tooling/lean-execution-contract-runner.js +158 -0
- package/src/tooling/lean-execution-contract.d.ts +16 -0
- package/src/tooling/lean-execution-contract.js +228 -0
- package/src/tooling/lora-runner.js +37 -0
- package/src/tooling/node-browser-command-runner.d.ts +34 -0
- package/src/tooling/node-browser-command-runner.js +827 -0
- package/src/tooling/node-command-runner.d.ts +36 -0
- package/src/tooling/node-command-runner.js +187 -0
- package/src/tooling/node-convert-worker-pool.d.ts +16 -0
- package/src/tooling/node-convert-worker-pool.js +186 -0
- package/src/tooling/node-convert-worker.d.ts +1 -0
- package/src/tooling/node-convert-worker.js +60 -0
- package/src/tooling/node-converter.d.ts +1 -0
- package/src/tooling/node-converter.js +1330 -0
- package/src/tooling/node-file-fetch.d.ts +1 -0
- package/src/tooling/node-file-fetch.js +38 -0
- package/src/tooling/node-source-runtime.d.ts +19 -0
- package/src/tooling/node-source-runtime.js +612 -0
- package/src/tooling/node-webgpu.d.ts +16 -0
- package/src/tooling/node-webgpu.js +421 -0
- package/src/tooling/opfs-cache.d.ts +12 -0
- package/src/tooling/opfs-cache.js +260 -0
- package/src/tooling/runtime-input-composition.d.ts +38 -0
- package/src/tooling/runtime-input-composition.js +90 -0
- package/src/tooling/source-runtime-bundle.d.ts +141 -0
- package/src/tooling/source-runtime-bundle.js +712 -0
- package/src/tooling/source-runtime-materializer.d.ts +6 -0
- package/src/tooling/source-runtime-materializer.js +93 -0
- package/src/tooling/verify-runner.js +63 -0
- package/src/tooling-exports.browser.d.ts +7 -0
- package/src/tooling-exports.browser.js +2 -0
- package/src/tooling-exports.d.ts +22 -0
- package/src/tooling-exports.js +7 -0
- package/src/tooling-exports.shared.d.ts +106 -0
- package/src/tooling-exports.shared.js +93 -0
- package/src/training/README.md +153 -0
- package/src/training/artifacts.d.ts +160 -0
- package/src/training/artifacts.js +896 -0
- package/src/training/attention-backward.d.ts +30 -0
- package/src/training/attention-backward.js +232 -0
- package/src/training/attention-forward.d.ts +22 -0
- package/src/training/attention-forward.js +82 -0
- package/src/training/autograd.d.ts +51 -0
- package/src/training/autograd.js +408 -0
- package/src/training/backward-kernels.js +39 -0
- package/src/training/checkpoint-watch.d.ts +8 -0
- package/src/training/checkpoint-watch.js +139 -0
- package/src/training/checkpoint.d.ts +36 -0
- package/src/training/checkpoint.js +281 -0
- package/src/training/clip.d.ts +9 -0
- package/src/training/clip.js +55 -0
- package/src/training/dataloader.d.ts +8 -0
- package/src/training/dataloader.js +44 -0
- package/src/training/datasets/index.d.ts +12 -0
- package/src/training/datasets/index.js +6 -0
- package/src/training/datasets/jsonl.d.ts +11 -0
- package/src/training/datasets/jsonl.js +50 -0
- package/src/training/datasets/reploid.d.ts +3 -0
- package/src/training/datasets/reploid.js +36 -0
- package/src/training/datasets/text-pairs.d.ts +21 -0
- package/src/training/datasets/text-pairs.js +42 -0
- package/src/training/datasets/token-batch.d.ts +21 -0
- package/src/training/datasets/token-batch.js +52 -0
- package/src/training/datasets/translation-pairs.d.ts +34 -0
- package/src/training/datasets/translation-pairs.js +49 -0
- package/src/training/distillation/artifacts.d.ts +71 -0
- package/src/training/distillation/artifacts.js +132 -0
- package/src/training/distillation/checkpoint-watch.d.ts +10 -0
- package/src/training/distillation/checkpoint-watch.js +58 -0
- package/src/training/distillation/dataset.d.ts +59 -0
- package/src/training/distillation/dataset.js +337 -0
- package/src/training/distillation/eval.d.ts +34 -0
- package/src/training/distillation/eval.js +313 -0
- package/src/training/distillation/index.d.ts +29 -0
- package/src/training/distillation/index.js +29 -0
- package/src/training/distillation/runtime.d.ts +20 -0
- package/src/training/distillation/runtime.js +121 -0
- package/src/training/distillation/scoreboard.d.ts +6 -0
- package/src/training/distillation/scoreboard.js +8 -0
- package/src/training/distillation/stage-a.d.ts +45 -0
- package/src/training/distillation/stage-a.js +338 -0
- package/src/training/distillation/stage-b.d.ts +24 -0
- package/src/training/distillation/stage-b.js +20 -0
- package/src/training/distillation/student-fixture.d.ts +22 -0
- package/src/training/distillation/student-fixture.js +846 -0
- package/src/training/distillation/suite-data.d.ts +45 -0
- package/src/training/distillation/suite-data.js +189 -0
- package/src/training/export.d.ts +32 -0
- package/src/training/export.js +112 -0
- package/src/training/index.d.ts +62 -0
- package/src/training/index.js +51 -0
- package/src/training/lora-pipeline.d.ts +40 -0
- package/src/training/lora-pipeline.js +793 -0
- package/src/training/lora.d.ts +19 -0
- package/src/training/lora.js +71 -0
- package/src/training/loss-scaling.d.ts +21 -0
- package/src/training/loss-scaling.js +80 -0
- package/src/training/loss.d.ts +10 -0
- package/src/training/loss.js +40 -0
- package/src/training/objectives/base.d.ts +58 -0
- package/src/training/objectives/base.js +38 -0
- package/src/training/objectives/cross_entropy.d.ts +18 -0
- package/src/training/objectives/cross_entropy.js +34 -0
- package/src/training/objectives/distill_kd.d.ts +16 -0
- package/src/training/objectives/distill_kd.js +369 -0
- package/src/training/objectives/distill_triplet.d.ts +16 -0
- package/src/training/objectives/distill_triplet.js +414 -0
- package/src/training/objectives/index.d.ts +12 -0
- package/src/training/objectives/index.js +6 -0
- package/src/training/objectives/ul_stage1_joint.d.ts +16 -0
- package/src/training/objectives/ul_stage1_joint.js +188 -0
- package/src/training/objectives/ul_stage2_base.d.ts +16 -0
- package/src/training/objectives/ul_stage2_base.js +218 -0
- package/src/training/operator-artifacts.d.ts +62 -0
- package/src/training/operator-artifacts.js +140 -0
- package/src/training/operator-command.d.ts +5 -0
- package/src/training/operator-command.js +455 -0
- package/src/training/operator-eval.d.ts +48 -0
- package/src/training/operator-eval.js +230 -0
- package/src/training/operator-scoreboard.d.ts +5 -0
- package/src/training/operator-scoreboard.js +44 -0
- package/src/training/optimizer.d.ts +22 -0
- package/src/training/optimizer.js +127 -0
- package/src/training/runner.d.ts +248 -0
- package/src/training/runner.js +1236 -0
- package/src/training/suite.d.ts +299 -0
- package/src/training/suite.js +2196 -0
- package/src/training/tensor-factory.d.ts +9 -0
- package/src/training/tensor-factory.js +13 -0
- package/src/training/trainer.d.ts +89 -0
- package/src/training/trainer.js +299 -0
- package/src/training/ul_dataset.d.ts +47 -0
- package/src/training/ul_dataset.js +151 -0
- package/src/training/ul_schedule.d.ts +6 -0
- package/src/training/ul_schedule.js +29 -0
- package/src/training/workload-packs/distill-translategemma-medium.json +103 -0
- package/src/training/workload-packs/distill-translategemma-tiny.json +103 -0
- package/src/training/workload-packs/lora-toy-medium.json +91 -0
- package/src/training/workload-packs/lora-toy-tiny.json +91 -0
- package/src/training/workload-packs/registry.json +98 -0
- package/src/training/workload-packs/ul-training-medium.json +55 -0
- package/src/training/workload-packs/ul-training-tiny.json +55 -0
- package/src/training/workloads.d.ts +164 -0
- package/src/training/workloads.js +530 -0
- package/src/types/chrome.d.ts +36 -0
- package/src/types/chrome.js +1 -0
- package/src/types/gpu.d.ts +185 -0
- package/src/types/gpu.js +5 -0
- package/src/types/index.d.ts +4 -0
- package/src/types/index.js +4 -0
- package/src/types/inference.d.ts +197 -0
- package/src/types/inference.js +5 -0
- package/src/types/model.d.ts +130 -0
- package/src/types/model.js +5 -0
- package/src/utils/format-bytes.js +20 -0
- package/src/utils/hf-resolve-url.d.ts +16 -0
- package/src/utils/hf-resolve-url.js +17 -0
- package/src/utils/index.d.ts +7 -0
- package/src/utils/index.js +7 -0
- package/src/utils/load-json.d.ts +5 -0
- package/src/utils/load-json.js +33 -0
- package/src/utils/plain-object.d.ts +1 -0
- package/src/utils/plain-object.js +3 -0
- package/src/utils/sha256.d.ts +4 -0
- package/src/utils/sha256.js +135 -0
- package/src/version.d.ts +2 -0
- package/src/version.js +2 -0
- package/tools/convert-safetensors-node.js +240 -0
|
@@ -0,0 +1,1150 @@
|
|
|
1
|
+
|
|
2
|
+
import { initializeInference } from './test-harness.js';
|
|
3
|
+
import { saveReport } from '../storage/reports.js';
|
|
4
|
+
import { getRuntimeConfig, setRuntimeConfig } from '../config/runtime.js';
|
|
5
|
+
import { clearLogHistory, getDebugSnapshot } from '../debug/history.js';
|
|
6
|
+
import { computeSampleStats } from '../debug/stats.js';
|
|
7
|
+
import {
|
|
8
|
+
setActiveKernelPath,
|
|
9
|
+
getActiveKernelPath,
|
|
10
|
+
getActiveKernelPathSource,
|
|
11
|
+
getActiveKernelPathPolicy,
|
|
12
|
+
} from '../config/kernel-path-loader.js';
|
|
13
|
+
import { validateTrainingMetricsReport } from '../config/schema/training-metrics.schema.js';
|
|
14
|
+
import {
|
|
15
|
+
resolveReportTimestamp,
|
|
16
|
+
resolveRuntime,
|
|
17
|
+
cloneRuntimeConfig,
|
|
18
|
+
runWithRuntimeIsolationForSuite,
|
|
19
|
+
sanitizeReportOutput,
|
|
20
|
+
loadRuntimeConfigFromUrl,
|
|
21
|
+
applyRuntimeConfigFromUrl,
|
|
22
|
+
loadRuntimeProfile,
|
|
23
|
+
applyRuntimeProfile,
|
|
24
|
+
applyRuntimeForRun,
|
|
25
|
+
normalizeManifest,
|
|
26
|
+
mergeRunDefaults,
|
|
27
|
+
summarizeManifestRuns,
|
|
28
|
+
} from './browser-harness-runtime-helpers.js';
|
|
29
|
+
import {
|
|
30
|
+
buildSuiteSummary,
|
|
31
|
+
normalizeCacheMode,
|
|
32
|
+
normalizeLoadMode,
|
|
33
|
+
normalizeWorkloadType,
|
|
34
|
+
assertDiffusionPerformanceArtifact,
|
|
35
|
+
toTimingNumber,
|
|
36
|
+
safeToFixed,
|
|
37
|
+
sampleTimingNumber,
|
|
38
|
+
buildCanonicalTiming,
|
|
39
|
+
buildTimingDiagnostics,
|
|
40
|
+
} from './browser-harness-suite-helpers.js';
|
|
41
|
+
import {
|
|
42
|
+
resolveDeviceInfo,
|
|
43
|
+
resolveKernelPathForModel,
|
|
44
|
+
initializeSuiteModel,
|
|
45
|
+
} from './browser-harness-model-helpers.js';
|
|
46
|
+
import {
|
|
47
|
+
resolveBenchmarkRunSettings,
|
|
48
|
+
runEmbeddingSemanticChecks,
|
|
49
|
+
isCoherentOutput,
|
|
50
|
+
runGeneration,
|
|
51
|
+
runEmbedding,
|
|
52
|
+
} from './browser-harness-text-helpers.js';
|
|
53
|
+
import { buildSuiteContractMetrics } from './browser-harness-contract-helpers.js';
|
|
54
|
+
import {
|
|
55
|
+
runDiffusionSuite,
|
|
56
|
+
runEnergySuite,
|
|
57
|
+
} from './browser-harness-diffusion-energy-suites.js';
|
|
58
|
+
import { collectTrainingArtifactsFromSuiteResult } from './browser-harness-report-helpers.js';
|
|
59
|
+
|
|
60
|
+
const TRAINING_SUITE_MODULE_PATH = '../training/suite.js';
|
|
61
|
+
let trainingSuiteModulePromise = null;
|
|
62
|
+
|
|
63
|
+
async function loadTrainingSuiteModule() {
|
|
64
|
+
if (!trainingSuiteModulePromise) {
|
|
65
|
+
trainingSuiteModulePromise = import(TRAINING_SUITE_MODULE_PATH);
|
|
66
|
+
}
|
|
67
|
+
return trainingSuiteModulePromise;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Clear the cached training suite module promise.
|
|
72
|
+
* Useful for testing or when the training module needs to be re-imported
|
|
73
|
+
* after configuration changes.
|
|
74
|
+
*/
|
|
75
|
+
export function clearTrainingSuiteModule() {
|
|
76
|
+
trainingSuiteModulePromise = null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export async function runTrainingSuite(options = {}) {
|
|
80
|
+
const module = await loadTrainingSuiteModule();
|
|
81
|
+
return module.runTrainingSuite(options);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export {
|
|
85
|
+
loadRuntimeConfigFromUrl,
|
|
86
|
+
applyRuntimeConfigFromUrl,
|
|
87
|
+
loadRuntimeProfile,
|
|
88
|
+
applyRuntimeProfile,
|
|
89
|
+
applyRuntimeForRun,
|
|
90
|
+
buildSuiteSummary,
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
async function runTrainingBenchSuite(options = {}) {
|
|
94
|
+
const module = await loadTrainingSuiteModule();
|
|
95
|
+
return module.runTrainingBenchSuite(options);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export async function initializeBrowserHarness(options = {}) {
|
|
99
|
+
const { modelUrl, onProgress, log } = options;
|
|
100
|
+
if (!modelUrl) {
|
|
101
|
+
throw new Error('modelUrl is required');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const runtime = resolveRuntime(options);
|
|
105
|
+
const result = await initializeInference(modelUrl, {
|
|
106
|
+
runtime,
|
|
107
|
+
onProgress,
|
|
108
|
+
log,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
return { ...result, runtime };
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export async function saveBrowserReport(modelId, report, options = {}) {
|
|
115
|
+
return saveReport(modelId, report, options);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export async function runBrowserHarness(options = {}) {
|
|
119
|
+
const harness = await initializeBrowserHarness(options);
|
|
120
|
+
const reportTimestamp = resolveReportTimestamp(options.timestamp, 'runBrowserHarness timestamp');
|
|
121
|
+
const modelId = options.modelId || harness.manifest?.modelId || 'unknown';
|
|
122
|
+
|
|
123
|
+
let report = options.report || null;
|
|
124
|
+
if (!report && typeof options.buildReport === 'function') {
|
|
125
|
+
report = await options.buildReport(harness);
|
|
126
|
+
}
|
|
127
|
+
if (!report) {
|
|
128
|
+
report = {
|
|
129
|
+
modelId,
|
|
130
|
+
timestamp: reportTimestamp,
|
|
131
|
+
};
|
|
132
|
+
} else if (!report.timestamp) {
|
|
133
|
+
report = { ...report, timestamp: reportTimestamp };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const reportInfo = await saveReport(modelId, report, { timestamp: report.timestamp || reportTimestamp });
|
|
137
|
+
return { ...harness, report, reportInfo };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const BROWSER_WORKLOAD_SET = Object.freeze([
|
|
141
|
+
'kernels',
|
|
142
|
+
'inference',
|
|
143
|
+
'embedding',
|
|
144
|
+
'training',
|
|
145
|
+
'diffusion',
|
|
146
|
+
'energy',
|
|
147
|
+
]);
|
|
148
|
+
|
|
149
|
+
const BROWSER_MODE_SET = Object.freeze(['verify', 'debug', 'bench', 'diagnose']);
|
|
150
|
+
|
|
151
|
+
const BROWSER_WORKLOAD_DISPATCH_MAP = Object.freeze({
|
|
152
|
+
verify: Object.freeze({
|
|
153
|
+
kernels: 'runKernelSuite',
|
|
154
|
+
inference: 'runInferenceSuite',
|
|
155
|
+
embedding: 'runEmbeddingSuite',
|
|
156
|
+
training: 'runTrainingSuite',
|
|
157
|
+
diffusion: 'runDiffusionSuite',
|
|
158
|
+
energy: 'runEnergySuite',
|
|
159
|
+
}),
|
|
160
|
+
debug: Object.freeze({
|
|
161
|
+
inference: 'runInferenceSuite(debug)',
|
|
162
|
+
embedding: 'runEmbeddingSuite(debug)',
|
|
163
|
+
}),
|
|
164
|
+
diagnose: Object.freeze({
|
|
165
|
+
inference: 'runInferenceSuite(diagnose)',
|
|
166
|
+
}),
|
|
167
|
+
bench: Object.freeze({
|
|
168
|
+
inference: 'runBenchSuite',
|
|
169
|
+
embedding: 'runBenchSuite',
|
|
170
|
+
training: 'runBenchSuite(training)',
|
|
171
|
+
diffusion: 'runBenchSuite(diffusion)',
|
|
172
|
+
}),
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
export function getBrowserSupportedSuites() {
|
|
176
|
+
return [...BROWSER_WORKLOAD_SET];
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export function getBrowserSuiteDispatchMap() {
|
|
180
|
+
return {
|
|
181
|
+
verify: { ...BROWSER_WORKLOAD_DISPATCH_MAP.verify },
|
|
182
|
+
debug: { ...BROWSER_WORKLOAD_DISPATCH_MAP.debug },
|
|
183
|
+
bench: { ...BROWSER_WORKLOAD_DISPATCH_MAP.bench },
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function getAllowedWorkloadsForMode(mode) {
|
|
188
|
+
return Object.keys(BROWSER_WORKLOAD_DISPATCH_MAP[mode] || {});
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function createUnsupportedWorkloadError(requestedWorkload, context = {}) {
|
|
192
|
+
const command = typeof context.command === 'string' && context.command.trim()
|
|
193
|
+
? context.command.trim()
|
|
194
|
+
: 'run-browser-suite';
|
|
195
|
+
const surface = typeof context.surface === 'string' && context.surface.trim()
|
|
196
|
+
? context.surface.trim()
|
|
197
|
+
: 'browser';
|
|
198
|
+
const mode = typeof context.mode === 'string' && context.mode.trim()
|
|
199
|
+
? context.mode.trim()
|
|
200
|
+
: 'verify';
|
|
201
|
+
const allowedWorkloads = getAllowedWorkloadsForMode(mode);
|
|
202
|
+
const error = new Error(
|
|
203
|
+
`Unsupported workload "${requestedWorkload}". Allowed workloads: ${allowedWorkloads.join(', ')}. ` +
|
|
204
|
+
`command="${command}" mode="${mode}" surface="${surface}".`
|
|
205
|
+
);
|
|
206
|
+
error.code = 'unsupported_workload';
|
|
207
|
+
error.requestedWorkload = requestedWorkload;
|
|
208
|
+
error.allowedWorkloads = allowedWorkloads;
|
|
209
|
+
error.command = command;
|
|
210
|
+
error.mode = mode;
|
|
211
|
+
error.surface = surface;
|
|
212
|
+
error.details = {
|
|
213
|
+
requestedWorkload,
|
|
214
|
+
allowedWorkloads,
|
|
215
|
+
command,
|
|
216
|
+
mode,
|
|
217
|
+
surface,
|
|
218
|
+
};
|
|
219
|
+
return error;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function resolveHarnessContext(options = {}) {
|
|
223
|
+
const command = typeof options.command === 'string' ? options.command : null;
|
|
224
|
+
const surface = typeof options.surface === 'string' ? options.surface : null;
|
|
225
|
+
const mode = typeof options.mode === 'string' ? options.mode : null;
|
|
226
|
+
return {
|
|
227
|
+
command: command ?? 'run-browser-suite',
|
|
228
|
+
mode: mode ?? command ?? 'verify',
|
|
229
|
+
surface: surface ?? 'browser',
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function normalizeLegacySuite(value) {
|
|
234
|
+
const suite = String(value || '').trim().toLowerCase();
|
|
235
|
+
if (!suite) {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
return suite === 'benchmark' ? 'bench' : suite;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function normalizeMode(value, context = {}) {
|
|
242
|
+
const mode = String(value || '').trim().toLowerCase();
|
|
243
|
+
if (!mode) {
|
|
244
|
+
return 'verify';
|
|
245
|
+
}
|
|
246
|
+
if (!BROWSER_MODE_SET.includes(mode)) {
|
|
247
|
+
throw new Error(`Unsupported browser harness mode "${mode}" for command "${context.command || 'run-browser-suite'}".`);
|
|
248
|
+
}
|
|
249
|
+
return mode;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function resolveHarnessMode(options = {}, context = {}) {
|
|
253
|
+
const explicitMode = options.mode ?? options.command ?? null;
|
|
254
|
+
if (explicitMode) {
|
|
255
|
+
return normalizeMode(explicitMode, context);
|
|
256
|
+
}
|
|
257
|
+
const legacySuite = normalizeLegacySuite(options.suite);
|
|
258
|
+
if (legacySuite === 'debug' || legacySuite === 'bench') {
|
|
259
|
+
return legacySuite;
|
|
260
|
+
}
|
|
261
|
+
return 'verify';
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function normalizeWorkload(value, mode, context = {}) {
|
|
265
|
+
const workload = String(value || '').trim().toLowerCase();
|
|
266
|
+
if (!workload) {
|
|
267
|
+
throw createUnsupportedWorkloadError(workload, { ...context, mode });
|
|
268
|
+
}
|
|
269
|
+
if (!getAllowedWorkloadsForMode(mode).includes(workload)) {
|
|
270
|
+
throw createUnsupportedWorkloadError(workload, { ...context, mode });
|
|
271
|
+
}
|
|
272
|
+
return workload;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function resolveWorkload(options = {}, mode, context = {}) {
|
|
276
|
+
if (options.workload) {
|
|
277
|
+
return normalizeWorkload(options.workload, mode, context);
|
|
278
|
+
}
|
|
279
|
+
const legacySuite = normalizeLegacySuite(options.suite);
|
|
280
|
+
if (legacySuite && legacySuite !== 'debug' && legacySuite !== 'bench') {
|
|
281
|
+
return normalizeWorkload(legacySuite, mode, context);
|
|
282
|
+
}
|
|
283
|
+
if (mode === 'debug' || mode === 'bench') {
|
|
284
|
+
return 'inference';
|
|
285
|
+
}
|
|
286
|
+
return normalizeWorkload('', mode, context);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function resolveDispatchSuite(mode, workload) {
|
|
290
|
+
if (mode === 'debug') {
|
|
291
|
+
return 'debug';
|
|
292
|
+
}
|
|
293
|
+
if (mode === 'bench') {
|
|
294
|
+
return 'bench';
|
|
295
|
+
}
|
|
296
|
+
return workload;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
async function runKernelSuite(options = {}) {
|
|
300
|
+
const startTime = performance.now();
|
|
301
|
+
const { testHarness, initGPU } = await import('../../tests/kernels/browser/test-page.js');
|
|
302
|
+
const { runKernelSuite: runAllKernelTests } = await import('../../tests/kernels/browser/kernel-suite.js');
|
|
303
|
+
await initGPU();
|
|
304
|
+
|
|
305
|
+
const previousKernelPath = getActiveKernelPath();
|
|
306
|
+
const previousKernelSource = getActiveKernelPathSource();
|
|
307
|
+
const previousKernelPathPolicy = getActiveKernelPathPolicy();
|
|
308
|
+
if (options.modelId) {
|
|
309
|
+
await resolveKernelPathForModel(options);
|
|
310
|
+
}
|
|
311
|
+
let results = [];
|
|
312
|
+
try {
|
|
313
|
+
results = await runAllKernelTests(testHarness);
|
|
314
|
+
} finally {
|
|
315
|
+
setActiveKernelPath(previousKernelPath, previousKernelSource, previousKernelPathPolicy);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
const summary = buildSuiteSummary('kernels', results, startTime);
|
|
319
|
+
return {
|
|
320
|
+
...summary,
|
|
321
|
+
deviceInfo: resolveDeviceInfo(),
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
async function runInferenceSuite(options = {}) {
|
|
326
|
+
const startTime = performance.now();
|
|
327
|
+
const harness = await initializeSuiteModel(options);
|
|
328
|
+
const runtimeConfig = getRuntimeConfig();
|
|
329
|
+
const modelType = harness.manifest?.modelType || 'transformer';
|
|
330
|
+
if (options.expectedModelType === 'embedding' && modelType !== 'embedding') {
|
|
331
|
+
throw new Error(
|
|
332
|
+
`Expected an embedding model for workload "${options.workload || 'inference'}", got "${modelType}".`
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
const cacheMode = normalizeCacheMode(options.cacheMode);
|
|
336
|
+
const loadMode = normalizeLoadMode(options.loadMode, !!options.modelUrl, options.modelUrl);
|
|
337
|
+
const safeModelLoadMs = toTimingNumber(harness.modelLoadMs, 0);
|
|
338
|
+
|
|
339
|
+
let results;
|
|
340
|
+
let output = null;
|
|
341
|
+
let metrics;
|
|
342
|
+
|
|
343
|
+
if (modelType === 'embedding') {
|
|
344
|
+
const run = await runEmbedding(harness.pipeline, runtimeConfig);
|
|
345
|
+
const semantic = await runEmbeddingSemanticChecks(harness.pipeline, options);
|
|
346
|
+
const isValidEmbedding = run.embeddingDim > 0 && run.nonFiniteCount === 0;
|
|
347
|
+
const isSemanticValid = semantic.passed;
|
|
348
|
+
output = {
|
|
349
|
+
mode: 'embedding',
|
|
350
|
+
tokens: run.tokenCount,
|
|
351
|
+
embeddingDim: run.embeddingDim,
|
|
352
|
+
finiteValues: run.finiteCount,
|
|
353
|
+
nonFiniteValues: run.nonFiniteCount,
|
|
354
|
+
finiteRatio: Number((run.finiteRatio ?? 0).toFixed(6)),
|
|
355
|
+
min: run.min == null ? null : Number(run.min.toFixed(6)),
|
|
356
|
+
max: run.max == null ? null : Number(run.max.toFixed(6)),
|
|
357
|
+
maxAbs: run.maxAbs == null ? null : Number(run.maxAbs.toFixed(6)),
|
|
358
|
+
mean: run.mean == null ? null : Number(run.mean.toFixed(6)),
|
|
359
|
+
stdDev: run.stdDev == null ? null : Number(run.stdDev.toFixed(6)),
|
|
360
|
+
l2Norm: run.l2Norm == null ? null : Number(run.l2Norm.toFixed(6)),
|
|
361
|
+
preview: run.preview,
|
|
362
|
+
semantic: {
|
|
363
|
+
passed: isSemanticValid,
|
|
364
|
+
style: semantic.style,
|
|
365
|
+
retrievalTop1Acc: Number(semantic.retrievalTop1Acc.toFixed(4)),
|
|
366
|
+
pairAcc: Number(semantic.pairAcc.toFixed(4)),
|
|
367
|
+
failedCaseIds: semantic.failedCaseIds,
|
|
368
|
+
details: {
|
|
369
|
+
retrieval: semantic.retrieval,
|
|
370
|
+
pairs: semantic.pairs,
|
|
371
|
+
},
|
|
372
|
+
},
|
|
373
|
+
};
|
|
374
|
+
results = [
|
|
375
|
+
{
|
|
376
|
+
name: 'embedding',
|
|
377
|
+
passed: isValidEmbedding,
|
|
378
|
+
duration: run.durationMs,
|
|
379
|
+
error: isValidEmbedding
|
|
380
|
+
? undefined
|
|
381
|
+
: (
|
|
382
|
+
run.embeddingDim <= 0
|
|
383
|
+
? 'No embedding returned'
|
|
384
|
+
: `Embedding contains non-finite values (${run.nonFiniteCount}/${run.embeddingDim})`
|
|
385
|
+
),
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
name: 'embedding-semantic',
|
|
389
|
+
passed: isSemanticValid,
|
|
390
|
+
duration: semantic.durationMs,
|
|
391
|
+
error: isSemanticValid
|
|
392
|
+
? undefined
|
|
393
|
+
: (
|
|
394
|
+
`Semantic checks below threshold: retrieval=${(semantic.retrievalTop1Acc * 100).toFixed(1)}% `
|
|
395
|
+
+ `(min ${(semantic.minRetrievalTop1Acc * 100).toFixed(1)}%), `
|
|
396
|
+
+ `pairs=${(semantic.pairAcc * 100).toFixed(1)}% `
|
|
397
|
+
+ `(min ${(semantic.minPairAcc * 100).toFixed(1)}%). `
|
|
398
|
+
+ (semantic.failedCaseIds.length > 0 ? `Failed: ${semantic.failedCaseIds.join(', ')}` : '')
|
|
399
|
+
),
|
|
400
|
+
},
|
|
401
|
+
];
|
|
402
|
+
metrics = {
|
|
403
|
+
prompt: run.prompt,
|
|
404
|
+
embeddingTokens: run.tokenCount,
|
|
405
|
+
embeddingDim: run.embeddingDim,
|
|
406
|
+
finiteValues: run.finiteCount,
|
|
407
|
+
finiteRatio: Number((run.finiteRatio ?? 0).toFixed(6)),
|
|
408
|
+
nonFiniteValues: run.nonFiniteCount,
|
|
409
|
+
embeddingMin: run.min == null ? null : Number(run.min.toFixed(6)),
|
|
410
|
+
embeddingMax: run.max == null ? null : Number(run.max.toFixed(6)),
|
|
411
|
+
embeddingMaxAbs: run.maxAbs == null ? null : Number(run.maxAbs.toFixed(6)),
|
|
412
|
+
embeddingMean: run.mean == null ? null : Number(run.mean.toFixed(6)),
|
|
413
|
+
embeddingStdDev: run.stdDev == null ? null : Number(run.stdDev.toFixed(6)),
|
|
414
|
+
embeddingL2Norm: run.l2Norm == null ? null : Number(run.l2Norm.toFixed(6)),
|
|
415
|
+
embeddingMs: Number(run.durationMs.toFixed(2)),
|
|
416
|
+
semanticPassed: isSemanticValid,
|
|
417
|
+
semanticDurationMs: Number(semantic.durationMs.toFixed(2)),
|
|
418
|
+
semanticRetrievalTop1Acc: Number(semantic.retrievalTop1Acc.toFixed(4)),
|
|
419
|
+
semanticPairAcc: Number(semantic.pairAcc.toFixed(4)),
|
|
420
|
+
semanticRetrievalPassed: semantic.retrievalPassed,
|
|
421
|
+
semanticRetrievalTotal: semantic.retrievalTotal,
|
|
422
|
+
semanticPairPassed: semantic.pairPassed,
|
|
423
|
+
semanticPairTotal: semantic.pairTotal,
|
|
424
|
+
semanticMinRetrievalTop1Acc: Number(semantic.minRetrievalTop1Acc.toFixed(4)),
|
|
425
|
+
semanticMinPairAcc: Number(semantic.minPairAcc.toFixed(4)),
|
|
426
|
+
semanticPairMarginThreshold: Number(semantic.pairMarginThreshold.toFixed(4)),
|
|
427
|
+
semanticStyle: semantic.style,
|
|
428
|
+
semanticFailedCases: semantic.failedCaseIds,
|
|
429
|
+
semanticDetails: {
|
|
430
|
+
retrieval: semantic.retrieval,
|
|
431
|
+
pairs: semantic.pairs,
|
|
432
|
+
},
|
|
433
|
+
modelLoadMs: safeModelLoadMs,
|
|
434
|
+
endToEndMs: safeToFixed(safeModelLoadMs + run.durationMs),
|
|
435
|
+
embeddingPreview: run.preview,
|
|
436
|
+
};
|
|
437
|
+
} else {
|
|
438
|
+
const run = await runGeneration(harness.pipeline, runtimeConfig);
|
|
439
|
+
const coherent = isCoherentOutput(run.tokens, run.output);
|
|
440
|
+
results = [
|
|
441
|
+
{
|
|
442
|
+
name: 'generation',
|
|
443
|
+
passed: run.tokens.length > 0 && coherent,
|
|
444
|
+
duration: run.durationMs,
|
|
445
|
+
error: run.tokens.length === 0
|
|
446
|
+
? 'No tokens generated'
|
|
447
|
+
: (!coherent ? 'Output dominated by padding or special tokens' : undefined),
|
|
448
|
+
},
|
|
449
|
+
];
|
|
450
|
+
output = run.output;
|
|
451
|
+
metrics = {
|
|
452
|
+
prompt: run.prompt,
|
|
453
|
+
maxTokens: run.maxTokens,
|
|
454
|
+
tokensGenerated: run.tokens.length,
|
|
455
|
+
tokensPerSec: safeToFixed(run.tokensPerSec),
|
|
456
|
+
totalRunMs: safeToFixed(run.phase.totalMs),
|
|
457
|
+
firstTokenMs: safeToFixed(run.phase.ttftMs),
|
|
458
|
+
firstResponseMs: safeToFixed(safeModelLoadMs + run.phase.ttftMs),
|
|
459
|
+
prefillMs: safeToFixed(run.phase.prefillMs),
|
|
460
|
+
decodeMs: safeToFixed(run.phase.decodeMs),
|
|
461
|
+
prefillTokens: Math.round(run.phase.prefillTokens),
|
|
462
|
+
decodeTokens: Math.round(run.phase.decodeTokens),
|
|
463
|
+
prefillTokensPerSec: safeToFixed(run.phase.prefillTokensPerSec),
|
|
464
|
+
prefillTokensPerSecTtft: safeToFixed(run.phase.prefillTokensPerSecTtft),
|
|
465
|
+
decodeTokensPerSec: safeToFixed(run.phase.decodeTokensPerSec),
|
|
466
|
+
modelLoadMs: safeModelLoadMs,
|
|
467
|
+
gpu: run.phase.gpu,
|
|
468
|
+
decodeProfileSteps: run.phase.decodeProfileSteps,
|
|
469
|
+
executionPlan: run.phase.executionPlan,
|
|
470
|
+
kernelPathId: run.phase.kernelPathId,
|
|
471
|
+
kernelPathSource: run.phase.kernelPathSource,
|
|
472
|
+
generationDiagnostics: run.tokenDiagnostics,
|
|
473
|
+
operatorDiagnostics: run.phase.operatorDiagnostics ?? null,
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
const memoryStats = typeof harness.pipeline?.getMemoryStats === 'function'
|
|
478
|
+
? harness.pipeline.getMemoryStats()
|
|
479
|
+
: null;
|
|
480
|
+
if (typeof harness.pipeline.unload === 'function' && !options.keepPipeline) {
|
|
481
|
+
await harness.pipeline.unload();
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
const summary = buildSuiteSummary(options.suiteName || 'inference', results, startTime);
|
|
485
|
+
const timing = buildCanonicalTiming({
|
|
486
|
+
modelLoadMs: safeModelLoadMs,
|
|
487
|
+
firstTokenMs: metrics.firstTokenMs ?? null,
|
|
488
|
+
firstResponseMs: Number.isFinite(metrics.firstTokenMs)
|
|
489
|
+
? safeModelLoadMs + metrics.firstTokenMs
|
|
490
|
+
: null,
|
|
491
|
+
prefillMs: metrics.prefillMs ?? 0,
|
|
492
|
+
decodeMs: metrics.decodeMs ?? 0,
|
|
493
|
+
decodeMsPerTokenP50: metrics.decodeMsPerTokenP50 ?? null,
|
|
494
|
+
decodeMsPerTokenP95: metrics.decodeMsPerTokenP95 ?? null,
|
|
495
|
+
decodeMsPerTokenP99: metrics.decodeMsPerTokenP99 ?? null,
|
|
496
|
+
totalRunMs: metrics.totalRunMs ?? metrics.decodeMs ?? 0,
|
|
497
|
+
decodeTokensPerSec: metrics.decodeTokensPerSec,
|
|
498
|
+
prefillTokensPerSec: metrics.prefillTokensPerSec,
|
|
499
|
+
cacheMode,
|
|
500
|
+
loadMode,
|
|
501
|
+
});
|
|
502
|
+
const timingDiagnostics = buildTimingDiagnostics(timing, {
|
|
503
|
+
source: 'doppler',
|
|
504
|
+
prefillSemantics: 'internal_prefill_phase',
|
|
505
|
+
});
|
|
506
|
+
const metricsWithContracts = buildSuiteContractMetrics(
|
|
507
|
+
options.suiteName || 'inference',
|
|
508
|
+
metrics,
|
|
509
|
+
harness.manifest
|
|
510
|
+
);
|
|
511
|
+
return {
|
|
512
|
+
...summary,
|
|
513
|
+
modelId: options.modelId || harness.manifest?.modelId || 'unknown',
|
|
514
|
+
cacheMode,
|
|
515
|
+
loadMode,
|
|
516
|
+
env: {
|
|
517
|
+
library: 'doppler',
|
|
518
|
+
runtime: 'browser',
|
|
519
|
+
device: 'webgpu',
|
|
520
|
+
browserUserAgent: typeof navigator !== 'undefined' ? (navigator.userAgent || null) : null,
|
|
521
|
+
browserPlatform: typeof navigator !== 'undefined' ? (navigator.platform || null) : null,
|
|
522
|
+
browserLanguage: typeof navigator !== 'undefined' ? (navigator.language || null) : null,
|
|
523
|
+
browserVendor: typeof navigator !== 'undefined' ? (navigator.vendor || null) : null,
|
|
524
|
+
},
|
|
525
|
+
timing,
|
|
526
|
+
timingDiagnostics,
|
|
527
|
+
output,
|
|
528
|
+
metrics: metricsWithContracts,
|
|
529
|
+
memoryStats,
|
|
530
|
+
deviceInfo: resolveDeviceInfo(),
|
|
531
|
+
pipeline: options.keepPipeline ? harness.pipeline : null,
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
async function runBenchSuite(options = {}) {
|
|
536
|
+
const startTime = performance.now();
|
|
537
|
+
const runtimeConfig = getRuntimeConfig();
|
|
538
|
+
const defaultBenchRun = resolveBenchmarkRunSettings(runtimeConfig);
|
|
539
|
+
const warmupRuns = defaultBenchRun.warmupRuns;
|
|
540
|
+
const timedRuns = defaultBenchRun.timedRuns;
|
|
541
|
+
const cacheMode = normalizeCacheMode(options.cacheMode);
|
|
542
|
+
const loadMode = normalizeLoadMode(options.loadMode, !!options.modelUrl, options.modelUrl);
|
|
543
|
+
const workloadType = normalizeWorkloadType(
|
|
544
|
+
options.workloadType
|
|
545
|
+
?? (
|
|
546
|
+
options.mode === 'bench' && (options.workload === 'training' || options.workload === 'diffusion')
|
|
547
|
+
? options.workload
|
|
548
|
+
: null
|
|
549
|
+
)
|
|
550
|
+
);
|
|
551
|
+
|
|
552
|
+
if (workloadType === 'training') {
|
|
553
|
+
const trainingBench = await runTrainingBenchSuite({
|
|
554
|
+
...options,
|
|
555
|
+
benchRun: defaultBenchRun,
|
|
556
|
+
workloadType,
|
|
557
|
+
});
|
|
558
|
+
const trainingReport = trainingBench?.metrics?.trainingMetricsReport;
|
|
559
|
+
if (Array.isArray(trainingReport) && trainingReport.length > 0) {
|
|
560
|
+
validateTrainingMetricsReport(trainingReport);
|
|
561
|
+
}
|
|
562
|
+
const runStats = trainingBench?.metrics?.latency?.runMs || computeSampleStats([]);
|
|
563
|
+
const stepStats = trainingBench?.metrics?.latency?.stepMs || computeSampleStats([]);
|
|
564
|
+
const throughputStats = trainingBench?.metrics?.throughput?.stepsPerSec || computeSampleStats([]);
|
|
565
|
+
const timing = buildCanonicalTiming({
|
|
566
|
+
modelLoadMs: 0,
|
|
567
|
+
firstTokenMs: null,
|
|
568
|
+
firstResponseMs: null,
|
|
569
|
+
prefillMs: null,
|
|
570
|
+
decodeMs: stepStats.median,
|
|
571
|
+
totalRunMs: runStats.median,
|
|
572
|
+
decodeTokensPerSec: throughputStats.median,
|
|
573
|
+
prefillTokensPerSec: null,
|
|
574
|
+
cacheMode,
|
|
575
|
+
loadMode,
|
|
576
|
+
});
|
|
577
|
+
const timingDiagnostics = buildTimingDiagnostics(timing, {
|
|
578
|
+
source: 'doppler',
|
|
579
|
+
prefillSemantics: 'not_applicable_training_workload',
|
|
580
|
+
});
|
|
581
|
+
return {
|
|
582
|
+
...trainingBench,
|
|
583
|
+
modelId: trainingBench.modelId || options.modelId || options.modelUrl || 'training',
|
|
584
|
+
cacheMode,
|
|
585
|
+
loadMode,
|
|
586
|
+
env: {
|
|
587
|
+
library: 'doppler',
|
|
588
|
+
runtime: 'browser',
|
|
589
|
+
device: 'webgpu',
|
|
590
|
+
browserUserAgent: typeof navigator !== 'undefined' ? (navigator.userAgent || null) : null,
|
|
591
|
+
browserPlatform: typeof navigator !== 'undefined' ? (navigator.platform || null) : null,
|
|
592
|
+
browserLanguage: typeof navigator !== 'undefined' ? (navigator.language || null) : null,
|
|
593
|
+
browserVendor: typeof navigator !== 'undefined' ? (navigator.vendor || null) : null,
|
|
594
|
+
},
|
|
595
|
+
timing,
|
|
596
|
+
timingDiagnostics,
|
|
597
|
+
output: null,
|
|
598
|
+
memoryStats: null,
|
|
599
|
+
deviceInfo: trainingBench.deviceInfo ?? resolveDeviceInfo(),
|
|
600
|
+
pipeline: null,
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
if (workloadType === 'diffusion') {
|
|
605
|
+
const diffusionBench = await runDiffusionSuite({
|
|
606
|
+
...options,
|
|
607
|
+
command: 'bench',
|
|
608
|
+
workload: 'diffusion',
|
|
609
|
+
captureOutput: options.captureOutput === true,
|
|
610
|
+
cacheMode,
|
|
611
|
+
loadMode,
|
|
612
|
+
});
|
|
613
|
+
|
|
614
|
+
const benchResults = [
|
|
615
|
+
{
|
|
616
|
+
name: 'benchmark-diffusion',
|
|
617
|
+
passed: diffusionBench.passed > 0 && diffusionBench.failed === 0,
|
|
618
|
+
duration: diffusionBench.duration,
|
|
619
|
+
error: diffusionBench.failed === 0 ? undefined : 'Diffusion benchmark run failed.',
|
|
620
|
+
},
|
|
621
|
+
];
|
|
622
|
+
const summary = buildSuiteSummary('bench', benchResults, startTime);
|
|
623
|
+
|
|
624
|
+
return {
|
|
625
|
+
...diffusionBench,
|
|
626
|
+
...summary,
|
|
627
|
+
suite: 'bench',
|
|
628
|
+
results: benchResults,
|
|
629
|
+
metrics: {
|
|
630
|
+
...(diffusionBench.metrics || {}),
|
|
631
|
+
workloadType: 'diffusion',
|
|
632
|
+
},
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
const harness = await initializeSuiteModel(options);
|
|
637
|
+
const benchRun = resolveBenchmarkRunSettings(runtimeConfig, harness.pipeline ?? harness);
|
|
638
|
+
const modelType = harness.manifest?.modelType || 'transformer';
|
|
639
|
+
if (options.expectedModelType === 'embedding' && modelType !== 'embedding') {
|
|
640
|
+
throw new Error(
|
|
641
|
+
`Expected an embedding model for bench workload "${options.workload || 'inference'}", got "${modelType}".`
|
|
642
|
+
);
|
|
643
|
+
}
|
|
644
|
+
const safeModelLoadMs = toTimingNumber(harness.modelLoadMs, 0);
|
|
645
|
+
|
|
646
|
+
let results;
|
|
647
|
+
let metrics;
|
|
648
|
+
let output = null;
|
|
649
|
+
let timing;
|
|
650
|
+
|
|
651
|
+
if (modelType === 'embedding') {
|
|
652
|
+
const durations = [];
|
|
653
|
+
const timedDurations = [];
|
|
654
|
+
const embeddingDims = [];
|
|
655
|
+
const embeddingTokenCounts = [];
|
|
656
|
+
const embeddingNorms = [];
|
|
657
|
+
let firstTimedEmbeddingMs = null;
|
|
658
|
+
let invalidRuns = 0;
|
|
659
|
+
let totalNonFiniteValues = 0;
|
|
660
|
+
for (let i = 0; i < warmupRuns + timedRuns; i++) {
|
|
661
|
+
harness.pipeline.reset?.();
|
|
662
|
+
const run = await runEmbedding(harness.pipeline, runtimeConfig, benchRun);
|
|
663
|
+
if (i >= warmupRuns) {
|
|
664
|
+
timedDurations.push(run.durationMs);
|
|
665
|
+
if (firstTimedEmbeddingMs == null) {
|
|
666
|
+
firstTimedEmbeddingMs = run.durationMs;
|
|
667
|
+
}
|
|
668
|
+
totalNonFiniteValues += run.nonFiniteCount;
|
|
669
|
+
if (Number.isFinite(run.tokenCount)) {
|
|
670
|
+
embeddingTokenCounts.push(run.tokenCount);
|
|
671
|
+
}
|
|
672
|
+
if (Number.isFinite(run.l2Norm)) {
|
|
673
|
+
embeddingNorms.push(run.l2Norm);
|
|
674
|
+
}
|
|
675
|
+
if (run.embeddingDim > 0 && run.nonFiniteCount === 0) {
|
|
676
|
+
durations.push(run.durationMs);
|
|
677
|
+
embeddingDims.push(run.embeddingDim);
|
|
678
|
+
} else {
|
|
679
|
+
invalidRuns++;
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
const embeddingMsStats = computeSampleStats(durations);
|
|
685
|
+
const timedEmbeddingMsStats = computeSampleStats(timedDurations);
|
|
686
|
+
const embeddingDimStats = computeSampleStats(embeddingDims);
|
|
687
|
+
const embeddingTokensStats = computeSampleStats(embeddingTokenCounts);
|
|
688
|
+
const embeddingNormStats = computeSampleStats(embeddingNorms);
|
|
689
|
+
const avgMs = embeddingMsStats.mean;
|
|
690
|
+
|
|
691
|
+
results = [
|
|
692
|
+
{
|
|
693
|
+
name: 'benchmark-embedding',
|
|
694
|
+
passed: durations.length > 0 && invalidRuns === 0,
|
|
695
|
+
duration: durations.reduce((sum, value) => sum + value, 0),
|
|
696
|
+
error: durations.length > 0
|
|
697
|
+
? (
|
|
698
|
+
invalidRuns === 0
|
|
699
|
+
? undefined
|
|
700
|
+
: `Invalid embedding runs: ${invalidRuns} (non-finite values observed)`
|
|
701
|
+
)
|
|
702
|
+
: 'No valid embedding benchmark runs completed',
|
|
703
|
+
},
|
|
704
|
+
];
|
|
705
|
+
|
|
706
|
+
metrics = {
|
|
707
|
+
warmupRuns,
|
|
708
|
+
timedRuns,
|
|
709
|
+
validRuns: durations.length,
|
|
710
|
+
invalidRuns,
|
|
711
|
+
invalidRatePct: Number((timedRuns > 0 ? (invalidRuns / timedRuns) * 100 : 0).toFixed(2)),
|
|
712
|
+
prompt: benchRun.promptLabel,
|
|
713
|
+
embeddingDim: Math.round(embeddingDims.reduce((a, b) => a + b, 0) / (embeddingDims.length || 1)),
|
|
714
|
+
nonFiniteValues: totalNonFiniteValues,
|
|
715
|
+
firstTimedEmbeddingMs: Number((firstTimedEmbeddingMs ?? 0).toFixed(2)),
|
|
716
|
+
minEmbeddingMs: Number(embeddingMsStats.min.toFixed(2)),
|
|
717
|
+
medianEmbeddingMs: Number(embeddingMsStats.median.toFixed(2)),
|
|
718
|
+
p95EmbeddingMs: Number(embeddingMsStats.p95.toFixed(2)),
|
|
719
|
+
p99EmbeddingMs: Number(embeddingMsStats.p99.toFixed(2)),
|
|
720
|
+
maxEmbeddingMs: Number(embeddingMsStats.max.toFixed(2)),
|
|
721
|
+
stdDevEmbeddingMs: Number(embeddingMsStats.stdDev.toFixed(2)),
|
|
722
|
+
ci95EmbeddingMs: Number(embeddingMsStats.ci95.toFixed(2)),
|
|
723
|
+
avgEmbeddingMs: Number(avgMs.toFixed(2)),
|
|
724
|
+
avgEmbeddingsPerSec: Number((avgMs > 0 ? (1000 / avgMs) : 0).toFixed(2)),
|
|
725
|
+
avgEmbeddingTokens: Number(embeddingTokensStats.mean.toFixed(2)),
|
|
726
|
+
avgEmbeddingL2Norm: Number(embeddingNormStats.mean.toFixed(4)),
|
|
727
|
+
modelLoadMs: safeModelLoadMs,
|
|
728
|
+
latency: {
|
|
729
|
+
timedEmbeddingMs: timedEmbeddingMsStats,
|
|
730
|
+
embeddingMs: embeddingMsStats,
|
|
731
|
+
},
|
|
732
|
+
dimensions: {
|
|
733
|
+
embedding: embeddingDimStats,
|
|
734
|
+
},
|
|
735
|
+
embedding: {
|
|
736
|
+
tokens: embeddingTokensStats,
|
|
737
|
+
l2Norm: embeddingNormStats,
|
|
738
|
+
},
|
|
739
|
+
};
|
|
740
|
+
|
|
741
|
+
const timedStats = computeSampleStats(durations);
|
|
742
|
+
timing = buildCanonicalTiming({
|
|
743
|
+
modelLoadMs: safeModelLoadMs,
|
|
744
|
+
firstTokenMs: null,
|
|
745
|
+
firstResponseMs: Number.isFinite(firstTimedEmbeddingMs)
|
|
746
|
+
? safeModelLoadMs + firstTimedEmbeddingMs
|
|
747
|
+
: null,
|
|
748
|
+
prefillMs: null,
|
|
749
|
+
decodeMs: null,
|
|
750
|
+
totalRunMs: timedStats.median,
|
|
751
|
+
cacheMode,
|
|
752
|
+
loadMode,
|
|
753
|
+
});
|
|
754
|
+
} else {
|
|
755
|
+
const tokensPerSec = [];
|
|
756
|
+
const durations = [];
|
|
757
|
+
const tokensGenerated = [];
|
|
758
|
+
const decodeMsPerToken = [];
|
|
759
|
+
const ttftMs = [];
|
|
760
|
+
const prefillMs = [];
|
|
761
|
+
const decodeMs = [];
|
|
762
|
+
const prefillTokens = [];
|
|
763
|
+
const decodeTokens = [];
|
|
764
|
+
const decodeTokensPerSec = [];
|
|
765
|
+
const prefillTokensPerSec = [];
|
|
766
|
+
const prefillTokensPerSecTtft = [];
|
|
767
|
+
const gpuPrefillMs = [];
|
|
768
|
+
const gpuDecodeMs = [];
|
|
769
|
+
const gpuDecodeRecordMs = [];
|
|
770
|
+
const gpuDecodeSubmitWaitMs = [];
|
|
771
|
+
const gpuDecodeReadbackWaitMs = [];
|
|
772
|
+
const singleTokenSubmitWaitMs = [];
|
|
773
|
+
const singleTokenReadbackWaitMs = [];
|
|
774
|
+
const singleTokenOrchestrationMs = [];
|
|
775
|
+
|
|
776
|
+
let generatedText = null;
|
|
777
|
+
let generatedPromptInput = null;
|
|
778
|
+
let lastDecodeMode = null;
|
|
779
|
+
let lastBatchGuardReason = null;
|
|
780
|
+
for (let i = 0; i < warmupRuns + timedRuns; i++) {
|
|
781
|
+
harness.pipeline.reset?.();
|
|
782
|
+
const run = await runGeneration(harness.pipeline, runtimeConfig, benchRun);
|
|
783
|
+
if (i === warmupRuns + timedRuns - 1) {
|
|
784
|
+
generatedText = run?.output ?? null;
|
|
785
|
+
generatedPromptInput = run?.promptInput ?? null;
|
|
786
|
+
lastDecodeMode = run?.phase?.decodeMode ?? null;
|
|
787
|
+
lastBatchGuardReason = run?.phase?.batchGuardReason ?? null;
|
|
788
|
+
}
|
|
789
|
+
if (i >= warmupRuns) {
|
|
790
|
+
const phase = run?.phase ?? {};
|
|
791
|
+
const phaseTokens = Array.isArray(run?.tokens) ? run.tokens : [];
|
|
792
|
+
const phaseGpu = phase.gpu;
|
|
793
|
+
tokensPerSec.push(run?.tokensPerSec);
|
|
794
|
+
durations.push(run?.durationMs);
|
|
795
|
+
tokensGenerated.push(phaseTokens.length);
|
|
796
|
+
ttftMs.push(phase.ttftMs);
|
|
797
|
+
prefillMs.push(phase.prefillMs);
|
|
798
|
+
decodeMs.push(phase.decodeMs);
|
|
799
|
+
prefillTokens.push(phase.prefillTokens);
|
|
800
|
+
decodeTokens.push(phase.decodeTokens);
|
|
801
|
+
decodeTokensPerSec.push(phase.decodeTokensPerSec);
|
|
802
|
+
prefillTokensPerSec.push(phase.prefillTokensPerSec);
|
|
803
|
+
prefillTokensPerSecTtft.push(phase.prefillTokensPerSecTtft);
|
|
804
|
+
if (phase.decodeMs > 0 && phase.decodeTokens > 0) {
|
|
805
|
+
decodeMsPerToken.push(phase.decodeMs / phase.decodeTokens);
|
|
806
|
+
}
|
|
807
|
+
if (Number.isFinite(phaseGpu?.prefillMs)) gpuPrefillMs.push(phaseGpu.prefillMs);
|
|
808
|
+
if (Number.isFinite(phaseGpu?.decodeMs)) gpuDecodeMs.push(phaseGpu.decodeMs);
|
|
809
|
+
if (Number.isFinite(phaseGpu?.decodeRecordMs)) gpuDecodeRecordMs.push(phaseGpu.decodeRecordMs);
|
|
810
|
+
if (Number.isFinite(phaseGpu?.decodeSubmitWaitMs)) gpuDecodeSubmitWaitMs.push(phaseGpu.decodeSubmitWaitMs);
|
|
811
|
+
if (Number.isFinite(phaseGpu?.decodeReadbackWaitMs)) gpuDecodeReadbackWaitMs.push(phaseGpu.decodeReadbackWaitMs);
|
|
812
|
+
if (Number.isFinite(phaseGpu?.singleTokenSubmitWaitMs)) singleTokenSubmitWaitMs.push(phaseGpu.singleTokenSubmitWaitMs);
|
|
813
|
+
if (Number.isFinite(phaseGpu?.singleTokenReadbackWaitMs)) singleTokenReadbackWaitMs.push(phaseGpu.singleTokenReadbackWaitMs);
|
|
814
|
+
if (Number.isFinite(phaseGpu?.singleTokenOrchestrationMs)) singleTokenOrchestrationMs.push(phaseGpu.singleTokenOrchestrationMs);
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
const totalMsStats = computeSampleStats(durations);
|
|
819
|
+
const tokensPerSecStats = computeSampleStats(tokensPerSec);
|
|
820
|
+
const decodeTokensPerSecStats = computeSampleStats(decodeTokensPerSec);
|
|
821
|
+
const prefillTokensPerSecStats = computeSampleStats(prefillTokensPerSec);
|
|
822
|
+
const prefillTokensPerSecTtftStats = computeSampleStats(prefillTokensPerSecTtft);
|
|
823
|
+
const decodeMsPerTokenStats = computeSampleStats(decodeMsPerToken);
|
|
824
|
+
const ttftMsStats = computeSampleStats(ttftMs);
|
|
825
|
+
const prefillMsStats = computeSampleStats(prefillMs);
|
|
826
|
+
const decodeMsStats = computeSampleStats(decodeMs);
|
|
827
|
+
const tokensGeneratedStats = computeSampleStats(tokensGenerated);
|
|
828
|
+
const prefillTokensStats = computeSampleStats(prefillTokens);
|
|
829
|
+
const decodeTokensStats = computeSampleStats(decodeTokens);
|
|
830
|
+
const hasGpuStats = gpuPrefillMs.length > 0 || gpuDecodeMs.length > 0 || gpuDecodeRecordMs.length > 0
|
|
831
|
+
|| gpuDecodeSubmitWaitMs.length > 0 || gpuDecodeReadbackWaitMs.length > 0
|
|
832
|
+
|| singleTokenSubmitWaitMs.length > 0 || singleTokenReadbackWaitMs.length > 0
|
|
833
|
+
|| singleTokenOrchestrationMs.length > 0;
|
|
834
|
+
const gpuPhaseStats = hasGpuStats
|
|
835
|
+
? {
|
|
836
|
+
prefillMs: computeSampleStats(gpuPrefillMs),
|
|
837
|
+
decodeMs: computeSampleStats(gpuDecodeMs),
|
|
838
|
+
decodeRecordMs: computeSampleStats(gpuDecodeRecordMs),
|
|
839
|
+
decodeSubmitWaitMs: computeSampleStats(gpuDecodeSubmitWaitMs),
|
|
840
|
+
decodeReadbackWaitMs: computeSampleStats(gpuDecodeReadbackWaitMs),
|
|
841
|
+
singleTokenSubmitWaitMs: computeSampleStats(singleTokenSubmitWaitMs),
|
|
842
|
+
singleTokenReadbackWaitMs: computeSampleStats(singleTokenReadbackWaitMs),
|
|
843
|
+
singleTokenOrchestrationMs: computeSampleStats(singleTokenOrchestrationMs),
|
|
844
|
+
}
|
|
845
|
+
: null;
|
|
846
|
+
|
|
847
|
+
results = [
|
|
848
|
+
{
|
|
849
|
+
name: 'benchmark',
|
|
850
|
+
passed: tokensPerSec.length > 0,
|
|
851
|
+
duration: durations.reduce((sum, value) => sum + value, 0),
|
|
852
|
+
error: tokensPerSec.length > 0 ? undefined : 'No benchmark runs completed',
|
|
853
|
+
},
|
|
854
|
+
];
|
|
855
|
+
|
|
856
|
+
const normalizedFirstTokenMs = sampleTimingNumber(ttftMsStats, 'median', null);
|
|
857
|
+
|
|
858
|
+
metrics = {
|
|
859
|
+
warmupRuns,
|
|
860
|
+
timedRuns,
|
|
861
|
+
prompt: benchRun.promptLabel,
|
|
862
|
+
maxTokens: benchRun.maxTokens,
|
|
863
|
+
decodeTokensPerSec: sampleTimingNumber(decodeTokensPerSecStats, 'median'),
|
|
864
|
+
avgTokensGenerated: Math.round(tokensGeneratedStats.mean),
|
|
865
|
+
avgPrefillTokens: Math.round(prefillTokensStats.mean),
|
|
866
|
+
avgDecodeTokens: Math.round(decodeTokensStats.mean),
|
|
867
|
+
medianPrefillTokensPerSec: sampleTimingNumber(prefillTokensPerSecStats, 'median'),
|
|
868
|
+
avgPrefillTokensPerSec: sampleTimingNumber(prefillTokensPerSecStats, 'mean'),
|
|
869
|
+
medianPrefillTokensPerSecTtft: sampleTimingNumber(prefillTokensPerSecTtftStats, 'median'),
|
|
870
|
+
avgPrefillTokensPerSecTtft: sampleTimingNumber(prefillTokensPerSecTtftStats, 'mean'),
|
|
871
|
+
avgDecodeTokensPerSec: sampleTimingNumber(decodeTokensPerSecStats, 'mean'),
|
|
872
|
+
firstTokenMs: normalizedFirstTokenMs,
|
|
873
|
+
firstResponseMs: safeToFixed(safeModelLoadMs + normalizedFirstTokenMs, null),
|
|
874
|
+
prefillMs: sampleTimingNumber(prefillMsStats, 'median'),
|
|
875
|
+
decodeMs: sampleTimingNumber(decodeMsStats, 'median'),
|
|
876
|
+
totalRunMs: sampleTimingNumber(totalMsStats, 'median'),
|
|
877
|
+
decodeMsPerTokenP50: sampleTimingNumber(decodeMsPerTokenStats, 'median'),
|
|
878
|
+
decodeMsPerTokenP95: sampleTimingNumber(decodeMsPerTokenStats, 'p95'),
|
|
879
|
+
decodeMsPerTokenP99: sampleTimingNumber(decodeMsPerTokenStats, 'p99'),
|
|
880
|
+
avgPrefillMs: sampleTimingNumber(prefillMsStats, 'mean'),
|
|
881
|
+
modelLoadMs: safeModelLoadMs,
|
|
882
|
+
throughput: {
|
|
883
|
+
tokensPerSec: tokensPerSecStats,
|
|
884
|
+
prefillTokensPerSec: prefillTokensPerSecStats,
|
|
885
|
+
prefillTokensPerSecTtft: prefillTokensPerSecTtftStats,
|
|
886
|
+
decodeTokensPerSec: decodeTokensPerSecStats,
|
|
887
|
+
},
|
|
888
|
+
latency: {
|
|
889
|
+
totalMs: totalMsStats,
|
|
890
|
+
prefillMs: prefillMsStats,
|
|
891
|
+
decodeMs: decodeMsStats,
|
|
892
|
+
firstTokenMs: ttftMsStats,
|
|
893
|
+
},
|
|
894
|
+
tokens: {
|
|
895
|
+
generated: tokensGeneratedStats,
|
|
896
|
+
prefill: prefillTokensStats,
|
|
897
|
+
decode: decodeTokensStats,
|
|
898
|
+
},
|
|
899
|
+
gpu: gpuPhaseStats,
|
|
900
|
+
decodeMode: lastDecodeMode,
|
|
901
|
+
batchGuardReason: lastBatchGuardReason,
|
|
902
|
+
generatedText,
|
|
903
|
+
promptInput: generatedPromptInput,
|
|
904
|
+
};
|
|
905
|
+
|
|
906
|
+
timing = buildCanonicalTiming({
|
|
907
|
+
modelLoadMs: safeModelLoadMs,
|
|
908
|
+
firstTokenMs: normalizedFirstTokenMs,
|
|
909
|
+
firstResponseMs: Number.isFinite(normalizedFirstTokenMs)
|
|
910
|
+
? safeModelLoadMs + normalizedFirstTokenMs
|
|
911
|
+
: null,
|
|
912
|
+
prefillMs: prefillMsStats?.median ?? null,
|
|
913
|
+
decodeMs: decodeMsStats?.median ?? null,
|
|
914
|
+
decodeMsPerTokenP50: decodeMsPerTokenStats?.median ?? null,
|
|
915
|
+
decodeMsPerTokenP95: decodeMsPerTokenStats?.p95 ?? null,
|
|
916
|
+
decodeMsPerTokenP99: decodeMsPerTokenStats?.p99 ?? null,
|
|
917
|
+
totalRunMs: totalMsStats.median,
|
|
918
|
+
decodeTokensPerSec: decodeTokensPerSecStats?.median,
|
|
919
|
+
prefillTokensPerSec: prefillTokensPerSecStats?.median,
|
|
920
|
+
prefillTokensPerSecTtft: prefillTokensPerSecTtftStats?.median,
|
|
921
|
+
cacheMode,
|
|
922
|
+
loadMode,
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
const memoryStats = typeof harness.pipeline?.getMemoryStats === 'function'
|
|
927
|
+
? harness.pipeline.getMemoryStats()
|
|
928
|
+
: null;
|
|
929
|
+
|
|
930
|
+
if (typeof harness.pipeline.unload === 'function' && !options.keepPipeline) {
|
|
931
|
+
await harness.pipeline.unload();
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
const summary = buildSuiteSummary('bench', results, startTime);
|
|
935
|
+
const timingDiagnostics = buildTimingDiagnostics(timing, {
|
|
936
|
+
source: 'doppler',
|
|
937
|
+
prefillSemantics: 'internal_prefill_phase',
|
|
938
|
+
});
|
|
939
|
+
const metricsWithContracts = buildSuiteContractMetrics('bench', metrics, harness.manifest);
|
|
940
|
+
return {
|
|
941
|
+
...summary,
|
|
942
|
+
modelId: options.modelId || harness.manifest?.modelId || 'unknown',
|
|
943
|
+
cacheMode,
|
|
944
|
+
loadMode,
|
|
945
|
+
env: {
|
|
946
|
+
library: 'doppler',
|
|
947
|
+
runtime: 'browser',
|
|
948
|
+
device: 'webgpu',
|
|
949
|
+
browserUserAgent: typeof navigator !== 'undefined' ? (navigator.userAgent || null) : null,
|
|
950
|
+
browserPlatform: typeof navigator !== 'undefined' ? (navigator.platform || null) : null,
|
|
951
|
+
browserLanguage: typeof navigator !== 'undefined' ? (navigator.language || null) : null,
|
|
952
|
+
browserVendor: typeof navigator !== 'undefined' ? (navigator.vendor || null) : null,
|
|
953
|
+
},
|
|
954
|
+
timing,
|
|
955
|
+
timingDiagnostics,
|
|
956
|
+
output,
|
|
957
|
+
metrics: metricsWithContracts,
|
|
958
|
+
memoryStats,
|
|
959
|
+
deviceInfo: resolveDeviceInfo(),
|
|
960
|
+
pipeline: options.keepPipeline ? harness.pipeline : null,
|
|
961
|
+
};
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
async function dispatchBrowserSuite(mode, workload, options) {
|
|
965
|
+
if (mode === 'verify' && workload === 'kernels') {
|
|
966
|
+
return runKernelSuite(options);
|
|
967
|
+
}
|
|
968
|
+
if (workload === 'embedding') {
|
|
969
|
+
return runInferenceSuite({
|
|
970
|
+
...options,
|
|
971
|
+
suiteName: 'embedding',
|
|
972
|
+
expectedModelType: options.expectedModelType ?? 'embedding',
|
|
973
|
+
});
|
|
974
|
+
}
|
|
975
|
+
if (mode === 'verify' && workload === 'training') {
|
|
976
|
+
return runTrainingSuite(options);
|
|
977
|
+
}
|
|
978
|
+
if (mode === 'bench') {
|
|
979
|
+
return runBenchSuite(options);
|
|
980
|
+
}
|
|
981
|
+
if (mode === 'verify' && workload === 'diffusion') {
|
|
982
|
+
return runDiffusionSuite(options);
|
|
983
|
+
}
|
|
984
|
+
if (mode === 'verify' && workload === 'energy') {
|
|
985
|
+
return runEnergySuite(options);
|
|
986
|
+
}
|
|
987
|
+
if (mode === 'debug' && workload === 'inference') {
|
|
988
|
+
return runInferenceSuite({ ...options, suiteName: 'debug' });
|
|
989
|
+
}
|
|
990
|
+
if (mode === 'diagnose' && workload === 'inference') {
|
|
991
|
+
return runInferenceSuite({ ...options, suiteName: 'diagnose' });
|
|
992
|
+
}
|
|
993
|
+
if (workload === 'inference') {
|
|
994
|
+
return runInferenceSuite({ ...options, suiteName: 'inference' });
|
|
995
|
+
}
|
|
996
|
+
return null;
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
function shouldCaptureDebugSnapshot(mode, runtimeConfig) {
|
|
1000
|
+
const debug = runtimeConfig?.shared?.debug ?? {};
|
|
1001
|
+
const logLevel = String(debug.logLevel?.defaultLogLevel ?? '').toLowerCase();
|
|
1002
|
+
return mode === 'debug'
|
|
1003
|
+
|| debug.trace?.enabled === true
|
|
1004
|
+
|| debug.pipeline?.enabled === true
|
|
1005
|
+
|| (Array.isArray(debug.probes) && debug.probes.length > 0)
|
|
1006
|
+
|| debug.profiler?.enabled === true
|
|
1007
|
+
|| logLevel === 'debug'
|
|
1008
|
+
|| logLevel === 'verbose';
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
export async function runBrowserSuite(options = {}) {
|
|
1012
|
+
return runWithRuntimeIsolationForSuite(async () => {
|
|
1013
|
+
const suiteTimestamp = resolveReportTimestamp(options.timestamp, 'runBrowserSuite timestamp');
|
|
1014
|
+
const harnessContext = resolveHarnessContext(options);
|
|
1015
|
+
const mode = resolveHarnessMode(options, harnessContext);
|
|
1016
|
+
const workload = resolveWorkload(options, mode, harnessContext);
|
|
1017
|
+
const suite = resolveDispatchSuite(mode, workload);
|
|
1018
|
+
const captureDebugSnapshot = shouldCaptureDebugSnapshot(mode, getRuntimeConfig());
|
|
1019
|
+
if (captureDebugSnapshot) {
|
|
1020
|
+
clearLogHistory();
|
|
1021
|
+
}
|
|
1022
|
+
const suiteResult = await dispatchBrowserSuite(mode, workload, {
|
|
1023
|
+
...options,
|
|
1024
|
+
mode,
|
|
1025
|
+
workload,
|
|
1026
|
+
suite,
|
|
1027
|
+
});
|
|
1028
|
+
if (!suiteResult) {
|
|
1029
|
+
throw createUnsupportedWorkloadError(workload, { ...harnessContext, mode });
|
|
1030
|
+
}
|
|
1031
|
+
const debugSnapshot = captureDebugSnapshot ? getDebugSnapshot() : null;
|
|
1032
|
+
|
|
1033
|
+
if (mode === 'bench' && suiteResult?.metrics?.workloadType === 'training') {
|
|
1034
|
+
const trainingReport = suiteResult?.metrics?.trainingMetricsReport;
|
|
1035
|
+
if (Array.isArray(trainingReport) && trainingReport.length > 0) {
|
|
1036
|
+
validateTrainingMetricsReport(trainingReport);
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
if (mode === 'verify' && workload === 'diffusion') {
|
|
1040
|
+
assertDiffusionPerformanceArtifact(suiteResult?.metrics, 'diffusion verify');
|
|
1041
|
+
}
|
|
1042
|
+
if (mode === 'bench' && suiteResult?.metrics?.workloadType === 'diffusion') {
|
|
1043
|
+
assertDiffusionPerformanceArtifact(suiteResult?.metrics, 'diffusion bench');
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
const modelId = suiteResult.modelId || options.modelId || options.modelUrl || workload || suite;
|
|
1047
|
+
const reportOutput = sanitizeReportOutput(suiteResult.output);
|
|
1048
|
+
const trainingArtifacts = collectTrainingArtifactsFromSuiteResult(suiteResult);
|
|
1049
|
+
const ulArtifacts = trainingArtifacts.ulArtifacts;
|
|
1050
|
+
const distillArtifacts = trainingArtifacts.distillArtifacts;
|
|
1051
|
+
const checkpointResumeTimeline = trainingArtifacts.checkpointResumeTimeline;
|
|
1052
|
+
const report = {
|
|
1053
|
+
mode,
|
|
1054
|
+
workload,
|
|
1055
|
+
suite,
|
|
1056
|
+
modelId,
|
|
1057
|
+
runtimeProfile: options.runtimeProfile ?? null,
|
|
1058
|
+
deviceInfo: suiteResult.deviceInfo ?? null,
|
|
1059
|
+
results: suiteResult.results,
|
|
1060
|
+
durationMs: suiteResult.duration,
|
|
1061
|
+
timestamp: suiteTimestamp,
|
|
1062
|
+
metrics: suiteResult.metrics ?? null,
|
|
1063
|
+
output: reportOutput,
|
|
1064
|
+
memory: suiteResult.memoryStats ?? null,
|
|
1065
|
+
debugSnapshot,
|
|
1066
|
+
...options.report,
|
|
1067
|
+
};
|
|
1068
|
+
if (ulArtifacts.length > 0 || distillArtifacts.length > 0 || checkpointResumeTimeline.length > 0) {
|
|
1069
|
+
report.lineage = {
|
|
1070
|
+
...(report.lineage && typeof report.lineage === 'object' ? report.lineage : {}),
|
|
1071
|
+
training: {
|
|
1072
|
+
...(
|
|
1073
|
+
report.lineage?.training && typeof report.lineage.training === 'object'
|
|
1074
|
+
? report.lineage.training
|
|
1075
|
+
: {}
|
|
1076
|
+
),
|
|
1077
|
+
...(ulArtifacts.length > 0 ? { ulArtifacts } : {}),
|
|
1078
|
+
...(distillArtifacts.length > 0 ? { distillArtifacts } : {}),
|
|
1079
|
+
...(checkpointResumeTimeline.length > 0 ? { checkpointResumeTimeline } : {}),
|
|
1080
|
+
},
|
|
1081
|
+
};
|
|
1082
|
+
}
|
|
1083
|
+
if (!report.timestamp) {
|
|
1084
|
+
report.timestamp = suiteTimestamp;
|
|
1085
|
+
}
|
|
1086
|
+
const reportInfo = await saveReport(modelId, report, { timestamp: report.timestamp });
|
|
1087
|
+
return { ...suiteResult, mode, workload, debugSnapshot, report, reportInfo };
|
|
1088
|
+
});
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
export async function runBrowserManifest(manifest, options = {}) {
|
|
1092
|
+
const normalized = normalizeManifest(manifest);
|
|
1093
|
+
const results = [];
|
|
1094
|
+
const manifestTimestamp = resolveReportTimestamp(options.timestamp, 'runBrowserManifest timestamp');
|
|
1095
|
+
const baseRuntimeConfig = cloneRuntimeConfig(getRuntimeConfig());
|
|
1096
|
+
const baseKernelPath = getActiveKernelPath();
|
|
1097
|
+
const baseKernelPathSource = getActiveKernelPathSource();
|
|
1098
|
+
const baseKernelPathPolicy = getActiveKernelPathPolicy();
|
|
1099
|
+
|
|
1100
|
+
for (let i = 0; i < normalized.runs.length; i++) {
|
|
1101
|
+
const run = mergeRunDefaults(normalized.defaults, normalized.runs[i] || {});
|
|
1102
|
+
try {
|
|
1103
|
+
setRuntimeConfig(baseRuntimeConfig);
|
|
1104
|
+
setActiveKernelPath(baseKernelPath, baseKernelPathSource, baseKernelPathPolicy);
|
|
1105
|
+
await applyRuntimeForRun(run, options);
|
|
1106
|
+
const runTimestamp = resolveReportTimestamp(
|
|
1107
|
+
run.timestamp,
|
|
1108
|
+
`runBrowserManifest run[${i}] timestamp`,
|
|
1109
|
+
manifestTimestamp
|
|
1110
|
+
);
|
|
1111
|
+
const result = await runBrowserSuite({ ...run, timestamp: runTimestamp });
|
|
1112
|
+
results.push({
|
|
1113
|
+
...result,
|
|
1114
|
+
label: run.label ?? `${run.workload || run.suite || 'inference'}:${result.modelId || 'unknown'}`,
|
|
1115
|
+
});
|
|
1116
|
+
options.onProgress?.({
|
|
1117
|
+
index: i + 1,
|
|
1118
|
+
total: normalized.runs.length,
|
|
1119
|
+
label: run.label ?? result.modelId ?? run.workload ?? run.suite ?? 'run',
|
|
1120
|
+
});
|
|
1121
|
+
} finally {
|
|
1122
|
+
setRuntimeConfig(baseRuntimeConfig);
|
|
1123
|
+
setActiveKernelPath(baseKernelPath, baseKernelPathSource, baseKernelPathPolicy);
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
const summary = summarizeManifestRuns(results);
|
|
1128
|
+
const report = {
|
|
1129
|
+
timestamp: manifestTimestamp,
|
|
1130
|
+
summary,
|
|
1131
|
+
runs: results.map((result) => ({
|
|
1132
|
+
label: result.label,
|
|
1133
|
+
mode: result.mode,
|
|
1134
|
+
workload: result.workload,
|
|
1135
|
+
suite: result.suite,
|
|
1136
|
+
modelId: result.modelId,
|
|
1137
|
+
results: result.results,
|
|
1138
|
+
metrics: result.metrics ?? null,
|
|
1139
|
+
output: typeof result.output === 'string' ? result.output : null,
|
|
1140
|
+
reportInfo: result.reportInfo ?? null,
|
|
1141
|
+
})),
|
|
1142
|
+
manifest: normalized.report ?? null,
|
|
1143
|
+
};
|
|
1144
|
+
|
|
1145
|
+
const reportInfo = options.saveReport === false
|
|
1146
|
+
? null
|
|
1147
|
+
: await saveReport(normalized.reportModelId, report, { timestamp: options.timestamp });
|
|
1148
|
+
|
|
1149
|
+
return { results, summary, report, reportInfo };
|
|
1150
|
+
}
|